/// <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); } }
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 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>(); }
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); }
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)); }); }
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)); }); }
/// <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); }
// 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); }); }
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); }); }
/// <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>(); }
private void Launch(Actor master, BaseSpawnerSlaveEntry slaveEntry, CPos targetLocation) { var slave = slaveEntry.Actor; SpawnIntoWorld(master, slave, master.CenterPosition); }