From 5bdb31a7061f370da81f99831bcf18bf97124f20 Mon Sep 17 00:00:00 2001 From: willuwontu Date: Wed, 1 Sep 2021 10:12:29 -0700 Subject: [PATCH 01/20] Added Support for centralizing custom stats. Currently only supports custom stats for Block, Gun, GunAmmo, CharacterStatModifiers, and Player, as they're the only ones with a built in method to reset stats. --- UnboundLib/Extensions/Block.cs | 48 +++++ UnboundLib/Extensions/CharacterData.cs | 48 +++++ .../Extensions/CharacterStatModifiers.cs | 48 +++++ UnboundLib/Extensions/Gravity.cs | 48 +++++ UnboundLib/Extensions/Gun.cs | 50 +++++ UnboundLib/Extensions/GunAmmo.cs | 40 ++++ UnboundLib/Extensions/HealthHandler.cs | 48 +++++ UnboundLib/Extensions/Player.cs | 48 +++++ UnboundLib/Patches/ApplyCardStats.cs | 5 +- UnboundLib/Stats/StatDictionary.cs | 196 ++++++++++++++++++ UnboundLib/Stats/StatInfo.cs | 24 +++ UnboundLib/Stats/StatOperation.cs | 48 +++++ UnboundLib/UnboundLib.csproj | 3 +- 13 files changed, 652 insertions(+), 2 deletions(-) create mode 100644 UnboundLib/Extensions/Block.cs create mode 100644 UnboundLib/Extensions/CharacterData.cs create mode 100644 UnboundLib/Extensions/CharacterStatModifiers.cs create mode 100644 UnboundLib/Extensions/Gravity.cs create mode 100644 UnboundLib/Extensions/Gun.cs create mode 100644 UnboundLib/Extensions/GunAmmo.cs create mode 100644 UnboundLib/Extensions/HealthHandler.cs create mode 100644 UnboundLib/Extensions/Player.cs create mode 100644 UnboundLib/Stats/StatDictionary.cs create mode 100644 UnboundLib/Stats/StatInfo.cs create mode 100644 UnboundLib/Stats/StatOperation.cs diff --git a/UnboundLib/Extensions/Block.cs b/UnboundLib/Extensions/Block.cs new file mode 100644 index 0000000..eac4d75 --- /dev/null +++ b/UnboundLib/Extensions/Block.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using HarmonyLib; + +//From PCE +namespace UnboundLib.Extensions +{ + // ADD FIELDS TO GUN + [Serializable] + public class BlockAdditionalData + { + public Dictionary customStats; + + public BlockAdditionalData() + { + customStats = new Dictionary(); + } + } + public static class BlockExtension + { + public static readonly ConditionalWeakTable data = + new ConditionalWeakTable(); + + public static BlockAdditionalData GetAdditionalData(this Block block) + { + return data.GetOrCreateValue(block); + } + + public static void AddData(this Block block, BlockAdditionalData value) + { + try + { + data.Add(block, value); + } + catch (Exception) { } + } + } + // reset extra block attributes when resetstats is called + [HarmonyPatch(typeof(Block), "ResetStats")] + class BlockPatchResetStats + { + private static void Prefix(Block __instance) + { + __instance.GetAdditionalData().customStats.Clear(); + } + } +} \ No newline at end of file diff --git a/UnboundLib/Extensions/CharacterData.cs b/UnboundLib/Extensions/CharacterData.cs new file mode 100644 index 0000000..32af55b --- /dev/null +++ b/UnboundLib/Extensions/CharacterData.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using HarmonyLib; + +//From PCE +namespace UnboundLib.Extensions +{ + // ADD FIELDS TO GUN + [Serializable] + public class CharacterDataAdditionalData + { + public Dictionary customStats; + + public CharacterDataAdditionalData() + { + customStats = new Dictionary(); + } + } + public static class CharacterDataExtension + { + public static readonly ConditionalWeakTable data = + new ConditionalWeakTable(); + + public static CharacterDataAdditionalData GetAdditionalData(this CharacterData characterData) + { + return data.GetOrCreateValue(characterData); + } + + public static void AddData(this CharacterData characterData, CharacterDataAdditionalData value) + { + try + { + data.Add(characterData, value); + } + catch (Exception) { } + } + } + // reset extra characterData attributes when resetstats is called + //[HarmonyPatch(typeof(CharacterData), "ResetStats")] + //class CharacterDataPatchResetStats + //{ + // private static void Prefix(CharacterData __instance) + // { + // __instance.GetAdditionalData().customStats.Clear(); + // } + //} +} \ No newline at end of file diff --git a/UnboundLib/Extensions/CharacterStatModifiers.cs b/UnboundLib/Extensions/CharacterStatModifiers.cs new file mode 100644 index 0000000..5e71759 --- /dev/null +++ b/UnboundLib/Extensions/CharacterStatModifiers.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using HarmonyLib; + +//From PCE +namespace UnboundLib.Extensions +{ + // ADD FIELDS TO GUN + [Serializable] + public class CharacterStatModifiersAdditionalData + { + public Dictionary customStats; + + public CharacterStatModifiersAdditionalData() + { + customStats = new Dictionary(); + } + } + public static class CharacterStatModifiersExtension + { + public static readonly ConditionalWeakTable data = + new ConditionalWeakTable(); + + public static CharacterStatModifiersAdditionalData GetAdditionalData(this CharacterStatModifiers statModifiers) + { + return data.GetOrCreateValue(statModifiers); + } + + public static void AddData(this CharacterStatModifiers statModifiers, CharacterStatModifiersAdditionalData value) + { + try + { + data.Add(statModifiers, value); + } + catch (Exception) { } + } + } + // reset extra statModifiers attributes when resetstats is called + [HarmonyPatch(typeof(CharacterStatModifiers), "ResetStats")] + class CharacterStatModifiersPatchResetStats + { + private static void Prefix(CharacterStatModifiers __instance) + { + __instance.GetAdditionalData().customStats.Clear(); + } + } +} \ No newline at end of file diff --git a/UnboundLib/Extensions/Gravity.cs b/UnboundLib/Extensions/Gravity.cs new file mode 100644 index 0000000..4131a89 --- /dev/null +++ b/UnboundLib/Extensions/Gravity.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using HarmonyLib; + +//From PCE +namespace UnboundLib.Extensions +{ + // ADD FIELDS TO GUN + [Serializable] + public class GravityAdditionalData + { + public Dictionary customStats; + + public GravityAdditionalData() + { + customStats = new Dictionary(); + } + } + public static class GravityExtension + { + public static readonly ConditionalWeakTable data = + new ConditionalWeakTable(); + + public static GravityAdditionalData GetAdditionalData(this Gravity gravity) + { + return data.GetOrCreateValue(gravity); + } + + public static void AddData(this Gravity gravity, GravityAdditionalData value) + { + try + { + data.Add(gravity, value); + } + catch (Exception) { } + } + } + // reset extra gravity attributes when resetstats is called + //[HarmonyPatch(typeof(Gravity), "ResetStats")] + //class GravityPatchResetStats + //{ + // private static void Prefix(Gravity __instance) + // { + // __instance.GetAdditionalData().customStats.Clear(); + // } + //} +} \ No newline at end of file diff --git a/UnboundLib/Extensions/Gun.cs b/UnboundLib/Extensions/Gun.cs new file mode 100644 index 0000000..6df8f08 --- /dev/null +++ b/UnboundLib/Extensions/Gun.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using HarmonyLib; + +//From PCE +namespace UnboundLib.Extensions +{ + // ADD FIELDS TO GUN + [Serializable] + public class GunAdditionalData + { + public Dictionary customStats; + + public GunAdditionalData() + { + customStats = new Dictionary(); + } + } + public static class GunExtension + { + public static readonly ConditionalWeakTable data = + new ConditionalWeakTable(); + + public static GunAdditionalData GetAdditionalData(this Gun gun) + { + return data.GetOrCreateValue(gun); + } + + public static void AddData(this Gun gun, GunAdditionalData value) + { + try + { + data.Add(gun, value); + } + catch (Exception) { } + } + } + // reset extra gun attributes when resetstats is called + [HarmonyPatch(typeof(Gun), "ResetStats")] + class GunPatchResetStats + { + private static void Prefix(Gun __instance) + { + __instance.GetAdditionalData().customStats.Clear(); + var gunAmmo = __instance.GetComponentInChildren(); + gunAmmo.GetAdditionalData().customStats.Clear(); + } + } +} \ No newline at end of file diff --git a/UnboundLib/Extensions/GunAmmo.cs b/UnboundLib/Extensions/GunAmmo.cs new file mode 100644 index 0000000..0abd41d --- /dev/null +++ b/UnboundLib/Extensions/GunAmmo.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using HarmonyLib; + +//From PCE +namespace UnboundLib.Extensions +{ + // ADD FIELDS TO GUN + [Serializable] + public class GunAmmoAdditionalData + { + public Dictionary customStats; + + public GunAmmoAdditionalData() + { + customStats = new Dictionary(); + } + } + public static class GunAmmoExtension + { + public static readonly ConditionalWeakTable data = + new ConditionalWeakTable(); + + public static GunAmmoAdditionalData GetAdditionalData(this GunAmmo gunAmmo) + { + return data.GetOrCreateValue(gunAmmo); + } + + public static void AddData(this GunAmmo gunAmmo, GunAmmoAdditionalData value) + { + try + { + data.Add(gunAmmo, value); + } + catch (Exception) { } + } + } + // reset extra gunAmmo attributes when resetstats is called via gun +} \ No newline at end of file diff --git a/UnboundLib/Extensions/HealthHandler.cs b/UnboundLib/Extensions/HealthHandler.cs new file mode 100644 index 0000000..bfb5aa8 --- /dev/null +++ b/UnboundLib/Extensions/HealthHandler.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using HarmonyLib; + +//From PCE +namespace UnboundLib.Extensions +{ + // ADD FIELDS TO GUN + [Serializable] + public class HealthHandlerAdditionalData + { + public Dictionary customStats; + + public HealthHandlerAdditionalData() + { + customStats = new Dictionary(); + } + } + public static class HealthHandlerExtension + { + public static readonly ConditionalWeakTable data = + new ConditionalWeakTable(); + + public static HealthHandlerAdditionalData GetAdditionalData(this HealthHandler healthHandler) + { + return data.GetOrCreateValue(healthHandler); + } + + public static void AddData(this HealthHandler healthHandler, HealthHandlerAdditionalData value) + { + try + { + data.Add(healthHandler, value); + } + catch (Exception) { } + } + } + // reset extra healthHandler attributes when resetstats is called + //[HarmonyPatch(typeof(HealthHandler), "ResetStats")] + //class HealthHandlerPatchResetStats + //{ + // private static void Prefix(HealthHandler __instance) + // { + // __instance.GetAdditionalData().customStats.Clear(); + // } + //} +} \ No newline at end of file diff --git a/UnboundLib/Extensions/Player.cs b/UnboundLib/Extensions/Player.cs new file mode 100644 index 0000000..e75f44c --- /dev/null +++ b/UnboundLib/Extensions/Player.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using HarmonyLib; + +//From PCE +namespace UnboundLib.Extensions +{ + // ADD FIELDS TO GUN + [Serializable] + public class PlayerAdditionalData + { + public Dictionary customStats; + + public PlayerAdditionalData() + { + customStats = new Dictionary(); + } + } + public static class PlayerExtension + { + public static readonly ConditionalWeakTable data = + new ConditionalWeakTable(); + + public static PlayerAdditionalData GetAdditionalData(this Player player) + { + return data.GetOrCreateValue(player); + } + + public static void AddData(this Player player, PlayerAdditionalData value) + { + try + { + data.Add(player, value); + } + catch (Exception) { } + } + } + // reset extra player attributes when resetstats is called + [HarmonyPatch(typeof(Player), "FullReset")] + class PlayerPatchResetStats + { + private static void Prefix(Player __instance) + { + __instance.GetAdditionalData().customStats.Clear(); + } + } +} \ No newline at end of file diff --git a/UnboundLib/Patches/ApplyCardStats.cs b/UnboundLib/Patches/ApplyCardStats.cs index 217f11d..5342273 100644 --- a/UnboundLib/Patches/ApplyCardStats.cs +++ b/UnboundLib/Patches/ApplyCardStats.cs @@ -1,12 +1,13 @@ using HarmonyLib; using UnboundLib.Cards; +using UnboundLib.Stats; namespace UnboundLib.Patches { [HarmonyPatch(typeof(ApplyCardStats), "ApplyStats")] class ApplyCardStats_Patch { - static void Prefix(ApplyCardStats __instance, Player ___playerToUpgrade) + static void Prefix(ApplyCardStats __instance, Player ___playerToUpgrade, Gun ___myGunStats, CharacterStatModifiers ___myPlayerStats, Block ___myBlock) { var player = ___playerToUpgrade.GetComponent(); var gun = ___playerToUpgrade.GetComponent().holdable.GetComponent(); @@ -17,6 +18,8 @@ static void Prefix(ApplyCardStats __instance, Player ___playerToUpgrade) var gunAmmo = gun.GetComponentInChildren(); var characterStatModifiers = player.GetComponent(); + StatDictionary.CopyCustomStats(player, gun, characterData, healthHandler, gravity, block, gunAmmo, characterStatModifiers, ___myGunStats, ___myPlayerStats, ___myBlock); + CustomCard customAbility = __instance.gameObject.GetComponent(); if (customAbility != null) { diff --git a/UnboundLib/Stats/StatDictionary.cs b/UnboundLib/Stats/StatDictionary.cs new file mode 100644 index 0000000..2699bf9 --- /dev/null +++ b/UnboundLib/Stats/StatDictionary.cs @@ -0,0 +1,196 @@ +using System.Collections.Generic; +using UnboundLib.Extensions; + +namespace UnboundLib.Stats +{ + public static class StatDictionary + { + private static Dictionary data = new Dictionary(); + + public static string[] GetStats() + { + if (data.Count > 0) + { + return (new List(data.Keys)).ToArray(); + } + + return null; + } + + public static void AddStat(string statName, StatInfo statInfo) + { + if (data.TryGetValue(statName, out StatInfo statdata)) + { + // Throw error, show pre-existing data in log. + } + else + { + data.Add(statName, statInfo); + } + } + + public static void Clear() + { + data.Clear(); + } + + public static Dictionary GetRaw() + { + return data; + } + + public static void CopyCustomStats(Player player, Gun gun, CharacterData characterdata, HealthHandler healthHandler, Gravity gravity, Block block, GunAmmo gunAmmo, CharacterStatModifiers statModifiers, Gun copyFromGun, CharacterStatModifiers copyFromCSM, Block copyFromBlock) + { + Dictionary> customStatChanges = new Dictionary>(); + StatOperation value; + foreach (var key in copyFromGun.GetAdditionalData().customStats) + { + if (key.Value.GetType() == typeof(StatOperation)) + { + value = key.Value; + if (!value.reroute) + { + value.reroute = true; + value.destination = StatOperation.Destination.Gun; + } + if (customStatChanges.TryGetValue(key.Key, out List list)) + { + list.Add(value); + } + else + { + customStatChanges.Add(key.Key, new List() { value }); + } + } + } + foreach (var key in copyFromBlock.GetAdditionalData().customStats) + { + if (key.Value.GetType() == typeof(StatOperation)) + { + value = key.Value; + if (!value.reroute) + { + value.reroute = true; + value.destination = StatOperation.Destination.Block; + } + if (customStatChanges.TryGetValue(key.Key, out List list)) + { + list.Add(value); + } + else + { + customStatChanges.Add(key.Key, new List() { value }); + } + } + } + foreach (var key in copyFromCSM.GetAdditionalData().customStats) + { + if (key.Value.GetType() == typeof(StatOperation)) + { + value = key.Value; + if (!value.reroute) + { + value.reroute = true; + value.destination = StatOperation.Destination.CharacterStatModifier; + } + if (customStatChanges.TryGetValue(key.Key, out List list)) + { + list.Add(value); + } + else + { + customStatChanges.Add(key.Key, new List() { value }); + } + } + } + + foreach (var key in customStatChanges) + { + foreach(var operation in key.Value) + { + switch (operation.destination) + { + case StatOperation.Destination.Gun: + PerformStatOperation(key.Key, gun.GetAdditionalData().customStats, operation); + break; + case StatOperation.Destination.Block: + PerformStatOperation(key.Key, block.GetAdditionalData().customStats, operation); + break; + //case StatOperation.Destination.CharacterData: + // PerformStatOperation(key.Key, characterdata.GetAdditionalData().customStats, operation); + // break; + case StatOperation.Destination.CharacterStatModifier: + PerformStatOperation(key.Key, statModifiers.GetAdditionalData().customStats, operation); + break; + //case StatOperation.Destination.Gravity: + // PerformStatOperation(key.Key, gravity.GetAdditionalData().customStats, operation); + // break; + //case StatOperation.Destination.HealthHandler: + // PerformStatOperation(key.Key, healthHandler.GetAdditionalData().customStats, operation); + // break; + //case StatOperation.Destination.Player: + // PerformStatOperation(key.Key, player.GetAdditionalData().customStats, operation); + // break; + case StatOperation.Destination.GunAmmo: + PerformStatOperation(key.Key, gunAmmo.GetAdditionalData().customStats, operation); + break; + } + } + } + } + + private static void PerformStatOperation(string key, Dictionary to, StatOperation from) + { + // If the stat doesn't exist yet, but we have a registered default value, set it to that. + if (!to.TryGetValue(key, out dynamic value) && StatDictionary.GetRaw().TryGetValue(key, out StatInfo statInfo)) + { + to.Add(key, statInfo.defaultValue); + } + // If the stat exists already, operate on it + if (to.TryGetValue(key, out dynamic statVal)) + { + // If the operation is a replace, we don't care about previous typing. + if (from.operation == StatOperation.Operation.Replace) + { + statVal = from.value; + } + // If we're adding to a list, and it is a list, we can add to it. + if (from.operation == StatOperation.Operation.AddToList && statVal.GetType().IsGenericType && statVal.GetType().GetGenericTypeDefinition() == typeof(List<>)) + { + statVal.Add(from.value); + } + // We cannot perform math with values of different types, so we check to make sure they're the same here. + if (statVal.GetType() == from.value.GetType()) + { + switch (from.operation) + { + case (StatOperation.Operation.Add): + statVal += from.value; + break; + case (StatOperation.Operation.Multiply): + statVal *= from.value; + break; + case (StatOperation.Operation.Divide): + statVal /= from.value; + break; + case (StatOperation.Operation.Subtract): + statVal -= from.value; + break; + } + } + else + { + // Throw error about types not being the same + } + } + else // If the stat doesn't exist yet (and therefore not registered, or it would be set already), we can only perform a replace operation. + { + if (from.operation == StatOperation.Operation.Replace) + { + to.Add(key, from.value); + } + } + + } + } +} diff --git a/UnboundLib/Stats/StatInfo.cs b/UnboundLib/Stats/StatInfo.cs new file mode 100644 index 0000000..7fde157 --- /dev/null +++ b/UnboundLib/Stats/StatInfo.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; +using UnityEngine; +using Photon.Pun; + +namespace UnboundLib.Stats +{ + public class StatInfo + { + public dynamic type; + public dynamic defaultValue; + public string sourceMod; + public string description; + + public StatInfo(dynamic statDefaultValue, string statSourceMod = "com.mod.id", string statDescription = "If only this stat had a description.") + { + type = statDefaultValue.GetType(); + defaultValue = statDefaultValue; + sourceMod = statSourceMod; + description = statDescription; + } + } +} diff --git a/UnboundLib/Stats/StatOperation.cs b/UnboundLib/Stats/StatOperation.cs new file mode 100644 index 0000000..987f381 --- /dev/null +++ b/UnboundLib/Stats/StatOperation.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Collections.ObjectModel; +using System.Text; +using UnityEngine; +using TMPro; + +namespace UnboundLib.Stats +{ + public class StatOperation + { + public dynamic value; + public Operation operation; + public bool reroute; + public Destination destination; + + public StatOperation(dynamic statValue, Operation operationType, bool routeToDifferentStat = false, Destination otherStat = Destination.CharacterStatModifier) + { + value = statValue; + operation = operationType; + reroute = routeToDifferentStat; + destination = otherStat; + } + + public enum Operation + { + Replace, + Multiply, + Add, + Divide, + Subtract, + AddToList + } + + public enum Destination + { + Gun, + CharacterStatModifier, + //Player, + //CharacterData, + //HealthHandler, + //Gravity, + GunAmmo, + Block + } + } +} diff --git a/UnboundLib/UnboundLib.csproj b/UnboundLib/UnboundLib.csproj index 1c5afb1..9d6fc79 100644 --- a/UnboundLib/UnboundLib.csproj +++ b/UnboundLib/UnboundLib.csproj @@ -35,7 +35,7 @@ - C:\Program Files (x86)\Steam\steamapps\common\ROUNDS + D:\Program Files (x86)\Steam\steamapps\common\ROUNDS true true 7.1 @@ -61,6 +61,7 @@ ..\Assemblies\BepInEx.dll + ..\Assemblies\MMHOOK_Assembly-CSharp.dll From 2359c5d3fa75afe74d857aee94d1a4691cb4b612 Mon Sep 17 00:00:00 2001 From: willuwontu Date: Thu, 2 Sep 2021 09:00:20 -0700 Subject: [PATCH 02/20] Debugging push --- UnboundLib/Patches/ApplyCardStats.cs | 19 ++++- UnboundLib/Stats/StatDictionary.cs | 100 +++++++++++++++------------ 2 files changed, 72 insertions(+), 47 deletions(-) diff --git a/UnboundLib/Patches/ApplyCardStats.cs b/UnboundLib/Patches/ApplyCardStats.cs index 5342273..1aa6ed5 100644 --- a/UnboundLib/Patches/ApplyCardStats.cs +++ b/UnboundLib/Patches/ApplyCardStats.cs @@ -7,7 +7,7 @@ namespace UnboundLib.Patches [HarmonyPatch(typeof(ApplyCardStats), "ApplyStats")] class ApplyCardStats_Patch { - static void Prefix(ApplyCardStats __instance, Player ___playerToUpgrade, Gun ___myGunStats, CharacterStatModifiers ___myPlayerStats, Block ___myBlock) + static void Prefix(ApplyCardStats __instance, Player ___playerToUpgrade) { var player = ___playerToUpgrade.GetComponent(); var gun = ___playerToUpgrade.GetComponent().holdable.GetComponent(); @@ -18,13 +18,26 @@ static void Prefix(ApplyCardStats __instance, Player ___playerToUpgrade, Gun ___ var gunAmmo = gun.GetComponentInChildren(); var characterStatModifiers = player.GetComponent(); - StatDictionary.CopyCustomStats(player, gun, characterData, healthHandler, gravity, block, gunAmmo, characterStatModifiers, ___myGunStats, ___myPlayerStats, ___myBlock); - CustomCard customAbility = __instance.gameObject.GetComponent(); if (customAbility != null) { customAbility.OnAddCard(player, gun, gunAmmo, characterData, healthHandler, gravity, block, characterStatModifiers); } } + + [HarmonyPrefix] + static void CustomStatsApplied(ApplyCardStats __instance, Player ___playerToUpgrade, Gun ___myGunStats, CharacterStatModifiers ___myPlayerStats, Block ___myBlock) + { + var player = ___playerToUpgrade.GetComponent(); + var gun = ___playerToUpgrade.GetComponent().holdable.GetComponent(); + var characterData = ___playerToUpgrade.GetComponent(); + var healthHandler = ___playerToUpgrade.GetComponent(); + var gravity = ___playerToUpgrade.GetComponent(); + var block = ___playerToUpgrade.GetComponent(); + var gunAmmo = gun.GetComponentInChildren(); + var characterStatModifiers = player.GetComponent(); + + StatDictionary.CopyCustomStats(player, gun, characterData, healthHandler, gravity, block, gunAmmo, characterStatModifiers, ___myGunStats, ___myPlayerStats, ___myBlock); + } } } diff --git a/UnboundLib/Stats/StatDictionary.cs b/UnboundLib/Stats/StatDictionary.cs index 2699bf9..0e47bbd 100644 --- a/UnboundLib/Stats/StatDictionary.cs +++ b/UnboundLib/Stats/StatDictionary.cs @@ -19,8 +19,11 @@ public static string[] GetStats() public static void AddStat(string statName, StatInfo statInfo) { + UnityEngine.Debug.Log("Attempting to add " + statName + " to the dictionary."); if (data.TryGetValue(statName, out StatInfo statdata)) { + UnityEngine.Debug.Log(statName + " already exists."); + // Throw error, show pre-existing data in log. } else @@ -43,70 +46,79 @@ public static void CopyCustomStats(Player player, Gun gun, CharacterData charact { Dictionary> customStatChanges = new Dictionary>(); StatOperation value; - foreach (var key in copyFromGun.GetAdditionalData().customStats) + if (copyFromGun) { - if (key.Value.GetType() == typeof(StatOperation)) + foreach (var key in copyFromGun.GetAdditionalData().customStats) { - value = key.Value; - if (!value.reroute) - { - value.reroute = true; - value.destination = StatOperation.Destination.Gun; - } - if (customStatChanges.TryGetValue(key.Key, out List list)) + if (key.Value.GetType() == typeof(StatOperation)) { - list.Add(value); - } - else - { - customStatChanges.Add(key.Key, new List() { value }); + value = (StatOperation) key.Value; + if (!value.reroute) + { + value.reroute = true; + value.destination = StatOperation.Destination.Gun; + } + if (customStatChanges.TryGetValue(key.Key, out List list)) + { + list.Add(value); + } + else + { + customStatChanges.Add(key.Key, new List() { value }); + } } } } - foreach (var key in copyFromBlock.GetAdditionalData().customStats) + if (copyFromBlock) { - if (key.Value.GetType() == typeof(StatOperation)) + foreach (var key in copyFromBlock.GetAdditionalData().customStats) { - value = key.Value; - if (!value.reroute) - { - value.reroute = true; - value.destination = StatOperation.Destination.Block; - } - if (customStatChanges.TryGetValue(key.Key, out List list)) + if (key.Value.GetType() == typeof(StatOperation)) { - list.Add(value); - } - else - { - customStatChanges.Add(key.Key, new List() { value }); + value = (StatOperation) key.Value; + if (!value.reroute) + { + value.reroute = true; + value.destination = StatOperation.Destination.Block; + } + if (customStatChanges.TryGetValue(key.Key, out List list)) + { + list.Add(value); + } + else + { + customStatChanges.Add(key.Key, new List() { value }); + } } } } - foreach (var key in copyFromCSM.GetAdditionalData().customStats) + if (copyFromCSM) { - if (key.Value.GetType() == typeof(StatOperation)) + foreach (var key in copyFromCSM.GetAdditionalData().customStats) { - value = key.Value; - if (!value.reroute) - { - value.reroute = true; - value.destination = StatOperation.Destination.CharacterStatModifier; - } - if (customStatChanges.TryGetValue(key.Key, out List list)) + if (key.Value.GetType() == typeof(StatOperation)) { - list.Add(value); - } - else - { - customStatChanges.Add(key.Key, new List() { value }); + value = (StatOperation) key.Value; + if (!value.reroute) + { + value.reroute = true; + value.destination = StatOperation.Destination.CharacterStatModifier; + } + if (customStatChanges.TryGetValue(key.Key, out List list)) + { + list.Add(value); + } + else + { + customStatChanges.Add(key.Key, new List() { value }); + } } } } foreach (var key in customStatChanges) - { - foreach(var operation in key.Value) + { + foreach (var operation in key.Value) { switch (operation.destination) { From 3d7bf99b8a43135b2bfd1ee7b6197285ca967be0 Mon Sep 17 00:00:00 2001 From: willuwontu Date: Tue, 7 Sep 2021 14:36:18 -0700 Subject: [PATCH 03/20] Add block to the base customcard, similar to gun and statmodifiers --- UnboundLib/Cards/CustomCard.cs | 12 +++++++++++- UnboundLib/Patches/ApplyCardStats.cs | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/UnboundLib/Cards/CustomCard.cs b/UnboundLib/Cards/CustomCard.cs index 14d458d..5d507de 100644 --- a/UnboundLib/Cards/CustomCard.cs +++ b/UnboundLib/Cards/CustomCard.cs @@ -17,6 +17,7 @@ public abstract class CustomCard : MonoBehaviour public Gun gun; public ApplyCardStats cardStats; public CharacterStatModifiers statModifiers; + public Block block; private bool isPrefab = false; void Awake() @@ -25,7 +26,9 @@ void Awake() gun = GetComponent(); cardStats = GetComponent(); statModifiers = GetComponent(); + block = GetComponent(); SetupCard(cardInfo, gun, cardStats, statModifiers); + SetupCard(cardInfo, gun, cardStats, statModifiers, block); } void Start() @@ -42,7 +45,14 @@ void Start() protected abstract CardInfo.Rarity GetRarity(); protected abstract GameObject GetCardArt(); protected abstract CardThemeColor.CardThemeColorType GetTheme(); - public abstract void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers); + public virtual void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers) + { + + } + public virtual void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block) + { + + } public abstract void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats); public abstract void OnRemoveCard(); public virtual bool GetEnabled() diff --git a/UnboundLib/Patches/ApplyCardStats.cs b/UnboundLib/Patches/ApplyCardStats.cs index 1aa6ed5..0a6813a 100644 --- a/UnboundLib/Patches/ApplyCardStats.cs +++ b/UnboundLib/Patches/ApplyCardStats.cs @@ -37,7 +37,7 @@ static void CustomStatsApplied(ApplyCardStats __instance, Player ___playerToUpgr var gunAmmo = gun.GetComponentInChildren(); var characterStatModifiers = player.GetComponent(); - StatDictionary.CopyCustomStats(player, gun, characterData, healthHandler, gravity, block, gunAmmo, characterStatModifiers, ___myGunStats, ___myPlayerStats, ___myBlock); + //StatDictionary.CopyCustomStats(player, gun, characterData, healthHandler, gravity, block, gunAmmo, characterStatModifiers, ___myGunStats, ___myPlayerStats, ___myBlock); } } } From 5c559a7d351901e0836ebba8d635a1dab25f3751 Mon Sep 17 00:00:00 2001 From: willuwontu Date: Wed, 14 Dec 2022 07:30:11 -0800 Subject: [PATCH 04/20] Create CardChoicePatchGetSourceCard.cs --- .../Patches/CardChoicePatchGetSourceCard.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 UnboundLib/Patches/CardChoicePatchGetSourceCard.cs diff --git a/UnboundLib/Patches/CardChoicePatchGetSourceCard.cs b/UnboundLib/Patches/CardChoicePatchGetSourceCard.cs new file mode 100644 index 0000000..122609e --- /dev/null +++ b/UnboundLib/Patches/CardChoicePatchGetSourceCard.cs @@ -0,0 +1,25 @@ +using HarmonyLib; + +namespace UnboundLib.Patches +{ + [HarmonyPatch(typeof(CardChoice))] + public class CardChoicePatchGetSourceCard + { + [HarmonyPrefix] + [HarmonyPatch(nameof(CardChoice.GetSourceCard))] + private static bool CheckHiddenCards(CardChoice __instance, CardInfo info, ref CardInfo __result) + { + for (int i = 0; i < __instance.cards.Length; i++) + { + if ((__instance.cards[i].gameObject.name + "(Clone)") == info.gameObject.name) + { + __result = __instance.cards[i]; + break; + } + } + __result = null; + + return false; + } + } +} From 8fdfe59998dc57d390c34ce09a4eee9e6bc22298 Mon Sep 17 00:00:00 2001 From: willuwontu Date: Tue, 20 Dec 2022 08:47:38 -0800 Subject: [PATCH 05/20] Update CustomCard.cs Beep --- UnboundLib/Cards/CustomCard.cs | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/UnboundLib/Cards/CustomCard.cs b/UnboundLib/Cards/CustomCard.cs index 886c8bd..e9e4ffc 100644 --- a/UnboundLib/Cards/CustomCard.cs +++ b/UnboundLib/Cards/CustomCard.cs @@ -169,6 +169,54 @@ public static void BuildCard(Action callback) where T : CustomCard }); } + public static void BuildUnityCard(GameObject cardPrefab, Action callback) where T : CustomCard + { + CardInfo cardInfo = cardPrefab.GetComponent(); + CustomCard customCard = cardPrefab.GetOrAddComponent(); + + cardInfo.cardBase = customCard.GetCardBase(); + cardInfo.cardStats = customCard.GetStats(); + cardInfo.cardName = customCard.GetTitle(); + cardInfo.gameObject.name = $"__{customCard.GetModName()}__{customCard.GetTitle()}".Sanitize(); + cardInfo.cardDestription = customCard.GetDescription(); + cardInfo.sourceCard = cardInfo; + cardInfo.rarity = customCard.GetRarity(); + cardInfo.colorTheme = customCard.GetTheme(); + cardInfo.cardArt = customCard.GetCardArt(); + + PhotonNetwork.PrefabPool.RegisterPrefab(cardInfo.gameObject.name, cardPrefab); + + if (customCard.GetEnabled()) + { + CardManager.cards.Add(cardInfo.gameObject.name, new Card(customCard.GetModName().Sanitize(), Unbound.config.Bind("Cards: " + customCard.GetModName().Sanitize(), cardInfo.gameObject.name, true), cardInfo)); + } + + cardInfo.ExecuteAfterFrames(5, () => + { + callback?.Invoke(cardInfo); + }); + } + + public static void RegisterUnityCard(GameObject cardPrefab, Action callback) where T : CustomCard + { + CardInfo cardInfo = cardPrefab.GetComponent(); + CustomCard customCard = cardPrefab.GetOrAddComponent(); + + cardInfo.gameObject.name = $"__{customCard.GetModName()}__{customCard.GetTitle()}".Sanitize(); + + PhotonNetwork.PrefabPool.RegisterPrefab(cardInfo.gameObject.name, cardPrefab); + + if (customCard.GetEnabled()) + { + CardManager.cards.Add(cardInfo.gameObject.name, new Card(customCard.GetModName().Sanitize(), Unbound.config.Bind("Cards: " + customCard.GetModName().Sanitize(), cardInfo.gameObject.name, true), cardInfo)); + } + + cardInfo.ExecuteAfterFrames(5, () => + { + callback?.Invoke(cardInfo); + }); + } + private static void DestroyChildren(GameObject t) { while (t.transform.childCount > 0) From 7b15559c106e10947d04b4c595b1f0fa41cf8293 Mon Sep 17 00:00:00 2001 From: willuwontu Date: Tue, 20 Dec 2022 08:51:10 -0800 Subject: [PATCH 06/20] Update CustomCard.cs --- UnboundLib/Cards/CustomCard.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/UnboundLib/Cards/CustomCard.cs b/UnboundLib/Cards/CustomCard.cs index e9e4ffc..ca04ca9 100644 --- a/UnboundLib/Cards/CustomCard.cs +++ b/UnboundLib/Cards/CustomCard.cs @@ -217,6 +217,25 @@ public static void RegisterUnityCard(GameObject cardPrefab, Action }); } + public static void RegisterUnityCard(GameObject cardPrefab, string modInitials, string cardname, bool enabled, Action callback) + { + CardInfo cardInfo = cardPrefab.GetComponent(); + + cardInfo.gameObject.name = $"__{modInitials}__{cardname}".Sanitize(); + + PhotonNetwork.PrefabPool.RegisterPrefab(cardInfo.gameObject.name, cardPrefab); + + if (enabled) + { + CardManager.cards.Add(cardInfo.gameObject.name, new Card(cardname.Sanitize(), Unbound.config.Bind("Cards: " + cardname.Sanitize(), cardInfo.gameObject.name, true), cardInfo)); + } + + cardInfo.ExecuteAfterFrames(5, () => + { + callback?.Invoke(cardInfo); + }); + } + private static void DestroyChildren(GameObject t) { while (t.transform.childCount > 0) From 70428e61a7f95f01cb36905dcdeb60e1a82d325f Mon Sep 17 00:00:00 2001 From: willuwontu Date: Tue, 20 Dec 2022 08:53:25 -0800 Subject: [PATCH 07/20] Update Unbound.cs --- UnboundLib/Unbound.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnboundLib/Unbound.cs b/UnboundLib/Unbound.cs index cf17a34..f7cf8f3 100644 --- a/UnboundLib/Unbound.cs +++ b/UnboundLib/Unbound.cs @@ -25,7 +25,7 @@ public class Unbound : BaseUnityPlugin { private const string ModId = "com.willis.rounds.unbound"; private const string ModName = "Rounds Unbound"; - public const string Version = "3.2.0"; + public const string Version = "3.2.1"; public static Unbound Instance { get; private set; } public static readonly ConfigFile config = new ConfigFile(Path.Combine(Paths.ConfigPath, "UnboundLib.cfg"), true); From 2c1abc0d6d3efe21edd67e95e44ad0a81dbe2d3e Mon Sep 17 00:00:00 2001 From: willuwontu Date: Tue, 20 Dec 2022 10:38:40 -0800 Subject: [PATCH 08/20] Update CustomCard.cs --- UnboundLib/Cards/CustomCard.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/UnboundLib/Cards/CustomCard.cs b/UnboundLib/Cards/CustomCard.cs index ca04ca9..bba2f1d 100644 --- a/UnboundLib/Cards/CustomCard.cs +++ b/UnboundLib/Cards/CustomCard.cs @@ -236,6 +236,25 @@ public static void RegisterUnityCard(GameObject cardPrefab, string modInitials, }); } + public void RegisterUnityCard(Action callback) + { + CardInfo cardInfo = this.gameObject.GetComponent(); + + cardInfo.gameObject.name = $"__{this.GetModName()}__{this.GetTitle()}".Sanitize(); + + PhotonNetwork.PrefabPool.RegisterPrefab(cardInfo.gameObject.name, this.gameObject); + + if (this.GetEnabled()) + { + CardManager.cards.Add(cardInfo.gameObject.name, new Card(this.GetModName().Sanitize(), Unbound.config.Bind("Cards: " + this.GetModName().Sanitize(), cardInfo.gameObject.name, true), cardInfo)); + } + + cardInfo.ExecuteAfterFrames(5, () => + { + callback?.Invoke(cardInfo); + }); + } + private static void DestroyChildren(GameObject t) { while (t.transform.childCount > 0) From df6d612d1498c7cd5d2c2cf7ffc5eceeb5f219a8 Mon Sep 17 00:00:00 2001 From: willuwontu Date: Tue, 20 Dec 2022 10:41:46 -0800 Subject: [PATCH 09/20] Update CustomCard.cs --- UnboundLib/Cards/CustomCard.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/UnboundLib/Cards/CustomCard.cs b/UnboundLib/Cards/CustomCard.cs index bba2f1d..5df2d33 100644 --- a/UnboundLib/Cards/CustomCard.cs +++ b/UnboundLib/Cards/CustomCard.cs @@ -197,6 +197,35 @@ public static void BuildUnityCard(GameObject cardPrefab, Action cal }); } + public void BuildUnityCard(Action callback) + { + CardInfo cardInfo = this.gameObject.GetComponent(); + CustomCard customCard = this; + GameObject cardPrefab = this.gameObject; + + cardInfo.cardBase = customCard.GetCardBase(); + cardInfo.cardStats = customCard.GetStats(); + cardInfo.cardName = customCard.GetTitle(); + cardInfo.gameObject.name = $"__{customCard.GetModName()}__{customCard.GetTitle()}".Sanitize(); + cardInfo.cardDestription = customCard.GetDescription(); + cardInfo.sourceCard = cardInfo; + cardInfo.rarity = customCard.GetRarity(); + cardInfo.colorTheme = customCard.GetTheme(); + cardInfo.cardArt = customCard.GetCardArt(); + + PhotonNetwork.PrefabPool.RegisterPrefab(cardInfo.gameObject.name, cardPrefab); + + if (customCard.GetEnabled()) + { + CardManager.cards.Add(cardInfo.gameObject.name, new Card(customCard.GetModName().Sanitize(), Unbound.config.Bind("Cards: " + customCard.GetModName().Sanitize(), cardInfo.gameObject.name, true), cardInfo)); + } + + cardInfo.ExecuteAfterFrames(5, () => + { + callback?.Invoke(cardInfo); + }); + } + public static void RegisterUnityCard(GameObject cardPrefab, Action callback) where T : CustomCard { CardInfo cardInfo = cardPrefab.GetComponent(); From 22689705055687b428cc9a3e98fe962f24e309f6 Mon Sep 17 00:00:00 2001 From: willuwontu Date: Tue, 20 Dec 2022 10:43:25 -0800 Subject: [PATCH 10/20] Update CustomCard.cs --- UnboundLib/Cards/CustomCard.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/UnboundLib/Cards/CustomCard.cs b/UnboundLib/Cards/CustomCard.cs index 5df2d33..6ec3b2c 100644 --- a/UnboundLib/Cards/CustomCard.cs +++ b/UnboundLib/Cards/CustomCard.cs @@ -191,7 +191,7 @@ public static void BuildUnityCard(GameObject cardPrefab, Action cal CardManager.cards.Add(cardInfo.gameObject.name, new Card(customCard.GetModName().Sanitize(), Unbound.config.Bind("Cards: " + customCard.GetModName().Sanitize(), cardInfo.gameObject.name, true), cardInfo)); } - cardInfo.ExecuteAfterFrames(5, () => + Unbound.Instance.ExecuteAfterFrames(5, () => { callback?.Invoke(cardInfo); }); @@ -220,7 +220,7 @@ public void BuildUnityCard(Action callback) CardManager.cards.Add(cardInfo.gameObject.name, new Card(customCard.GetModName().Sanitize(), Unbound.config.Bind("Cards: " + customCard.GetModName().Sanitize(), cardInfo.gameObject.name, true), cardInfo)); } - cardInfo.ExecuteAfterFrames(5, () => + Unbound.Instance.ExecuteAfterFrames(5, () => { callback?.Invoke(cardInfo); }); @@ -240,7 +240,7 @@ public static void RegisterUnityCard(GameObject cardPrefab, Action CardManager.cards.Add(cardInfo.gameObject.name, new Card(customCard.GetModName().Sanitize(), Unbound.config.Bind("Cards: " + customCard.GetModName().Sanitize(), cardInfo.gameObject.name, true), cardInfo)); } - cardInfo.ExecuteAfterFrames(5, () => + Unbound.Instance.ExecuteAfterFrames(5, () => { callback?.Invoke(cardInfo); }); @@ -259,7 +259,7 @@ public static void RegisterUnityCard(GameObject cardPrefab, string modInitials, CardManager.cards.Add(cardInfo.gameObject.name, new Card(cardname.Sanitize(), Unbound.config.Bind("Cards: " + cardname.Sanitize(), cardInfo.gameObject.name, true), cardInfo)); } - cardInfo.ExecuteAfterFrames(5, () => + Unbound.Instance.ExecuteAfterFrames(5, () => { callback?.Invoke(cardInfo); }); @@ -278,7 +278,7 @@ public void RegisterUnityCard(Action callback) CardManager.cards.Add(cardInfo.gameObject.name, new Card(this.GetModName().Sanitize(), Unbound.config.Bind("Cards: " + this.GetModName().Sanitize(), cardInfo.gameObject.name, true), cardInfo)); } - cardInfo.ExecuteAfterFrames(5, () => + Unbound.Instance.ExecuteAfterFrames(5, () => { callback?.Invoke(cardInfo); }); From 845f7fa3329b12f0278d33599a6f454ee825178b Mon Sep 17 00:00:00 2001 From: willuwontu Date: Wed, 21 Dec 2022 05:57:53 -0800 Subject: [PATCH 11/20] Update CustomCard.cs By Calling awake, we setup any information done in `SetupCard` to restrict access to a card, such as setting card categories or setting allow multiple to false. --- UnboundLib/Cards/CustomCard.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/UnboundLib/Cards/CustomCard.cs b/UnboundLib/Cards/CustomCard.cs index 6ec3b2c..6af5052 100644 --- a/UnboundLib/Cards/CustomCard.cs +++ b/UnboundLib/Cards/CustomCard.cs @@ -191,6 +191,8 @@ public static void BuildUnityCard(GameObject cardPrefab, Action cal CardManager.cards.Add(cardInfo.gameObject.name, new Card(customCard.GetModName().Sanitize(), Unbound.config.Bind("Cards: " + customCard.GetModName().Sanitize(), cardInfo.gameObject.name, true), cardInfo)); } + customCard.Awake(); + Unbound.Instance.ExecuteAfterFrames(5, () => { callback?.Invoke(cardInfo); @@ -220,6 +222,8 @@ public void BuildUnityCard(Action callback) CardManager.cards.Add(cardInfo.gameObject.name, new Card(customCard.GetModName().Sanitize(), Unbound.config.Bind("Cards: " + customCard.GetModName().Sanitize(), cardInfo.gameObject.name, true), cardInfo)); } + this.Awake(); + Unbound.Instance.ExecuteAfterFrames(5, () => { callback?.Invoke(cardInfo); From feb77aa968a61b5f4eb9c054ba9450d5c40900ab Mon Sep 17 00:00:00 2001 From: willuwontu Date: Wed, 21 Dec 2022 06:30:43 -0800 Subject: [PATCH 12/20] Update UnboundLib.csproj --- UnboundLib/UnboundLib.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnboundLib/UnboundLib.csproj b/UnboundLib/UnboundLib.csproj index a3907d2..020955f 100644 --- a/UnboundLib/UnboundLib.csproj +++ b/UnboundLib/UnboundLib.csproj @@ -35,7 +35,7 @@ - D:\Program Files (x86)\Steam\steamapps\common\ROUNDS + E:\Program Files (x86)\Steam\steamapps\common\ROUNDS true true 7.1 From 0c24676d0b4a695b160ea88a41ec5a6db8c9eba4 Mon Sep 17 00:00:00 2001 From: willuwontu Date: Fri, 30 Dec 2022 22:10:18 -0800 Subject: [PATCH 13/20] Update CustomCard.cs --- UnboundLib/Cards/CustomCard.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/UnboundLib/Cards/CustomCard.cs b/UnboundLib/Cards/CustomCard.cs index 6af5052..0f3a409 100644 --- a/UnboundLib/Cards/CustomCard.cs +++ b/UnboundLib/Cards/CustomCard.cs @@ -43,17 +43,17 @@ private void Start() { GameObject bottomLeftCorner = edgeTransform.gameObject; modNameObj.gameObject.transform.SetParent(bottomLeftCorner.transform); - } - TextMeshProUGUI modText = modNameObj.gameObject.AddComponent(); - modText.text = GetModName().Sanitize(); - modNameObj.transform.localEulerAngles = new Vector3(0f, 0f, 135f); + TextMeshProUGUI modText = modNameObj.gameObject.AddComponent(); + modText.text = GetModName().Sanitize(); + modNameObj.transform.localEulerAngles = new Vector3(0f, 0f, 135f); - modNameObj.transform.localScale = Vector3.one; - modNameObj.AddComponent(); - modText.alignment = TextAlignmentOptions.Bottom; - modText.alpha = 0.1f; - modText.fontSize = 54; + modNameObj.transform.localScale = Vector3.one; + modNameObj.AddComponent(); + modText.alignment = TextAlignmentOptions.Bottom; + modText.alpha = 0.1f; + modText.fontSize = 54; + } Callback(); } From 36a71c2381270157ac7a578546c9e0ac277eff56 Mon Sep 17 00:00:00 2001 From: willuwontu Date: Fri, 30 Dec 2022 22:10:21 -0800 Subject: [PATCH 14/20] Update Unbound.cs --- UnboundLib/Unbound.cs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/UnboundLib/Unbound.cs b/UnboundLib/Unbound.cs index f7cf8f3..1a99ced 100644 --- a/UnboundLib/Unbound.cs +++ b/UnboundLib/Unbound.cs @@ -25,7 +25,7 @@ public class Unbound : BaseUnityPlugin { private const string ModId = "com.willis.rounds.unbound"; private const string ModName = "Rounds Unbound"; - public const string Version = "3.2.1"; + public const string Version = "3.2.2"; public static Unbound Instance { get; private set; } public static readonly ConfigFile config = new ConfigFile(Path.Combine(Paths.ConfigPath, "UnboundLib.cfg"), true); @@ -228,6 +228,9 @@ private void Awake() LoadAssets(); GameModeManager.Init(); + + // fetch card to use as a template for all custom cards + templateCard = Resources.Load("0 Cards/0. PlainCard").GetComponent(); } private void Start() @@ -258,17 +261,6 @@ private void Start() GameModeManager.CurrentHandler.SetSettings((GameSettings) data[1]); }); - // fetch card to use as a template for all custom cards - CardInfo huge = CardChoice.instance.cards.FirstOrDefault(c => c.cardName.ToLower() == "huge"); - templateCard = Instantiate(huge.gameObject, Vector3.up * 100f, Quaternion.identity) - .GetComponent(); - templateCard.cardBase = huge.cardBase; - - templateCard.gameObject.name = "__UNBOUND_TEMPLATE_CARD__"; - DestroyImmediate(templateCard.transform.GetChild(0).gameObject); - templateCard.GetComponent().health = 1f; // remove huge's stats - DontDestroyOnLoad(templateCard.gameObject); - CardManager.defaultCards = CardChoice.instance.cards; // register default cards with toggle menu From eae72b6c173856b96acae6826f8023db0a07d947 Mon Sep 17 00:00:00 2001 From: willuwontu Date: Sat, 31 Dec 2022 10:48:56 -0800 Subject: [PATCH 15/20] Update CustomCard.cs --- UnboundLib/Cards/CustomCard.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/UnboundLib/Cards/CustomCard.cs b/UnboundLib/Cards/CustomCard.cs index 0f3a409..17fc209 100644 --- a/UnboundLib/Cards/CustomCard.cs +++ b/UnboundLib/Cards/CustomCard.cs @@ -22,10 +22,10 @@ public abstract class CustomCard : MonoBehaviour private void Awake() { - cardInfo = GetComponent(); - gun = GetComponent(); - cardStats = GetComponent(); - statModifiers = GetComponent(); + cardInfo = gameObject.GetOrAddComponent(); + gun = gameObject.GetOrAddComponent(); + cardStats = gameObject.GetOrAddComponent(); + statModifiers = gameObject.GetOrAddComponent(); block = gameObject.GetOrAddComponent(); SetupCard(cardInfo, gun, cardStats, statModifiers, block); } From 5baeb2dff1b9a54753193e2a4b14ae247794a4b9 Mon Sep 17 00:00:00 2001 From: willuwontu Date: Sat, 31 Dec 2022 10:52:21 -0800 Subject: [PATCH 16/20] Revert "Merge branch 'master' into CardChoicePatch" This reverts commit f00f3df75a9e89cf616ae731f4f6f0392951cb1b, reversing changes made to eae72b6c173856b96acae6826f8023db0a07d947. --- UnboundLib/Extensions/Block.cs | 48 ---- UnboundLib/Extensions/CharacterData.cs | 48 ---- .../Extensions/CharacterStatModifiers.cs | 48 ---- UnboundLib/Extensions/Gravity.cs | 48 ---- UnboundLib/Extensions/Gun.cs | 50 ----- UnboundLib/Extensions/GunAmmo.cs | 40 ---- UnboundLib/Extensions/HealthHandler.cs | 48 ---- UnboundLib/Patches/ApplyCardStats.cs | 16 -- UnboundLib/Stats/StatDictionary.cs | 208 ------------------ UnboundLib/Stats/StatInfo.cs | 24 -- UnboundLib/Stats/StatOperation.cs | 48 ---- UnboundLib/UnboundLib.csproj | 3 +- 12 files changed, 1 insertion(+), 628 deletions(-) delete mode 100644 UnboundLib/Extensions/Block.cs delete mode 100644 UnboundLib/Extensions/CharacterData.cs delete mode 100644 UnboundLib/Extensions/CharacterStatModifiers.cs delete mode 100644 UnboundLib/Extensions/Gravity.cs delete mode 100644 UnboundLib/Extensions/Gun.cs delete mode 100644 UnboundLib/Extensions/GunAmmo.cs delete mode 100644 UnboundLib/Extensions/HealthHandler.cs delete mode 100644 UnboundLib/Stats/StatDictionary.cs delete mode 100644 UnboundLib/Stats/StatInfo.cs delete mode 100644 UnboundLib/Stats/StatOperation.cs diff --git a/UnboundLib/Extensions/Block.cs b/UnboundLib/Extensions/Block.cs deleted file mode 100644 index eac4d75..0000000 --- a/UnboundLib/Extensions/Block.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using HarmonyLib; - -//From PCE -namespace UnboundLib.Extensions -{ - // ADD FIELDS TO GUN - [Serializable] - public class BlockAdditionalData - { - public Dictionary customStats; - - public BlockAdditionalData() - { - customStats = new Dictionary(); - } - } - public static class BlockExtension - { - public static readonly ConditionalWeakTable data = - new ConditionalWeakTable(); - - public static BlockAdditionalData GetAdditionalData(this Block block) - { - return data.GetOrCreateValue(block); - } - - public static void AddData(this Block block, BlockAdditionalData value) - { - try - { - data.Add(block, value); - } - catch (Exception) { } - } - } - // reset extra block attributes when resetstats is called - [HarmonyPatch(typeof(Block), "ResetStats")] - class BlockPatchResetStats - { - private static void Prefix(Block __instance) - { - __instance.GetAdditionalData().customStats.Clear(); - } - } -} \ No newline at end of file diff --git a/UnboundLib/Extensions/CharacterData.cs b/UnboundLib/Extensions/CharacterData.cs deleted file mode 100644 index 32af55b..0000000 --- a/UnboundLib/Extensions/CharacterData.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using HarmonyLib; - -//From PCE -namespace UnboundLib.Extensions -{ - // ADD FIELDS TO GUN - [Serializable] - public class CharacterDataAdditionalData - { - public Dictionary customStats; - - public CharacterDataAdditionalData() - { - customStats = new Dictionary(); - } - } - public static class CharacterDataExtension - { - public static readonly ConditionalWeakTable data = - new ConditionalWeakTable(); - - public static CharacterDataAdditionalData GetAdditionalData(this CharacterData characterData) - { - return data.GetOrCreateValue(characterData); - } - - public static void AddData(this CharacterData characterData, CharacterDataAdditionalData value) - { - try - { - data.Add(characterData, value); - } - catch (Exception) { } - } - } - // reset extra characterData attributes when resetstats is called - //[HarmonyPatch(typeof(CharacterData), "ResetStats")] - //class CharacterDataPatchResetStats - //{ - // private static void Prefix(CharacterData __instance) - // { - // __instance.GetAdditionalData().customStats.Clear(); - // } - //} -} \ No newline at end of file diff --git a/UnboundLib/Extensions/CharacterStatModifiers.cs b/UnboundLib/Extensions/CharacterStatModifiers.cs deleted file mode 100644 index 5e71759..0000000 --- a/UnboundLib/Extensions/CharacterStatModifiers.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using HarmonyLib; - -//From PCE -namespace UnboundLib.Extensions -{ - // ADD FIELDS TO GUN - [Serializable] - public class CharacterStatModifiersAdditionalData - { - public Dictionary customStats; - - public CharacterStatModifiersAdditionalData() - { - customStats = new Dictionary(); - } - } - public static class CharacterStatModifiersExtension - { - public static readonly ConditionalWeakTable data = - new ConditionalWeakTable(); - - public static CharacterStatModifiersAdditionalData GetAdditionalData(this CharacterStatModifiers statModifiers) - { - return data.GetOrCreateValue(statModifiers); - } - - public static void AddData(this CharacterStatModifiers statModifiers, CharacterStatModifiersAdditionalData value) - { - try - { - data.Add(statModifiers, value); - } - catch (Exception) { } - } - } - // reset extra statModifiers attributes when resetstats is called - [HarmonyPatch(typeof(CharacterStatModifiers), "ResetStats")] - class CharacterStatModifiersPatchResetStats - { - private static void Prefix(CharacterStatModifiers __instance) - { - __instance.GetAdditionalData().customStats.Clear(); - } - } -} \ No newline at end of file diff --git a/UnboundLib/Extensions/Gravity.cs b/UnboundLib/Extensions/Gravity.cs deleted file mode 100644 index 4131a89..0000000 --- a/UnboundLib/Extensions/Gravity.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using HarmonyLib; - -//From PCE -namespace UnboundLib.Extensions -{ - // ADD FIELDS TO GUN - [Serializable] - public class GravityAdditionalData - { - public Dictionary customStats; - - public GravityAdditionalData() - { - customStats = new Dictionary(); - } - } - public static class GravityExtension - { - public static readonly ConditionalWeakTable data = - new ConditionalWeakTable(); - - public static GravityAdditionalData GetAdditionalData(this Gravity gravity) - { - return data.GetOrCreateValue(gravity); - } - - public static void AddData(this Gravity gravity, GravityAdditionalData value) - { - try - { - data.Add(gravity, value); - } - catch (Exception) { } - } - } - // reset extra gravity attributes when resetstats is called - //[HarmonyPatch(typeof(Gravity), "ResetStats")] - //class GravityPatchResetStats - //{ - // private static void Prefix(Gravity __instance) - // { - // __instance.GetAdditionalData().customStats.Clear(); - // } - //} -} \ No newline at end of file diff --git a/UnboundLib/Extensions/Gun.cs b/UnboundLib/Extensions/Gun.cs deleted file mode 100644 index 6df8f08..0000000 --- a/UnboundLib/Extensions/Gun.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using HarmonyLib; - -//From PCE -namespace UnboundLib.Extensions -{ - // ADD FIELDS TO GUN - [Serializable] - public class GunAdditionalData - { - public Dictionary customStats; - - public GunAdditionalData() - { - customStats = new Dictionary(); - } - } - public static class GunExtension - { - public static readonly ConditionalWeakTable data = - new ConditionalWeakTable(); - - public static GunAdditionalData GetAdditionalData(this Gun gun) - { - return data.GetOrCreateValue(gun); - } - - public static void AddData(this Gun gun, GunAdditionalData value) - { - try - { - data.Add(gun, value); - } - catch (Exception) { } - } - } - // reset extra gun attributes when resetstats is called - [HarmonyPatch(typeof(Gun), "ResetStats")] - class GunPatchResetStats - { - private static void Prefix(Gun __instance) - { - __instance.GetAdditionalData().customStats.Clear(); - var gunAmmo = __instance.GetComponentInChildren(); - gunAmmo.GetAdditionalData().customStats.Clear(); - } - } -} \ No newline at end of file diff --git a/UnboundLib/Extensions/GunAmmo.cs b/UnboundLib/Extensions/GunAmmo.cs deleted file mode 100644 index 0abd41d..0000000 --- a/UnboundLib/Extensions/GunAmmo.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using HarmonyLib; - -//From PCE -namespace UnboundLib.Extensions -{ - // ADD FIELDS TO GUN - [Serializable] - public class GunAmmoAdditionalData - { - public Dictionary customStats; - - public GunAmmoAdditionalData() - { - customStats = new Dictionary(); - } - } - public static class GunAmmoExtension - { - public static readonly ConditionalWeakTable data = - new ConditionalWeakTable(); - - public static GunAmmoAdditionalData GetAdditionalData(this GunAmmo gunAmmo) - { - return data.GetOrCreateValue(gunAmmo); - } - - public static void AddData(this GunAmmo gunAmmo, GunAmmoAdditionalData value) - { - try - { - data.Add(gunAmmo, value); - } - catch (Exception) { } - } - } - // reset extra gunAmmo attributes when resetstats is called via gun -} \ No newline at end of file diff --git a/UnboundLib/Extensions/HealthHandler.cs b/UnboundLib/Extensions/HealthHandler.cs deleted file mode 100644 index bfb5aa8..0000000 --- a/UnboundLib/Extensions/HealthHandler.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using HarmonyLib; - -//From PCE -namespace UnboundLib.Extensions -{ - // ADD FIELDS TO GUN - [Serializable] - public class HealthHandlerAdditionalData - { - public Dictionary customStats; - - public HealthHandlerAdditionalData() - { - customStats = new Dictionary(); - } - } - public static class HealthHandlerExtension - { - public static readonly ConditionalWeakTable data = - new ConditionalWeakTable(); - - public static HealthHandlerAdditionalData GetAdditionalData(this HealthHandler healthHandler) - { - return data.GetOrCreateValue(healthHandler); - } - - public static void AddData(this HealthHandler healthHandler, HealthHandlerAdditionalData value) - { - try - { - data.Add(healthHandler, value); - } - catch (Exception) { } - } - } - // reset extra healthHandler attributes when resetstats is called - //[HarmonyPatch(typeof(HealthHandler), "ResetStats")] - //class HealthHandlerPatchResetStats - //{ - // private static void Prefix(HealthHandler __instance) - // { - // __instance.GetAdditionalData().customStats.Clear(); - // } - //} -} \ No newline at end of file diff --git a/UnboundLib/Patches/ApplyCardStats.cs b/UnboundLib/Patches/ApplyCardStats.cs index 0a6813a..217f11d 100644 --- a/UnboundLib/Patches/ApplyCardStats.cs +++ b/UnboundLib/Patches/ApplyCardStats.cs @@ -1,6 +1,5 @@ using HarmonyLib; using UnboundLib.Cards; -using UnboundLib.Stats; namespace UnboundLib.Patches { @@ -24,20 +23,5 @@ static void Prefix(ApplyCardStats __instance, Player ___playerToUpgrade) customAbility.OnAddCard(player, gun, gunAmmo, characterData, healthHandler, gravity, block, characterStatModifiers); } } - - [HarmonyPrefix] - static void CustomStatsApplied(ApplyCardStats __instance, Player ___playerToUpgrade, Gun ___myGunStats, CharacterStatModifiers ___myPlayerStats, Block ___myBlock) - { - var player = ___playerToUpgrade.GetComponent(); - var gun = ___playerToUpgrade.GetComponent().holdable.GetComponent(); - var characterData = ___playerToUpgrade.GetComponent(); - var healthHandler = ___playerToUpgrade.GetComponent(); - var gravity = ___playerToUpgrade.GetComponent(); - var block = ___playerToUpgrade.GetComponent(); - var gunAmmo = gun.GetComponentInChildren(); - var characterStatModifiers = player.GetComponent(); - - //StatDictionary.CopyCustomStats(player, gun, characterData, healthHandler, gravity, block, gunAmmo, characterStatModifiers, ___myGunStats, ___myPlayerStats, ___myBlock); - } } } diff --git a/UnboundLib/Stats/StatDictionary.cs b/UnboundLib/Stats/StatDictionary.cs deleted file mode 100644 index 0e47bbd..0000000 --- a/UnboundLib/Stats/StatDictionary.cs +++ /dev/null @@ -1,208 +0,0 @@ -using System.Collections.Generic; -using UnboundLib.Extensions; - -namespace UnboundLib.Stats -{ - public static class StatDictionary - { - private static Dictionary data = new Dictionary(); - - public static string[] GetStats() - { - if (data.Count > 0) - { - return (new List(data.Keys)).ToArray(); - } - - return null; - } - - public static void AddStat(string statName, StatInfo statInfo) - { - UnityEngine.Debug.Log("Attempting to add " + statName + " to the dictionary."); - if (data.TryGetValue(statName, out StatInfo statdata)) - { - UnityEngine.Debug.Log(statName + " already exists."); - - // Throw error, show pre-existing data in log. - } - else - { - data.Add(statName, statInfo); - } - } - - public static void Clear() - { - data.Clear(); - } - - public static Dictionary GetRaw() - { - return data; - } - - public static void CopyCustomStats(Player player, Gun gun, CharacterData characterdata, HealthHandler healthHandler, Gravity gravity, Block block, GunAmmo gunAmmo, CharacterStatModifiers statModifiers, Gun copyFromGun, CharacterStatModifiers copyFromCSM, Block copyFromBlock) - { - Dictionary> customStatChanges = new Dictionary>(); - StatOperation value; - if (copyFromGun) - { - foreach (var key in copyFromGun.GetAdditionalData().customStats) - { - if (key.Value.GetType() == typeof(StatOperation)) - { - value = (StatOperation) key.Value; - if (!value.reroute) - { - value.reroute = true; - value.destination = StatOperation.Destination.Gun; - } - if (customStatChanges.TryGetValue(key.Key, out List list)) - { - list.Add(value); - } - else - { - customStatChanges.Add(key.Key, new List() { value }); - } - } - } - } - if (copyFromBlock) - { - foreach (var key in copyFromBlock.GetAdditionalData().customStats) - { - if (key.Value.GetType() == typeof(StatOperation)) - { - value = (StatOperation) key.Value; - if (!value.reroute) - { - value.reroute = true; - value.destination = StatOperation.Destination.Block; - } - if (customStatChanges.TryGetValue(key.Key, out List list)) - { - list.Add(value); - } - else - { - customStatChanges.Add(key.Key, new List() { value }); - } - } - } - } - if (copyFromCSM) - { - foreach (var key in copyFromCSM.GetAdditionalData().customStats) - { - if (key.Value.GetType() == typeof(StatOperation)) - { - value = (StatOperation) key.Value; - if (!value.reroute) - { - value.reroute = true; - value.destination = StatOperation.Destination.CharacterStatModifier; - } - if (customStatChanges.TryGetValue(key.Key, out List list)) - { - list.Add(value); - } - else - { - customStatChanges.Add(key.Key, new List() { value }); - } - } - } - } - - foreach (var key in customStatChanges) - { - foreach (var operation in key.Value) - { - switch (operation.destination) - { - case StatOperation.Destination.Gun: - PerformStatOperation(key.Key, gun.GetAdditionalData().customStats, operation); - break; - case StatOperation.Destination.Block: - PerformStatOperation(key.Key, block.GetAdditionalData().customStats, operation); - break; - //case StatOperation.Destination.CharacterData: - // PerformStatOperation(key.Key, characterdata.GetAdditionalData().customStats, operation); - // break; - case StatOperation.Destination.CharacterStatModifier: - PerformStatOperation(key.Key, statModifiers.GetAdditionalData().customStats, operation); - break; - //case StatOperation.Destination.Gravity: - // PerformStatOperation(key.Key, gravity.GetAdditionalData().customStats, operation); - // break; - //case StatOperation.Destination.HealthHandler: - // PerformStatOperation(key.Key, healthHandler.GetAdditionalData().customStats, operation); - // break; - //case StatOperation.Destination.Player: - // PerformStatOperation(key.Key, player.GetAdditionalData().customStats, operation); - // break; - case StatOperation.Destination.GunAmmo: - PerformStatOperation(key.Key, gunAmmo.GetAdditionalData().customStats, operation); - break; - } - } - } - } - - private static void PerformStatOperation(string key, Dictionary to, StatOperation from) - { - // If the stat doesn't exist yet, but we have a registered default value, set it to that. - if (!to.TryGetValue(key, out dynamic value) && StatDictionary.GetRaw().TryGetValue(key, out StatInfo statInfo)) - { - to.Add(key, statInfo.defaultValue); - } - // If the stat exists already, operate on it - if (to.TryGetValue(key, out dynamic statVal)) - { - // If the operation is a replace, we don't care about previous typing. - if (from.operation == StatOperation.Operation.Replace) - { - statVal = from.value; - } - // If we're adding to a list, and it is a list, we can add to it. - if (from.operation == StatOperation.Operation.AddToList && statVal.GetType().IsGenericType && statVal.GetType().GetGenericTypeDefinition() == typeof(List<>)) - { - statVal.Add(from.value); - } - // We cannot perform math with values of different types, so we check to make sure they're the same here. - if (statVal.GetType() == from.value.GetType()) - { - switch (from.operation) - { - case (StatOperation.Operation.Add): - statVal += from.value; - break; - case (StatOperation.Operation.Multiply): - statVal *= from.value; - break; - case (StatOperation.Operation.Divide): - statVal /= from.value; - break; - case (StatOperation.Operation.Subtract): - statVal -= from.value; - break; - } - } - else - { - // Throw error about types not being the same - } - } - else // If the stat doesn't exist yet (and therefore not registered, or it would be set already), we can only perform a replace operation. - { - if (from.operation == StatOperation.Operation.Replace) - { - to.Add(key, from.value); - } - } - - } - } -} diff --git a/UnboundLib/Stats/StatInfo.cs b/UnboundLib/Stats/StatInfo.cs deleted file mode 100644 index 7fde157..0000000 --- a/UnboundLib/Stats/StatInfo.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using UnityEngine; -using Photon.Pun; - -namespace UnboundLib.Stats -{ - public class StatInfo - { - public dynamic type; - public dynamic defaultValue; - public string sourceMod; - public string description; - - public StatInfo(dynamic statDefaultValue, string statSourceMod = "com.mod.id", string statDescription = "If only this stat had a description.") - { - type = statDefaultValue.GetType(); - defaultValue = statDefaultValue; - sourceMod = statSourceMod; - description = statDescription; - } - } -} diff --git a/UnboundLib/Stats/StatOperation.cs b/UnboundLib/Stats/StatOperation.cs deleted file mode 100644 index 987f381..0000000 --- a/UnboundLib/Stats/StatOperation.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Collections.ObjectModel; -using System.Text; -using UnityEngine; -using TMPro; - -namespace UnboundLib.Stats -{ - public class StatOperation - { - public dynamic value; - public Operation operation; - public bool reroute; - public Destination destination; - - public StatOperation(dynamic statValue, Operation operationType, bool routeToDifferentStat = false, Destination otherStat = Destination.CharacterStatModifier) - { - value = statValue; - operation = operationType; - reroute = routeToDifferentStat; - destination = otherStat; - } - - public enum Operation - { - Replace, - Multiply, - Add, - Divide, - Subtract, - AddToList - } - - public enum Destination - { - Gun, - CharacterStatModifier, - //Player, - //CharacterData, - //HealthHandler, - //Gravity, - GunAmmo, - Block - } - } -} diff --git a/UnboundLib/UnboundLib.csproj b/UnboundLib/UnboundLib.csproj index 020955f..099ac14 100644 --- a/UnboundLib/UnboundLib.csproj +++ b/UnboundLib/UnboundLib.csproj @@ -35,7 +35,7 @@ - E:\Program Files (x86)\Steam\steamapps\common\ROUNDS + C:\Program Files (x86)\Steam\steamapps\common\ROUNDS true true 7.1 @@ -64,7 +64,6 @@ ..\Assemblies\BepInEx.dll - ..\Assemblies\MMHOOK_Assembly-CSharp.dll From aba530b1ae0cb745bfdd7d58370fb89634c1ff1d Mon Sep 17 00:00:00 2001 From: willuwontu Date: Sat, 31 Dec 2022 11:00:18 -0800 Subject: [PATCH 17/20] Update Unbound.cs --- UnboundLib/Unbound.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnboundLib/Unbound.cs b/UnboundLib/Unbound.cs index 9793e9a..c16fcab 100644 --- a/UnboundLib/Unbound.cs +++ b/UnboundLib/Unbound.cs @@ -25,7 +25,7 @@ public class Unbound : BaseUnityPlugin { private const string ModId = "com.willis.rounds.unbound"; private const string ModName = "Rounds Unbound"; - public const string Version = "3.2.4"; + public const string Version = "3.2.5"; public static Unbound Instance { get; private set; } public static readonly ConfigFile config = new ConfigFile(Path.Combine(Paths.ConfigPath, "UnboundLib.cfg"), true); From 22f754513b43bb43b15ca49f88f0d0c0fb1d9c3e Mon Sep 17 00:00:00 2001 From: willuwontu Date: Sun, 1 Jan 2023 20:56:27 -0800 Subject: [PATCH 18/20] Update CustomCard.cs --- UnboundLib/Cards/CustomCard.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UnboundLib/Cards/CustomCard.cs b/UnboundLib/Cards/CustomCard.cs index 00ad3a2..59068bf 100644 --- a/UnboundLib/Cards/CustomCard.cs +++ b/UnboundLib/Cards/CustomCard.cs @@ -171,7 +171,7 @@ public static void BuildCard(Action callback) where T : CustomCard public static void BuildUnityCard(GameObject cardPrefab, Action callback) where T : CustomCard { - CardInfo cardInfo = cardPrefab.GetComponent(); + CardInfo cardInfo = cardPrefab.GetOrAddComponent(); CustomCard customCard = cardPrefab.GetOrAddComponent(); cardInfo.cardBase = customCard.GetCardBase(); @@ -201,7 +201,7 @@ public static void BuildUnityCard(GameObject cardPrefab, Action cal public void BuildUnityCard(Action callback) { - CardInfo cardInfo = this.gameObject.GetComponent(); + CardInfo cardInfo = this.gameObject.GetOrAddComponent(); CustomCard customCard = this; GameObject cardPrefab = this.gameObject; From 3ee5997dafd78320fd55407aa31f383c7e18d295 Mon Sep 17 00:00:00 2001 From: willuwontu Date: Sun, 1 Jan 2023 21:31:40 -0800 Subject: [PATCH 19/20] Update CustomCard.cs --- UnboundLib/Cards/CustomCard.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/UnboundLib/Cards/CustomCard.cs b/UnboundLib/Cards/CustomCard.cs index 59068bf..3a13da2 100644 --- a/UnboundLib/Cards/CustomCard.cs +++ b/UnboundLib/Cards/CustomCard.cs @@ -172,6 +172,7 @@ public static void BuildCard(Action callback) where T : CustomCard public static void BuildUnityCard(GameObject cardPrefab, Action callback) where T : CustomCard { CardInfo cardInfo = cardPrefab.GetOrAddComponent(); + PhotonView view = cardPrefab.GetOrAddComponent(); CustomCard customCard = cardPrefab.GetOrAddComponent(); cardInfo.cardBase = customCard.GetCardBase(); @@ -202,6 +203,7 @@ public static void BuildUnityCard(GameObject cardPrefab, Action cal public void BuildUnityCard(Action callback) { CardInfo cardInfo = this.gameObject.GetOrAddComponent(); + PhotonView view = this.gameObject.GetOrAddComponent(); CustomCard customCard = this; GameObject cardPrefab = this.gameObject; From 115ec373361189e4e3c2bfba68083fd0b271f01a Mon Sep 17 00:00:00 2001 From: willuwontu Date: Mon, 2 Jan 2023 09:32:43 -0800 Subject: [PATCH 20/20] Update CustomCard.cs --- UnboundLib/Cards/CustomCard.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/UnboundLib/Cards/CustomCard.cs b/UnboundLib/Cards/CustomCard.cs index 3a13da2..af7acba 100644 --- a/UnboundLib/Cards/CustomCard.cs +++ b/UnboundLib/Cards/CustomCard.cs @@ -24,9 +24,21 @@ private void Awake() { cardInfo = gameObject.GetOrAddComponent(); gun = gameObject.GetOrAddComponent(); + if (gun.objectsToSpawn == null) + { + gun.objectsToSpawn = new ObjectsToSpawn[0]; + } + if (gun.projectiles == null) + { + gun.projectiles = new ProjectilesToSpawn[0]; + } cardStats = gameObject.GetOrAddComponent(); statModifiers = gameObject.GetOrAddComponent(); block = gameObject.GetOrAddComponent(); + if (block.objectsToSpawn == null) + { + block.objectsToSpawn = new List(); + } SetupCard(cardInfo, gun, cardStats, statModifiers, block); }