Skip to content

Commit

Permalink
- Blue fixes
Browse files Browse the repository at this point in the history
- Corrects Wang to Yang in dialog tree
- Fixes issue with unable to withdraw after Sumire is overhead and then leaves
  • Loading branch information
IceRaptor committed Jun 1, 2019
1 parent 812da42 commit 1e27428
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 147 deletions.
198 changes: 63 additions & 135 deletions DisorderlyWithdrawal/DisorderlyWithdrawal/Patches/Patches.cs

Large diffs are not rendered by default.

71 changes: 67 additions & 4 deletions DisorderlyWithdrawal/DisorderlyWithdrawal/Patches/UIPatches.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BattleTech;
using BattleTech.Framework;
using BattleTech.UI;
using Harmony;
using System;
Expand All @@ -9,11 +10,41 @@
using UnityEngine;

namespace DisorderlyWithdrawal.Patches {


[HarmonyPatch(typeof(SimGameState), "GetExpenditures")]
[HarmonyPatch(new Type[] { typeof(EconomyScale), typeof(bool) })]
[HarmonyAfter(new string[] { "de.morphyum.MechMaintenanceByCost", "us.frostraptor.IttyBittyLivingSpace" })]
public static class SimGameState_GetExpenditures {
public static void Postfix(SimGameState __instance, ref int __result, EconomyScale expenditureLevel, bool proRate) {
Mod.Log.Trace($"SGS:GE entered with {__result}");

Statistic aerospaceAssets = __instance.CompanyStats.GetStatistic("AerospaceAssets");
int aerospaceSupport = aerospaceAssets != null ? aerospaceAssets.Value<int>() : 0;

switch (aerospaceSupport) {
case 3:
__result = __result + Mod.Config.HeavyWingMonthlyCost;
Mod.Log.Trace($"Charging player for a heavy wing, result = {__result}.");
break;
case 2:
__result = __result + Mod.Config.MediumWingMonthlyCost;
Mod.Log.Trace($"Charging player for a medium wing, result = {__result}.");
break;
case 1:
__result = __result + Mod.Config.LightWingMonthlyCost;
Mod.Log.Trace($"Charging player for a light wing, result = {__result}.");
break;
default:
Mod.Log.Trace($"Charging player for no aerospace, result = {__result}");
break;
}
}
}

[HarmonyPatch(typeof(SGCaptainsQuartersStatusScreen), "RefreshData")]
[HarmonyAfter(new string[] { "dZ.Zappo.MonthlyTechAdjustment", "us.frostraptor.IttyBittyLivingSpace" })]
[HarmonyAfter(new string[] { "dZ.Zappo.MonthlyTechAdjustment", "us.frostraptor.IttyBittyLivingSpace", "us.frostraptor.IttyBittyLivingSpace" })]
public static class SGCaptainsQuartersStatusScreen_RefreshData {
public static void Postfix(SGCaptainsQuartersStatusScreen __instance, bool showMoraleChange,
public static void Postfix(SGCaptainsQuartersStatusScreen __instance, EconomyScale expenditureLevel, bool showMoraleChange,
Transform ___SectionOneExpensesList, TextMeshProUGUI ___SectionOneExpensesField,
SimGameState ___simState) {

Expand All @@ -23,6 +54,9 @@ public static void Postfix(SGCaptainsQuartersStatusScreen __instance, bool showM
return;
}

// TODO: Add this to mech parts maybe?
//float expenditureCostModifier = simGameState.GetExpenditureCostModifier(expenditureLevel);

// Determine the level of aerospace support
Statistic aerospaceAssets = simGameState.CompanyStats.GetStatistic("AerospaceAssets");
int aerospaceSupport = aerospaceAssets != null ? aerospaceAssets.Value<int>() : 0;
Expand Down Expand Up @@ -79,7 +113,6 @@ public static void Postfix(SGCaptainsQuartersStatusScreen __instance, bool showM
}
}


public static List<KeyValuePair<string, int>> GetCurrentKeys(Transform container, SimGameState sgs) {

List<KeyValuePair<string, int>> currentKeys = new List<KeyValuePair<string, int>>();
Expand Down Expand Up @@ -146,4 +179,34 @@ private static void ClearListLineItems(Transform container, SimGameState sgs) {
}
}

[HarmonyPatch(typeof(AAR_ContractObjectivesWidget), "FillInObjectives")]
[HarmonyAfter(new string[] { "de.morphyum.DropCostPerMech" })]
public static class AAR_ContractObjectivesWidget_FillInObjectives {

static void Prefix(AAR_ContractObjectivesWidget __instance, Contract ___theContract) {
int repairCost = (int)Math.Ceiling(State.CombatDamage) * Mod.Config.LeopardRepairCostPerDamage;
if (repairCost != 0) {
Mod.Log.Debug($"AAR_COW:FIO adding repair cost objective:{repairCost}");
string objectiveLabel = $"LEOPARD REPAIR COSTS: {SimGameState.GetCBillString(repairCost)}";
MissionObjectiveResult missionObjectiveResult = new MissionObjectiveResult(objectiveLabel, "7facf07a-626d-4a3b-a1ec-b29a35ff1ac0", false, true, ObjectiveStatus.Succeeded, false);
___theContract.MissionObjectiveResultList.Add(missionObjectiveResult);
}
}
}

[HarmonyPatch(typeof(Contract), "CompleteContract")]
[HarmonyAfter(new string[] { "de.morphyum.DropCostPerMech", "de.morphyum.PersistentMapClient" })]
public static class Contract_CompleteContract {

static void Postfix(Contract __instance) {
int repairCost = (int)Math.Ceiling(State.CombatDamage) * Mod.Config.LeopardRepairCostPerDamage;
if (repairCost != 0) {
Mod.Log.Debug($"C:CC adding repair costs:{repairCost}");
int newMoneyResults = Mathf.FloorToInt(__instance.MoneyResults - repairCost);
Traverse traverse = Traverse.Create(__instance).Property("MoneyResults");
traverse.SetValue(newMoneyResults);
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,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.3.0.0")]
[assembly: AssemblyFileVersion("0.3.0.0")]
[assembly: AssemblyVersion("0.4.0.0")]
[assembly: AssemblyFileVersion("0.4.0.0")]
3 changes: 2 additions & 1 deletion DisorderlyWithdrawal/DisorderlyWithdrawal/Utils/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public Logger(string modDir, string logName) {
LogStream = File.AppendText(LogFile);
}

public void Debug(string message) { if (Mod.Config.Debug) { Info("[DBG] " + message); } }
public void Debug(string message) { if (Mod.Config.Debug) { Info(message); } }
public void Trace(string message) { if (Mod.Config.Trace) { Info(message); } }

public void Info(string message) {
string now = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff", System.Globalization.CultureInfo.InvariantCulture);
Expand Down
5 changes: 4 additions & 1 deletion DisorderlyWithdrawal/DisorderlyWithdrawal/Utils/ModConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ namespace DisorderlyWithdrawal {

public class ModConfig {

// If true, extra logging will be used
// If true, troubleshooting logging will be enabled
public bool Debug = false;

// If true, all logging will be enabled
public bool Trace = false;

public int LeopardRepairCostPerDamage = 100;

public int LightWingMonthlyCost = 50000;
Expand Down
23 changes: 19 additions & 4 deletions DisorderlyWithdrawal/DisorderlyWithdrawal/Utils/State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,31 @@

namespace DisorderlyWithdrawal {

public static class ModState {
public static class State {

public static bool WithdrawalTriggered = false;
public static int RoundsUntilOverhead = -1;
public static int RoundsUntilReady = -1;
public static bool WithdrawStarted = false;

public static int CanWithdrawOnRound = -1;
public static int CanApproachOnRound = -1;

public static HBSDOTweenButton RetreatButton = null;
public static TextMeshProUGUI RetreatButtonText = null;
public static CombatHUD HUD = null;

public static float CombatDamage = 0f;

public static void Reset() {
// Reinitialize state
WithdrawStarted = false;

CanWithdrawOnRound = -1;
CanWithdrawOnRound = -1;

RetreatButton = null;
RetreatButtonText = null;
HUD = null;

CombatDamage = 0f;
}
}
}
Binary file not shown.

0 comments on commit 1e27428

Please sign in to comment.