Sex props plus quiver visuals

This commit is contained in:
AbstractConcept 2022-10-07 21:52:27 -05:00
parent f275ed90ae
commit 4a2905c7fc
152 changed files with 1985 additions and 184 deletions

View file

@ -16,7 +16,7 @@ namespace RimWorldAnimationStudio
void Update()
{
PawnKeyframe keyframe = Workspace.Instance.GetCurrentPawnKeyframe();
PawnKeyframe keyframe = Workspace.Instance.GetCurrentOrPreviousKeyframe(Workspace.actorID);
if (keyframe != null)
{ text.text = keyframe.soundEffect == null || keyframe.soundEffect == "" ? "None" : keyframe.soundEffect; }

View file

@ -28,10 +28,10 @@ namespace RimWorldAnimationStudio
_optionToggle.Find("Text").GetComponent<Text>().text = tag;
Toggle toggleComp = _optionToggle.GetComponent<Toggle>();
toggleComp.isOn = Workspace.Instance.GetCurrentPawnKeyframe()?.soundEffect == tag;
toggleComp.isOn = Workspace.Instance.GetCurrentOrPreviousKeyframe(Workspace.actorID)?.soundEffect == tag;
toggleComp.onValueChanged.AddListener(delegate
{
PawnKeyframe keyframe = Workspace.Instance.GetCurrentPawnKeyframe();
PawnKeyframe keyframe = Workspace.Instance.GetCurrentOrPreviousKeyframe(Workspace.actorID);
if (keyframe != null)
{ keyframe.soundEffect = tag; }

View file

@ -9,13 +9,13 @@ namespace RimWorldAnimationStudio
{
public void Update()
{
PawnKeyframe keyframe = Workspace.Instance.GetCurrentPawnKeyframe();
PawnKeyframe keyframe = Workspace.Instance.GetCurrentOrPreviousKeyframe(Workspace.actorID);
GetComponent<Toggle>().isOn = keyframe != null && keyframe.quiver.HasValue && keyframe.quiver.Value;
}
public void OnValueChanged()
{
PawnKeyframe keyframe = Workspace.Instance.GetCurrentPawnKeyframe();
PawnKeyframe keyframe = Workspace.Instance.GetCurrentOrPreviousKeyframe(Workspace.actorID);
if (keyframe != null)
{ keyframe.quiver = GetComponent<Toggle>().isOn; }

View file

@ -5,7 +5,6 @@ using System.Linq;
using System.IO;
using System.Xml.Serialization;
using UnityEngine;
using SFB;
using UnityEngine.UI;
namespace RimWorldAnimationStudio
@ -143,6 +142,8 @@ namespace RimWorldAnimationStudio
if (clip == null)
{ continue; }
bool quiver = isAnimating && Workspace.Instance.GetCurrentOrPreviousKeyframe(actorID).quiver == true;
float clipPercent = (float)(stageTick % clip.duration) / clip.duration;
if (stageTick == clip.duration) clipPercent = 1f;
@ -156,6 +157,8 @@ namespace RimWorldAnimationStudio
Vector3 deltaPos = new Vector3(clip.BodyOffsetX.Evaluate(clipPercent), 0, clip.BodyOffsetZ.Evaluate(clipPercent));
float bodyAngle = clip.BodyAngle.Evaluate(clipPercent);
bodyAngle += quiver ? UnityEngine.Random.value * 2f - 1f : 0f;
float headAngle = clip.HeadAngle.Evaluate(clipPercent);
int bodyFacing = (int)clip.BodyFacing.Evaluate(clipPercent);

View file

@ -144,7 +144,7 @@ namespace RimWorldAnimationStudio
public void SaveCustomArrays()
{
var path = Path.Combine(Application.streamingAssetsPath, "customTags.xml");
var path = Path.Combine(Application.persistentDataPath, "customTags.xml");
CustomTagsHelper helper = new CustomTagsHelper();
@ -159,8 +159,14 @@ namespace RimWorldAnimationStudio
public void LoadCustomArrays()
{
var path = Path.Combine(Application.streamingAssetsPath, "customTags.xml");
string path;
if (File.Exists(Path.Combine(Application.persistentDataPath, "customTags.xml")))
{ path = Path.Combine(Application.persistentDataPath, "customTags.xml"); }
else
{ path = Path.Combine(Application.streamingAssetsPath, "customTags.xml"); }
if (File.Exists(path) == false)
{ SaveCustomArrays(); return; }
@ -186,7 +192,13 @@ namespace RimWorldAnimationStudio
public void LoadAlienRaceDefs()
{
var path = Path.Combine(Application.streamingAssetsPath, "alienRaceDefs.xml");
string path;
if (File.Exists(Path.Combine(Application.persistentDataPath, "alienRaceDefs.xml")))
{ path = Path.Combine(Application.persistentDataPath, "alienRaceDefs.xml"); }
else
{ path = Path.Combine(Application.streamingAssetsPath, "alienRaceDefs.xml"); }
if (File.Exists(path) == false)
{ SaveAlienRaceDefs(); return; }
@ -197,7 +209,7 @@ namespace RimWorldAnimationStudio
public void SaveAlienRaceDefs()
{
var path = Path.Combine(Application.streamingAssetsPath, "alienRaceDefs.xml");
var path = Path.Combine(Application.persistentDataPath, "alienRaceDefs.xml");
XmlUtility.WriteXML(AlienRaceDefs.allDefs, path);
}

12
Assets/Scripts/SexProp.cs Normal file
View file

@ -0,0 +1,12 @@
using System;
using UnityEngine;
namespace RimWorldAnimationStudio
{
[Serializable]
public class SexProp
{
public string label;
public Sprite sprite;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 94f6b7ad49adabe428c011abfcf4da53
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace RimWorldAnimationStudio
{
public class SexPropManager : MonoBehaviour
{
public List<SexProp> sexProps = new List<SexProp>();
public Dropdown sexPropDropdown;
private SpriteRenderer spriteRenderer;
public void OnEnable()
{
spriteRenderer = GetComponent<SpriteRenderer>();
foreach (SexProp sexProp in sexProps)
{ sexPropDropdown.options.Add(new Dropdown.OptionData(sexProp.label)); }
}
public void OnOptionChanged()
{
spriteRenderer.sprite = sexProps[sexPropDropdown.value].sprite;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 587f7397b0c3ecf4495edb8af5dbd777
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -109,36 +109,20 @@ namespace RimWorldAnimationStudio
return animationDef.animationStages[stageID].animationClips[actorID].keyframes.Any(x => x.atTick == atTick);
}
public static void FindAdjacentKeyframes(int atTick, out PawnKeyframe prevKeyframe, out PawnKeyframe nextKeyframe, int actorID = -1, int excludedActorID = -1, bool ignoreSelf = true, int searchDistance = int.MaxValue)
public PawnKeyframe GetCurrentOrPreviousKeyframe(int actorID)
{
prevKeyframe = null;
nextKeyframe = null;
PawnKeyframe pawnKeyframe = null;
PawnAnimationClip clip = GetPawnAnimationClip(actorID);
List<PawnKeyframe> keyframesToCheck;
int stageTick = AnimationController.Instance.stageTick;
if (actorID >= 0)
{ keyframesToCheck = animationDef.animationStages[stageID].animationClips[actorID].keyframes; }
else
foreach (PawnKeyframe keyframe in clip.keyframes)
{
keyframesToCheck = animationDef.animationStages[stageID].animationClips.Where(x =>
animationDef.animationStages[stageID].animationClips.IndexOf(x) != excludedActorID).SelectMany(x => x.keyframes)?.ToList();
if (keyframe.atTick <= stageTick)
{ pawnKeyframe = keyframe; }
}
foreach (PawnKeyframe keyframe in keyframesToCheck)
{
if (keyframe.atTick <= atTick && atTick - keyframe.atTick <= searchDistance)
{
if (keyframe.atTick != atTick || ignoreSelf)
{ prevKeyframe = keyframe; }
else
{ prevKeyframe = null; }
}
if (nextKeyframe == null && keyframe.atTick > atTick && keyframe.atTick - atTick <= searchDistance)
{ nextKeyframe = keyframe; }
}
return pawnKeyframe;
}
public static int FindClosestKeyFrameAtTick(int atTick, int searchDistance = int.MaxValue, int excludedActorID = -1)