protected override void Created(Actor self) { conditionManager = self.Trait <ConditionManager>(); if (conditionToken == ConditionManager.InvalidConditionToken) { //Grant condition to all actors belong to this faction World w = self.World; var actors = w.Actors.Where(o => o.Owner == self.Owner); foreach (var actor in actors) { RemoteControlSlave slave = actor.TraitOrDefault <RemoteControlSlave>(); if (slave == null) { continue; } if (slave.HasMaster) { continue; } slave.LinkMaster(this); slave.GrandCondition(info.GrantRemoteControlCondition); slaves.Add(actor); } } base.Created(self); }
public void Tick(Actor self) { World w = self.World; var actors = w.Actors.Where(o => o.Owner == self.Owner); foreach (var actor in actors) { RemoteControlSlave slave = actor.TraitOrDefault <RemoteControlSlave>(); if (slave == null) { continue; } if (slave.HasMaster) { continue; } if (slaves.Where(o => o.ActorID == actor.ActorID).Count() == 0) { slave.LinkMaster(this); slave.GrandCondition(info.GrantRemoteControlCondition); slaves.Add(actor); } } for (int i = slaves.Count - 1; i >= 0; i--) { Actor s = slaves[i]; if (!s.IsInWorld || s.IsDead) { slaves.RemoveAt(i); } } CheckDisableSlaves(); }