Files
ichni_Official/Assets/Scripts/Game/Animations/Transform/Scale.cs

84 lines
3.3 KiB
C#
Raw Normal View History

2025-06-03 02:42:28 -04:00
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class Scale : AnimationBase
{
2026-03-14 03:13:10 -04:00
#region [] Exposed Fields & References
2025-06-03 02:42:28 -04:00
public TransformSubmodule targetTransformSubmodule;
public FlexibleFloat scaleX, scaleY, scaleZ;
2026-03-14 03:13:10 -04:00
#endregion
2025-06-03 02:42:28 -04:00
2026-03-14 03:13:10 -04:00
#region [] Lifecycle & Factory
2025-06-03 02:42:28 -04:00
public static Scale GenerateElement(string elementName, Guid id,
List<string> tags, bool isFirstGenerated, GameElement animatedObject,
FlexibleFloat scaleX, FlexibleFloat scaleY, FlexibleFloat scaleZ)
{
2026-03-14 03:13:10 -04:00
Scale scale = Instantiate(GameManager.Instance.basePrefabs.emptyObject).AddComponent<Scale>();
2025-06-03 02:42:28 -04:00
scale.Initialize(elementName, id, tags, isFirstGenerated, animatedObject);
scale.animatedObject = animatedObject;
scale.scaleX = scaleX;
scale.scaleY = scaleY;
scale.scaleZ = scaleZ;
scale.animationReturnType = FlexibleReturnType.Before;
scale.targetTransformSubmodule = (animatedObject as IHaveTransformSubmodule).transformSubmodule;
//scale.timeDurationSubmodule.SetDuration(scaleX, scaleY, scaleZ);
return scale;
}
public override void SetDefaultSubmodules()
{
timeDurationSubmodule = new TimeDurationSubmodule(this);
}
2026-03-14 03:13:10 -04:00
#endregion
2025-06-03 02:42:28 -04:00
2026-03-14 03:13:10 -04:00
#region [] Core Animation Logic
2026-04-03 10:53:11 -04:00
protected override void UpdateAnimation(float songTime, bool forceUpdate)
2025-06-03 02:42:28 -04:00
{
scaleX.UpdateFlexibleFloat(songTime);
scaleY.UpdateFlexibleFloat(songTime);
scaleZ.UpdateFlexibleFloat(songTime);
2026-04-03 10:53:11 -04:00
if (forceUpdate || scaleX.returnType is FlexibleReturnType.MiddleExecuting ||
2025-08-22 14:54:40 -04:00
scaleY.returnType is FlexibleReturnType.MiddleExecuting ||
scaleZ.returnType is FlexibleReturnType.MiddleExecuting)
{
2026-04-03 10:53:11 -04:00
if(!forceUpdate) animationReturnType = FlexibleReturnType.MiddleExecuting;
2025-08-22 14:54:40 -04:00
Vector3 currentScale = new Vector3(scaleX.value, scaleY.value, scaleZ.value);
targetTransformSubmodule.scaleOffset += currentScale;
targetTransformSubmodule.scaleDirtyMark = true;
}
else if (scaleX.isSwitchingReturnType || scaleY.isSwitchingReturnType || scaleZ.isSwitchingReturnType)
2025-06-03 02:42:28 -04:00
{
2026-03-31 07:51:40 -04:00
//animationReturnType = FlexibleReturnType.MiddleExecuting;
2026-03-19 14:14:28 -04:00
//Vector3 currentScale = new Vector3(scaleX.value, scaleY.value, scaleZ.value);
//targetTransformSubmodule.scaleOffset += currentScale;
2026-03-31 07:51:40 -04:00
//targetTransformSubmodule.scaleDirtyMark = true;
2025-06-03 02:42:28 -04:00
}
else
{
animationReturnType = FlexibleReturnType.MiddleInterval;
}
}
2025-08-22 14:54:40 -04:00
2025-06-03 02:42:28 -04:00
public override void ApplyTimeOffset(float offset)
{
base.ApplyTimeOffset(offset);
scaleX.animations.ForEach(anim => anim.ApplyTimeOffset(offset));
scaleY.animations.ForEach(anim => anim.ApplyTimeOffset(offset));
scaleZ.animations.ForEach(anim => anim.ApplyTimeOffset(offset));
}
2026-03-14 03:13:10 -04:00
#endregion
2025-06-03 02:42:28 -04:00
}
}