mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Code refactor
This commit is contained in:
parent
cd4711a8e5
commit
757badf4f6
517 changed files with 2534 additions and 2221 deletions
49
Assets/Scripts/AnimationComponents/PawnRaceOffset.cs
Normal file
49
Assets/Scripts/AnimationComponents/PawnRaceOffset.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue