Esempio n. 1
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);

            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 CenterPositionInit(startEdge + spawnOffset),
                        new OwnerInit(self.Owner),
                        new FacingInit(attackFacing)
                    });

                    // Initialize slave entry
                    InitializeSlaveEntry(slave, entry);
                    entry.SpawnerSlave.LinkMaster(entry.Actor, self, this);
                }
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Replenish destoyed slaves or create new ones from nothing.
        /// Follows policy defined by Info.OneShotSpawn.
        /// </summary>
        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);
            }
        }
Esempio n. 3
0
        public override void InitializeSlaveEntry(Actor slave, BaseSpawnerSlaveEntry entry)
        {
            var se = entry as MobSpawnerSlaveEntry;

            base.InitializeSlaveEntry(slave, se);

            se.SpawnerSlave = slave.Trait <MobSpawnerSlave>();
            se.Health       = slave.Trait <Health>();
        }
Esempio n. 4
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>();
        }
Esempio n. 5
0
        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>();
        }
Esempio n. 6
0
        public virtual BaseSpawnerSlaveEntry[] CreateSlaveEntries(BaseSpawnerMasterInfo info)
        {
            var slaveEntries = new BaseSpawnerSlaveEntry[info.Actors.Length];

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

            return(slaveEntries);
        }
Esempio n. 7
0
        /// <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>();

            if (IsTraitDisabled)
            {
                entry.SpawnerSlave.GrantMasterDisabledCondition(entry.Actor);
            }

            if (IsTraitPaused)
            {
                entry.SpawnerSlave.GrantMasterPausedCondition(entry.Actor);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Replenish one slave entry.
        /// </summary>
        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);
        }
Esempio n. 9
0
        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));
                }
            }
        }
Esempio n. 10
0
 /// <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>();
 }