mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-07-31 00:11:13 +00:00
47 lines
1.5 KiB
C#
47 lines
1.5 KiB
C#
using System.Reflection;
|
|
using UnityEngine;
|
|
//using Microsoft.Toolkit.Uwp.UI;
|
|
|
|
namespace RimWorldAnimationStudio
|
|
{
|
|
public class BodyTypeOffset
|
|
{
|
|
public string Male;
|
|
public string Female;
|
|
public string Thin;
|
|
public string Hulk;
|
|
public string Fat;
|
|
|
|
public void SetOffset(string bodyType, Vector2 bodyOffset)
|
|
{
|
|
FieldInfo bodyTypeOffsetInfo = typeof(BodyTypeOffset).GetField(bodyType);
|
|
|
|
if (bodyTypeOffsetInfo == null)
|
|
{ return; }
|
|
|
|
string _bodyOffset = "(" + bodyOffset.x + ", " + bodyOffset.y + ")";
|
|
bodyTypeOffsetInfo.SetValue(this, _bodyOffset);
|
|
}
|
|
|
|
public Vector3 GetOffset(string bodyType)
|
|
{
|
|
FieldInfo bodyTypeOffsetInfo = typeof(BodyTypeOffset).GetField(bodyType);
|
|
|
|
if (bodyTypeOffsetInfo == null)
|
|
{ return new Vector2(); }
|
|
|
|
string bodyTypeOffsetString = (string)bodyTypeOffsetInfo.GetValue(this);
|
|
|
|
if (bodyTypeOffsetString == null || bodyTypeOffsetString == "")
|
|
{ return new Vector2(); }
|
|
|
|
bodyTypeOffsetString = bodyTypeOffsetString.Trim();
|
|
bodyTypeOffsetString = bodyTypeOffsetString.Replace("(", "");
|
|
bodyTypeOffsetString = bodyTypeOffsetString.Replace(")", "");
|
|
var bodyTypeOffsetStrings = bodyTypeOffsetString.Split(',');
|
|
|
|
return new Vector3(float.Parse(bodyTypeOffsetStrings[0]), 0f, float.Parse(bodyTypeOffsetStrings[1]));
|
|
}
|
|
}
|
|
}
|