Skip to content

Commit

Permalink
1.增加重启流程Procedure接口。2.增加进入热更域后的流程Procedure。
Browse files Browse the repository at this point in the history
1.增加重启流程Procedure接口。2.增加进入热更域后的流程Procedure。
  • Loading branch information
ALEXTANGXIAO committed Aug 26, 2023
1 parent 54214cd commit 04a43a3
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Assets/GameScripts/HotFix/GameLogic/GameApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static void Entrance(object[] objects)
Utility.Unity.AddDestroyListener(Instance.OnDestroy);
Utility.Unity.AddOnDrawGizmosListener(Instance.OnDrawGizmos);
Utility.Unity.AddOnApplicationPauseListener(Instance.OnApplicationPause);
GameModule.Procedure.RestartProcedure(new GameLogic.OnEnterGameAppProcedure());
Instance.StartGameLogic();
}

Expand All @@ -33,7 +34,7 @@ public static void Entrance(object[] objects)
/// </summary>
private void StartGameLogic()
{

}

/// <summary>
Expand Down
13 changes: 13 additions & 0 deletions Assets/GameScripts/HotFix/GameLogic/OnEnterGameAppProcedure.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using TEngine;

namespace GameLogic
{
public class OnEnterGameAppProcedure : ProcedureBase
{
protected override void OnEnter(IFsm<IProcedureManager> procedureOwner)
{
base.OnEnter(procedureOwner);
Log.Debug("OnEnter GameApp Procedure");
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/GameScripts/Main/Procedure/ProcedureLoadAssembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ protected override void OnUpdate(IFsm<IProcedureManager> procedureOwner, float e

private void AllAssemblyLoadComplete()
{
ChangeState<ProcedureStartGame>(m_procedureOwner);
#if UNITY_EDITOR
m_MainLogicAssembly = AppDomain.CurrentDomain.GetAssemblies().
First(assembly => $"{assembly.GetName().Name}.dll" == SettingsUtils.HybridCLRCustomGlobalSettings.LogicMainDllName);
Expand All @@ -139,7 +140,6 @@ private void AllAssemblyLoadComplete()
}
object[] objects = new object[] { new object[] { m_HotfixAssemblys } };
entryMethod.Invoke(appType, objects);
ChangeState<ProcedureStartGame>(m_procedureOwner);
}

private Assembly GetMainLogicAssembly()
Expand Down
36 changes: 31 additions & 5 deletions Assets/TEngine/Runtime/GameFramework/Procedure/ProcedureModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ public sealed class ProcedureModule : GameFrameworkModuleBase
private IProcedureManager m_ProcedureManager = null;
private ProcedureBase m_EntranceProcedure = null;

[SerializeField]
private string[] m_AvailableProcedureTypeNames = null;
[SerializeField] private string[] m_AvailableProcedureTypeNames = null;

[SerializeField]
private string m_EntranceProcedureTypeName = null;
[SerializeField] private string m_EntranceProcedureTypeName = null;

/// <summary>
/// 获取当前流程。
Expand All @@ -30,6 +28,7 @@ public ProcedureBase CurrentProcedure
{
return null;
}

return m_ProcedureManager.CurrentProcedure;
}
}
Expand All @@ -45,6 +44,7 @@ public float CurrentProcedureTime
{
return 0f;
}

return m_ProcedureManager.CurrentProcedureTime;
}
}
Expand Down Expand Up @@ -140,5 +140,31 @@ public ProcedureBase GetProcedure(Type procedureType)
{
return m_ProcedureManager.GetProcedure(procedureType);
}

/// <summary>
/// 重启流程。
/// <remarks>默认使用第一个流程作为启动流程。</remarks>
/// </summary>
/// <param name="procedures">新的的流程。</param>
/// <returns>是否重启成功。</returns>
/// <exception cref="GameFrameworkException">重启异常。</exception>
public bool RestartProcedure(params ProcedureBase[] procedures)
{
if (procedures == null || procedures.Length <= 0)
{
throw new GameFrameworkException("RestartProcedure Failed procedures is invalid.");
}

if (!GameModule.Fsm.DestroyFsm<IProcedureManager>())
{
return false;
}
m_ProcedureManager = null;
m_ProcedureManager = GameFrameworkModuleSystem.GetModule<IProcedureManager>();
IFsmManager fsmManager = GameFrameworkModuleSystem.GetModule<IFsmManager>();
m_ProcedureManager.Initialize(fsmManager, procedures);
m_ProcedureManager.StartProcedure(procedures[0].GetType());
return true;
}
}
}
}

0 comments on commit 04a43a3

Please sign in to comment.