Skip to content

Commit

Permalink
v1.0.133 release
Browse files Browse the repository at this point in the history
  • Loading branch information
liangxiegame committed May 15, 2024
1 parent e30403f commit c4fcd88
Show file tree
Hide file tree
Showing 23 changed files with 1,051 additions and 339 deletions.
1,030 changes: 785 additions & 245 deletions Doc.md

Large diffs are not rendered by default.

Binary file modified QFramework.Toolkits.unitypackage
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Id": "",
"Version": "v1.0.132",
"Version": "v1.0.133",
"Type": 0,
"AccessRight": 0,
"DownloadUrl": "",
Expand All @@ -11,10 +11,10 @@
],
"DocUrl": "https://liangxiegame.com",
"Readme": {
"version": "v1.0.132",
"content": "CodeGenKit: 增加 TabCustomCode(misakiMeiii 提供)\nActionKit: 增加 StartCurrentScene(misakiMeiii 提供建议,已包含示例和文档)\nQFramework.cs: 增加 UnRegisterWhenCurrentSceneUnloaded(misakiMeiii 提供建议,已包含示例和文档)",
"version": "v1.0.133",
"content": "* ActionKit: 增加 IgnoreTimeScale API(秋濑 建议,已包含示例和文档)\n* Readme.md 补全作者\n* TabCustomCode 增加 misakiMeii 的声明",
"author": "liangxie",
"date": "2024 年 05 月 1220:27",
"date": "2024 年 05 月 1519:49",
"PackageId": ""
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************************************************
* Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License
*
*
* https://qframework.cn
* https://github.com/liangxiegame/QFramework
* https://gitee.com/liangxiegame/QFramework
Expand All @@ -18,12 +18,20 @@ public enum ActionStatus
Finished,
}

public enum ActionUpdateModes
{
ScaledDeltaTime,
UnscaledDeltaTime,
}

