/// <summary>
        /// Replenish destoyed slaves or create new ones from nothing.
        /// Follows policy defined by Info.OneShotSpawn.
        /// </summary>
        /// <returns>true when a new slave actor is created.</returns>
        public void Replenish(Actor self, BaseSpawnerSlaveEntry[] slaveEntries)
        {
            if (Info.SpawnAllAtOnce)
            {
                foreach (var se in slaveEntries)
                {
                    if (!se.IsValid)
                    {
                        Replenish(self, se);
                    }
                }
            }
            else
            {
                BaseSpawnerSlaveEntry entry = SelectEntryToSpawn(slaveEntries);

                // All are alive and well.
                if (entry == null)
                {
                    return;
                }

                Replenish(self, entry);
            }
        }
Beispiel #2
0
        public override void InitializeSlaveEntry(Actor slave, BaseSpawnerSlaveEntry entry)
        {
            var se = entry as AirstrikeSlaveEntry;

            base.InitializeSlaveEntry(slave, se);

            se.RearmTicks   = 0;
            se.IsLaunched   = false;
            se.SpawnerSlave = slave.Trait <AirstrikeSlave>();
        }
        public override void InitializeSlaveEntry(Actor slave, BaseSpawnerSlaveEntry entry)
        {
            var carrierSlaveEntry = entry as CarrierSlaveEntry;

            base.InitializeSlaveEntry(slave, carrierSlaveEntry);

            carrierSlaveEntry.RearmTicks   = 0;
            carrierSlaveEntry.IsLaunched   = false;
            carrierSlaveEntry.SpawnerSlave = slave.Trait <CarrierSlave>();
        }
        public virtual BaseSpawnerSlaveEntry[] CreateSlaveEntries(BaseSpawnerMasterInfo info)
        {
            var slaveEntries = new BaseSpawnerSlaveEntry[info.Actors.Length];

            for (int i = 0; i < slaveEntries.Length; i++)
            {
                slaveEntries[i] = new BaseSpawnerSlaveEntry();
            }

            return(slaveEntries);
        }
        /// <summary>
        /// Replenish one slave entry.
        /// </summary>
        /// <returns>true when a new slave actor is created.</returns>
        public virtual void Replenish(Actor self, BaseSpawnerSlaveEntry entry)
        {
            if (entry.IsValid)
            {
                throw new InvalidOperationException("Replenish must not be run on a valid entry!");
            }

            // Some members are missing. Create a new one.
            var slave = self.World.CreateActor(false, entry.ActorName,
                                               new TypeDictionary {
                new OwnerInit(self.Owner)
            });

            // Initialize slave entry
            InitializeSlaveEntry(slave, entry);
            entry.SpawnerSlave.LinkMaster(entry.Actor, self, this);
        }
Beispiel #6
0
        public override void Replenish(Actor self, BaseSpawnerSlaveEntry entry)
        {
            if (entry.IsValid)
            {
                throw new InvalidOperationException("Replenish must not be run on a valid entry!");
            }

            string attacker = entry.ActorName;

            Game.Sound.Play(SoundType.World, Info.MarkSound);

            var aircraftInRange = new Dictionary <Actor, bool>();

            self.World.AddFrameEndTask(w =>
            {
                for (var i = -Info.SquadSize / 2; i <= Info.SquadSize / 2; i++)
                {
                    // Even-sized squads skip the lead plane
                    if (i == 0 && (Info.SquadSize & 1) == 0)
                    {
                        continue;
                    }

                    // Includes the 90 degree rotation between body and world coordinates

                    var slave = w.CreateActor(attacker, new TypeDictionary()
                    {
                        new OwnerInit(self.Owner)
                    }

                                              /*, new TypeDictionary
                                               * {
                                               * new CenterPositionInit(startEdge + spawnOffset),
                                               * new OwnerInit(self.Owner),
                                               * new FacingInit(attackFacing),
                                               * }*/);

                    // Initialize slave entry
                    InitializeSlaveEntry(slave, entry);
                    entry.SpawnerSlave.LinkMaster(entry.Actor, self, this);
                }
            });
        }
        public override void Replenish(Actor self, BaseSpawnerSlaveEntry entry)
        {
            base.Replenish(self, entry);

            string spawnContainCondition;

            if (conditionManager != null)
            {
                if (Info.SpawnContainConditions.TryGetValue(entry.Actor.Info.Name, out spawnContainCondition))
                {
                    spawnContainTokens.GetOrAdd(entry.Actor.Info.Name).Push(conditionManager.GrantCondition(self, spawnContainCondition));
                }

                if (!string.IsNullOrEmpty(Info.LoadedCondition))
                {
                    loadedTokens.Push(conditionManager.GrantCondition(self, Info.LoadedCondition));
                }
            }
        }
 /// <summary>
 /// Slave entry initializer function.
 /// Override this function from derived classes to initialize their own specific stuff.
 /// </summary>
 public virtual void InitializeSlaveEntry(Actor slave, BaseSpawnerSlaveEntry entry)
 {
     entry.Actor        = slave;
     entry.SpawnerSlave = slave.Trait <BaseSpawnerSlave>();
 }