mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
50 lines
1.4 KiB
C#
50 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace RimWorldAnimationStudio
|
|
{
|
|
[Serializable]
|
|
public class PawnRaceOffset
|
|
{
|
|
// Local data
|
|
public string defName = "Human";
|
|
public string offset = "(0, 0)";
|
|
|
|
// SHoulda serialize
|
|
public bool ShouldSerializedefName() { return OffsetIsZero() == false; }
|
|
public bool ShouldSerializeoffset() { return OffsetIsZero() == false; }
|
|
|
|
// Constructors
|
|
public PawnRaceOffset() { }
|
|
|
|
public PawnRaceOffset(string defName)
|
|
{
|
|
this.defName = defName;
|
|
}
|
|
|
|
// Methods
|
|
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);
|
|
}
|
|
}
|
|
}
|