using System; using System.Collections.Generic; using UnityEngine; namespace RimWorldAnimationStudio { [Serializable] public class AlienRaceOffset { public string defName = "Human"; public string offset = "(0, 0)"; public bool ShouldSerializedefName() { return OffsetIsZero() == false; } public bool ShouldSerializeoffset() { return OffsetIsZero() == false; } public AlienRaceOffset() { } 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])); } public bool OffsetIsZero() { Vector3 vec = GetOffset(); return Mathf.Approximately(vec.x, 0f) && Mathf.Approximately(vec.y, 0f) && Mathf.Approximately(vec.x, 0f); } } }