Bug fixes and build files

This commit is contained in:
AbstractConcept 2022-09-27 00:56:35 -05:00
parent 73f7e32e0c
commit 0e653f863a
252 changed files with 25598 additions and 90 deletions

View file

@ -25,6 +25,8 @@ namespace RimWorldAnimationStudio
public bool isFucking;
public bool isFucked;
[XmlIgnore] public string bodyType = "Male";
public bool ShouldSerializedefNames() { return defNames.NotNullOrEmpty(); }
public bool ShouldSerializebodyDefTypes() { return bodyDefTypes.NotNullOrEmpty(); }
public bool ShouldSerializerequiredGender() { return requiredGender.NotNullOrEmpty(); }

View file

@ -36,7 +36,7 @@ namespace RimWorldAnimationStudio
public void ValidateData()
{
sexTypes = interactionDefTypes.Intersect(Tags.sexTypes.Concat(CustomTags.sexTypes))?.ToList();
sexTypes = sexTypes.Intersect(Tags.sexTypes.Concat(CustomTags.sexTypes))?.ToList();
interactionDefTypes = interactionDefTypes.Intersect(Tags.interactionDefTypes.Concat(CustomTags.interactionDefTypes))?.ToList();
}
}

View file

@ -23,9 +23,9 @@ namespace RimWorldAnimationStudio
{
clip.BuildSimpleCurves();
//select playTimeTicks as longest playtime of all the animations
// Select playTimeTicks as longest playtime of all the animations
if (clip.duration > playTimeTicks)
{ playTimeTicks = clip.duration; }
{ playTimeTicks = clip.duration; }
}
}

View file

@ -9,7 +9,6 @@ namespace RimWorldAnimationStudio
public class ActorBody : MonoBehaviour, IPointerClickHandler, IDragHandler, IEndDragHandler
{
public int actorID;
public string bodyType = "Male";
public bool isSelected = false;
public SpriteRenderer bodyRenderer;

View file

@ -79,7 +79,7 @@ namespace RimWorldAnimationStudio
{
if (Workspace.actorManipulationMode == ActorManipulationMode.Rotate)
{
float angle = Vector2.SignedAngle(Vector2.up, (Vector2)mousePosition - (Vector2)transform.position);
float angle = -Vector2.SignedAngle(Vector2.up, (Vector2)mousePosition - (Vector2)transform.position);
keyframe.genitalAngle = angle;
Workspace.animationDef.actors[Workspace.actorID].controlGenitalAngle = Workspace.animationDef.animationStages.Any(x => x.animationClips[Workspace.actorID].keyframes.Any(y => y.genitalAngle != 0));

View file

@ -37,7 +37,7 @@ namespace RimWorldAnimationStudio
string bodyType = bodyTypeDropdown.options[bodyTypeDropdown.value].text;
bodyType = bodyType == null || bodyType == "" ? "Male" : bodyType;
AnimationController.Instance.actorBodies.GetComponentsInChildren<ActorBody>()[Workspace.actorID].bodyType = bodyType;
Workspace.animationDef.actors[Workspace.actorID].bodyType = bodyType;
bodyOffsetXField.text = actor.bodyTypeOffset.GetOffset(bodyType).x.ToString();
bodyOffsetZField.text = actor.bodyTypeOffset.GetOffset(bodyType).z.ToString();
@ -93,7 +93,7 @@ namespace RimWorldAnimationStudio
ActorBody actorBody = AnimationController.Instance.actorBodies.GetComponentsInChildren<ActorBody>()[Workspace.actorID];
PawnAnimationClip clip = Workspace.Instance.GetCurrentPawnAnimationClip();
string bodyType = actorBody.bodyType;
string bodyType = actor.bodyType;
bodyType = bodyType == null || bodyType == "" ? "Male" : bodyType;
bodyTypeDropdown.value = bodyTypeDropdown.options.IndexOf(bodyTypeDropdown.options.First(x => x.text == bodyType));
@ -112,10 +112,10 @@ namespace RimWorldAnimationStudio
initiatorToggle.isOn = actor.initiator;
if (actor.requiredGender.Contains("Female"))
if (actor.requiredGender.NotNullOrEmpty() && actor.requiredGender.Contains("Female"))
{ genderDropdown.SetValueWithoutNotify(0); }
else if (actor.requiredGender.Contains("Male"))
else if (actor.requiredGender.NotNullOrEmpty() && actor.requiredGender.Contains("Male"))
{ genderDropdown.SetValueWithoutNotify(2); }
else

View file

@ -14,10 +14,16 @@ namespace RimWorldAnimationStudio
public InputField labelField;
public Toggle playSoundsToggle;
public void Initialize()
public void Update()
{
defNameField.text = Workspace.animationDef.defName;
labelField.text = Workspace.animationDef.label;
if (Workspace.animationDef == null) return;
if (defNameField.isFocused == false)
{ defNameField.text = Workspace.animationDef.defName; }
if (labelField.isFocused == false)
{ labelField.text = Workspace.animationDef.label; }
playSoundsToggle.isOn = Workspace.animationDef.sounds;
}
@ -26,22 +32,8 @@ namespace RimWorldAnimationStudio
Workspace.animationDef.defName = defNameField.text;
Workspace.animationDef.label = labelField.text;
Workspace.animationDef.sounds = playSoundsToggle.isOn;
}
public void OpenSelectSexTypesDialog()
{
var dialog = Resources.FindObjectsOfTypeAll(typeof(SelectSexTypesDialog)) as SelectSexTypesDialog[];
if (dialog != null)
{ dialog[0].Initialize(); dialog[0].Pop(); }
}
public void OpenSelectInteractionDefsDialog()
{
var dialog = Resources.FindObjectsOfTypeAll(typeof(SelectInteractionDefsDialog)) as SelectInteractionDefsDialog[];
if (dialog != null)
{ dialog[0].Initialize(); dialog[0].Pop(); }
Workspace.Instance.MakeHistoricRecord("AnimationDef update");
}
}
}

