/// <inheritdoc /> public void Initialize(IStateComponent state) { Assert.IsNull(m_State, "Missing Dispose call."); m_State = state as TStateComponent; BeginStateChange(); }
/// <summary> /// Gets the current version of the state component. /// </summary> /// <param name="component">The state component.</param> /// <returns>The current version of the state component.</returns> internal static StateComponentVersion GetStateComponentVersion(this IStateComponent component) { return(new StateComponentVersion { HashCode = component.GetHashCode(), Version = component.CurrentVersion }); }
public Character(string name) : base(name) { _physicsComponent = new PhysicsComponent(this); _damageComponent = new DamageableComponent(this); _stateComponent = new StateComponent <ChararacterState>(ChararacterState.Idle); DrawableComponent = new DrawableComponent(this); }
/// <summary> /// Serializes a <see cref="IStateComponent"/> to JSON. /// </summary> /// <param name="obj">The state component to serialize.</param> /// <returns>A JSON string containing the serialized state component.</returns> public static string Serialize(IStateComponent obj) { if (obj == null) { return(""); } obj.BeforeSerialize(); return(JsonUtility.ToJson(obj)); }
public void SetState(Hash128 key, IStateComponent state) { ThrowIfInvalid(key); if (state == null) { throw new ArgumentNullException(nameof(state)); } m_Cache[key] = state; }
/// <summary> /// Initializes a new instance of the <see cref="Observation" /> class. /// </summary> /// <param name="observer">The observer.</param> /// <param name="observedComponent">The observed state</param> /// <param name="updateObserverVersion">True if we should update the observer's observed version /// at the end of the observation (default). False otherwise.</param> internal Observation(IStateObserver observer, IStateComponent observedComponent, bool updateObserverVersion = true) { Assert.IsTrue(observer.ObservedStateComponents.Contains(observedComponent.StateSlotName), $"Observer {observer.GetType().FullName} does not specify that it observes {observedComponent.StateSlotName}. Please add the state component to its {nameof(IStateObserver.ObservedStateComponents)}."); m_ObservedComponent = observedComponent; m_Observer = observer; m_UpdateObserverVersion = updateObserverVersion; var internalObserver = m_Observer as IInternalStateObserver; var lastObservedVersion = internalObserver?.GetLastObservedComponentVersion(observedComponent.StateSlotName) ?? default; UpdateType = m_ObservedComponent.GetUpdateType(lastObservedVersion); LastObservedVersion = lastObservedVersion.Version; }
public StateMachineTests() { this.core = Mock.Of <IStateMachineCore>(MockBehavior.Strict); this.component = Mock.Of <IStateComponent>(MockBehavior.Strict); }
/// <summary> /// Creates a new <see cref="Observation"/> instance that will not update the observer's last observed version. /// </summary> /// <param name="observer">The observer.</param> /// <param name="stateComponent">The observed state component.</param> /// <returns>An <see cref="Observation"/> object.</returns> public static Observation PeekAtState(this IStateObserver observer, IStateComponent stateComponent) { return(new Observation(observer, stateComponent, false)); }
/// <summary> /// Creates a new <see cref="Observation"/> instance that will update the observer's last observed version. /// </summary> /// <param name="observer">The observer.</param> /// <param name="stateComponent">The observed state component.</param> /// <returns>An <see cref="Observation"/> object.</returns> public static Observation ObserveState(this IStateObserver observer, IStateComponent stateComponent) { return(new Observation(observer, stateComponent)); }
public StateMachine(IStateMachineCore core) { this.component = core.Component; this.Current = core.InitialStateId; }
public ResultComponentTests() { this.next = Mock.Of <IStateComponent>(MockBehavior.Strict); this.state = TestStateId.Complete; this.component = new ResultComponent(this.state); }
public StateComponentCollectionTests() { this.next = Mock.Of <IStateComponent>(MockBehavior.Strict); this.component = new StateComponentCollection(); }
public void AddComponentState(SimpleComponent component, IStateComponent stateComponent) { States.Add(component, stateComponent); }
public SpecComponentTests() { this.next = Mock.Of <IStateComponent>(MockBehavior.Strict); this.spec = Mock.Of <ISpec <TestAction> >(MockBehavior.Strict); }
public ActionsComponentTests() { this.next = Mock.Of <IStateComponent>(MockBehavior.Strict); this.component = new ActionsComponent(); }
public StateComponentTests() { this.next = Mock.Of <IStateComponent>(MockBehavior.Strict); this.defaultComponent = Mock.Of <IStateComponent>(MockBehavior.Strict); this.component = new StateComponent(); }
public CallbackComponentTests() { this.next = Mock.Of <IStateComponent>(MockBehavior.Strict); this.callback = Mock.Of <ITransitionCallback <TestAction> >(MockBehavior.Strict); }
public StateMachineCore(StateId initialStateId, IStateComponent component) { this.InitialStateId = initialStateId; this.Component = component; }