Ejemplo n.º 1
0
        public void FindNextGroupId()
        {
            const int maxIdValue = 1000;

            for (int id = 1; id <= 1000; id++)
            {
                if (id == maxIdValue)
                {
                    Log.Warning("MiningCo. spotlight turret: found no free group ID. Resetting to 1.");
                    nextGroupId = 1;
                    return;
                }
                bool idIsFree = true;
                foreach (Thing thing in this.Map.listerThings.ThingsOfDef(Util_SpotlightTurret.SpotlightTurretDef))
                {
                    Building_SpotlightTurret turret = thing as Building_SpotlightTurret;
                    if ((turret != null) &&
                        (turret.groupId == id))
                    {
                        idIsFree = false;
                        break;
                    }
                }
                if (idIsFree)
                {
                    nextGroupId = id;
                    break;
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Synchronize a group of turrets (instantaneously reset their light rotation).
 /// </summary>
 public void SynchronizeTurretsInGroup()
 {
     if (this.groupId == 0)
     {
         return;
     }
     foreach (Building building in this.Map.listerBuildings.AllBuildingsColonistOfDef(Util_SpotlightTurret.SpotlightTurretDef))
     {
         Building_SpotlightTurret turret = building as Building_SpotlightTurret;
         if ((turret != null) &&
             (turret.groupId == this.groupId) &&
             (turret.target == null) &&
             (turret.Faction == this.Faction) &&
             turret.powerComp.PowerOn)
         {
             turret.spotLightRotation = turret.Rotation.AsAngle;
             turret.spotLightRange    = spotlightMinRange;
             turret.StartNewIdleMotion();
         }
     }
 }