ASTExtension: Fixed ClearAvatar patch not being prefix

This commit is contained in:
NotAKidoS 2024-07-03 01:33:56 -05:00
parent b37d49647e
commit 6930807665
6 changed files with 54 additions and 58 deletions

View file

@ -82,7 +82,7 @@ public class ASTExtensionMod : MelonMod
HarmonyInstance.Patch( HarmonyInstance.Patch(
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar), typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar),
BindingFlags.Public | BindingFlags.Instance), BindingFlags.Public | BindingFlags.Instance),
postfix: new HarmonyMethod(typeof(ASTExtensionMod).GetMethod(nameof(OnClearAvatar), prefix: new HarmonyMethod(typeof(ASTExtensionMod).GetMethod(nameof(OnClearAvatar),
BindingFlags.NonPublic | BindingFlags.Static)) BindingFlags.NonPublic | BindingFlags.Static))
); );

View file

@ -1,36 +1,37 @@
using NAK.PropLoadingHexagon.Components; // using NAK.PropLoadingHexagon.Components;
using UnityEngine; // using UnityEngine;
//
namespace NAK.PropLoadingHexagon.Integrations; // namespace NAK.PropLoadingHexagon.Integrations;
//
public static class TheClapperIntegration // // ReSharper disable once ClassNeverInstantiated.Global
{ // public class TheClapperIntegration
public static void Init() // {
{ // public static void Init()
PropLoadingHexagonMod.OnPropPlaceholderCreated += (placeholder) => // {
{ // PropLoadingHexagonMod.OnPropPlaceholderCreated += (placeholder) =>
if (placeholder.TryGetComponent(out LoadingHexagonController loadingHexagon)) // {
ClappableLoadingHex.Create(loadingHexagon); // if (placeholder.TryGetComponent(out LoadingHexagonController loadingHexagon))
}; // ClappableLoadingHex.Create(loadingHexagon);
} // };
} // }
// }
public class ClappableLoadingHex : Kafe.TheClapper.Clappable //
{ // public class ClappableLoadingHex : Kafe.TheClapper.Clappable
private LoadingHexagonController _loadingHexagon; // {
// private LoadingHexagonController _loadingHexagon;
public override void OnClapped(Vector3 clappablePosition) //
{ // public override void OnClapped(Vector3 clappablePosition)
if (_loadingHexagon == null) return; // {
_loadingHexagon.IsLoadingCanceled = true; // if (_loadingHexagon == null) return;
Kafe.TheClapper.TheClapper.EmitParticles(clappablePosition, new Color(1f, 1f, 0f), 2f); // why this internal // _loadingHexagon.IsLoadingCanceled = true;
} // Kafe.TheClapper.TheClapper.EmitParticles(clappablePosition, new Color(1f, 1f, 0f), 2f); // why this internal
// }
public static void Create(LoadingHexagonController loadingHexagon) //
{ // public static void Create(LoadingHexagonController loadingHexagon)
GameObject target = loadingHexagon.transform.GetChild(0).gameObject; // {
if (!target.gameObject.TryGetComponent(out ClappableLoadingHex clappableHexagon)) // GameObject target = loadingHexagon.transform.GetChild(0).gameObject;
clappableHexagon = target.AddComponent<ClappableLoadingHex>(); // if (!target.gameObject.TryGetComponent(out ClappableLoadingHex clappableHexagon))
clappableHexagon._loadingHexagon = loadingHexagon; // clappableHexagon = target.AddComponent<ClappableLoadingHex>();
} // clappableHexagon._loadingHexagon = loadingHexagon;
} // }
// }

View file

@ -65,8 +65,7 @@ public class PropLoadingHexagonMod : MelonMod
); );
LoadAssetBundle(); LoadAssetBundle();
//HandleIntegrations();
InitializeIntegration("TheClapper", Integrations.TheClapperIntegration.Init);
} }
public override void OnUpdate() public override void OnUpdate()
@ -100,18 +99,19 @@ public class PropLoadingHexagonMod : MelonMod
#endregion Melon Events #endregion Melon Events
#region Integrations // #region Integrations
//
private void InitializeIntegration(string modName, Action integrationAction) // [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ // private void HandleIntegrations()
if (RegisteredMelons.All(it => it.Info.Name != modName)) // {
return; // if (RegisteredMelons.Any(it => it.Info.Name == "TheClapper"))
// {
LoggerInstance.Msg($"Initializing {modName} integration."); // LoggerInstance.Msg("Initializing TheClapper integration.");
integrationAction.Invoke(); // Integrations.TheClapperIntegration.Init();
} // }
// }
#endregion Integrations //
// #endregion Integrations
#region Asset Bundle Loading #region Asset Bundle Loading

View file

@ -4,11 +4,6 @@
<TargetFramework>net48</TargetFramework> <TargetFramework>net48</TargetFramework>
<RootNamespace>PropSpawnTweaks</RootNamespace> <RootNamespace>PropSpawnTweaks</RootNamespace>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Reference Include="TheClapper">
<HintPath>..\.ManagedLibs\TheClapper.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Resources\loading_hexagon.assets"> <EmbeddedResource Include="Resources\loading_hexagon.assets">
<LogicalName>loading_hexagon.assets</LogicalName> <LogicalName>loading_hexagon.assets</LogicalName>

View file

@ -4,7 +4,7 @@ https://github.com/NotAKidoS/NAK_CVR_Mods/assets/37721153/a892c765-71c1-47f3-a78
Adds a hexagon indicator to downloading props. Indicator is styled to look similar to Portals. Adds a hexagon indicator to downloading props. Indicator is styled to look similar to Portals.
Can use Delete Mode & The Clapper on loading hexagons to cancel stuck downloads. Setting is provided to display the hexagon for Blocked/Filtered props. Can use Delete Mode ~~& The Clapper~~ on loading hexagons to cancel stuck downloads. Setting is provided to display the hexagon for Blocked/Filtered props.
--- ---

View file

@ -6,7 +6,7 @@
"loaderversion": "0.6.1", "loaderversion": "0.6.1",
"modtype": "Mod", "modtype": "Mod",
"author": "Exterrata & NotAKidoS", "author": "Exterrata & NotAKidoS",
"description": "Adds a hexagon indicator to downloading props. Indicator is styled to look similar to Portals.\n\nCan use Delete Mode & The Clapper on loading hexagons to cancel stuck downloads. Setting is provided to display the hexagon for Blocked/Filtered props.", "description": "Adds a hexagon indicator to downloading props. Indicator is styled to look similar to Portals.\n\nCan use Delete Mode on loading hexagons to cancel stuck downloads. Setting is provided to display the hexagon for Blocked/Filtered props.",
"searchtags": [ "searchtags": [
"prop", "prop",
"spawn", "spawn",