private StateSpecifier InternalPermitIf(TTriggerType trigger, TStateType destinationState, Func <bool> triggerCondition) { _specification.AddTriggerStrategy(new StateTransitionTriggerStrategy(trigger, destinationState, triggerCondition)); return(this); }
private StateSpecifier PermitIfInternal(TTriggerType trigger, Func <object[], TStateType> destinationStateSelector, Func <bool> triggerCondition) { _specification.AddTriggerStrategy(new DestinationFunctionTriggerStrategy(trigger, destinationStateSelector, triggerCondition)); return(this); }
public void AddEntryAction(TTriggerType trigger, Action <StateTransition, object[]> action) { _entryActions.Add((t, args) => { if (t.Trigger.Equals(trigger)) { action(t, args); } }); }
private bool HasLocalHandlerFor(TTriggerType trigger, out TriggerStrategy handler) { ICollection <TriggerStrategy> possible; if (!_triggerStrategies.TryGetValue(trigger, out possible)) { handler = null; return(false); } var actual = possible.Where(at => at.ConditionPositive).ToArray(); if (actual.Count() > 1) { throw new InvalidOperationException( string.Format("Ambiguous trigger transition on trigger {0} on state {1}", trigger, _state)); } handler = actual.FirstOrDefault(); return(handler != null); }
private StateSpecifier InternalPermitDynamic(TTriggerType trigger, Func <object[], TStateType> destinationStateSelector) { return(PermitIfInternal(trigger, destinationStateSelector, Promiscuous)); }
public override void Trigger(TTriggerType trigger, TTriggerData data) { Universe.GetComponents <TComponent>() .ForAll(component => OnTrigger(trigger, data, component as TComponent)); }
public StateTransition(TStateType source, TStateType destination, TTriggerType trigger) { _source = source; _destination = destination; _trigger = trigger; }
public StateSpecifier OnEntryFrom(TTriggerType trigger, Action <StateTransition> entryAction) { _specification.AddEntryAction(trigger, (t, args) => entryAction(t)); return(this); }
public StateSpecifier IgnoreIf(TTriggerType trigger, Func <bool> triggerCondition) { _specification.AddTriggerStrategy(new IgnoredTriggerStrategy(trigger, triggerCondition)); return(this); }
public StateSpecifier PermitReentryIf(TTriggerType trigger, Func <bool> triggerCondition) { return(InternalPermitIf(trigger, _specification.UnderlyingState, triggerCondition)); }
public StateSpecifier PermitIf(TTriggerType trigger, TStateType destinationState, Func <bool> triggerCondition) { EnforceNotIdentityTransition(destinationState); return(InternalPermitIf(trigger, destinationState, triggerCondition)); }
public bool HasHandlerFor(TTriggerType trigger, out TriggerStrategy handler) { return(HasLocalHandlerFor(trigger, out handler) || (Superstate != null && Superstate.HasHandlerFor(trigger, out handler))); }
public bool CanHandle(TTriggerType trigger) { TriggerStrategy unused; return(HasHandlerFor(trigger, out unused)); }
public abstract void OnTrigger(TTriggerType trigger, TTriggerData data, TEntity entity);
public override void Trigger(TTriggerType trigger, TTriggerData data) { Universe.GetEntities <TEntity>().ForAll(entity => OnTrigger(trigger, data, entity)); }
public abstract void OnTrigger(TTriggerType trigger, TTriggerData data, TComponent component);
public StateSpecifier Permit(TTriggerType trigger, TStateType destinationState) { EnforceNotIdentityTransition(destinationState); return(InternalPermit(trigger, destinationState)); }
public StateTransitionTriggerStrategy(TTriggerType trigger, TStateType destination, Func <bool> triggerCondition) : base(trigger, triggerCondition) { _destination = destination; }
public StateSpecifier PermitReentry(TTriggerType trigger) { return(InternalPermit(trigger, _specification.UnderlyingState)); }
public IgnoredTriggerStrategy(TTriggerType trigger, Func <bool> triggerCondition) : base(trigger, triggerCondition) { }
public StateSpecifier Ignore(TTriggerType trigger) { return(IgnoreIf(trigger, Promiscuous)); }
public StateSpecifier Permit(TTriggerType trigger, Func <TStateType> destinationStateSelector) { return(PermitIf(trigger, destinationStateSelector, Promiscuous)); }
public StateSpecifier OnEntryFrom(TTriggerType trigger, Action entryAction) { return(OnEntryFrom(trigger, t => entryAction())); }
public StateSpecifier PermitIf(TTriggerType trigger, Func <TStateType> destinationStateSelector, Func <bool> triggerCondition) { return(PermitIfInternal(trigger, args => destinationStateSelector(), triggerCondition)); }
protected TriggerStrategy(TTriggerType trigger, Func <bool> triggerCondition) { _trigger = trigger; _triggerCondition = triggerCondition; }
private StateSpecifier InternalPermit(TTriggerType trigger, TStateType destinationState) { return(InternalPermitIf(trigger, destinationState, () => true)); }
public DestinationFunctionTriggerStrategy(TTriggerType trigger, Func <object[], TStateType> destination, Func <bool> triggerCondition) : base(trigger, triggerCondition) { _destination = destination; }
public ParameterizedTrigger(TTriggerType underlyingTrigger, params Type[] argumentTypes) { _underlyingTrigger = underlyingTrigger; _argumentTypes = argumentTypes; }