Files
ichni_Creator_Studio/Assets/Scripts/Animations/Transform/Swirl.cs
SoulliesOfficial bc1c5d65ef 基础内容-8
添加BM存档类
2025-02-02 21:59:43 -05:00

108 lines
4.2 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using Lean.Pool;
using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class Swirl : AnimationBase
{
public TransformSubmodule targetTransformSubmodule;
public FlexibleFloat eulerAngleX, eulerAngleY, eulerAngleZ;
public static Swirl GenerateElement(string elementName, Guid id,
List<string> tags, BaseElement targetObject,
FlexibleFloat eulerAngleX, FlexibleFloat eulerAngleY, FlexibleFloat eulerAngleZ)
{
Swirl swirl = Instantiate(EditorManager.instance.basePrefabs.emptyObject).AddComponent<Swirl>();
swirl.Initialize(elementName, id, tags);
swirl.targetObject = targetObject;
swirl.eulerAngleX = eulerAngleX;
swirl.eulerAngleY = eulerAngleY;
swirl.eulerAngleZ = eulerAngleZ;
swirl.animationReturnType = FlexibleReturnType.Before;
if (targetObject.transformSubmodule != null)
{
swirl.targetTransformSubmodule = targetObject.transformSubmodule;
}
else
{
throw new System.Exception("Target object does not have a TransformSubmodule");
}
swirl.SetParent(targetObject);
swirl.timeDurationSubmodule.SetDuration(eulerAngleX, eulerAngleY, eulerAngleZ);
return swirl;
}
protected override void UpdateAnimation(float songTime)
{
eulerAngleX.UpdateFlexibleFloat(songTime);
eulerAngleY.UpdateFlexibleFloat(songTime);
eulerAngleZ.UpdateFlexibleFloat(songTime);
if (eulerAngleX.returnType is FlexibleReturnType.MiddleExecuting ||
eulerAngleY.returnType is FlexibleReturnType.MiddleExecuting ||
eulerAngleZ.returnType is FlexibleReturnType.MiddleExecuting)
{
animationReturnType = FlexibleReturnType.MiddleExecuting;
Vector3 currentEulerAngles = new Vector3(eulerAngleX.value, eulerAngleY.value, eulerAngleZ.value);
targetTransformSubmodule.eulerAnglesOffset.Add(currentEulerAngles);
targetTransformSubmodule.eulerAnglesDirtyMark = true;
}
else
{
animationReturnType = FlexibleReturnType.MiddleInterval;
}
}
}
public partial class Swirl
{
public override void SaveBM()
{
matchedBM = new Beatmap.Swirl_BM(elementName, elementGuid, tags, parentElement.matchedBM,
eulerAngleX.ConvertToBM(), eulerAngleY.ConvertToBM(), eulerAngleZ.ConvertToBM());
}
}
namespace Beatmap
{
public class Swirl_BM : BaseElement_BM
{
public FlexibleFloat_BM eulerAngleX, eulerAngleY, eulerAngleZ;
public Swirl_BM()
{
}
public Swirl_BM(string elementName, Guid elementGuid, List<string> tags,
BaseElement_BM attachedElement, FlexibleFloat_BM eulerAngleX, FlexibleFloat_BM eulerAngleY, FlexibleFloat_BM eulerAngleZ)
: base(elementName, elementGuid, tags, attachedElement)
{
this.eulerAngleX = eulerAngleX;
this.eulerAngleY = eulerAngleY;
this.eulerAngleZ = eulerAngleZ;
}
public override void ExecuteBM()
{
Swirl.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid),
eulerAngleX.ConvertToGameType(), eulerAngleY.ConvertToGameType(), eulerAngleZ.ConvertToGameType());
}
public override BaseElement DuplicateBM(BaseElement parent)
{
return Swirl.GenerateElement(elementName, elementGuid, tags, parent,
eulerAngleX.ConvertToGameType(), eulerAngleY.ConvertToGameType(), eulerAngleZ.ConvertToGameType());
}
}
}
}