Exemple #1
0
        static void Main()
        {
            // add systems
            SystemManager.Add <CommandSystem>();
            SystemManager.Add <ViewSystem>();

            // add commands
            var commands = SystemManager.Get <CommandSystem>();

            commands.Add <HelpCommand>();
            commands.Add <BackCommand>();
            commands.Add <ExitCommand>();

            // add views
            var views = SystemManager.Get <ViewSystem>();

            views.Add <HelpView>();
            views.Add <BackView>();
            views.Add <ExitView>();

            // show help
            SystemManager.Get <ViewSystem>().SetView <HelpView>();

            // app loop
            while (!commands.Get <ExitCommand>().Executing)
            {
                SystemManager.OnUpdate();
            }
        }
 protected GameSystem()
 {
     EntityManager.EntityEvent += OnNotify;
     SystemManager.Add(this);
     TimerClock = new Clock();
     Console.WriteLine("Added {0} to SystemMananger", GetType().FullName);
 }
Exemple #3
0
        private void Deserialize(BitBuffer buffer)
        {
            while (buffer.TotalBitsLeft >= RealPlacedBlock.SerializedBitsSize)
            {
                ushort        type     = (ushort)buffer.ReadBits(BlockFactory.BlockTypeSerializedBitsSize);
                BlockPosition position = BlockPosition.Deserialize(buffer);

                BlockInfo info = BlockFactory.GetInfo(BlockFactory.GetType(type));
                if (info.Type == BlockType.Mainframe)
                {
                    _mainframePosition = position;
                }

                byte          rotation = Rotation.Deserialize(buffer);
                RealLiveBlock block;
                if (info is SingleBlockInfo single)
                {
                    block = BlockFactory.MakeSingleLive(transform, single, rotation, position);
                }
                else
                {
                    block = BlockFactory.MakeMultiLive(transform, (MultiBlockInfo)info, rotation,
                                                       position, out LiveMultiBlockPart[] parts);
                    foreach (LiveMultiBlockPart part in parts)
                    {
                        _blocks.Add(part.Position, part);
                    }
                }

                Health += info.Health;
                Mass   += info.Mass;
                _blocks.Add(position, block);
                if (SystemFactory.Create(this, block, out BotSystem system))
                {
                    _systems.Add(position, system);
                }
            }
        }
Exemple #4
0
 public Line2DSystem()
 {
     entities = new Dictionary <BaseEntity, ValueTuple <Line2DComponent, PositionComponent> >();
     SystemManager.Add(this);
 }
Exemple #5
0
 public Text2DSystem()
 {
     entities = new Dictionary <BaseEntity, (Text2DComponent, PositionComponent)>();
     SystemManager.Add(this);
 }
Exemple #6
0
        internal void RegisterSystem(ISystem system)
        {
            _systemManager.Add(system);

            system.Initialize(this);
        }
 public virtual void SetActive(bool status)
 {
     gameObject.SetActive(status);
     if (!Application.isPlaying)
     {
         return;
     }
     if (_poolListeners != null)
     {
         for (int i = 0; i < _poolListeners.Length; i++)
         {
             if (_poolListeners[i] == null)
             {
                 continue;
             }
             if (status)
             {
                 _poolListeners[i].OnPoolSpawned();
             }
             else
             {
                 _poolListeners[i].OnPoolDespawned();
             }
         }
     }
     if (_systemFixedUpdate != null)
     {
         for (int i = 0; i < _systemFixedUpdate.Length; i++)
         {
             if (_systemFixedUpdate[i] == null)
             {
                 continue;
             }
             if (status)
             {
                 SystemManager.AddFixed(_systemFixedUpdate[i]);
             }
             else
             {
                 SystemManager.Remove(_systemFixedUpdate[i]);
             }
         }
     }
     if (_systemUpdate != null)
     {
         for (int i = 0; i < _systemUpdate.Length; i++)
         {
             if (_systemUpdate[i] == null)
             {
                 continue;
             }
             if (status)
             {
                 SystemManager.Add(_systemUpdate[i]);
             }
             else
             {
                 SystemManager.Remove(_systemUpdate[i]);
             }
         }
     }
     if (_turnUpdate != null)
     {
         for (int i = 0; i < _turnUpdate.Length; i++)
         {
             if (_turnUpdate[i] == null)
             {
                 continue;
             }
             if (status)
             {
                 SystemManager.AddTurn(_turnUpdate[i]);
             }
             else
             {
                 SystemManager.RemoveTurn(_turnUpdate[i]);
             }
         }
     }
 }
Exemple #8
0
 public ButtonSystem()
 {
     entities = new Dictionary <BaseEntity, (ButtonComponent, SpriteComponent, PositionComponent)>();
     SystemManager.Add(this);
 }
Exemple #9
0
 public SpriteSystem()
 {
     entities = new Dictionary <BaseEntity, ValueTuple <SpriteComponent, PositionComponent> >();
     SystemManager.Add(this);
 }