public interface IActionController
{
ulong ActionID { get; set; }

IAction Action { get; set; }

ActionUpdateModes UpdateMode { get; set; }

bool Paused { get; set; }
void Reset();
void Deinit();
Expand All @@ -33,6 +41,7 @@ public interface IAction<TStatus>
{
ulong ActionID { get; set; }
TStatus Status { get; set; }

void OnStart();
void OnExecute(float dt);
void OnFinish();
Expand All @@ -49,10 +58,12 @@ public interface IAction : IAction<ActionStatus>
{
}

public abstract class AbstractAction<T> : IAction where T : AbstractAction<T>,new()
public abstract class AbstractAction<T> : IAction where T : AbstractAction<T>, new()
{
protected AbstractAction(){}

protected AbstractAction()
{
}

private static readonly SimpleObjectPool<T> mPool =
new SimpleObjectPool<T>(() => new T(), null, 10);

Expand All @@ -67,16 +78,26 @@ public static T Allocate()

public ulong ActionID { get; set; }
public ActionStatus Status { get; set; }

public virtual void OnStart() {}

public virtual void OnExecute(float dt) {}
public virtual void OnStart()
{
}

public virtual void OnFinish() { }
public virtual void OnExecute(float dt)
{
}

protected virtual void OnReset(){}

protected virtual void OnDeinit(){}
public virtual void OnFinish()
{
}

protected virtual void OnReset()
{
}

protected virtual void OnDeinit()
{
}

public void Reset()
{
Expand All @@ -93,18 +114,29 @@ public void Deinit()
{
Deinited = true;
OnDeinit();
ActionQueue.AddCallback(new ActionQueueRecycleCallback<T>(mPool,this as T));
ActionQueue.AddCallback(new ActionQueueRecycleCallback<T>(mPool, this as T));
}
}

public bool Deinited { get; set; }
}

public struct ActionController : IActionController
public class ActionController : IActionController
{
private static SimpleObjectPool<IActionController> mPool = new SimpleObjectPool<IActionController>(
() => new ActionController(), controller =>
{
controller.UpdateMode = ActionUpdateModes.ScaledDeltaTime;
controller.ActionID = 0;
controller.Action = null;
}, 50);

public ulong ActionID { get; set; }
public IAction Action { get; set; }

public ActionUpdateModes UpdateMode { get; set; }


public bool Paused
{
get => Action.Paused;
Expand All @@ -119,47 +151,49 @@ public void Reset()
}
}

public static IActionController Allocate() => mPool.Allocate();

public void Deinit()
{
if (Action.ActionID == ActionID)
{
Action.Deinit();
mPool.Recycle(this);
}
}
}


public static class IActionExtensions
{

public static IActionController Start(this IAction self, MonoBehaviour monoBehaviour,
Action<IActionController> onFinish = null)
{
monoBehaviour.ExecuteByUpdate(self, onFinish);

return new ActionController()
{
Action = self,
ActionID = self.ActionID,
};
var controller = ActionController.Allocate();
controller.ActionID = self.ActionID;
controller.Action = self;
controller.UpdateMode = ActionUpdateModes.ScaledDeltaTime;
monoBehaviour.ExecuteByUpdate(self, controller, onFinish);
return controller;
}

public static IActionController Start(this IAction self, MonoBehaviour monoBehaviour,
Action onFinish)
{
monoBehaviour.ExecuteByUpdate(self, _ => onFinish());

return new ActionController()
{
Action = self,
ActionID = self.ActionID,
};
var controller = ActionController.Allocate();
controller.ActionID = self.ActionID;
controller.Action = self;
controller.UpdateMode = ActionUpdateModes.ScaledDeltaTime;
monoBehaviour.ExecuteByUpdate(self, controller, _ => onFinish());
return controller;
}

public static IActionController StartCurrentScene(this IAction self, Action<IActionController> onFinish = null)
{
return self.Start(ActionKitCurrentScene.SceneComponent, onFinish);
}

public static IActionController StartCurrentScene(this IAction self, Action onFinish)
{
return self.Start(ActionKitCurrentScene.SceneComponent, onFinish);
Expand All @@ -169,7 +203,7 @@ public static IActionController StartGlobal(this IAction self, Action<IActionCon
{
return self.Start(ActionKitMonoBehaviourEvents.Instance, onFinish);
}

public static IActionController StartGlobal(this IAction self, Action onFinish)
{
return self.Start(ActionKitMonoBehaviourEvents.Instance, onFinish);
Expand Down Expand Up @@ -232,4 +266,13 @@ public static bool Execute(this IAction self, float dt)
return false;
}
}

public static class IActionControllerExtensions
{
public static IActionController IgnoreTimeScale(this IActionController self)
{
self.UpdateMode = ActionUpdateModes.UnscaledDeltaTime;
return self;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,23 @@ namespace QFramework
{
public interface IActionExecutor
{
void Execute(IAction action,Action<IActionController> onFinish = null);
void Execute(IActionController controller,Action<IActionController> onFinish = null);
}


public static class IActionExecutorExtensions
{
public static bool UpdateAction(this IActionExecutor self,IAction action,float dt,Action<IActionController> onFinish = null)
public static bool UpdateAction(this IActionExecutor self,IActionController controller,float dt,Action<IActionController> onFinish = null)
{
if (!action.Deinited && action.Execute(dt))
if (!controller.Action.Deinited && controller.Action.Execute(dt))
{
onFinish?.Invoke(new ActionController()
{
Action = action,
ActionID = action.ActionID
});
onFinish?.Invoke(controller);

action.Deinit();
controller.Deinit();
return true;
}

return action.Deinited;
return controller.Action.Deinited;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/****************************************************************************
* Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License
* Copyright (c) 2015 - 2024 liangxiegame UNDER MIT License
*
* http://qframework.cn
* https://qframework.cn
* https://github.com/liangxiegame/QFramework
* https://gitee.com/liangxiegame/QFramework
****************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/****************************************************************************
* Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License
* Copyright (c) 2015 - 2024 liangxiegame UNDER MIT License
*
* http://qframework.cn
* https://qframework.cn
* https://github.com/liangxiegame/QFramework
* https://gitee.com/liangxiegame/QFramework
****************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/****************************************************************************
* Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License
* Copyright (c) 2015 - 2024 liangxiegame UNDER MIT License
*
* http://qframework.cn
* https://qframework.cn
* https://github.com/liangxiegame/QFramework
* https://gitee.com/liangxiegame/QFramework
****************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/****************************************************************************
* Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License
* Copyright (c) 2015 - 2024 liangxiegame UNDER MIT License
*
* http://qframework.cn
* https://qframework.cn
* https://github.com/liangxiegame/QFramework
* https://gitee.com/liangxiegame/QFramework
****************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/****************************************************************************
* Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License
* Copyright (c) 2015 - 2024 liangxiegame UNDER MIT License
*
* http://qframework.cn
* https://qframework.cn
* https://github.com/liangxiegame/QFramework
* https://gitee.com/liangxiegame/QFramework
****************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/****************************************************************************
* Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License
* Copyright (c) 2015 - 2024 liangxiegame UNDER MIT License
*
* http://qframework.cn
* https://qframework.cn
* https://github.com/liangxiegame/QFramework
* https://gitee.com/liangxiegame/QFramework
****************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/****************************************************************************
* Copyright (c) 2016 - 2023 liangxiegame UNDER MIT License
* Copyright (c) 2016 - 2024 liangxiegame UNDER MIT License
*
* http://qframework.cn
* https://qframework.cn
* https://github.com/liangxiegame/QFramework
* https://gitee.com/liangxiegame/QFramework
****************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/****************************************************************************
* Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License
* Copyright (c) 2015 - 2024 liangxiegame UNDER MIT License
*
* http://qframework.cn
* https://qframework.cn
* https://github.com/liangxiegame/QFramework
* https://gitee.com/liangxiegame/QFramework
****************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/****************************************************************************
* Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License
* Copyright (c) 2015 - 2024 liangxiegame UNDER MIT License
*
* http://qframework.cn
* https://qframework.cn
* https://github.com/liangxiegame/QFramework
* https://gitee.com/liangxiegame/QFramework
****************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/****************************************************************************
* Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License
* Copyright (c) 2015 - 2024 liangxiegame UNDER MIT License
*
* http://qframework.cn
* https://qframework.cn
* https://github.com/liangxiegame/QFramework
* https://gitee.com/liangxiegame/QFramework
****************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 2015 - 2023 liangxiegame UNDER MIT License
* Copyright (c) 2015 - 2024 liangxiegame UNDER MIT License
*
* https://qframework.cn
* https://github.com/liangxiegame/QFramework
Expand Down
Loading

0 comments on commit c4fcd88

Please sign in to comment.