mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
v 1.0.0
This commit is contained in:
parent
0828ecd037
commit
2998865184
9821 changed files with 90 additions and 90 deletions
183
Source/Assets/Scripts/Utilities/PawnUtility.cs
Normal file
183
Source/Assets/Scripts/Utilities/PawnUtility.cs
Normal file
|
@ -0,0 +1,183 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public static class PawnUtility
|
||||
{
|
||||
public static Vector3 BaseHeadOffsetAt(string bodyType, int rotation)
|
||||
{
|
||||
Vector2 headOffset = Vector3.zero;
|
||||
|
||||
switch (bodyType)
|
||||
{
|
||||
case "Male": headOffset = new Vector2(0.04f, 0.34f); break;
|
||||
case "Female": headOffset = new Vector2(0.10f, 0.34f); break;
|
||||
case "Thin": headOffset = new Vector2(0.09f, 0.34f); break;
|
||||
case "Hulk": headOffset = new Vector2(0.10f, 0.34f); break;
|
||||
case "Fat": headOffset = new Vector2(0.09f, 0.34f); break;
|
||||
}
|
||||
|
||||
switch (rotation)
|
||||
{
|
||||
case 0: return new Vector3(0f, headOffset.y, 0);
|
||||
case 1: return new Vector3(headOffset.x, headOffset.y, 0);
|
||||
case 2: return new Vector3(0f, headOffset.y, 0f);
|
||||
case 3: return new Vector3(-headOffset.x, headOffset.y, 0f);
|
||||
default: return Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector3 GroinOffsetAt(string bodyType, int rotation)
|
||||
{
|
||||
if (rotation == 0 || rotation == 2)
|
||||
{
|
||||
switch (bodyType)
|
||||
{
|
||||
case "Male": return new Vector3(0.00f, 0f, -0.46f);
|
||||
case "Female": return new Vector3(0.00f, 0f, -0.51f);
|
||||
case "Thin": return new Vector3(0.00f, 0f, -0.46f);
|
||||
case "Hulk": return new Vector3(0.00f, 0f, -0.66f);
|
||||
case "Fat": return new Vector3(0.00f, 0f, -0.52f);
|
||||
default: return Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
else if (rotation == 1)
|
||||
{
|
||||
switch (bodyType)
|
||||
{
|
||||
case "Male": return new Vector3(0.07f, 0f, -0.41f);
|
||||
case "Female": return new Vector3(0.07f, 0f, -0.47f);
|
||||
case "Thin": return new Vector3(-0.05f, 0f, -0.43f);
|
||||
case "Hulk": return new Vector3(-0.03f, 0f, -0.64f);
|
||||
case "Fat": return new Vector3(0.24f, 0f, -0.50f);
|
||||
default: return Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
switch (bodyType)
|
||||
{
|
||||
case "Male": return new Vector3(-0.07f, 0f, -0.41f);
|
||||
case "Female": return new Vector3(-0.07f, 0f, -0.47f);
|
||||
case "Thin": return new Vector3(0.05f, 0f, -0.43f);
|
||||
case "Hulk": return new Vector3(0.03f, 0f, -0.64f);
|
||||
case "Fat": return new Vector3(-0.24f, 0f, -0.50f);
|
||||
default: return Vector3.zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector3 BreastLeftOffsetAt(string bodyType, int rotation)
|
||||
{
|
||||
if (rotation == 0 || rotation == 2)
|
||||
{
|
||||
float multi = rotation == 0 ? -1f : 1f;
|
||||
|
||||
switch (bodyType)
|
||||
{
|
||||
case "Male": return new Vector3(0.035f * multi, 0f, -0.050f);
|
||||
case "Female": return new Vector3(0.002f * multi, 0f, -0.044f);
|
||||
case "Thin": return new Vector3(0.000f * multi, 0f, -0.024f);
|
||||
case "Hulk": return new Vector3(0.118f * multi, 0f, -0.194f);
|
||||
case "Fat": return new Vector3(0.141f * multi, 0f, -0.084f);
|
||||
default: return Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
else if (rotation == 1)
|
||||
{
|
||||
switch (bodyType)
|
||||
{
|
||||
case "Male": return new Vector3(0.098f, 0f, -0.053f);
|
||||
case "Female": return new Vector3(0.008f, 0f, -0.008f);
|
||||
case "Thin": return new Vector3(-0.011f, 0f, -0.024f);
|
||||
case "Hulk": return new Vector3(0.180f, 0f, -0.151f);
|
||||
case "Fat": return new Vector3(0.200f, 0f, -0.034f);
|
||||
default: return Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
switch (bodyType)
|
||||
{
|
||||
case "Male": return new Vector3(-0.098f, 0f, -0.053f);
|
||||
case "Female": return new Vector3(-0.008f, 0f, -0.008f);
|
||||
case "Thin": return new Vector3(0.011f, 0f, -0.024f);
|
||||
case "Hulk": return new Vector3(-0.180f, 0f, -0.151f);
|
||||
case "Fat": return new Vector3(-0.200f, 0f, -0.034f);
|
||||
default: return Vector3.zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector3 BreastRightOffsetAt(string bodyType, int rotation)
|
||||
{
|
||||
if (rotation == 0 || rotation == 2)
|
||||
{
|
||||
float multi = rotation == 0 ? -1f : 1f;
|
||||
|
||||
switch (bodyType)
|
||||
{
|
||||
case "Male": return new Vector3(-0.035f * multi, 0f, -0.050f);
|
||||
case "Female": return new Vector3(-0.002f * multi, 0f, -0.044f);
|
||||
case "Thin": return new Vector3(-0.000f * multi, 0f, -0.024f);
|
||||
case "Hulk": return new Vector3(-0.118f * multi, 0f, -0.194f);
|
||||
case "Fat": return new Vector3(-0.141f * multi, 0f, -0.084f);
|
||||
default: return Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
else if (rotation == 1)
|
||||
{
|
||||
switch (bodyType)
|
||||
{
|
||||
case "Male": return new Vector3(0.098f, 0f, -0.053f);
|
||||
case "Female": return new Vector3(0.008f, 0f, -0.008f);
|
||||
case "Thin": return new Vector3(-0.011f, 0f, -0.024f);
|
||||
case "Hulk": return new Vector3(0.180f, 0f, -0.151f);
|
||||
case "Fat": return new Vector3(0.200f, 0f, -0.034f);
|
||||
default: return Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
switch (bodyType)
|
||||
{
|
||||
case "Male": return new Vector3(-0.098f, 0f, -0.053f);
|
||||
case "Female": return new Vector3(-0.008f, 0f, -0.008f);
|
||||
case "Thin": return new Vector3(0.011f, 0f, -0.024f);
|
||||
case "Hulk": return new Vector3(-0.180f, 0f, -0.151f);
|
||||
case "Fat": return new Vector3(-0.200f, 0f, -0.034f);
|
||||
default: return Vector3.zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector3 GetBodyPartAnchor(ActorBody anchoringActorBody, string anchorName)
|
||||
{
|
||||
Actor anchoringActor = Workspace.GetActor(anchoringActorBody.actorID);
|
||||
Vector3 anchoringActorBodyPos = anchoringActorBody.transform.position;
|
||||
Quaternion anchoringActorBodyQuad = Quaternion.AngleAxis(anchoringActorBody.transform.rotation.eulerAngles.z, Vector3.forward);
|
||||
int anchoringActorFacing = anchoringActor.GetCurrentPosition().bodyFacing;
|
||||
|
||||
switch (anchorName)
|
||||
{
|
||||
case "torso": return anchoringActorBodyPos;
|
||||
case "head": return anchoringActorBody.GetComponentsInChildren<ActorBodyPart>().FirstOrDefault(x => x.bodyPart.ToLower() == "head").transform.position;
|
||||
case "groin": return anchoringActorBodyPos + anchoringActorBodyQuad * PawnUtility.GroinOffsetAt(anchoringActor.bodyType, anchoringActorFacing).FlipAxes();
|
||||
case "left breast": return anchoringActorBodyPos + anchoringActorBodyQuad * PawnUtility.BreastLeftOffsetAt(anchoringActor.bodyType, anchoringActorFacing).FlipAxes();
|
||||
case "right breast": return anchoringActorBodyPos + anchoringActorBodyQuad * PawnUtility.BreastRightOffsetAt(anchoringActor.bodyType, anchoringActorFacing).FlipAxes();
|
||||
default: return new Vector3();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Source/Assets/Scripts/Utilities/PawnUtility.cs.meta
Normal file
11
Source/Assets/Scripts/Utilities/PawnUtility.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d7c648d5b6a74be448da40e4ed79c8c5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
39
Source/Assets/Scripts/Utilities/XmlUtility.cs
Normal file
39
Source/Assets/Scripts/Utilities/XmlUtility.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public static class XmlUtility
|
||||
{
|
||||
public static T ReadXML<T>(string path)
|
||||
{
|
||||
using (StreamReader stringReader = new StreamReader(path))
|
||||
{
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(T));
|
||||
var data = (T)serializer.Deserialize(stringReader);
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteXML<T>(T obj, string path)
|
||||
{
|
||||
if (obj == null || path == null || path == "")
|
||||
{ return; }
|
||||
|
||||
XmlSerializer writer = new XmlSerializer(typeof(T));
|
||||
XmlSerializerNamespaces nameSpaces = new XmlSerializerNamespaces();
|
||||
nameSpaces.Add("", "");
|
||||
|
||||
FileStream file = File.Create(path);
|
||||
writer.Serialize(file, obj, nameSpaces);
|
||||
file.Close();
|
||||
}
|
||||
}
|
||||
}
|
11
Source/Assets/Scripts/Utilities/XmlUtility.cs.meta
Normal file
11
Source/Assets/Scripts/Utilities/XmlUtility.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 98d85a0061a130d47863c6a7b14df10f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue