mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-04 02:49:23 +00:00
Avatar parameters changes
This commit is contained in:
parent
b1b1a324ad
commit
b6bf52b8a1
3 changed files with 95 additions and 81 deletions
78
ml_amt/AvatarParameter.cs
Normal file
78
ml_amt/AvatarParameter.cs
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
using ABI_RC.Core.Player;
|
||||||
|
|
||||||
|
namespace ml_amt
|
||||||
|
{
|
||||||
|
class AvatarParameter
|
||||||
|
{
|
||||||
|
public enum ParameterType
|
||||||
|
{
|
||||||
|
Upright,
|
||||||
|
GroundedRaw,
|
||||||
|
Moving
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ParameterSyncType
|
||||||
|
{
|
||||||
|
Synced,
|
||||||
|
Local
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly ParameterType m_type;
|
||||||
|
public readonly ParameterSyncType m_sync;
|
||||||
|
public readonly string m_name;
|
||||||
|
public readonly int m_hash; // For local only
|
||||||
|
|
||||||
|
|
||||||
|
public AvatarParameter(ParameterType p_type, string p_name, ParameterSyncType p_sync = ParameterSyncType.Synced, int p_hash = 0)
|
||||||
|
{
|
||||||
|
m_type = p_type;
|
||||||
|
m_sync = p_sync;
|
||||||
|
m_name = p_name;
|
||||||
|
m_hash = p_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(MotionTweaker p_tweaker)
|
||||||
|
{
|
||||||
|
switch(m_type)
|
||||||
|
{
|
||||||
|
case ParameterType.Upright:
|
||||||
|
SetFloat(p_tweaker.GetUpright());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ParameterType.GroundedRaw:
|
||||||
|
SetBoolean(p_tweaker.GetGroundedRaw());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ParameterType.Moving:
|
||||||
|
SetBoolean(p_tweaker.GetMoving());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetFloat(float p_value)
|
||||||
|
{
|
||||||
|
switch(m_sync)
|
||||||
|
{
|
||||||
|
case ParameterSyncType.Local:
|
||||||
|
PlayerSetup.Instance._animator.SetFloat(m_hash, p_value);
|
||||||
|
break;
|
||||||
|
case ParameterSyncType.Synced:
|
||||||
|
PlayerSetup.Instance.animatorManager.SetAnimatorParameterFloat(m_name, p_value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetBoolean(bool p_value)
|
||||||
|
{
|
||||||
|
switch(m_sync)
|
||||||
|
{
|
||||||
|
case ParameterSyncType.Local:
|
||||||
|
PlayerSetup.Instance._animator.SetBool(m_hash, p_value);
|
||||||
|
break;
|
||||||
|
case ParameterSyncType.Synced:
|
||||||
|
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool(m_name, p_value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,27 +15,6 @@ namespace ml_amt
|
||||||
static readonly FieldInfo ms_groundedRaw = typeof(MovementSystem).GetField("_isGroundedRaw", BindingFlags.NonPublic | BindingFlags.Instance);
|
static readonly FieldInfo ms_groundedRaw = typeof(MovementSystem).GetField("_isGroundedRaw", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
static readonly int ms_emoteHash = Animator.StringToHash("Emote");
|
static readonly int ms_emoteHash = Animator.StringToHash("Emote");
|
||||||
|
|
||||||
enum ParameterType
|
|
||||||
{
|
|
||||||
Upright,
|
|
||||||
GroundedRaw,
|
|
||||||
Moving
|
|
||||||
}
|
|
||||||
|
|
||||||
enum ParameterSyncType
|
|
||||||
{
|
|
||||||
Local,
|
|
||||||
Synced
|
|
||||||
}
|
|
||||||
|
|
||||||
struct AdditionalParameterInfo
|
|
||||||
{
|
|
||||||
public ParameterType m_type;
|
|
||||||
public ParameterSyncType m_sync;
|
|
||||||
public string m_name;
|
|
||||||
public int m_hash; // For local only
|
|
||||||
}
|
|
||||||
|
|
||||||
enum PoseState
|
enum PoseState
|
||||||
{
|
{
|
||||||
Standing = 0,
|
Standing = 0,
|
||||||
|
@ -84,11 +63,11 @@ namespace ml_amt
|
||||||
bool m_followHips = true;
|
bool m_followHips = true;
|
||||||
Vector3 m_hipsToPlayer = Vector3.zero;
|
Vector3 m_hipsToPlayer = Vector3.zero;
|
||||||
|
|
||||||
readonly List<AdditionalParameterInfo> m_parameters = null;
|
readonly List<AvatarParameter> m_parameters = null;
|
||||||
|
|
||||||
public MotionTweaker()
|
public MotionTweaker()
|
||||||
{
|
{
|
||||||
m_parameters = new List<AdditionalParameterInfo>();
|
m_parameters = new List<AvatarParameter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
|
@ -173,53 +152,8 @@ namespace ml_amt
|
||||||
|
|
||||||
if(m_parameters.Count > 0)
|
if(m_parameters.Count > 0)
|
||||||
{
|
{
|
||||||
foreach(AdditionalParameterInfo l_param in m_parameters)
|
foreach(AvatarParameter l_param in m_parameters)
|
||||||
{
|
l_param.Update(this);
|
||||||
switch(l_param.m_type)
|
|
||||||
{
|
|
||||||
case ParameterType.Upright:
|
|
||||||
{
|
|
||||||
switch(l_param.m_sync)
|
|
||||||
{
|
|
||||||
case ParameterSyncType.Local:
|
|
||||||
PlayerSetup.Instance._animator.SetFloat(l_param.m_hash, m_upright);
|
|
||||||
break;
|
|
||||||
case ParameterSyncType.Synced:
|
|
||||||
PlayerSetup.Instance.animatorManager.SetAnimatorParameterFloat(l_param.m_name, m_upright);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ParameterType.GroundedRaw:
|
|
||||||
{
|
|
||||||
switch(l_param.m_sync)
|
|
||||||
{
|
|
||||||
case ParameterSyncType.Local:
|
|
||||||
PlayerSetup.Instance._animator.SetBool(l_param.m_hash, m_groundedRaw);
|
|
||||||
break;
|
|
||||||
case ParameterSyncType.Synced:
|
|
||||||
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool(l_param.m_name, m_groundedRaw);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ParameterType.Moving:
|
|
||||||
{
|
|
||||||
switch(l_param.m_sync)
|
|
||||||
{
|
|
||||||
case ParameterSyncType.Local:
|
|
||||||
PlayerSetup.Instance._animator.SetBool(l_param.m_hash, m_moving);
|
|
||||||
break;
|
|
||||||
case ParameterSyncType.Synced:
|
|
||||||
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool(l_param.m_name, m_moving);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,30 +190,27 @@ namespace ml_amt
|
||||||
|
|
||||||
// Parse animator parameters
|
// Parse animator parameters
|
||||||
AnimatorControllerParameter[] l_params = PlayerSetup.Instance._animator.parameters;
|
AnimatorControllerParameter[] l_params = PlayerSetup.Instance._animator.parameters;
|
||||||
ParameterType[] l_enumParams = (ParameterType[])System.Enum.GetValues(typeof(ParameterType));
|
|
||||||
|
|
||||||
foreach(var l_param in l_params)
|
foreach(var l_param in l_params)
|
||||||
{
|
{
|
||||||
foreach(var l_enumParam in l_enumParams)
|
foreach(AvatarParameter.ParameterType l_enumParam in System.Enum.GetValues(typeof(AvatarParameter.ParameterType)))
|
||||||
{
|
{
|
||||||
if(l_param.name.Contains(l_enumParam.ToString()) && (m_parameters.FindIndex(p => p.m_type == l_enumParam) == -1))
|
if(l_param.name.Contains(l_enumParam.ToString()) && (m_parameters.FindIndex(p => p.m_type == l_enumParam) == -1))
|
||||||
{
|
{
|
||||||
bool l_local = (l_param.name[0] == '#');
|
bool l_local = (l_param.name[0] == '#');
|
||||||
|
|
||||||
m_parameters.Add(new AdditionalParameterInfo
|
m_parameters.Add(new AvatarParameter(
|
||||||
{
|
l_enumParam,
|
||||||
m_type = l_enumParam,
|
l_param.name,
|
||||||
m_sync = (l_local ? ParameterSyncType.Local : ParameterSyncType.Synced),
|
(l_local ? AvatarParameter.ParameterSyncType.Local : AvatarParameter.ParameterSyncType.Synced),
|
||||||
m_name = l_param.name,
|
(l_local ? l_param.nameHash : 0)
|
||||||
m_hash = (l_local ? l_param.nameHash : 0)
|
));
|
||||||
});
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_compatibleAvatar = m_parameters.Exists(p => p.m_name.Contains("Upright"));
|
m_compatibleAvatar = m_parameters.Exists(p => p.m_type == AvatarParameter.ParameterType.Upright);
|
||||||
m_avatarScale = Mathf.Abs(PlayerSetup.Instance._avatar.transform.localScale.y);
|
m_avatarScale = Mathf.Abs(PlayerSetup.Instance._avatar.transform.localScale.y);
|
||||||
|
|
||||||
Transform l_customTransform = PlayerSetup.Instance._avatar.transform.Find("CrouchLimit");
|
Transform l_customTransform = PlayerSetup.Instance._avatar.transform.Find("CrouchLimit");
|
||||||
|
@ -417,5 +348,9 @@ namespace ml_amt
|
||||||
{
|
{
|
||||||
m_followHips = p_state;
|
m_followHips = p_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float GetUpright() => m_upright;
|
||||||
|
public bool GetGroundedRaw() => m_groundedRaw;
|
||||||
|
public bool GetMoving() => m_moving;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="AvatarParameter.cs" />
|
||||||
<Compile Include="MotionTweaker.cs" />
|
<Compile Include="MotionTweaker.cs" />
|
||||||
<Compile Include="Main.cs" />
|
<Compile Include="Main.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue