2025-06-03 02:42:28 -04:00
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Ichni.RhythmGame.Beatmap;
|
|
|
|
|
using Unity.VisualScripting;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace Ichni.RhythmGame
|
|
|
|
|
{
|
|
|
|
|
public partial class Displacement : AnimationBase
|
|
|
|
|
{
|
|
|
|
|
private TransformSubmodule targetTransformSubmodule;
|
|
|
|
|
public FlexibleFloat positionX, positionY, positionZ;
|
|
|
|
|
|
|
|
|
|
public static Displacement GenerateElement(string elementName, Guid id,
|
|
|
|
|
List<string> tags, bool isFirstGenerated, GameElement animatedObject,
|
|
|
|
|
FlexibleFloat positionX, FlexibleFloat positionY, FlexibleFloat positionZ)
|
|
|
|
|
{
|
|
|
|
|
Displacement displacement = Instantiate(GameManager.instance.basePrefabs.emptyObject).AddComponent<Displacement>();
|
|
|
|
|
|
|
|
|
|
displacement.Initialize(elementName, id, tags, isFirstGenerated, animatedObject);
|
|
|
|
|
|
|
|
|
|
displacement.animatedObject = animatedObject;
|
|
|
|
|
|
|
|
|
|
displacement.positionX = positionX;
|
|
|
|
|
displacement.positionY = positionY;
|
|
|
|
|
displacement.positionZ = positionZ;
|
|
|
|
|
displacement.animationReturnType = FlexibleReturnType.Before;
|
|
|
|
|
|
|
|
|
|
displacement.targetTransformSubmodule = (animatedObject as IHaveTransformSubmodule).transformSubmodule;
|
|
|
|
|
|
|
|
|
|
//displacement.timeDurationSubmodule.SetDuration(positionX, positionY, positionZ);
|
|
|
|
|
|
|
|
|
|
return displacement;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateAnimation(float songTime)
|
|
|
|
|
{
|
|
|
|
|
positionX.UpdateFlexibleFloat(songTime);
|
|
|
|
|
positionY.UpdateFlexibleFloat(songTime);
|
|
|
|
|
positionZ.UpdateFlexibleFloat(songTime);
|
|
|
|
|
|
|
|
|
|
if ((positionX.returnType is FlexibleReturnType.MiddleExecuting || positionX.isSwitchingReturnType) ||
|
|
|
|
|
(positionY.returnType is FlexibleReturnType.MiddleExecuting || positionY.isSwitchingReturnType) ||
|
|
|
|
|
(positionZ.returnType is FlexibleReturnType.MiddleExecuting || positionZ.isSwitchingReturnType))
|
|
|
|
|
{
|
|
|
|
|
animationReturnType = FlexibleReturnType.MiddleExecuting;
|
|
|
|
|
Vector3 currentPosition = new Vector3(positionX.value, positionY.value, positionZ.value);
|
2025-07-21 05:42:20 -04:00
|
|
|
targetTransformSubmodule.positionOffset += currentPosition;
|
2025-06-03 02:42:28 -04:00
|
|
|
targetTransformSubmodule.positionDirtyMark = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
animationReturnType = FlexibleReturnType.MiddleInterval;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void ApplyTimeOffset(float offset)
|
|
|
|
|
{
|
|
|
|
|
base.ApplyTimeOffset(offset);
|
|
|
|
|
positionX.animations.ForEach(anim => anim.ApplyTimeOffset(offset));
|
|
|
|
|
positionY.animations.ForEach(anim => anim.ApplyTimeOffset(offset));
|
|
|
|
|
positionZ.animations.ForEach(anim => anim.ApplyTimeOffset(offset));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public partial class Displacement
|
|
|
|
|
{
|
|
|
|
|
public override void SaveBM()
|
|
|
|
|
{
|
|
|
|
|
matchedBM = new Beatmap.Displacement_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
|
|
|
|
|
positionX.ConvertToBM(), positionY.ConvertToBM(), positionZ.ConvertToBM());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace Beatmap
|
|
|
|
|
{
|
|
|
|
|
public class Displacement_BM : AnimationBase_BM
|
|
|
|
|
{
|
|
|
|
|
public FlexibleFloat_BM positionX, positionY, positionZ;
|
|
|
|
|
|
|
|
|
|
public Displacement_BM()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Displacement_BM(string elementName, Guid elementGuid, List<string> tags,
|
|
|
|
|
GameElement_BM attachedElement, FlexibleFloat_BM positionX, FlexibleFloat_BM positionY, FlexibleFloat_BM positionZ)
|
|
|
|
|
: base(elementName, elementGuid, tags, attachedElement)
|
|
|
|
|
{
|
|
|
|
|
this.positionX = positionX;
|
|
|
|
|
this.positionY = positionY;
|
|
|
|
|
this.positionZ = positionZ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void ExecuteBM()
|
|
|
|
|
{
|
|
|
|
|
matchedElement = Displacement.GenerateElement(elementName, elementGuid, tags, false, GetElement(attachedElementGuid),
|
|
|
|
|
positionX.ConvertToGameType(), positionY.ConvertToGameType(), positionZ.ConvertToGameType());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override GameElement DuplicateBM(GameElement parent)
|
|
|
|
|
{
|
|
|
|
|
return Displacement.GenerateElement(elementName, Guid.NewGuid(), tags, false, parent,
|
|
|
|
|
positionX.ConvertToGameType(), positionY.ConvertToGameType(), positionZ.ConvertToGameType());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|