示例#1
0
        /// <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);
            }
        }
示例#2
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>();
        }
示例#3
0
        public override void InitializeSlaveEntry(Actor slave, BaseSpawnerSlaveEntry entry)
        {
            var se = entry as CarrierSlaveEntry;

            base.InitializeSlaveEntry(slave, se);

            se.RearmTicks   = 0;
            se.IsLaunched   = false;
            se.SpawnerSlave = slave.Trait <CarrierSlave>();
        }
示例#4
0
        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);
        }
示例#5
0
        /// <summary>
        /// Replenish one slave entry.
        /// </summary>
        /// <returns>true when a new slave actor is created.</returns>
        public 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);
        }
示例#6
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>();
 }