Exemple #1
0
        public static IArea WithStateMachine(this IArea room, Enum id, Action <StateMachine, IArea> initializer)
        {
            if (room == null)
            {
                throw new ArgumentNullException(nameof(room));
            }
            if (initializer == null)
            {
                throw new ArgumentNullException(nameof(initializer));
            }

            var stateMachine = new StateMachine(ActuatorIdFactory.Create(room, id), room.Controller.HttpApiController, room.Controller.Logger);

            initializer(stateMachine, room);
            stateMachine.SetInitialState();

            room.AddActuator(stateMachine);
            return(room);
        }
Exemple #2
0
        public IStateMachine RegisterStateMachine(IArea area, Enum id, Action <StateMachine, IArea> initializer)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }
            if (initializer == null)
            {
                throw new ArgumentNullException(nameof(initializer));
            }

            var stateMachine = new StateMachine(ComponentIdGenerator.Generate(area.Id, id));

            initializer(stateMachine, area);
            stateMachine.SetInitialState(BinaryStateId.Off);

            area.AddComponent(stateMachine);
            return(stateMachine);
        }