Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions Anarchy/Assembly/Anarchy/Skins/Skin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Anarchy.Skins
{
internal abstract class Skin
{
private static object LoadingSkin = false;
public abstract int DataLength { get; }

protected Dictionary<int, SkinElement> elements;
Expand All @@ -33,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<int, SkinElement> el in elements)
{
Expand All @@ -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));
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 1 addition & 5 deletions Anarchy/Assembly/Anarchy/Skins/SkinElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 11 additions & 5 deletions Anarchy/Assembly/Anarchy/Skins/Titans/TitanSkin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TITAN>().mainMaterial.GetComponent<SkinnedMeshRenderer>().material;
TryApplyTexture(elements[0], rend);
// rend.material = Owner.GetComponent<TITAN>().mainMaterial.GetComponent<SkinnedMeshRenderer>().material;
if (elements[0] != null && elements[0].IsDone)
{
TryApplyTexture(elements[0], rend);
}
}
}
}
5 changes: 4 additions & 1 deletion Anarchy/Assembly/Anarchy/Skins/Titans/TitanSkinHair.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
2 changes: 1 addition & 1 deletion Anarchy/Assembly/AoTTG/Titans/TITAN.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4099,4 +4099,4 @@ public void UpdateCollider()
ColliderEnabled = true;
}
}
}
}
6 changes: 3 additions & 3 deletions Anarchy/Assembly/AoTTG/Titans/TITAN_SETUP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down