From 4cd8d26673abb014f77c66af71410e14813c5df6 Mon Sep 17 00:00:00 2001 From: kmlkmljkl2 <57689055+kmlkmljkl2@users.noreply.github.com> Date: Fri, 8 Dec 2023 23:17:00 +0100 Subject: [PATCH 1/5] Update Skin.cs Loading the skins one by one to prevent crashes in high Titancount rooms Also helps with the lag spike when someone joins --- Anarchy/Assembly/Anarchy/Skins/Skin.cs | 33 ++++++++++++++++---------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/Anarchy/Assembly/Anarchy/Skins/Skin.cs b/Anarchy/Assembly/Anarchy/Skins/Skin.cs index 0e722b5..2d469f5 100644 --- a/Anarchy/Assembly/Anarchy/Skins/Skin.cs +++ b/Anarchy/Assembly/Anarchy/Skins/Skin.cs @@ -8,6 +8,7 @@ namespace Anarchy.Skins { internal abstract class Skin { + private static object LoadingSkin = false; public abstract int DataLength { get; } protected Dictionary elements; @@ -62,9 +63,6 @@ public static void Check(Skin skin, string[] newData) private static System.Collections.IEnumerator CheckRoutine(Skin skin, string[] newData) { - //Needed for Anarchy to not Crash on high TItanCount (Maybe increase?) - //The better the net the lower it can be ig - yield return new WaitForSeconds(5); if (skin.NeedReload(newData)) { yield return FengGameManagerMKII.FGM.StartCoroutine(skin.Reload(newData)); @@ -95,20 +93,29 @@ public virtual bool NeedReload(string[] data) public virtual System.Collections.IEnumerator Reload(string[] newData) { - for (int i = 0; i < elements.Count; i++) + while ((bool)LoadingSkin) { - SkinElement skin = elements[i]; - if (skin == null) - { - continue; - } - if (skin.NeedReload || !skin.Path.Equals(newData[i])) + yield return new WaitForSeconds(0.05f); + } + lock (LoadingSkin) + { + LoadingSkin = true; + for (int i = 0; i < elements.Count; i++) { - SkinElement element = new SkinElement(newData[i], true); - yield return FengGameManagerMKII.FGM.StartCoroutine(element.TryLoad()); - elements[i] = element; + SkinElement skin = elements[i]; + if (skin == null) + { + continue; + } + if (skin.NeedReload || !skin.Path.Equals(newData[i])) + { + SkinElement element = new SkinElement(newData[i], true); + yield return FengGameManagerMKII.FGM.StartCoroutine(element.TryLoad()); + elements[i] = element; + } } } + LoadingSkin = false; yield break; } From 7c4b47f0674fe6080a842bb316f45f38cc19a08a Mon Sep 17 00:00:00 2001 From: kmlkmljkl2 <57689055+kmlkmljkl2@users.noreply.github.com> Date: Fri, 8 Dec 2023 23:23:24 +0100 Subject: [PATCH 2/5] Fixed Titan Skinloading Fixed the Titan Skinloading. Hair and Eyes now load correctly. --- Anarchy/Assembly/Anarchy/Skins/Skin.cs | 8 ++++---- Anarchy/Assembly/Anarchy/Skins/SkinElement.cs | 6 +----- .../Assembly/Anarchy/Skins/Titans/TitanSkin.cs | 16 +++++++++++----- .../Anarchy/Skins/Titans/TitanSkinHair.cs | 5 ++++- Anarchy/Assembly/AoTTG/Titans/TITAN.cs | 2 +- Anarchy/Assembly/AoTTG/Titans/TITAN_SETUP.cs | 6 +++--- 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/Anarchy/Assembly/Anarchy/Skins/Skin.cs b/Anarchy/Assembly/Anarchy/Skins/Skin.cs index 2d469f5..0ec1a06 100644 --- a/Anarchy/Assembly/Anarchy/Skins/Skin.cs +++ b/Anarchy/Assembly/Anarchy/Skins/Skin.cs @@ -34,10 +34,10 @@ public Skin(GameObject owner, string[] data) public virtual void CheckReload(string[] data) { - if (data.Length != DataLength) - { - return; - } + //if (data.Length != DataLength) + //{ + // return; + //} int i = 0; foreach (KeyValuePair el in elements) { diff --git a/Anarchy/Assembly/Anarchy/Skins/SkinElement.cs b/Anarchy/Assembly/Anarchy/Skins/SkinElement.cs index cd7fed8..3d28ad4 100644 --- a/Anarchy/Assembly/Anarchy/Skins/SkinElement.cs +++ b/Anarchy/Assembly/Anarchy/Skins/SkinElement.cs @@ -107,11 +107,7 @@ public System.Collections.IEnumerator TryLoad() break; } Texture.Apply(); - //Needed since Running simultaneously (<- googled that word) - if (!_cache.ContainsKey(Path)) - _cache.Add(Path, Texture); - else - _cache[Path] = Texture; + _cache.Add(Path, Texture); } IsDone = true; yield break; diff --git a/Anarchy/Assembly/Anarchy/Skins/Titans/TitanSkin.cs b/Anarchy/Assembly/Anarchy/Skins/Titans/TitanSkin.cs index 49a02fc..6d7e593 100644 --- a/Anarchy/Assembly/Anarchy/Skins/Titans/TitanSkin.cs +++ b/Anarchy/Assembly/Anarchy/Skins/Titans/TitanSkin.cs @@ -30,17 +30,23 @@ private void ApplyEye(Renderer rend) { if (elements[1] != null && elements[1].IsDone) { - rend.material.mainTextureScale = new Vector2(rend.material.mainTextureScale.x * 4f, rend.material.mainTextureScale.y * 8f); - rend.material.mainTextureOffset = new Vector2(0f, 0f); TryApplyTexture(elements[1], rend, true); - rend.material.mainTexture = elements[1].Texture; + //idk why it works with this but it does... + if (PhotonNetwork.IsMasterClient) + rend.material.mainTextureScale = new Vector2(rend.material.mainTextureScale.x * 2f, rend.material.mainTextureScale.y * 3f); + else + rend.material.mainTextureScale = new Vector2(rend.material.mainTextureScale.x * 4f, rend.material.mainTextureScale.y * 8f); //RC + rend.material.mainTextureOffset = new Vector2(0f, 0f); } } private void ApplyBody(Renderer rend) { - rend.material = Owner.GetComponent().mainMaterial.GetComponent().material; - TryApplyTexture(elements[0], rend); + // rend.material = Owner.GetComponent().mainMaterial.GetComponent().material; + if (elements[0] != null && elements[0].IsDone) + { + TryApplyTexture(elements[0], rend); + } } } } \ No newline at end of file diff --git a/Anarchy/Assembly/Anarchy/Skins/Titans/TitanSkinHair.cs b/Anarchy/Assembly/Anarchy/Skins/Titans/TitanSkinHair.cs index 93981ba..9b595f2 100644 --- a/Anarchy/Assembly/Anarchy/Skins/Titans/TitanSkinHair.cs +++ b/Anarchy/Assembly/Anarchy/Skins/Titans/TitanSkinHair.cs @@ -12,7 +12,10 @@ internal class TitanSkinHair : Skin public override void Apply() { - TryApplyTexture(elements[0], Owner.renderer, true); + if (elements[0] != null && elements[0].IsDone) + { + TryApplyTexture(elements[0], Owner.renderer, true); + } } } } \ No newline at end of file diff --git a/Anarchy/Assembly/AoTTG/Titans/TITAN.cs b/Anarchy/Assembly/AoTTG/Titans/TITAN.cs index 58567c4..799e52d 100644 --- a/Anarchy/Assembly/AoTTG/Titans/TITAN.cs +++ b/Anarchy/Assembly/AoTTG/Titans/TITAN.cs @@ -2798,7 +2798,7 @@ public void SetAbnormalType(AbnormalType type, bool forceCrawler = false) if (IN_GAME_MAIN_CAMERA.GameType != GameType.Single && BasePV.IsMine) { - BasePV.RPC("netSetAbnormalType", PhotonTargets.AllBuffered, num); + BasePV.RPC("netSetAbnormalType", PhotonTargets.OthersBuffered, num); } else if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single) { diff --git a/Anarchy/Assembly/AoTTG/Titans/TITAN_SETUP.cs b/Anarchy/Assembly/AoTTG/Titans/TITAN_SETUP.cs index e91f673..080cbd8 100644 --- a/Anarchy/Assembly/AoTTG/Titans/TITAN_SETUP.cs +++ b/Anarchy/Assembly/AoTTG/Titans/TITAN_SETUP.cs @@ -27,11 +27,11 @@ private void ApplyHairSkin(int hair, int eye, string hairlink) part_hair.transform.localScale = this.hair_go_ref.transform.localScale; part_hair.renderer.material = CharacterMaterials.Materials[this.hair.texture]; } - if (hairSkin != null) + if (part_hair != null) { - hairSkin = new Anarchy.Skins.Titans.TitanSkinHair(part_hair, hairlink); + hairSkin = new Anarchy.Skins.Titans.TitanSkinHair(this.part_hair, hairlink); + Anarchy.Skins.Skin.Check(hairSkin, new string[] { hairlink }); } - Anarchy.Skins.Skin.Check(hairSkin, new string[] { hairlink }); this.setFacialTexture(this.eye, eye); } From fe7dc30ffa1fc15ee8f3b3e376ba4ddc6adf2a14 Mon Sep 17 00:00:00 2001 From: kmlkmljkl2 <57689055+kmlkmljkl2@users.noreply.github.com> Date: Mon, 5 Feb 2024 13:48:22 +0100 Subject: [PATCH 3/5] Update TITAN.cs --- Anarchy/Assembly/AoTTG/Titans/TITAN.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Anarchy/Assembly/AoTTG/Titans/TITAN.cs b/Anarchy/Assembly/AoTTG/Titans/TITAN.cs index 799e52d..23861e9 100644 --- a/Anarchy/Assembly/AoTTG/Titans/TITAN.cs +++ b/Anarchy/Assembly/AoTTG/Titans/TITAN.cs @@ -2791,7 +2791,7 @@ public void SetAbnormalType(AbnormalType type, bool forceCrawler = false) if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer && PhotonNetwork.IsMasterClient && SkinSettings.TitanSkins.Value != 2) { - BasePV.RPC("loadskinRPC", PhotonTargets.OthersBuffered, body, eyes); + .OthBasePV.RPC("loadskinRPC", PhotonTargets.AllBuffered, body, eyes); } } } @@ -4099,4 +4099,4 @@ public void UpdateCollider() ColliderEnabled = true; } } -} \ No newline at end of file +} From 23e7d9e969544a711706d7a484d798bad4fa89f2 Mon Sep 17 00:00:00 2001 From: kmlkmljkl2 <57689055+kmlkmljkl2@users.noreply.github.com> Date: Mon, 5 Feb 2024 13:50:54 +0100 Subject: [PATCH 4/5] Update TITAN.cs --- Anarchy/Assembly/AoTTG/Titans/TITAN.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Anarchy/Assembly/AoTTG/Titans/TITAN.cs b/Anarchy/Assembly/AoTTG/Titans/TITAN.cs index 23861e9..15cf87f 100644 --- a/Anarchy/Assembly/AoTTG/Titans/TITAN.cs +++ b/Anarchy/Assembly/AoTTG/Titans/TITAN.cs @@ -2791,14 +2791,14 @@ public void SetAbnormalType(AbnormalType type, bool forceCrawler = false) if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer && PhotonNetwork.IsMasterClient && SkinSettings.TitanSkins.Value != 2) { - .OthBasePV.RPC("loadskinRPC", PhotonTargets.AllBuffered, body, eyes); + BasePV.RPC("loadskinRPC", PhotonTargets.OthersBuffered, new object[] { set.Colossal }); } } } if (IN_GAME_MAIN_CAMERA.GameType != GameType.Single && BasePV.IsMine) { - BasePV.RPC("netSetAbnormalType", PhotonTargets.OthersBuffered, num); + BasePV.RPC("netSetAbnormalType", PhotonTargets.AllBuffered, num); } else if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single) { From fa32a0ee8d47e5734a05ee56f3d719618e6e8243 Mon Sep 17 00:00:00 2001 From: kmlkmljkl2 <57689055+kmlkmljkl2@users.noreply.github.com> Date: Mon, 5 Feb 2024 13:51:43 +0100 Subject: [PATCH 5/5] Update TITAN.cs --- Anarchy/Assembly/AoTTG/Titans/TITAN.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Anarchy/Assembly/AoTTG/Titans/TITAN.cs b/Anarchy/Assembly/AoTTG/Titans/TITAN.cs index 15cf87f..e690c73 100644 --- a/Anarchy/Assembly/AoTTG/Titans/TITAN.cs +++ b/Anarchy/Assembly/AoTTG/Titans/TITAN.cs @@ -2791,7 +2791,7 @@ public void SetAbnormalType(AbnormalType type, bool forceCrawler = false) if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer && PhotonNetwork.IsMasterClient && SkinSettings.TitanSkins.Value != 2) { - BasePV.RPC("loadskinRPC", PhotonTargets.OthersBuffered, new object[] { set.Colossal }); + BasePV.RPC("loadskinRPC", PhotonTargets.OthersBuffered, body, eyes); } } }