using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Hatify")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4e40f331e2a363a833372dc6e8b68c865d0f8328")]
[assembly: AssemblyProduct("Hatify")]
[assembly: AssemblyTitle("Hatify")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace Hatify
{
[BepInPlugin("com.Nuxlar.Hatify", "Hatify", "1.0.3")]
public class Hatify : BaseUnityPlugin
{
private Material hatMat = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Commando/matCommandoDualies.mat").WaitForCompletion();
private GameObject hat = ((Component)Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Bandit2/mdlBandit2.fbx").WaitForCompletion().transform.GetChild(4).GetChild(2).GetChild(0)
.GetChild(6)
.GetChild(0)
.GetChild(2)
.GetChild(0)).gameObject;
private Material banditHatMat = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Bandit2/matBandit2AltColossus.mat").WaitForCompletion();
public static ConfigEntry<float> commandoSize;
public static ConfigEntry<float> banditSize;
public static ConfigEntry<float> huntressSize;
public static ConfigEntry<float> engiSize;
public static ConfigEntry<float> engiTurretSize;
public static ConfigEntry<float> engiWalkerTurretSize;
public static ConfigEntry<float> artiSize;
public static ConfigEntry<float> mercSize;
public static ConfigEntry<float> loaderSize;
public static ConfigEntry<float> acridSize;
public static ConfigEntry<float> captainSize;
public static ConfigEntry<float> railgunnerSize;
public static ConfigEntry<float> fiendSize;
private static ConfigFile HatifyConfig { get; set; }
public void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Expected O, but got Unknown
HatifyConfig = new ConfigFile(Paths.ConfigPath + "\\com.Nuxlar.Hatify.cfg", true);
commandoSize = HatifyConfig.Bind<float>("General", "Commando Hat Size", 1.3f, "The scale of the hat.");
banditSize = HatifyConfig.Bind<float>("General", "Bandit Hat Size", 1f, "The scale of the hat.");
huntressSize = HatifyConfig.Bind<float>("General", "Huntress Hat Size", 1.3f, "The scale of the hat.");
engiSize = HatifyConfig.Bind<float>("General", "Engi Hat Size", 1.6f, "The scale of the hat.");
engiTurretSize = HatifyConfig.Bind<float>("General", "Engi Turret Hat Size", 10f, "The scale of the hat.");
engiWalkerTurretSize = HatifyConfig.Bind<float>("General", "Engi Walker Turret Hat Size", 8f, "The scale of the hat.");
artiSize = HatifyConfig.Bind<float>("General", "Artificer Hat Size", 1f, "The scale of the hat.");
mercSize = HatifyConfig.Bind<float>("General", "Merc Hat Size", 1.4f, "The scale of the hat.");
loaderSize = HatifyConfig.Bind<float>("General", "Loader Hat Size", 1.5f, "The scale of the hat.");
acridSize = HatifyConfig.Bind<float>("General", "Acrid Hat Size", 15f, "The scale of the hat.");
captainSize = HatifyConfig.Bind<float>("General", "Captain Hat Size", 1.3f, "The scale of the hat.");
railgunnerSize = HatifyConfig.Bind<float>("General", "Railgunner Hat Size", 1f, "The scale of the hat.");
fiendSize = HatifyConfig.Bind<float>("General", "Fiend Hat Size", 1.4f, "The scale of the hat.");
CharacterModel.Start += new hook_Start(CharacterModel_Start);
}
private void CharacterModel_Start(orig_Start orig, CharacterModel self)
{
orig.Invoke(self);
((MonoBehaviour)self).StartCoroutine(HatifyThese(self));
}
private IEnumerator HatifyThese(CharacterModel model)
{
yield return (object)new WaitForFixedUpdate();
if (!Object.op_Implicit((Object)(object)model.body))
{
yield break;
}
if (((Object)model.body).name == "Bandit2Body(Clone)")
{
if (((Component)model).GetComponent<ModelSkinController>().currentSkinIndex == 2)
{
GameObject obj = Object.Instantiate<GameObject>(hat, ((Component)model).transform.GetChild(4).GetChild(2).GetChild(0)
.GetChild(6)
.GetChild(0)
.GetChild(2));
obj.AddComponent<NetworkIdentity>();
obj.transform.localScale = new Vector3(banditSize.Value, banditSize.Value, banditSize.Value);
obj.transform.localPosition = new Vector3(0f, 0.15f, 0f);
obj.transform.Rotate(new Vector3(10f, 0f, 0f));
((Renderer)((Component)obj.transform.GetChild(0)).GetComponent<MeshRenderer>()).material = banditHatMat;
List<RendererInfo> list = model.baseRendererInfos.ToList();
Renderer[] componentsInChildren = obj.GetComponentsInChildren<Renderer>();
foreach (Renderer val in componentsInChildren)
{
list.Add(new RendererInfo
{
renderer = val,
defaultMaterial = val.sharedMaterial,
defaultShadowCastingMode = val.shadowCastingMode,
hideOnDeath = false,
ignoreOverlays = false
});
}
model.baseRendererInfos = list.ToArray();
}
}
else if (((Object)model.body).name == "CaptainBody(Clone)")
{
Transform child = ((Component)model).transform.GetChild(1).GetChild(0).GetChild(0)
.GetChild(2)
.GetChild(0)
.GetChild(2)
.GetChild(0);
Transform val2 = child.Find("CaptainHat");
if (Object.op_Implicit((Object)(object)val2))
{
((Component)val2).gameObject.SetActive(false);
}
GameObject obj2 = Object.Instantiate<GameObject>(hat, child);
obj2.AddComponent<NetworkIdentity>();
obj2.transform.localScale = new Vector3(captainSize.Value, captainSize.Value, captainSize.Value);
obj2.transform.localPosition = new Vector3(0f, 0.15f, 0f);
obj2.transform.Rotate(new Vector3(15f, 0f, 0f));
((Renderer)((Component)obj2.transform.GetChild(0)).GetComponent<MeshRenderer>()).material = hatMat;
List<RendererInfo> list2 = model.baseRendererInfos.ToList();
Renderer[] componentsInChildren2 = obj2.GetComponentsInChildren<Renderer>();
foreach (Renderer val3 in componentsInChildren2)
{
list2.Add(new RendererInfo
{
renderer = val3,
defaultMaterial = val3.sharedMaterial,
defaultShadowCastingMode = val3.shadowCastingMode,
hideOnDeath = false,
ignoreOverlays = false
});
}
model.baseRendererInfos = list2.ToArray();
}
else if (((Object)model.body).name == "CommandoBody(Clone)")
{
GameObject obj3 = Object.Instantiate<GameObject>(hat, ((Component)model).transform.GetChild(0).GetChild(0).GetChild(0)
.GetChild(3)
.GetChild(0)
.GetChild(0));
obj3.AddComponent<NetworkIdentity>();
obj3.transform.localScale = new Vector3(commandoSize.Value, commandoSize.Value, commandoSize.Value);
obj3.transform.localPosition = new Vector3(0f, 0.3f, 0f);
obj3.transform.Rotate(new Vector3(15f, 0f, 0f));
((Renderer)((Component)obj3.transform.GetChild(0)).GetComponent<MeshRenderer>()).material = hatMat;
List<RendererInfo> list3 = model.baseRendererInfos.ToList();
Renderer[] componentsInChildren3 = obj3.GetComponentsInChildren<Renderer>();
foreach (Renderer val4 in componentsInChildren3)
{
list3.Add(new RendererInfo
{
renderer = val4,
defaultMaterial = val4.sharedMaterial,
defaultShadowCastingMode = val4.shadowCastingMode,
hideOnDeath = false,
ignoreOverlays = false
});
}
model.baseRendererInfos = list3.ToArray();
}
else if (((Object)model.body).name == "RailgunnerBody(Clone)")
{
GameObject obj4 = Object.Instantiate<GameObject>(hat, ((Component)model).transform.GetChild(5).GetChild(0).GetChild(0)
.GetChild(2)
.GetChild(1)
.GetChild(2)
.GetChild(0));
obj4.AddComponent<NetworkIdentity>();
obj4.transform.localScale = new Vector3(railgunnerSize.Value, railgunnerSize.Value, railgunnerSize.Value);
obj4.transform.localPosition = new Vector3(0f, 0.175f, -0.025f);
obj4.transform.Rotate(new Vector3(30f, 0f, 0f));
((Renderer)((Component)obj4.transform.GetChild(0)).GetComponent<MeshRenderer>()).material = hatMat;
List<RendererInfo> list4 = model.baseRendererInfos.ToList();
Renderer[] componentsInChildren4 = obj4.GetComponentsInChildren<Renderer>();
foreach (Renderer val5 in componentsInChildren4)
{
list4.Add(new RendererInfo
{
renderer = val5,
defaultMaterial = val5.sharedMaterial,
defaultShadowCastingMode = val5.shadowCastingMode,
hideOnDeath = false,
ignoreOverlays = false
});
}
model.baseRendererInfos = list4.ToArray();
}
else if (((Object)model.body).name == "MageBody(Clone)")
{
GameObject obj5 = Object.Instantiate<GameObject>(hat, ((Component)model).transform.GetChild(0).GetChild(2).GetChild(0)
.GetChild(3)
.GetChild(0)
.GetChild(2)
.GetChild(0));
obj5.AddComponent<NetworkIdentity>();
obj5.transform.localScale = new Vector3(artiSize.Value, artiSize.Value, artiSize.Value);
obj5.transform.localPosition = new Vector3(0f, 0.15f, -0.1f);
obj5.transform.Rotate(new Vector3(15f, 0f, 0f));
((Renderer)((Component)obj5.transform.GetChild(0)).GetComponent<MeshRenderer>()).material = hatMat;
List<RendererInfo> list5 = model.baseRendererInfos.ToList();
Renderer[] componentsInChildren5 = obj5.GetComponentsInChildren<Renderer>();
foreach (Renderer val6 in componentsInChildren5)
{
list5.Add(new RendererInfo
{
renderer = val6,
defaultMaterial = val6.sharedMaterial,
defaultShadowCastingMode = val6.shadowCastingMode,
hideOnDeath = false,
ignoreOverlays = false
});
}
model.baseRendererInfos = list5.ToArray();
}
else if (((Object)model.body).name == "HuntressBody(Clone)")
{
GameObject obj6 = Object.Instantiate<GameObject>(hat, ((Component)model).transform.GetChild(2).GetChild(3).GetChild(0)
.GetChild(2)
.GetChild(0)
.GetChild(1));
obj6.AddComponent<NetworkIdentity>();
obj6.transform.localScale = new Vector3(huntressSize.Value, huntressSize.Value, huntressSize.Value);
obj6.transform.localPosition = new Vector3(0f, 0.3f, -0.05f);
obj6.transform.Rotate(new Vector3(15f, 0f, 0f));
((Renderer)((Component)obj6.transform.GetChild(0)).GetComponent<MeshRenderer>()).material = hatMat;
List<RendererInfo> list6 = model.baseRendererInfos.ToList();
Renderer[] componentsInChildren6 = obj6.GetComponentsInChildren<Renderer>();
foreach (Renderer val7 in componentsInChildren6)
{
list6.Add(new RendererInfo
{
renderer = val7,
defaultMaterial = val7.sharedMaterial,
defaultShadowCastingMode = val7.shadowCastingMode,
hideOnDeath = false,
ignoreOverlays = false
});
}
model.baseRendererInfos = list6.ToArray();
}
else if (((Object)model.body).name == "CrocoBody(Clone)")
{
GameObject obj7 = Object.Instantiate<GameObject>(hat, ((Component)model).transform.GetChild(5).GetChild(0).GetChild(0)
.GetChild(2)
.GetChild(0)
.GetChild(2)
.GetChild(0)
.GetChild(0)
.GetChild(0));
obj7.AddComponent<NetworkIdentity>();
obj7.transform.localScale = new Vector3(acridSize.Value, acridSize.Value, acridSize.Value);
obj7.transform.localPosition = new Vector3(0f, 0f, 1.6f);
obj7.transform.Rotate(new Vector3(55f, 180f, 180f));
((Renderer)((Component)obj7.transform.GetChild(0)).GetComponent<MeshRenderer>()).material = hatMat;
List<RendererInfo> list7 = model.baseRendererInfos.ToList();
Renderer[] componentsInChildren7 = obj7.GetComponentsInChildren<Renderer>();
foreach (Renderer val8 in componentsInChildren7)
{
list7.Add(new RendererInfo
{
renderer = val8,
defaultMaterial = val8.sharedMaterial,
defaultShadowCastingMode = val8.shadowCastingMode,
hideOnDeath = false,
ignoreOverlays = false
});
}
model.baseRendererInfos = list7.ToArray();
}
else if (((Object)model.body).name == "EngiBody(Clone)")
{
GameObject obj8 = Object.Instantiate<GameObject>(hat, ((Component)model).transform.GetChild(0).GetChild(2).GetChild(0)
.GetChild(3)
.GetChild(0));
obj8.AddComponent<NetworkIdentity>();
obj8.transform.localScale = new Vector3(engiSize.Value, engiSize.Value, engiSize.Value);
obj8.transform.localPosition = new Vector3(0f, 0.65f, 0f);
obj8.transform.Rotate(new Vector3(15f, 0f, 0f));
((Renderer)((Component)obj8.transform.GetChild(0)).GetComponent<MeshRenderer>()).material = hatMat;
List<RendererInfo> list8 = model.baseRendererInfos.ToList();
Renderer[] componentsInChildren8 = obj8.GetComponentsInChildren<Renderer>();
foreach (Renderer val9 in componentsInChildren8)
{
list8.Add(new RendererInfo
{
renderer = val9,
defaultMaterial = val9.sharedMaterial,
defaultShadowCastingMode = val9.shadowCastingMode,
hideOnDeath = false,
ignoreOverlays = false
});
}
model.baseRendererInfos = list8.ToArray();
}
else if (((Object)model.body).name == "EngiWalkerTurretBody(Clone)")
{
GameObject obj9 = Object.Instantiate<GameObject>(hat, ((Component)model).transform.GetChild(1).GetChild(0).GetChild(4)
.GetChild(0));
obj9.AddComponent<NetworkIdentity>();
obj9.transform.localScale = new Vector3(engiWalkerTurretSize.Value, engiWalkerTurretSize.Value, engiWalkerTurretSize.Value);
obj9.transform.localPosition = new Vector3(0f, 1f, 0f);
obj9.transform.Rotate(new Vector3(15f, 0f, 0f));
((Renderer)((Component)obj9.transform.GetChild(0)).GetComponent<MeshRenderer>()).material = hatMat;
List<RendererInfo> list9 = model.baseRendererInfos.ToList();
Renderer[] componentsInChildren9 = obj9.GetComponentsInChildren<Renderer>();
foreach (Renderer val10 in componentsInChildren9)
{
list9.Add(new RendererInfo
{
renderer = val10,
defaultMaterial = val10.sharedMaterial,
defaultShadowCastingMode = val10.shadowCastingMode,
hideOnDeath = false,
ignoreOverlays = false
});
}
model.baseRendererInfos = list9.ToArray();
}
else if (((Object)model.body).name == "EngiTurretBody(Clone)")
{
GameObject obj10 = Object.Instantiate<GameObject>(hat, ((Component)model).transform.GetChild(1).GetChild(0).GetChild(4)
.GetChild(0));
obj10.AddComponent<NetworkIdentity>();
obj10.transform.localScale = new Vector3(engiTurretSize.Value, engiTurretSize.Value, engiTurretSize.Value);
obj10.transform.localPosition = new Vector3(0f, 0.3f, 0f);
obj10.transform.Rotate(new Vector3(15f, 0f, 0f));
((Renderer)((Component)obj10.transform.GetChild(0)).GetComponent<MeshRenderer>()).material = hatMat;
List<RendererInfo> list10 = model.baseRendererInfos.ToList();
Renderer[] componentsInChildren10 = obj10.GetComponentsInChildren<Renderer>();
foreach (Renderer val11 in componentsInChildren10)
{
list10.Add(new RendererInfo
{
renderer = val11,
defaultMaterial = val11.sharedMaterial,
defaultShadowCastingMode = val11.shadowCastingMode,
hideOnDeath = false,
ignoreOverlays = false
});
}
model.baseRendererInfos = list10.ToArray();
}
else if (((Object)model.body).name == "MercBody(Clone)")
{
GameObject obj11 = Object.Instantiate<GameObject>(hat, ((Component)model).transform.GetChild(0).GetChild(2).GetChild(0)
.GetChild(3)
.GetChild(0)
.GetChild(3)
.GetChild(1));
obj11.AddComponent<NetworkIdentity>();
obj11.transform.localScale = new Vector3(mercSize.Value, mercSize.Value, mercSize.Value);
obj11.transform.localPosition = new Vector3(0f, 0.2f, 0f);
obj11.transform.Rotate(new Vector3(15f, 0f, 0f));
((Renderer)((Component)obj11.transform.GetChild(0)).GetComponent<MeshRenderer>()).material = hatMat;
List<RendererInfo> list11 = model.baseRendererInfos.ToList();
Renderer[] componentsInChildren11 = obj11.GetComponentsInChildren<Renderer>();
foreach (Renderer val12 in componentsInChildren11)
{
list11.Add(new RendererInfo
{
renderer = val12,
defaultMaterial = val12.sharedMaterial,
defaultShadowCastingMode = val12.shadowCastingMode,
hideOnDeath = false,
ignoreOverlays = false
});
}
model.baseRendererInfos = list11.ToArray();
}
else if (((Object)model.body).name == "VoidSurvivorBody(Clone)")
{
GameObject obj12 = Object.Instantiate<GameObject>(hat, ((Component)model).transform.GetChild(7).GetChild(0).GetChild(0)
.GetChild(1)
.GetChild(2)
.GetChild(2)
.GetChild(0));
obj12.AddComponent<NetworkIdentity>();
obj12.transform.localScale = new Vector3(fiendSize.Value, fiendSize.Value, fiendSize.Value);
obj12.transform.localPosition = new Vector3(0f, 0.1f, 0f);
obj12.transform.Rotate(new Vector3(15f, 0f, 0f));
((Renderer)((Component)obj12.transform.GetChild(0)).GetComponent<MeshRenderer>()).material = hatMat;
List<RendererInfo> list12 = model.baseRendererInfos.ToList();
Renderer[] componentsInChildren12 = obj12.GetComponentsInChildren<Renderer>();
foreach (Renderer val13 in componentsInChildren12)
{
list12.Add(new RendererInfo
{
renderer = val13,
defaultMaterial = val13.sharedMaterial,
defaultShadowCastingMode = val13.shadowCastingMode,
hideOnDeath = false,
ignoreOverlays = false
});
}
model.baseRendererInfos = list12.ToArray();
}
else if (((Object)model.body).name == "LoaderBody(Clone)")
{
GameObject obj13 = Object.Instantiate<GameObject>(hat, ((Component)model).transform.GetChild(0).GetChild(0).GetChild(0)
.GetChild(5)
.GetChild(0)
.GetChild(3)
.GetChild(0));
obj13.AddComponent<NetworkIdentity>();
obj13.transform.localScale = new Vector3(loaderSize.Value, loaderSize.Value, loaderSize.Value);
obj13.transform.localPosition = new Vector3(0f, 0.2f, 0f);
obj13.transform.Rotate(new Vector3(15f, 0f, 0f));
((Renderer)((Component)obj13.transform.GetChild(0)).GetComponent<MeshRenderer>()).material = hatMat;
List<RendererInfo> list13 = model.baseRendererInfos.ToList();
Renderer[] componentsInChildren13 = obj13.GetComponentsInChildren<Renderer>();
foreach (Renderer val14 in componentsInChildren13)
{
list13.Add(new RendererInfo
{
renderer = val14,
defaultMaterial = val14.sharedMaterial,
defaultShadowCastingMode = val14.shadowCastingMode,
hideOnDeath = false,
ignoreOverlays = false
});
}
model.baseRendererInfos = list13.ToArray();
}
}
}
}