コード例 #1
0
            internal bool <> m__0(Region x)
            {
                FacilitiesUtility.visited.Add(x);
                List <Thing> list = x.ListerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial);

                for (int i = 0; i < list.Count; i++)
                {
                    if (!FacilitiesUtility.processed.Contains(list[i]))
                    {
                        FacilitiesUtility.processed.Add(list[i]);
                        CompFacility             compFacility             = list[i].TryGetComp <CompFacility>();
                        CompAffectedByFacilities compAffectedByFacilities = list[i].TryGetComp <CompAffectedByFacilities>();
                        if (compFacility != null)
                        {
                            compFacility.Notify_LOSBlockerSpawnedOrDespawned();
                            this.facilitiesProcessed++;
                        }
                        if (compAffectedByFacilities != null)
                        {
                            compAffectedByFacilities.Notify_LOSBlockerSpawnedOrDespawned();
                            this.affectedByFacilitiesProcessed++;
                        }
                    }
                }
                return(this.facilitiesProcessed >= this.facilitiesToProcess && this.affectedByFacilitiesProcessed >= this.affectedByFacilitiesToProcess);
            }
コード例 #2
0
        private void FacilityChanged()
        {
            CompFacility             compFacility             = this.TryGetComp <CompFacility>();
            CompAffectedByFacilities compAffectedByFacilities = this.TryGetComp <CompAffectedByFacilities>();

            compFacility?.Notify_ThingChanged();
            compAffectedByFacilities?.Notify_ThingChanged();
        }
コード例 #3
0
        public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot)
        {
            Map visibleMap = Find.VisibleMap;

            if (def.HasComp(typeof(CompAffectedByFacilities)))
            {
                CompAffectedByFacilities.DrawLinesToPotentialThingsToLinkTo(def, center, rot, visibleMap);
            }
            else
            {
                CompFacility.DrawLinesToPotentialThingsToLinkTo(def, center, rot, visibleMap);
            }
        }
        public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol, Thing thing = null)
        {
            Map currentMap = Find.CurrentMap;

            if (def.HasComp(typeof(CompAffectedByFacilities)))
            {
                CompAffectedByFacilities.DrawLinesToPotentialThingsToLinkTo(def, center, rot, currentMap);
            }
            else
            {
                CompFacility.DrawLinesToPotentialThingsToLinkTo(def, center, rot, currentMap);
            }
        }
コード例 #5
0
        private void FacilityChanged()
        {
            CompFacility             compFacility             = this.TryGetComp <CompFacility>();
            CompAffectedByFacilities compAffectedByFacilities = this.TryGetComp <CompAffectedByFacilities>();

            if (compFacility != null)
            {
                compFacility.Notify_ThingChanged();
            }
            if (compAffectedByFacilities != null)
            {
                compAffectedByFacilities.Notify_ThingChanged();
            }
        }
コード例 #6
0
 public static void NotifyFacilitiesAboutChangedLOSBlockers(List <Region> affectedRegions)
 {
     if (FacilitiesUtility.working)
     {
         Log.Warning("Tried to update facilities while already updating.");
     }
     else
     {
         FacilitiesUtility.working = true;
         try
         {
             FacilitiesUtility.visited.Clear();
             for (int i = 0; i < affectedRegions.Count; i++)
             {
                 if (!FacilitiesUtility.visited.Contains(affectedRegions[i]))
                 {
                     RegionTraverser.BreadthFirstTraverse(affectedRegions[i], (Region from, Region r) => !FacilitiesUtility.visited.Contains(r), delegate(Region x)
                     {
                         FacilitiesUtility.visited.Add(x);
                         List <Thing> list = x.ListerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial);
                         for (int j = 0; j < list.Count; j++)
                         {
                             CompFacility compFacility = list[j].TryGetComp <CompFacility>();
                             CompAffectedByFacilities compAffectedByFacilities = list[j].TryGetComp <CompAffectedByFacilities>();
                             if (compFacility != null)
                             {
                                 compFacility.Notify_LOSBlockerSpawnedOrDespawned();
                             }
                             if (compAffectedByFacilities != null)
                             {
                                 compAffectedByFacilities.Notify_LOSBlockerSpawnedOrDespawned();
                             }
                         }
                         return(false);
                     }, FacilitiesUtility.RegionsToSearch, RegionType.Set_Passable);
                 }
             }
         }
         finally
         {
             FacilitiesUtility.working = false;
             FacilitiesUtility.visited.Clear();
         }
     }
 }
コード例 #7
0
ファイル: FacilitiesUtility.cs プロジェクト: potsh/RimWorld
 public static void NotifyFacilitiesAboutChangedLOSBlockers(List <Region> affectedRegions)
 {
     if (affectedRegions.Any())
     {
         if (working)
         {
             Log.Warning("Tried to update facilities while already updating.");
         }
         else
         {
             working = true;
             try
             {
                 visited.Clear();
                 processed.Clear();
                 int facilitiesToProcess           = affectedRegions[0].Map.listerThings.ThingsInGroup(ThingRequestGroup.Facility).Count;
                 int affectedByFacilitiesToProcess = affectedRegions[0].Map.listerThings.ThingsInGroup(ThingRequestGroup.AffectedByFacilities).Count;
                 int facilitiesProcessed           = 0;
                 int affectedByFacilitiesProcessed = 0;
                 if (facilitiesToProcess > 0 && affectedByFacilitiesToProcess > 0)
                 {
                     for (int i = 0; i < affectedRegions.Count; i++)
                     {
                         if (!visited.Contains(affectedRegions[i]))
                         {
                             RegionTraverser.BreadthFirstTraverse(affectedRegions[i], (Region from, Region r) => !visited.Contains(r), delegate(Region x)
                             {
                                 visited.Add(x);
                                 List <Thing> list = x.ListerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial);
                                 for (int j = 0; j < list.Count; j++)
                                 {
                                     if (!processed.Contains(list[j]))
                                     {
                                         processed.Add(list[j]);
                                         CompFacility compFacility = list[j].TryGetComp <CompFacility>();
                                         CompAffectedByFacilities compAffectedByFacilities = list[j].TryGetComp <CompAffectedByFacilities>();
                                         if (compFacility != null)
                                         {
                                             compFacility.Notify_LOSBlockerSpawnedOrDespawned();
                                             facilitiesProcessed++;
                                         }
                                         if (compAffectedByFacilities != null)
                                         {
                                             compAffectedByFacilities.Notify_LOSBlockerSpawnedOrDespawned();
                                             affectedByFacilitiesProcessed++;
                                         }
                                     }
                                 }
                                 return(facilitiesProcessed >= facilitiesToProcess && affectedByFacilitiesProcessed >= affectedByFacilitiesToProcess);
                             }, RegionsToSearch);
                             if (facilitiesProcessed >= facilitiesToProcess && affectedByFacilitiesProcessed >= affectedByFacilitiesToProcess)
                             {
                                 break;
                             }
                         }
                     }
                 }
             }
             finally
             {
                 working = false;
                 visited.Clear();
                 processed.Clear();
             }
         }
     }
 }