Exemplo n.º 1
0
        /// <summary>
        /// Create a new system instance from the block if the block comes with a system.
        /// </summary>
        public static bool Create(CompleteStructure structure, RealLiveBlock block, out BotSystem system)
        {
            if (!Constructors.TryGetValue(block.Info.Type, out SystemConstructor constructor))
            {
                system = null;
                return(false);
            }

            system = constructor(structure, block);
            return(true);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Add a new system to the storage.
 /// </summary>
 public void Add(BlockPosition position, BotSystem system)
 {
     _systems.Add(position, system);
     if (system is PropulsionSystem propulsion)
     {
         _propulsions.Add(propulsion);
     }
     else if (system is WeaponSystem weapon)
     {
         if (WeaponType == WeaponSystem.Type.None)
         {
             WeaponType = weapon.Constants.Type;
         }
         _weapons.Add(weapon);
     }
     else
     {
         Assert.IsNull(_active, "The active system can only be set once.");
         _active = system as ActiveSystem;
     }
 }