From f11498fc44c54cc12a6db3168a70828a49e61a97 Mon Sep 17 00:00:00 2001 From: Zuplyx Date: Sun, 14 Apr 2024 20:52:31 +0200 Subject: [PATCH] Add support for Rimworld 1.5 --- 1.5/Assemblies/RaidsForMe.dll | Bin 0 -> 12288 bytes About/About.xml | 3 +- Source/1.5/GC_RFM.cs | 44 +++++++ .../1.5/Harmony/FactionDialogMaker_Patch.cs | 117 ++++++++++++++++++ Source/1.5/Harmony/Patches.cs | 19 +++ Source/1.5/Properties/AssemblyInfo.cs | 36 ++++++ Source/1.5/RaidForMe.cs | 31 +++++ Source/1.5/RaidForMe.csproj | 51 ++++++++ Source/1.5/RaidForMe.sln | 25 ++++ Source/1.5/Settings.cs | 73 +++++++++++ Source/1.5/Utils.cs | 24 ++++ 11 files changed, 422 insertions(+), 1 deletion(-) create mode 100644 1.5/Assemblies/RaidsForMe.dll create mode 100644 Source/1.5/GC_RFM.cs create mode 100644 Source/1.5/Harmony/FactionDialogMaker_Patch.cs create mode 100644 Source/1.5/Harmony/Patches.cs create mode 100644 Source/1.5/Properties/AssemblyInfo.cs create mode 100644 Source/1.5/RaidForMe.cs create mode 100644 Source/1.5/RaidForMe.csproj create mode 100644 Source/1.5/RaidForMe.sln create mode 100644 Source/1.5/Settings.cs create mode 100644 Source/1.5/Utils.cs diff --git a/1.5/Assemblies/RaidsForMe.dll b/1.5/Assemblies/RaidsForMe.dll new file mode 100644 index 0000000000000000000000000000000000000000..bc66c7d215720ef4728d93138b8cb79c2190782f GIT binary patch literal 12288 zcmeHNeQ+Dsao_g<9DpMY5uij$wroM4g++=Ysqa{_#c$CfB}#-o?U*_ONAfHHN8JIU zV1+U?j+4`C3!aXb^dNheO+N!(7-v6^wCG)|_|u`|wB?Myt0GihSAPNz;& zxxak}fS_dA&L8bR%}LnX-M71M-@bkC?cH(s=*P%MM1K6G zO@y8fKfnB|V(9th$tlZ?PdoOcV`SqgBbT%D@o_Wm6moGZ7w_FW8qeBkv+bH|^i^fk zBYi|e!bc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5/GC_RFM.cs b/Source/1.5/GC_RFM.cs new file mode 100644 index 0000000..146fe45 --- /dev/null +++ b/Source/1.5/GC_RFM.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using RimWorld; +using Verse; +using Verse.AI.Group; +using Verse.AI; +using UnityEngine; + +namespace aRandomKiwi.RFM +{ + public class GC_RFM : GameComponent + { + + public GC_RFM(Game game) + { + this.game = game; + Utils.GCRFM = this; + } + + public override void ExposeData() + { + base.ExposeData(); + + Scribe_Collections.Look(ref this.lastRaidGT, "lastRaidGT", LookMode.Value); + } + + public override void LoadedGame() + { + base.LoadedGame(); + + + } + + public override void StartedNewGame() + { + + } + + public Dictionary lastRaidGT = new Dictionary(); + private Game game; + } +} \ No newline at end of file diff --git a/Source/1.5/Harmony/FactionDialogMaker_Patch.cs b/Source/1.5/Harmony/FactionDialogMaker_Patch.cs new file mode 100644 index 0000000..66f9a7f --- /dev/null +++ b/Source/1.5/Harmony/FactionDialogMaker_Patch.cs @@ -0,0 +1,117 @@ +using Verse; +using Verse.AI; +using Verse.AI.Group; +using HarmonyLib; +using RimWorld; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +namespace aRandomKiwi.RFM +{ + internal class FactionDialogMaker_Patch + { + [HarmonyPatch(typeof(FactionDialogMaker), "FactionDialogFor")] + public class FactionDialogFor + { + private static Texture2D insultTex; + [HarmonyPostfix] + public static void Listener( ref DiaNode __result, Pawn negotiator, Faction faction) + { + DiaOption opt = new DiaOption("RFM_InsultFaction".Translate(faction.leader.LabelCap, faction.Name)); + opt.action = delegate + { + List list = new List(); + string text; + + //Goodwill decrement + faction.TryAffectGoodwillWith(Faction.OfPlayer, -1 * Rand.Range(1,Settings.goodwillLoss+1) , true, true, null, null); + + if (insultTex == null) + insultTex = ContentFinder.Get("Things/Mote/SpeechSymbols/Insult", true); + + //InteractionDefOf.Insult.Worker.Interacted(negotiator, faction.leader, list, out text, out label, out letterDef); + PlayLogEntry_Interaction playLogEntry_Interaction = new PlayLogEntry_Interaction(InteractionDefOf.Insult, negotiator, faction.leader, list); + MoteMaker.MakeInteractionBubble(negotiator, null, InteractionDefOf.Insult.interactionMote, insultTex); + + text = (string) Traverse.Create(playLogEntry_Interaction).Method("ToGameStringFromPOV_Worker", faction.leader, true).GetValue(); + + //If still ally then just display message + if (faction.PlayerRelationKind == FactionRelationKind.Ally || faction.PlayerRelationKind == FactionRelationKind.Neutral) + { + Messages.Message("RFM_InsultAlly".Translate(text, faction.leader.LabelCap, faction.Name), MessageTypeDefOf.NegativeEvent, false); + } + else + { + //If raid + if (Rand.Chance(Settings.chanceGetRaided)) + { + int random = 0; + string sub = ""; + if (Settings.maxHourStartRaid > 0) + random = Rand.Range(Settings.minHourStartRaid, Settings.maxHourStartRaid); + + if (random == 0) + { + sub = "RFM_StartRaidNow".Translate(faction.leader.LabelCap,faction.Name); + } + else + { + sub = "RFM_StartRaidDelayed".Translate(faction.leader.LabelCap,faction.Name,Utils.TranslateTicksToTextIRLSeconds(random * 2500)); + } + + + IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(incCat: IncidentCategoryDefOf.ThreatBig, target: negotiator.Map); + incidentParms.forced = true; + incidentParms.faction = faction; + incidentParms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; + incidentParms.target = negotiator.Map; + + int delay = 0; + //Small chance to get an instant drop pod raid if activated and if faction at minimum industrial level + if (Settings.allowChanceAirDrop && faction.def.techLevel >= TechLevel.Industrial && Rand.Chance(0.05f)) + { + if (Rand.Chance(0.75f)) + { + incidentParms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeDrop; + } + else + { + incidentParms.raidArrivalMode = PawnsArrivalModeDefOf.CenterDrop; + } + //Execution now + sub = "RFM_StartAirDropRaidNow".Translate(faction.leader.LabelCap, faction.Name); + } + else + { + incidentParms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn; + delay = (random * 2500); + } + + Messages.Message("RFM_InsultEnemy".Translate(text, sub), MessageTypeDefOf.NegativeEvent, false); + + Find.Storyteller.incidentQueue.Add(IncidentDefOf.RaidEnemy, Find.TickManager.TicksGame + delay, incidentParms, 240000); + //lastRaidGT increment of the time to wait for the raid + the conventional waiting time + Utils.GCRFM.lastRaidGT[faction.GetUniqueLoadID()] = Find.TickManager.TicksGame + delay + (Settings.timeBeforeInsultingAgain * 2500); + } + else + { + Messages.Message("RFM_InsultEnemyWithoutRaid".Translate(text, faction.leader.LabelCap, faction.Name), MessageTypeDefOf.NegativeEvent, false); + } + } + }; + + //If the waiting time is not reached, the control is grayed out + if ( Utils.GCRFM.lastRaidGT.ContainsKey(faction.GetUniqueLoadID()) && Utils.GCRFM.lastRaidGT[faction.GetUniqueLoadID()] > Find.TickManager.TicksGame) + { + opt.disabled = true; + } + + opt.resolveTree = true; + + //Add dialog menu allowing to insult the interlocutor just before the finish button + __result.options.Insert(__result.options.Count-1, opt); + } + } + } +} \ No newline at end of file diff --git a/Source/1.5/Harmony/Patches.cs b/Source/1.5/Harmony/Patches.cs new file mode 100644 index 0000000..446b834 --- /dev/null +++ b/Source/1.5/Harmony/Patches.cs @@ -0,0 +1,19 @@ +using System; +using System.Reflection; +using HarmonyLib; +using Verse; + +namespace aRandomKiwi.KFM +{ + [StaticConstructorOnStartup] + public static class HarmonyPatches + { + static HarmonyPatches() + { + var inst = new Harmony("rimworld.randomKiwi.RFM"); + inst.PatchAll(Assembly.GetExecutingAssembly()); + } + + public static FieldInfo MapFieldInfo; + } +} diff --git a/Source/1.5/Properties/AssemblyInfo.cs b/Source/1.5/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..acfd0ec --- /dev/null +++ b/Source/1.5/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Les informations générales relatives à un assembly dépendent de +// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations +// associées à un assembly. +[assembly: AssemblyTitle("RaidForMe")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("aRandomKiwi")] +[assembly: AssemblyProduct("RaidForMe")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly +// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de +// COM, affectez la valeur true à l'attribut ComVisible sur ce type. +[assembly: ComVisible(false)] + +// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM +[assembly: Guid("0ed2f8ee-3171-4a47-9e23-2eb50d2515b6")] + +// Les informations de version pour un assembly se composent des quatre valeurs suivantes : +// +// Version principale +// Version secondaire +// Numéro de build +// Révision +// +// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut +// en utilisant '*', comme indiqué ci-dessous : +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.6.0")] +[assembly: AssemblyFileVersion("1.0.6.0")] diff --git a/Source/1.5/RaidForMe.cs b/Source/1.5/RaidForMe.cs new file mode 100644 index 0000000..ef753d6 --- /dev/null +++ b/Source/1.5/RaidForMe.cs @@ -0,0 +1,31 @@ +using HarmonyLib; +using System.Reflection; +using Verse; +using UnityEngine; + +namespace aRandomKiwi.RFM +{ + [StaticConstructorOnStartup] + class RaidForMe : Mod + { + public RaidForMe(ModContentPack content) : base(content) + { + base.GetSettings(); + } + + public void Save() + { + LoadedModManager.GetMod().GetSettings().Write(); + } + + public override string SettingsCategory() + { + return "Raids For Me"; + } + + public override void DoSettingsWindowContents(Rect inRect) + { + Settings.DoSettingsWindowContents(inRect); + } + } +} \ No newline at end of file diff --git a/Source/1.5/RaidForMe.csproj b/Source/1.5/RaidForMe.csproj new file mode 100644 index 0000000..b73d015 --- /dev/null +++ b/Source/1.5/RaidForMe.csproj @@ -0,0 +1,51 @@ + + + + + Debug + AnyCPU + {0ED2F8EE-3171-4A47-9E23-2EB50D2515B6} + Library + Properties + aRandomKiwi.RFM + RaidsForMe + v4.7.2 + 512 + true + + + + false + none + false + ..\..\1.5\Assemblies\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/1.5/RaidForMe.sln b/Source/1.5/RaidForMe.sln new file mode 100644 index 0000000..9f87705 --- /dev/null +++ b/Source/1.5/RaidForMe.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2050 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RaidForMe", "RaidForMe.csproj", "{0ED2F8EE-3171-4A47-9E23-2EB50D2515B6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0ED2F8EE-3171-4A47-9E23-2EB50D2515B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0ED2F8EE-3171-4A47-9E23-2EB50D2515B6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0ED2F8EE-3171-4A47-9E23-2EB50D2515B6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0ED2F8EE-3171-4A47-9E23-2EB50D2515B6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C69E7B3B-CCA2-46DB-9A9A-457148E1453B} + EndGlobalSection +EndGlobal diff --git a/Source/1.5/Settings.cs b/Source/1.5/Settings.cs new file mode 100644 index 0000000..9ddb307 --- /dev/null +++ b/Source/1.5/Settings.cs @@ -0,0 +1,73 @@ +using UnityEngine; +using Verse; +using System; +using System.Collections.Generic; + +namespace aRandomKiwi.RFM +{ + public class Settings : ModSettings + { + public static float chanceGetRaided = 1.0f; + public static int timeBeforeInsultingAgain = 0; + public static bool allowRangedAttack = true; + public static int goodwillLoss = 15; + public static int minHourStartRaid = 1; + public static int maxHourStartRaid = 8; + public static bool allowChanceAirDrop = true; + + public static Vector2 scrollPosition = Vector2.zero; + + public static void DoSettingsWindowContents(Rect inRect) + { + inRect.yMin += 15f; + inRect.yMax -= 15f; + + var defaultColumnWidth = (inRect.width - 50); + Listing_Standard list = new Listing_Standard() { ColumnWidth = defaultColumnWidth }; + + + var outRect = new Rect(inRect.x, inRect.y, inRect.width, inRect.height); + var scrollRect = new Rect(0f, 0f, inRect.width - 16f, inRect.height * 2.2f + 300); + Widgets.BeginScrollView(outRect, ref scrollPosition, scrollRect, true); + + list.Begin(scrollRect); + + + list.CheckboxLabeled("RFM_SettingsAllowChanceAirDrop".Translate(), ref allowChanceAirDrop); + //Percentage chance of RAID generation + list.Label("RFM_SettingsChanceGetRaided".Translate((int)(chanceGetRaided * 100))); + chanceGetRaided = list.Slider(chanceGetRaided, 0.01f, 1.0f); + //Minimum time between raids + list.Label("RFM_SettingsTimeBeforeInsultingAgain".Translate(timeBeforeInsultingAgain)); + timeBeforeInsultingAgain = (int) list.Slider(timeBeforeInsultingAgain, 0, 1000); + //Loss of goodwill when insulting + list.Label("RFM_SettingsGoodwillLoss".Translate(goodwillLoss)); + goodwillLoss = (int)list.Slider(goodwillLoss, 0, 100); + //Minimum hour before start of the raid + list.Label("RFM_SettingsMinHourStartRaid".Translate(minHourStartRaid)); + minHourStartRaid = (int)list.Slider(minHourStartRaid, 0, 128); + //maximum hour before start of the raid + list.Label("RFM_SettingsMaxHourStartRaid".Translate(maxHourStartRaid)); + if (maxHourStartRaid < minHourStartRaid) + maxHourStartRaid += 1; + + maxHourStartRaid = (int)list.Slider(maxHourStartRaid, 0, 128); + + list.End(); + Widgets.EndScrollView(); + } + + public override void ExposeData() + { + base.ExposeData(); + + Scribe_Values.Look(ref chanceGetRaided, "chanceGetRaided", 1.0f); + Scribe_Values.Look(ref timeBeforeInsultingAgain, "timeBeforeInsultingAgain", 0); + Scribe_Values.Look(ref goodwillLoss, "goodwillLoss", 15); + Scribe_Values.Look(ref minHourStartRaid, "minHourStartRaid", 1); + Scribe_Values.Look(ref maxHourStartRaid, "maxHourStartRaid", 8); + Scribe_Values.Look(ref allowChanceAirDrop, "allowChanceAirDrop", true); + + } + } +} \ No newline at end of file diff --git a/Source/1.5/Utils.cs b/Source/1.5/Utils.cs new file mode 100644 index 0000000..655d3e9 --- /dev/null +++ b/Source/1.5/Utils.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using RimWorld; +using Verse; +using UnityEngine; + +namespace aRandomKiwi.RFM +{ + static class Utils + { + static public GC_RFM GCRFM; + + public static string TranslateTicksToTextIRLSeconds(int ticks) + { + //If less than one hour ingame then display seconds + if (ticks < 2500) + return ticks.ToStringSecondsFromTicks(); + else + return ticks.ToStringTicksToPeriodVerbose(true); + } + } +}