VirtualFramework/Assets/Scripts/Actions/CameraLockAction.cs
2025-01-09 15:06:14 +08:00

79 lines
1.9 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine;
namespace QFramework
{
internal class CameraLockAction : IAction
{
public System.Action OnFinished { get; set; }
private CameraLockAction()
{
}
private static readonly SimpleObjectPool<CameraLockAction> mPool =
new SimpleObjectPool<CameraLockAction>(() => new CameraLockAction(), null, 10);
string isMove;
string isRotate;
public static CameraLockAction Allocate(Dictionary<string, string> datas, System.Action OnFinished = null)
{
var retNode = mPool.Allocate();
retNode.ActionID = ActionKit.ID_GENERATOR++;
retNode.Deinited = false;
retNode.Reset();
retNode.isMove = datas.ContainsKey("isMove") ? datas["isMove"] : "true";
retNode.isRotate = datas.ContainsKey("isRotate") ? datas["isRotate"] : "true";
retNode.OnFinished = OnFinished;
return retNode;
}
public ulong ActionID { get; set; }
public ActionStatus Status { get; set; }
public void OnStart()
{
bool isMov = true;
bool isRot = true;
bool.TryParse(isMove, out isMov);
bool.TryParse(isRotate, out isRot);
FreeCameraController.instance.SetLock(isMov, isRot);
}
public void OnExecute(float dt)
{
this.Finish();
OnFinished?.Invoke();
}
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; }
}
}