mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Race customization and data saving
This commit is contained in:
parent
2f3f807911
commit
d3b676df06
456 changed files with 6388 additions and 419 deletions
|
@ -130,9 +130,11 @@ namespace RimWorldAnimationStudio
|
|||
{ continue; }
|
||||
|
||||
float clipPercent = (float)(stageTick % clip.duration) / clip.duration;
|
||||
if (stageTick == clip.duration) clipPercent = 1f;
|
||||
|
||||
AlienRaceDef alienRaceDef = Workspace.animationDef.actors[actorID].GetAlienRaceDef();
|
||||
ActorBody actorBody = _actorBodies[actorID];
|
||||
string bodyType = actorBody.bodyType;
|
||||
string bodyType = alienRaceDef.isHumanoid ? actorBody.bodyType : "None";
|
||||
|
||||
Vector3 deltaPos = new Vector3(clip.BodyOffsetX.Evaluate(clipPercent), 0, clip.BodyOffsetZ.Evaluate(clipPercent));
|
||||
deltaPos += Workspace.animationDef.actors[actorID].bodyTypeOffset.GetOffset(bodyType);
|
||||
|
@ -158,23 +160,31 @@ namespace RimWorldAnimationStudio
|
|||
float appendageRotation = clip.GenitalAngle.Evaluate(clipPercent);
|
||||
|
||||
actorBody.transform.position = bodyPos;
|
||||
actorBody.transform.eulerAngles = new Vector3(0, 0, bodyAngle);
|
||||
actorBody.transform.eulerAngles = new Vector3(0, 0, -bodyAngle);
|
||||
|
||||
actorBody.headRenderer.transform.localPosition = headPos;
|
||||
actorBody.headRenderer.transform.eulerAngles = new Vector3(0, 0, headAngle);
|
||||
actorBody.headRenderer.transform.eulerAngles = new Vector3(0, 0, -headAngle);
|
||||
|
||||
actorBody.appendageRenderer.transform.localPosition = new Vector3(appendagePos.x, appendagePos.z, 0f);
|
||||
actorBody.appendageRenderer.transform.eulerAngles = new Vector3(0, 0, appendageRotation);
|
||||
actorBody.appendageRenderer.transform.eulerAngles = new Vector3(0, 0, -appendageRotation);
|
||||
|
||||
actorBody.bodyRenderer.sprite = Resources.Load<Sprite>("Textures/Humanlike/Bodies/" + bodyType + bodyFacing);
|
||||
actorBody.headRenderer.sprite = Resources.Load<Sprite>("Textures/Humanlike/Heads/Head" + headFacing);
|
||||
actorBody.appendageRenderer.sprite = Resources.Load<Sprite>("Textures/Humanlike/Appendages/Appendage" + bodyFacing);
|
||||
actorBody.bodyRenderer.sprite = alienRaceDef.GetBodyTypeGraphic((CardinalDirection)bodyFacing, bodyType);
|
||||
actorBody.headRenderer.sprite = alienRaceDef.isHumanoid ? alienRaceDef.GetHeadGraphic((CardinalDirection)headFacing) : null;
|
||||
actorBody.appendageRenderer.sprite = alienRaceDef.isHumanoid && bodyFacing != 0 ? Resources.Load<Sprite>("Textures/Humanlike/Appendages/Appendage" + bodyFacing) : null;
|
||||
|
||||
actorBody.bodyRenderer.gameObject.SetActive(actorBody.bodyRenderer.sprite != null);
|
||||
actorBody.headRenderer.gameObject.SetActive(actorBody.headRenderer.sprite != null);
|
||||
actorBody.appendageRenderer.gameObject.SetActive(actorBody.appendageRenderer.sprite != null);
|
||||
|
||||
actorBody.bodyRenderer.sortingLayerName = clip.layer;
|
||||
actorBody.headRenderer.sortingLayerName = clip.layer;
|
||||
actorBody.headRenderer.sortingOrder = bodyFacing == 0 ? -1 : 1;
|
||||
actorBody.appendageRenderer.sortingLayerName = clip.layer;
|
||||
|
||||
actorBody.bodyRenderer.flipX = bodyFacing == 3;
|
||||
actorBody.headRenderer.flipX = headFacing == 3;
|
||||
//actorBody.appendageRenderer.flipX = bodyFacing == 3;
|
||||
|
||||
// ActorKeyframeCard update
|
||||
if (ActorKeyframeCard.Instance.positionXField.isFocused == false) { ActorKeyframeCard.Instance.positionXField.text = bodyPos.x.ToString("0.000"); }
|
||||
if (ActorKeyframeCard.Instance.positionZField.isFocused == false) { ActorKeyframeCard.Instance.positionZField.text = bodyPos.y.ToString("0.000"); }
|
||||
|
|
|
@ -18,6 +18,37 @@ namespace RimWorldAnimationStudio
|
|||
public void Start()
|
||||
{
|
||||
LoadCustomArrays();
|
||||
|
||||
/*AlienRaceDef human = new AlienRaceDef();
|
||||
human.Initialize("Human");
|
||||
|
||||
human.SetHeadGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Heads/Head0.png"), CardinalDirection.North);
|
||||
human.SetHeadGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Heads/Head1.png"), CardinalDirection.East);
|
||||
human.SetHeadGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Heads/Head2.png"), CardinalDirection.South);
|
||||
|
||||
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Male0.png"), CardinalDirection.North, "Male");
|
||||
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Male1.png"), CardinalDirection.East, "Male");
|
||||
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Male2.png"), CardinalDirection.South, "Male");
|
||||
|
||||
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Female0.png"), CardinalDirection.North, "Female");
|
||||
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Female1.png"), CardinalDirection.East, "Female");
|
||||
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Female2.png"), CardinalDirection.South, "Female");
|
||||
|
||||
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Fat0.png"), CardinalDirection.North, "Fat");
|
||||
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Fat1.png"), CardinalDirection.East, "Fat");
|
||||
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Fat2.png"), CardinalDirection.South, "Fat");
|
||||
|
||||
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Hulk0.png"), CardinalDirection.North, "Hulk");
|
||||
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Hulk1.png"), CardinalDirection.East, "Hulk");
|
||||
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Hulk2.png"), CardinalDirection.South, "Hulk");
|
||||
|
||||
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Thin0.png"), CardinalDirection.North, "Thin");
|
||||
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Thin1.png"), CardinalDirection.East, "Thin");
|
||||
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Thin2.png"), CardinalDirection.South, "Thin");*/
|
||||
|
||||
//AlienRaceDefs.allDefs.Add(human);
|
||||
|
||||
LoadAlienRaceDefs();
|
||||
}
|
||||
|
||||
public void TryToCloseApplication()
|
||||
|
@ -139,7 +170,6 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
CustomTagsHelper helper = new CustomTagsHelper();
|
||||
|
||||
helper.defNames = CustomTags.defNames;
|
||||
helper.bodyParts = CustomTags.bodyParts;
|
||||
helper.bodyDefTypes = CustomTags.bodyDefTypes;
|
||||
helper.sexTypes = CustomTags.sexTypes;
|
||||
|
@ -158,7 +188,6 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
CustomTagsHelper helper = XmlUtility.ReadXML<CustomTagsHelper>(path);
|
||||
|
||||
CustomTags.defNames = helper.defNames;
|
||||
CustomTags.bodyParts = helper.bodyParts;
|
||||
CustomTags.bodyDefTypes = helper.bodyDefTypes;
|
||||
CustomTags.sexTypes = helper.sexTypes;
|
||||
|
@ -168,7 +197,6 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public void UpdateCustomArrays(AnimationDef animationDef)
|
||||
{
|
||||
CustomTags.defNames.AddRangeDistinct(animationDef.actors.SelectMany(x => x.defNames).Except(Tags.defNames));
|
||||
CustomTags.bodyParts.AddRangeDistinct(animationDef.actors.SelectMany(x => x.requiredGenitals).Except(Tags.bodyParts));
|
||||
CustomTags.bodyDefTypes.AddRangeDistinct(animationDef.actors.SelectMany(x => x.bodyDefTypes).Except(Tags.bodyDefTypes));
|
||||
CustomTags.sexTypes.AddRangeDistinct(animationDef.sexTypes.Except(Tags.sexTypes));
|
||||
|
@ -177,5 +205,23 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
SaveCustomArrays();
|
||||
}
|
||||
|
||||
public void LoadAlienRaceDefs()
|
||||
{
|
||||
var path = Path.Combine(Application.streamingAssetsPath, "alienRaceDefs.xml");
|
||||
|
||||
if (File.Exists(path) == false)
|
||||
{ SaveAlienRaceDefs(); return; }
|
||||
|
||||
AlienRaceDefs.allDefs = XmlUtility.ReadXML<List<AlienRaceDef>>(path);
|
||||
AlienRaceDefs.OnLoad();
|
||||
}
|
||||
|
||||
public void SaveAlienRaceDefs()
|
||||
{
|
||||
var path = Path.Combine(Application.streamingAssetsPath, "alienRaceDefs.xml");
|
||||
|
||||
XmlUtility.WriteXML(AlienRaceDefs.allDefs, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue