using QFramework.Example; using System; using Unity.VisualScripting; using UnityEngine; namespace QFramework { internal class CameraSwitchAction : IAction { public System.Action OnFinished { get; set; } private CameraSwitchAction() { } private static readonly SimpleObjectPool mPool = new SimpleObjectPool(() => new CameraSwitchAction(), null, 10); string nearPos; string nearRot; string normalPos; string normalRot; string isNear; string nearTime; string farTime; public static CameraSwitchAction Allocate(string nearPos, string nearRot, string nearTime, string normalPos, string normalRot, string farTime, string isNear, System.Action OnFinished = null) { var retNode = mPool.Allocate(); retNode.ActionID = ActionKit.ID_GENERATOR++; retNode.Deinited = false; retNode.Reset(); retNode.OnFinished = OnFinished; retNode.nearPos = nearPos; retNode.nearRot = nearRot; retNode.nearTime = nearTime; retNode.normalPos = normalPos; retNode.normalRot = normalRot; retNode.farTime = farTime; retNode.isNear = isNear; return retNode; } public ulong ActionID { get; set; } public ActionStatus Status { get; set; } public void OnStart() { UICameraSwitchData data = new UICameraSwitchData(); data.nearPos = Utility.GetVector3FromStrArray(nearPos); data.nearRot = Utility.GetVector3FromStrArray(nearRot); data.normalPos = Utility.GetVector3FromStrArray(normalPos); data.normalRot = Utility.GetVector3FromStrArray(normalRot); bool.TryParse(isNear, out data.isNear); UIKit.OpenPanelAsync(uiData: data, canvasLevel: UILevel.RightBottom).ToAction().StartGlobal(() => this.Finish()); } public void OnExecute(float dt) { } public void OnFinish() { } public void Reset() { Status = ActionStatus.NotStart; Paused = false; } public bool Paused { get; set; } public void Deinit() { if (!Deinited) { OnFinished = null; Deinited = true; mPool.Recycle(this); } } public bool Deinited { get; set; } } }