mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Bug fixes and build files
This commit is contained in:
parent
73f7e32e0c
commit
0e653f863a
252 changed files with 25598 additions and 90 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue