diff --git a/About/ModSync.xml b/About/ModSync.xml index 6f49987..e9163f5 100644 --- a/About/ModSync.xml +++ b/About/ModSync.xml @@ -2,7 +2,7 @@ 1e80a892-6217-4b34-9430-85d6ac00e66f More Faction Interaction - 0.1.0.6 + 0.1.0.7 False Mehni diff --git a/Assemblies/MoreFactionInteraction.dll b/Assemblies/MoreFactionInteraction.dll index 75e24c8..0fd7a6a 100644 Binary files a/Assemblies/MoreFactionInteraction.dll and b/Assemblies/MoreFactionInteraction.dll differ diff --git a/MoreFactionInteraction/General/HarmonyPatches.cs b/MoreFactionInteraction/General/HarmonyPatches.cs index 710e94a..86ef43f 100644 --- a/MoreFactionInteraction/General/HarmonyPatches.cs +++ b/MoreFactionInteraction/General/HarmonyPatches.cs @@ -6,6 +6,7 @@ using Harmony; using UnityEngine; using RimWorld.Planet; +using MoreFactionInteraction.MoreFactionWar; using System.Reflection; using System.Reflection.Emit; @@ -51,6 +52,28 @@ static HarmonyPatches() //harmony.Patch(original: AccessTools.Method(type: typeof(ThoughtWorker_PsychicEmanatorSoothe), name: "CurrentStateInternal"), prefix: null, postfix: null, // transpiler: new HarmonyMethod(type: typeof(HarmonyPatches), name: nameof(PsychicEmanatorSoothe_Transpiler))); + if (ModsConfig.ActiveModsInLoadOrder.Any(m => m.Name == "Relations Tab")) + { + try + { + ((Action)(() => + { + harmony.Patch(AccessTools.Method(typeof(Fluffy_Relations.MainTabWindow_Relations), nameof(Fluffy_Relations.MainTabWindow_Relations.DrawFactionInformation)), null, + new HarmonyMethod(typeof(HarmonyPatches), nameof(WonderfullyFluffyRelations))); + }))(); + } + catch (TypeLoadException) { } + } + } + + private static void WonderfullyFluffyRelations(ref float __result, Faction faction, Vector2 pos, float width) + { + if (Find.World.GetComponent().StuffIsGoingDown) + { + Rect canvas = new Rect(pos.x, pos.y + 5, width, 125f); + MainTabWindow_FactionWar.DrawFactionWarBar(canvas); + __result += 125f; + } } //private static IEnumerable PsychicEmanatorSoothe_Transpiler(IEnumerable instructions) diff --git a/MoreFactionInteraction/MoreFactionInteraction.csproj b/MoreFactionInteraction/MoreFactionInteraction.csproj index 9cf6d8f..4c9bcef 100644 --- a/MoreFactionInteraction/MoreFactionInteraction.csproj +++ b/MoreFactionInteraction/MoreFactionInteraction.csproj @@ -41,6 +41,10 @@ C:\Program Files (x86)\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp.dll False + + C:\Program Files (x86)\Steam\steamapps\workshop\content\294100\709317151\Assemblies\Fluffy_Relations.dll + False + diff --git a/MoreFactionInteraction/MoreFactionWar/MainTabWindow_FactionWar.cs b/MoreFactionInteraction/MoreFactionWar/MainTabWindow_FactionWar.cs index fd7b967..f594217 100644 --- a/MoreFactionInteraction/MoreFactionWar/MainTabWindow_FactionWar.cs +++ b/MoreFactionInteraction/MoreFactionWar/MainTabWindow_FactionWar.cs @@ -1,6 +1,8 @@ using RimWorld; using Verse; using UnityEngine; +using System.Linq; +using System; namespace MoreFactionInteraction.MoreFactionWar { @@ -9,37 +11,37 @@ public class MainTabWindow_FactionWar : MainTabWindow_Factions private const float TitleHeight = 70f; private const float InfoHeight = 60f; - private Texture2D factionOneColorTexture; - private Texture2D factionTwoColorTexture; + private static Texture2D factionOneColorTexture; + private static Texture2D factionTwoColorTexture; - public Texture2D FactionOneColorTexture + public static Texture2D FactionOneColorTexture { get { - if (this.factionOneColorTexture == null) + Faction factionOne = Find.World.GetComponent().WarringFactionOne; + + if (factionOneColorTexture == null && factionOne != null) { - this.factionOneColorTexture = SolidColorMaterials.NewSolidColorTexture(factionOne.Color); + factionOneColorTexture = SolidColorMaterials.NewSolidColorTexture(factionOne.Color); } - return this.factionOneColorTexture; + return factionOneColorTexture; } } - public Texture2D FactionTwoColorTexture + public static Texture2D FactionTwoColorTexture { get { - if (this.factionTwoColorTexture == null) + Faction factionInstigator = Find.World.GetComponent().WarringFactionTwo; + + if (factionTwoColorTexture == null && factionInstigator != null) { - this.factionTwoColorTexture = SolidColorMaterials.NewSolidColorTexture(factionInstigator.Color); + factionTwoColorTexture = SolidColorMaterials.NewSolidColorTexture(factionInstigator.Color); } - return this.factionTwoColorTexture; + return factionTwoColorTexture; } } - readonly Faction factionOne = Find.World.GetComponent().WarringFactionOne; - readonly Faction factionInstigator = Find.World.GetComponent().WarringFactionTwo; - - //[TweakValue("MainTabWindow_FactionWar", -100f, 150f)] private static float yMaxOffset = 0; @@ -60,7 +62,7 @@ public override void DoWindowContents(Rect fillRect) } else { - this.DrawFactionWarBar(fillRect); + DrawFactionWarBar(fillRect); // scooch down original. amount of offset depends on devmode or not (because of devmode "show all" button) Rect baseRect = fillRect; @@ -73,9 +75,15 @@ public override void DoWindowContents(Rect fillRect) } } - private void DrawFactionWarBar(Rect fillRect) + public static void DrawFactionWarBar(Rect fillRect) { - Rect position = new Rect(0f, 0f, fillRect.width, fillRect.height); + if (!Find.World.GetComponent().StuffIsGoingDown) + return; + + Faction factionOne = Find.World.GetComponent().WarringFactionOne; + Faction factionInstigator = Find.World.GetComponent().WarringFactionTwo; + + Rect position = new Rect(fillRect.x, fillRect.y, fillRect.width, fillRect.height); GUI.BeginGroup(position); Text.Font = GameFont.Small; GUI.color = Color.white; @@ -100,9 +108,9 @@ private void DrawFactionWarBar(Rect fillRect) //"score card" bar Rect leftFactionOneScoreBox = new Rect(0f, yPositionBar, position.width * Find.World.GetComponent().ScoreForFaction(factionOne), barHeight); - GUI.DrawTexture(leftFactionOneScoreBox, this.FactionOneColorTexture); - Rect rightFactionTwoScoreBox = new Rect(position.width * Find.World.GetComponent().ScoreForFaction(factionOne), yPositionBar, position.width * Find.World.GetComponent().ScoreForFaction(this.factionInstigator), barHeight); - GUI.DrawTexture(rightFactionTwoScoreBox, this.FactionTwoColorTexture); + GUI.DrawTexture(leftFactionOneScoreBox, FactionOneColorTexture); + Rect rightFactionTwoScoreBox = new Rect(position.width * Find.World.GetComponent().ScoreForFaction(factionOne), yPositionBar, position.width * Find.World.GetComponent().ScoreForFaction(factionInstigator), barHeight); + GUI.DrawTexture(rightFactionTwoScoreBox, FactionTwoColorTexture); //stuff that fills up and does the faction name and call label boxes. Text.Font = GameFont.Medium; diff --git a/MoreFactionInteraction/MoreFactionWar/WorldComponent_MFI_FactionWar.cs b/MoreFactionInteraction/MoreFactionWar/WorldComponent_MFI_FactionWar.cs index 26068fe..319ed7b 100644 --- a/MoreFactionInteraction/MoreFactionWar/WorldComponent_MFI_FactionWar.cs +++ b/MoreFactionInteraction/MoreFactionWar/WorldComponent_MFI_FactionWar.cs @@ -52,6 +52,7 @@ public Faction WarringFactionTwo public bool WarIsOngoing => this.warIsOngoing; public bool UnrestIsBrewing => this.unrestIsBrewing; + public bool StuffIsGoingDown => this.unrestIsBrewing || this.warIsOngoing; private void SetFirstWarringFaction(Faction faction) { diff --git a/MoreFactionInteraction/Properties/AssemblyInfo.cs b/MoreFactionInteraction/Properties/AssemblyInfo.cs index 84ad5a3..4d80f96 100644 --- a/MoreFactionInteraction/Properties/AssemblyInfo.cs +++ b/MoreFactionInteraction/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.1.0.6")] -[assembly: AssemblyFileVersion("0.1.0.6")] +[assembly: AssemblyVersion("0.1.0.7")] +[assembly: AssemblyFileVersion("0.1.0.7")] diff --git a/Patches/MoreFactionInteraction.xml b/Patches/MoreFactionInteraction.xml index 027e4a5..24d07bb 100644 --- a/Patches/MoreFactionInteraction.xml +++ b/Patches/MoreFactionInteraction.xml @@ -4,27 +4,33 @@ /Defs/WorldObjectDef[defName="Settlement"]/comps - -
  • - + +
  • + /Defs/WorldObjectDef[defName="Caravan"] - - -
  • - MoreFactionInteraction.World_Incidents.WorldObjectComp_CaravanComp -
  • - -
    + + +
  • + MoreFactionInteraction.World_Incidents.WorldObjectComp_CaravanComp +
  • +
    +
    - - /Defs/MainButtonDef[defName="Factions"]/tabWindowClass + + +
  • Relations Tab
  • +
    + + /Defs/MainButtonDef[defName="Factions"]/tabWindowClass MoreFactionInteraction.MoreFactionWar.MainTabWindow_FactionWar + +
    \ No newline at end of file