protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            RuinedBaseComp comp = (p.Map?.Parent as MapParent)?.GetComponent <RuinedBaseComp>();

            if (comp == null)
            {
                return(ThoughtState.Inactive);
            }
            if (!comp.isActive)
            {
                return(ThoughtState.Inactive);
            }

            if (comp.currentCapCost < MaxForUpset)
            {
                return(ThoughtState.ActiveAtStage(0));
            }
            if (comp.currentCapCost > MinForExtreme)
            {
                return(ThoughtState.ActiveAtStage(4));
            }
            if (comp.currentCapCost > MinForVeryHigh)
            {
                return(ThoughtState.ActiveAtStage(3));
            }
            if (comp.currentCapCost > MinForHigh)
            {
                return(ThoughtState.ActiveAtStage(2));
            }
            if (comp.currentCapCost > MinForMedium)
            {
                return(ThoughtState.ActiveAtStage(1));
            }
            return(ThoughtState.Inactive);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Faction faction = parms.faction;

            if (faction == null)
            {
                faction = Find.FactionManager.RandomNonHostileFaction(false, false, false, TechLevel.Undefined);
            }
            if (faction == null)
            {
                return(false);
            }
            if (!TryFindTile(out int tile))
            {
                return(false);
            }

            AbandonedBaseWorldObject site = (AbandonedBaseWorldObject)WorldObjectMaker.MakeWorldObject(DefDatabase <WorldObjectDef> .GetNamed("AbandonedBase"));

            site.Tile = tile;
            site.SetFaction(null);
            Find.WorldObjects.Add(site);

            string    filename = null;
            Blueprint bp       = BlueprintFinder.FindRandomBlueprintWithParameters(out filename, 6400, 0.01f, 30000, maxAttemptsCount: 50);

            RuinedBaseComp comp = site.GetComponent <RuinedBaseComp>();

            if (comp == null)
            {
                Debug.Warning("Component is null");
            }
            else
            {
                Debug.Warning("Starting scavenging...");
                int cost = 10000;
                if (bp != null)
                {
                    cost = (int)bp.totalCost;
                }
                comp.blueprintFileName = filename;
                comp.StartScavenging(cost);
            }



            var    lifetime   = (int)(Math.Pow(site.GetComponent <RuinedBaseComp>().currentCapCost / 1000, 0.41) * 1.1);
            string letterText = GetLetterText(faction, lifetime);

            Find.LetterStack.ReceiveLetter(def.letterLabel, letterText, def.letterDef, site, faction, null);
            return(true);
        }
Пример #3
0
 static bool Prefix(ref bool __result, Map map)
 {
     if (RealRuins_ModSettings.caravanReformType != 2)
     {
         return(true); //ignore if setting is off
     }
     else if (map.Parent is AbandonedBaseWorldObject ||
              map.Parent is RealRuinsPOIWorldObject)
     {
         RuinedBaseComp comp = (map.Parent as WorldObject)?.GetComponent <RuinedBaseComp>();
         if (comp?.mapExitLocked == true)
         {
             __result = true; //Always think there is something hostile in an abandoned base event if it was not explicitly unlocket dy the map itself
             return(false);   //prevent original method execution
         }
     }
     return(true);
 }