示例#1
0
 public static void Postfix(Thing __instance, bool respawningAfterLoad)
 {
     if ((__instance?.Map?.IsPlayerHome ?? false) && __instance.def.mote == null)
     {
         StoryHandler.Missions.ForEach(m => m.objectives.Where(o => o.CurrentState == MOState.Active).Do(o =>
         {
             o.thingTracker?.ProcessTarget(__instance.def, __instance.Position, __instance.Map, ObjectiveType.MapCheck, __instance, __instance as Pawn);
         }));
         Dictionary<ObjectiveDef, List<ThingDef>> stations = StoryHandler.StationDefs();
         foreach (ObjectiveDef objective in stations.Keys)
         {
             if (stations[objective].Contains(__instance.def))
             {
                 bool active = __instance.TryGetComp<CompPowerTrader>()?.PowerOn ?? true;
                 ObjectiveStation station = StoryHandler.AllStations.Station(null, __instance);
                 if (station != null)
                 {
                     if (!station.objectives.Contains(objective))
                     {
                         station.objectives.Add(objective);
                     }
                     return;
                 }
                 StoryHandler.AllStations.Add(new ObjectiveStation(__instance, objective, active));
             }
         }
     }
 }
        private void UpdateStations()
        {
            //Check power for stations
            List <Thing> PoweredThings = AllStations.Stations();

            foreach (Thing thing in PoweredThings)
            {
                CompPowerTrader  compPower = thing.TryGetComp <CompPowerTrader>();
                ObjectiveStation station   = AllStations.Station(null, thing);
                station.active = compPower?.PowerOn ?? true;
            }
            AllStations.RemoveAll(t => t.station.DestroyedOrNull());
        }
        public void Notify_NewMission(Mission mission)
        {
            List <Thing> PoweredThings = AllStations.Stations();

            foreach (Thing thing in PoweredThings)
            {
                foreach (Objective objective in mission.objectives)
                {
                    if (objective.CurrentState != MOState.Finished && objective.def.type == ObjectiveType.Research && (objective.def.targetSettings?.targets.Any(tv => tv.ThingDef == thing.def) ?? false))
                    {
                        ObjectiveStation station = StoryHandler.AllStations.Station(null, thing);
                        if (station != null)
                        {
                            station.AddObjective(objective);
                        }
                    }
                }
            }
        }