@ue-too/board-game-engine / index / NumberModificationEffect
類別: NumberModificationEffect<T>
定義於: action-system/effect.ts:26
Unified number modification effect that works with both custom schema components and typed components. Automatically detects which approach to use based on whether the component has a registered schema.
範例
// With custom schema component
const effect1 = new NumberModificationEffect(
coordinator, 25, HEALTH_COMPONENT, entity, 'health', 'subtract'
);
// With typed component (type-safe)
type HealthComponent = { health: number; maxHealth: number };
const effect2 = new NumberModificationEffect<HealthComponent>(
coordinator, HEALTH_COMPONENT, entity, 'health', 25, 'subtract'
);型別參數
T
T = Record<string, unknown>
實作
建構函式
建構函式
new NumberModificationEffect<
T>(coordinator,componentName,entity,valuePath,amount,operation?):NumberModificationEffect<T>
定義於: action-system/effect.ts:38
參數
coordinator
Coordinator
componentName
symbol
entity
number
valuePath
keyof T
amount
number
operation?
"add" | "subtract" | "set"
回傳
NumberModificationEffect<T>
建構函式
new NumberModificationEffect<
T>(coordinator,amount,componentName,entity,valuePath,operation?):NumberModificationEffect<T>
定義於: action-system/effect.ts:47
參數
coordinator
Coordinator
amount
number
componentName
symbol
entity
number
valuePath
string
operation?
"add" | "subtract" | "set"
回傳
NumberModificationEffect<T>
方法
apply()
apply():
void
定義於: action-system/effect.ts:89
回傳
void