SHARE
TWEET

Untitled

a guest Mar 24th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     [StaticConstructorOnStartup]
  2.     static class Patching
  3.     {
  4.  
  5.         static HarmonyInstance harmony;
  6.  
  7.         public static void PatchAll()
  8.         {
  9.             harmony = HarmonyInstance.Create("net.marvinkosh.rimworld.mod.thingsgowrong");
  10.  
  11.             Log.Message("Things Go Wrong: Starting annotated patching.");
  12.  
  13.             harmony.Patch(AccessTools.Method(typeof(TwitchToolkit.Incidents.IncidentWorker_RaidEnemy), "TryExecuteWorker"), new HarmonyMethod(typeof(Patching).GetMethod("Try_Execute_Worker_Patch.Prefix")));
  14.  
  15.             Log.Message("Things Go Wrong: Annotated patching complete.");
  16.  
  17.         }
  18.     }
  19.  
  20.     class Try_Execute_Worker_Patch
  21.     {
  22.         static bool Prefix(ref bool __result, IncidentParms parms)
  23.         {
  24.             int chanceForRaidGoesWrong = TGW_Loader.settings.tgw_chancePercent;
  25.  
  26.             if ((Rand.RangeInclusive(0, 100)) < chanceForRaidGoesWrong)
  27.             {
  28.                 var raidEnemy = new TwitchToolkit_RaidEnemy();
  29.                 __result = raidEnemy.TryRandomExecuteWorker(parms);
  30.                 if (__result)
  31.                 {
  32.                     Find.TickManager.slower.SignalForceNormalSpeedShort();
  33.                     Find.StoryWatcher.statsRecord.numRaidsEnemy++;
  34.                 }
  35.                 return false;
  36.             }
  37.             return true;
  38.         }
  39.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top