Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sonic Frontiers] Implemented basic code library support for PlayerVisuals #60

Merged
merged 6 commits into from
Nov 19, 2023
23 changes: 22 additions & 1 deletion Source/Sonic Frontiers/Libraries/GOComponents.hmm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Library "GOComponents" by "Hyper"

#import "Cameras"
#import "Collections"
#import "PlayerVisuals"
#import "Plugins"
#import "Postures"
#import "States"
Expand Down Expand Up @@ -472,7 +473,27 @@ Library "GOComponents" by "Hyper"
[StructLayout(LayoutKind.Explicit, Size = 0x180)]
public struct GOCPlayerVisual
{
[FieldOffset(0)] public GOComponent Base;
[FieldOffset(0x000)] public GOComponent Base;

/// <summary>
/// A pointer to an instance of `app::player::PlayerVisual`.
/// </summary>
[FieldOffset(0x108)] public PlayerVisual* pPlayerVisual;

/// <summary>
/// Retrieves the contained <see cref="PlayerVisual"/>, given that its name matches <see cref="in_visualName"/>.
/// </summary>
/// <param name="in_visualName">The name of the visual to retrieve.</param>
/// <returns>A pointer to the <see cref="PlayerVisual"/> if the names match; otherwise, null.</returns>
public PlayerVisual* GetVisual(string in_visualName)
{
if (pPlayerVisual->GetNameHash()() == StringMapOperation.ComputeHash(in_visualName))
return pPlayerVisual;
else
return null;
}

MAKE_GENERIC_API(GetVisual)
}

/// <summary>
Expand Down
26 changes: 26 additions & 0 deletions Source/Sonic Frontiers/Libraries/PlayerVisuals.hmm
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Library "PlayerVisuals" by "Hyper & NM"
{
#include "Helpers" noemit

using System.Runtime.InteropServices;

/// <summary>
/// A struct representation of `app::player::PlayerVisual`.
/// </summary>
[StructLayout(LayoutKind.Explicit, Size = 0x40)]
public struct PlayerVisual
{
VFUNCTION_PTR(PlayerVisual, 1, uint, GetNameHash)
}

/// <summary>
/// A struct representation of `app::player::VisualSuperSonic`.
/// </summary>
[StructLayout(LayoutKind.Explicit, Size = 0x130)]
public struct VisualSuperSonic
{
[FieldOffset(0x000)] public PlayerVisual Base;

[FieldOffset(0x118)] public bool IsSuperSonic2;
}
}