private void AddAction(BaseAction action) { if (action != null) { PendingActions.Add(action); } }
public static BaseAction ValidateAction(BaseAction action) { var resultAction = CheckOutcomeConditions(action); resultAction = CheckIncomeConditions(resultAction); return resultAction; }
private static BaseAction CheckOutcomeConditions(BaseAction action) { BaseAction result = action; if (action.Source.Conditions == null) return result; foreach (ICondition condition in action.Source.Conditions.OrderBy(x => x.Priority)) result = condition.TransformOutcomeAction(result); return result; }
public void Observe(BaseAction action, World world) { foreach (var gameEvent in Events) { if (gameEvent.Condition(action, world)) { gameEvent.Reaction(); } } }
public virtual BaseAction TransformOutcomeAction(BaseAction action) { return action; }
public abstract BaseAction TransformOutcomeAction(BaseAction action);
private static BaseAction CheckIncomeConditions(BaseAction action) { var resultAction = action; if (resultAction as ISingleTargetAffecter == null) return action; return (action as ISingleTargetAffecter).Target.Conditions.OrderBy(x => x.Priority).Aggregate(resultAction, (current, condition) => condition.TransformIncomeAction(current)); }