private void CheckDisableSlaves()
        {
            List <Actor> remoteMasterActorsInThisMap = new List <Actor>();
            bool         ret = IsDisableAllSlaves(self, out remoteMasterActorsInThisMap);

            if (remoteMasterActorsInThisMap == null)
            {
                ret = true;
            }
            if (ret)
            {
                foreach (Actor slave in slaves)
                {
                    RemoteControlSlave s = slave.TraitOrDefault <RemoteControlSlave>();
                    if (s != null)
                    {
                        s.RevokeCondition();
                    }
                }
            }
            else
            {
                Random rand = new Random();
                rand.Next(0, remoteMasterActorsInThisMap.Count);
                foreach (Actor slave in slaves)
                {
                    RemoteControlSlave s = slave.TraitOrDefault <RemoteControlSlave>();
                    if (s != null && !s.HasMaster)
                    {
                        s.LinkMaster(remoteMasterActorsInThisMap[rand.Next()].TraitOrDefault <RemoteControlMaster>());
                    }
                }
            }
        }
        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();
        }