rimworld-animation-studio/Assets/Scripts/AnimationComponents/AlienRaceOffset.cs

46 lines
1.3 KiB
C#
Raw Normal View History

2022-09-24 07:17:40 +00:00
using System;
using System.Collections.Generic;
using UnityEngine;
2022-09-13 05:36:34 +00:00
namespace RimWorldAnimationStudio
{
2022-09-24 07:17:40 +00:00
[Serializable]
2022-09-13 05:36:34 +00:00
public class AlienRaceOffset
{
2022-09-24 19:12:18 +00:00
public string defName = "Human";
public string offset = "(0, 0)";
2022-09-26 04:10:41 +00:00
public bool ShouldSerializedefName() { return OffsetIsZero() == false; }
public bool ShouldSerializeoffset() { return OffsetIsZero() == false; }
2022-09-24 19:12:18 +00:00
2022-09-26 04:10:41 +00:00
public AlienRaceOffset() { }
2022-09-24 19:12:18 +00:00
public AlienRaceOffset(string defName)
{
this.defName = defName;
}
public void SetOffset(Vector2 raceOffset)
{
offset = "(" + raceOffset.x + ", " + raceOffset.y + ")";
}
public Vector3 GetOffset()
{
string raceOffset = offset;
raceOffset = raceOffset.Trim();
raceOffset = raceOffset.Replace("(", "");
raceOffset = raceOffset.Replace(")", "");
var raceOffsets = raceOffset.Split(',');
return new Vector3(float.Parse(raceOffsets[0]), 0f, float.Parse(raceOffsets[1]));
}
2022-09-26 04:10:41 +00:00
public bool OffsetIsZero()
{
Vector3 vec = GetOffset();
return Mathf.Approximately(vec.x, 0f) && Mathf.Approximately(vec.y, 0f) && Mathf.Approximately(vec.x, 0f);
}
2022-09-13 05:36:34 +00:00
}
}