View file

@ -30,6 +30,9 @@ namespace RimWorldAnimationStudio
public void UpdateDropdown()
{
if (dropdown == null)
{ OnEnable(); }
string alienRaceDefName = Workspace.animationDef.actors[Workspace.actorID].GetAlienRaceDef().defName;
dropdown.ClearOptions();

View file

@ -28,6 +28,7 @@ namespace RimWorldAnimationStudio
public Transform actorBodies;
public Toggle stretchkeyframesToggle;
public InputField playBackSpeedField;
public Button playToggleButton;
[Header("Prefabs")]
public ActorBody actorBodyPrefab;
@ -72,7 +73,7 @@ namespace RimWorldAnimationStudio
if (stageLoopDropdown.value == 1)
{ stageTick = 1; }
else if (stageLoopDropdown.value >= 2 && Workspace.stageID < Workspace.animationDef.animationStages.Count - 1)
else if (stageLoopDropdown.value >= 2)
{
++cycleIndex;
stageTick = 1;
@ -83,10 +84,20 @@ namespace RimWorldAnimationStudio
++Workspace.stageID;
cycleIndex = 0;
}
if (Workspace.stageID > Workspace.animationDef.animationStages.Count - 1)
{
Workspace.stageID = Workspace.animationDef.animationStages.Count - 1;
stageTick = Workspace.StageWindowSize;
isAnimating = false;
}
}
else
{ stageTick = Workspace.StageWindowSize; }
{
stageTick = Workspace.StageWindowSize;
isAnimating = false;
}
}
}
@ -102,6 +113,8 @@ namespace RimWorldAnimationStudio
lastStageTick = stageTick;
}
playToggleButton.image.color = isAnimating ? Constants.ColorGoldYellow : Constants.ColorWhite;
// Update animation
UpdateAnimation();
}
@ -124,6 +137,7 @@ namespace RimWorldAnimationStudio
if (actorID >= Workspace.animationDef?.animationStages[Workspace.stageID]?.animationClips.Count)
{ Debug.Log("Waiting for animation clip data to initialize..."); return; }
Actor actor = Workspace.animationDef.actors[actorID];
PawnAnimationClip clip = Workspace.animationDef?.animationStages[Workspace.stageID]?.animationClips[actorID];
if (clip == null)
@ -132,22 +146,25 @@ namespace RimWorldAnimationStudio
float clipPercent = (float)(stageTick % clip.duration) / clip.duration;
if (stageTick == clip.duration) clipPercent = 1f;
AlienRaceDef alienRaceDef = Workspace.animationDef.actors[actorID].GetAlienRaceDef();
AlienRaceDef alienRaceDef = actor.GetAlienRaceDef();
ActorBody actorBody = _actorBodies[actorID];
string bodyType = alienRaceDef.isHumanoid ? actorBody.bodyType : "None";
string bodyType = alienRaceDef.isHumanoid ? actor.bodyType : "None";
Vector3 deltaPos = new Vector3(clip.BodyOffsetX.Evaluate(clipPercent), 0, clip.BodyOffsetZ.Evaluate(clipPercent));
deltaPos += Workspace.animationDef.actors[actorID].bodyTypeOffset.GetOffset(bodyType) + Workspace.animationDef.actors[actorID].GetAlienRaceOffset();
deltaPos += actor.bodyTypeOffset.GetOffset(bodyType) + actor.GetAlienRaceOffset();
float bodyAngle = clip.BodyAngle.Evaluate(clipPercent);
float headAngle = clip.HeadAngle.Evaluate(clipPercent);
if (bodyAngle < 0) bodyAngle = 360 - ((-1f * bodyAngle) % 360);
/*if (bodyAngle < 0) bodyAngle = 360 - ((-1f * bodyAngle) % 360);
if (bodyAngle > 360) bodyAngle %= 360;
if (headAngle < 0) headAngle = 360 - ((-1f * headAngle) % 360);
if (headAngle > 360) headAngle %= 360;
bodyAngle = bodyAngle > 180 ? 180 - bodyAngle : bodyAngle;
headAngle = headAngle > 180 ? 180 - headAngle : headAngle;*/
int bodyFacing = (int)clip.BodyFacing.Evaluate(clipPercent);
int headFacing = (int)clip.HeadFacing.Evaluate(clipPercent);
@ -189,6 +206,7 @@ namespace RimWorldAnimationStudio
actorBody.transform.localScale = new Vector3(alienRaceDef.scale, alienRaceDef.scale, alienRaceDef.scale);
// ActorKeyframeCard update
if (actorID != Workspace.actorID) continue;
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"); }
if (ActorKeyframeCard.Instance.rotationField.isFocused == false) { ActorKeyframeCard.Instance.rotationField.text = bodyAngle.ToString("0.000"); }
@ -468,7 +486,9 @@ namespace RimWorldAnimationStudio
if (Workspace.animationDef == null) return;
if (int.TryParse(cyclesNormalField.text, out int cycles))
{
{
cycles = cycles <= 0 ? 1 : cycles;
Workspace.animationDef.animationStages[Workspace.stageID].playTimeTicks = cycles * Workspace.StageWindowSize;
Workspace.animationDef.animationStages[Workspace.stageID].isLooping = cycles > 1;
@ -485,6 +505,8 @@ namespace RimWorldAnimationStudio
if (int.TryParse(cyclesFastField.text, out int fastCycles))
{
fastCycles = fastCycles < 0 ? 0 : fastCycles;
int.TryParse(cyclesNormalField.text, out int cycles);
if (fastCycles > cycles) fastCycles = cycles;
cyclesFastField.text = fastCycles.ToString();
@ -498,7 +520,9 @@ namespace RimWorldAnimationStudio
public void OnPlayBackSpeedChange()
{
if (float.TryParse(playBackSpeedField.text, out playBackSpeed))
{ playBackSpeed = Mathf.Clamp(playBackSpeed, 0.01f, 4f); }
{ playBackSpeed = Mathf.Clamp(playBackSpeed, 0.01f, 16f); }
playBackSpeedField.text = playBackSpeed.ToString();
}
private int lastactorCount = 0;

View file

@ -88,7 +88,9 @@ namespace RimWorldAnimationStudio
animationDef = record.animationDef.Copy();
stageID = record.stageID;
AnimationController.Instance.MakeDirty();
AnimationController.Instance.MakeTimelineDirty();
StageCardManager.Instance.Reset();
StageCardManager.Instance.Initialize();
}
public void Undo()
@ -102,7 +104,7 @@ namespace RimWorldAnimationStudio
futureSnapshots.AddLast(recordToStore);
RestoreToHistoricRecord(recordToRead);
//Debug.Log("Undo : " + recordToStore.eventDesc + " (record ID: " + recordToStore.recordID + ")");
Debug.Log("Undoing : " + recordToStore.eventDesc);
}
public void Redo()
@ -115,7 +117,7 @@ namespace RimWorldAnimationStudio
pastSnapshots.AddLast(recordToReadAndStore);
RestoreToHistoricRecord(recordToReadAndStore);
//Debug.Log("Redo : " + recordToReadAndStore.eventDesc + " (record ID: " + recordToReadAndStore.recordID + ")");
Debug.Log("Redoing : " + recordToReadAndStore.eventDesc);
}
public void ClearHistory()