예제 #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 virtual 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 carrierSlaveEntry = entry as CarrierSlaveEntry;

            base.InitializeSlaveEntry(slave, carrierSlaveEntry);

            carrierSlaveEntry.RearmTicks   = 0;
            carrierSlaveEntry.IsLaunched   = false;
            carrierSlaveEntry.SpawnerSlave = slave.Trait <CarrierSlave>();
        }
예제 #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 <MarkerSlave>();
        }
예제 #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
        void Launch(Actor self, BaseSpawnerSlaveEntry se, CPos targetLocation)
        {
            var slave = se.Actor;

            SpawnIntoWorld(self, slave, self.CenterPosition);

            self.World.AddFrameEndTask(w =>
            {
                slave.QueueActivity(new FindAndDeliverResources(slave));
            });
        }
예제 #6
0
        void Launch(Actor master, BaseSpawnerSlaveEntry slaveEntry, CPos targetLocation)
        {
            var slave = slaveEntry.Actor;

            SpawnIntoWorld(master, slave, master.CenterPosition);

            master.World.AddFrameEndTask(w =>
            {
                slave.QueueActivity(new FindAndDeliverResources(slave, master));
            });
        }
예제 #7
0
        /// <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);
        }
예제 #8
0
        // Launch a freshly created slave that isn't in world to the world.
        void Launch(Actor self, BaseSpawnerSlaveEntry se, CPos targetLocation)
        {
            var slave = se.Actor;

            SpawnIntoWorld(self, slave, self.CenterPosition);

            self.World.AddFrameEndTask(w =>
            {
                // Move into world, if not. Ground units get stuck without this.
                if (info.SpawnIsGroundUnit)
                {
                    var mv = se.Actor.Trait <IMove>().MoveToTarget(slave, Target.FromPos(self.CenterPosition));
                    if (mv != null)
                    {
                        slave.QueueActivity(mv);
                    }
                }

                AssignTargetForSpawned(slave, targetLocation);
            });
        }
예제 #9
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 =>
            {
                var slave = w.CreateActor(attacker, new TypeDictionary()
                {
                    new OwnerInit(self.Owner)
                });

                // Initialize slave entry
                InitializeSlaveEntry(slave, entry);
                entry.SpawnerSlave.LinkMaster(entry.Actor, self, this);
            });
        }
예제 #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>();
 }
예제 #11
0
        private void Launch(Actor master, BaseSpawnerSlaveEntry slaveEntry, CPos targetLocation)
        {
            var slave = slaveEntry.Actor;

            SpawnIntoWorld(master, slave, master.CenterPosition);
        }