Clean up based on static analyzer suggestions

This commit is contained in:
SDraw 2024-10-07 12:08:35 +03:00
parent a7f4c96748
commit ecba461845
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
39 changed files with 165 additions and 146 deletions

View file

@ -25,13 +25,13 @@ namespace ml_pmc
try
{
p_instance.Patch(
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar)),
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar), BindingFlags.Instance | BindingFlags.Public),
null,
new HarmonyLib.HarmonyMethod(typeof(GameEvents).GetMethod(nameof(OnAvatarClear_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
);
p_instance.Patch(
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetupAvatar)),
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetupAvatar), BindingFlags.Instance | BindingFlags.Public),
null,
new HarmonyLib.HarmonyMethod(typeof(GameEvents).GetMethod(nameof(OnSetupAvatar_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
);

View file

@ -16,13 +16,6 @@ namespace ml_pmc
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
}
public override void OnDeinitializeMelon()
{
if(m_poseCopycat != null)
Object.Destroy(m_poseCopycat.gameObject);
m_poseCopycat = null;
}
System.Collections.IEnumerator WaitForLocalPlayer()
{
while(PlayerSetup.Instance == null)
@ -30,5 +23,12 @@ namespace ml_pmc
m_poseCopycat = new GameObject("[PlayerMovementCopycat]").AddComponent<PoseCopycat>();
}
public override void OnDeinitializeMelon()
{
if(m_poseCopycat != null)
Object.Destroy(m_poseCopycat.gameObject);
m_poseCopycat = null;
}
}
}

View file

@ -90,7 +90,7 @@ namespace ml_pmc
l_hits.RemoveAll(hit => hit.collider.gameObject.layer == LayerMask.NameToLayer("PlayerLocal"));
l_hits.RemoveAll(hit => hit.collider.gameObject.layer == LayerMask.NameToLayer("PlayerClone"));
l_hits.Sort((a, b) => ((a.distance < b.distance) ? -1 : 1));
l_result = (l_hits.First().collider.gameObject.transform.root == p_target.transform.root);
l_result = (l_hits[0].collider.gameObject.transform.root == p_target.transform.root);
}
}
return l_result;