WIP: remove singleton of CECWorld, rename CECGameRun's file
This commit is contained in:
@@ -109,7 +109,8 @@ public class CECPendingLogoutHalf : CECPendingAction
|
||||
bool bSuccess = false;
|
||||
if (IsInGame())
|
||||
{
|
||||
GetGameSession().SendPlayerLogout(PendingActionConstants._PLAYER_LOGOUT_HALF);
|
||||
// GetGameSession().SendPlayerLogout(PendingActionConstants._PLAYER_LOGOUT_HALF);
|
||||
UnityGameSession.ReturnToSelectRole();
|
||||
bSuccess = true;
|
||||
}
|
||||
return bSuccess;
|
||||
@@ -128,7 +129,9 @@ public class CECPendingLogoutFull : CECPendingAction
|
||||
bool bSuccess = false;
|
||||
if (IsInGame())
|
||||
{
|
||||
GetGameSession().SendPlayerLogout(PendingActionConstants._PLAYER_LOGOUT_FULL);
|
||||
// C++ code: GetGameSession()->SendPlayerLogout(PendingActionConstants::_PLAYER_LOGOUT_FULL);
|
||||
// GetGameSession().SendPlayerLogout(PendingActionConstants._PLAYER_LOGOUT_FULL);
|
||||
UnityGameSession.LogoutAccount();
|
||||
bSuccess = true;
|
||||
}
|
||||
return bSuccess;
|
||||
@@ -147,8 +150,9 @@ public class CECPendingSellingRole : CECPendingAction
|
||||
bool bSuccess = false;
|
||||
if (IsInGame())
|
||||
{
|
||||
GetGameSession().SendPlayerLogout(PendingActionConstants._PLAYER_LOGOUT_HALF);
|
||||
GetGameRun().SetSellingRoleID(GetHostPlayer().GetCharacterID());
|
||||
// GetGameSession().SendPlayerLogout(PendingActionConstants._PLAYER_LOGOUT_HALF);
|
||||
// GetGameRun().SetSellingRoleID(GetHostPlayer().GetCharacterID());
|
||||
UnityGameSession.ReturnToSelectRole();
|
||||
bSuccess = true;
|
||||
}
|
||||
return bSuccess;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BrewMonster.Scripts
|
||||
{
|
||||
public interface ITickable
|
||||
{
|
||||
bool Tick(uint dwDeltaTime);
|
||||
}
|
||||
|
||||
|
||||
public class TickInvoker : MonoSingleton<TickInvoker>
|
||||
{
|
||||
List<ITickable> tickables = new List<ITickable>();
|
||||
|
||||
public void RegisterTickable(ITickable tickable)
|
||||
{
|
||||
if (!tickables.Contains(tickable))
|
||||
tickables.Add(tickable);
|
||||
}
|
||||
|
||||
public void UnregisterTickable(ITickable tickable)
|
||||
{
|
||||
tickables.Remove(tickable);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
for (int i=0; i<tickables.Count; i++)
|
||||
{
|
||||
tickables[i].Tick( (uint)(Time.deltaTime * 1000)); // Convert to milliseconds
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94ae88742bf5484ea9a61c2f850f9e18
|
||||
timeCreated: 1772424967
|
||||
@@ -841,7 +841,7 @@ public class CECNPCMan : IMsgHandler
|
||||
}
|
||||
}
|
||||
// Set born stamp & born-in-sight (giữ nguyên semantics)
|
||||
uint bornStamp = CECWorld.Instance.GetBornStamp();
|
||||
uint bornStamp = CECGameRun.Instance.GetWorld().GetBornStamp();
|
||||
|
||||
if (!object.ReferenceEquals(pNPC, null))
|
||||
{
|
||||
|
||||
@@ -245,7 +245,7 @@ namespace PerfectWorld.Scripts.Managers
|
||||
Debug.LogError($"Failed to create matter: {info.mid}");
|
||||
return false;
|
||||
}
|
||||
pMatter.SetBornStamp(CECWorld.Instance.GetBornStamp());
|
||||
pMatter.SetBornStamp(CECGameRun.Instance.GetWorld().GetBornStamp());
|
||||
m_MatterTab[info.mid] = pMatter;
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using BrewMonster.Network;
|
||||
using BrewMonster.Network;
|
||||
using BrewMonster.Scripts;
|
||||
using CSNetwork.GPDataType;
|
||||
using System;
|
||||
@@ -392,8 +392,9 @@ namespace BrewMonster
|
||||
EC_CDR.OnGroundMove(ref cdr);
|
||||
BMLogger.LogError($"HoangDev: FlashMove seg={i} stepTime={cdr.t} center=({cdr.vCenter})");
|
||||
|
||||
if (CECWorld.Instance.GetAssureMove() != null)
|
||||
CECWorld.Instance.GetAssureMove().NoAssureMove();
|
||||
var world = CECGameRun.Instance?.GetWorld();
|
||||
if (world?.GetAssureMove() != null)
|
||||
world.GetAssureMove().NoAssureMove();
|
||||
|
||||
if ((cdr.vCenter - vStartPos).Magnitude() >= fDist * 0.98f)
|
||||
{
|
||||
|
||||
@@ -896,7 +896,7 @@ namespace BrewMonster
|
||||
public static bool CollideWithTerrain(A3DVECTOR3 vStart, A3DVECTOR3 vDelta, ref float fFraction, ref A3DVECTOR3 vHitNormal, ref bool bStart)
|
||||
{
|
||||
|
||||
CECWorld pWorld = CECWorld.Instance; //g_pGame.GetGameRun().GetWorld();
|
||||
CECWorld pWorld = CECGameRun.Instance.GetWorld(); //g_pGame.GetGameRun().GetWorld();
|
||||
A3DTerrain2 pTerrain = pWorld.GetTerrain();
|
||||
bStart = false;
|
||||
float h1 = pTerrain.GetPosHeight(vStart, ref vHitNormal);
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace CSNetwork
|
||||
{
|
||||
private static IPrefixedLogger
|
||||
_logger = LoggerFactory.GetLogger(nameof(GameSession)); // Get class-specific logger
|
||||
|
||||
private NetworkManager _networkManager;
|
||||
private string _host;
|
||||
private int _port;
|
||||
@@ -571,7 +570,8 @@ namespace CSNetwork
|
||||
break;
|
||||
case ProtocolType.PROTOCOL_GETUICONFIG_RE: OnPrtcGetConfigRe(protocol); break;
|
||||
case ProtocolType.PROTOCOL_PLAYERLOGOUT:
|
||||
HandlePlayerLogout((playerlogout)protocol);
|
||||
// HandlePlayerLogout((playerlogout)protocol);
|
||||
OnPrtcPlayerLogout((playerlogout)protocol);
|
||||
break;
|
||||
|
||||
case ProtocolType.PROTOCOL_AUTOTEAMSETGOAL_RE:
|
||||
@@ -590,11 +590,52 @@ namespace CSNetwork
|
||||
|
||||
private void HandlePlayerLogout(playerlogout protocol)
|
||||
{
|
||||
// old code of HUNGDK
|
||||
// Original client receives this before EVENT_DISCONNECT.
|
||||
// We just publish it to allow higher-level flow (UnityGameSession/UI) to react.
|
||||
PostToUnityContext(() => PlayerLogoutReceived?.Invoke(protocol));
|
||||
// PostToUnityContext(() => PlayerLogoutReceived?.Invoke(protocol));
|
||||
}
|
||||
|
||||
// void CECGameSession::OnPrtcPlayerLogout(GNET::Protocol* pProtocol)
|
||||
// {
|
||||
// using namespace GNET;
|
||||
// PlayerLogout* p = (PlayerLogout*)pProtocol;
|
||||
void OnPrtcPlayerLogout(playerlogout protocol)
|
||||
{
|
||||
// m_CmdCache.RemoveAllCmds();
|
||||
m_CmdCache.RemoveAllCmds();
|
||||
|
||||
// int iFlag;
|
||||
// switch (p->result)
|
||||
// {
|
||||
// case _PLAYER_LOGOUT_FULL: iFlag = 0; break;
|
||||
// case _PLAYER_LOGOUT_HALF: iFlag = 1; break;
|
||||
// default: iFlag = 2; break;
|
||||
// }
|
||||
int iFlag;
|
||||
switch (protocol.Result)
|
||||
{
|
||||
case PendingActionConstants._PLAYER_LOGOUT_FULL: iFlag = 0; break;
|
||||
case PendingActionConstants._PLAYER_LOGOUT_HALF: iFlag = 1; break;
|
||||
default: iFlag = 2; break;
|
||||
}
|
||||
|
||||
// g_pGame->GetGameRun()->SetLogoutFlag(iFlag);
|
||||
EC_Game.GetGameRun().SetLogoutFlag(iFlag);
|
||||
|
||||
// if (!IsConnected() && g_pGame->GetGameRun()->GetLogoutFlag() == 1)
|
||||
// {
|
||||
// a_LogOutput(1, "CECGameSession::OnPrtcPlayerLogout, LogoutFlag=1 replaced by 2.");
|
||||
// g_pGame->GetGameRun()->SetLogoutFlag(2);
|
||||
// }
|
||||
if (!IsConnected && EC_Game.GetGameRun().GetLogoutFlag() == 1)
|
||||
{
|
||||
// _logger.Log(LogType.Log, "CECGameSession::OnPrtcPlayerLogout, LogoutFlag=1 replaced by 2.");
|
||||
EC_Game.GetGameRun().SetLogoutFlag(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void HandleServerDataSend(gamedatasend protocol)
|
||||
{
|
||||
int lenghtHeader = Marshal.SizeOf<ushort>();
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace BrewMonster.Network
|
||||
public static void LogoutAccount()
|
||||
{
|
||||
if (Instance == null) return;
|
||||
_ = Instance.LogoutAndReturnAsync(outType: 0, entryTarget: LogoutFlowState.LoginEntryTarget.LoginUI, clearSavedCreds: true);
|
||||
_ = Instance.LogoutAndReturnAsync(outType: 0, entryTarget: LogoutFlowState.LoginEntryTarget.LoginUI, clearSavedCreds: false);
|
||||
}
|
||||
public static void c2s_CmdCastSkill(int idSkill, byte byPVPMask, int iNumTarget, int[] aTargets)
|
||||
{
|
||||
|
||||
@@ -877,7 +877,7 @@ namespace BrewMonster.Scripts.Task
|
||||
pos[1] = vPos.y;
|
||||
pos[2] = vPos.z;
|
||||
}
|
||||
var world = World.CECWorld.Instance;
|
||||
var world = CECGameRun.Instance.GetWorld();
|
||||
return world != null ? world.GetInstanceID() : 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace BrewMonster.UI
|
||||
m_TargetPos = EC_Game.GetGameRun().GetHostPlayer().GetObjectCoordinates(
|
||||
idTarget, out m_Targets, ref bInTable);
|
||||
//todo: add map feature here.
|
||||
if(!bInTable /*&& MAJOR_MAP== CECWorld.Instance.GetInstanceID())*/)
|
||||
if(!bInTable /*&& MAJOR_MAP== CECGameRun.Instance.GetWorld().GetInstanceID())*/)
|
||||
{
|
||||
ATaskTemplMan pMan = EC_Game.GetTaskTemplateMan();
|
||||
if(pMan.TryGetTaskNPCInfo((uint)idTarget, out NPC_INFO pInfo))
|
||||
|
||||
@@ -152,10 +152,10 @@ namespace BrewMonster.Scripts.Task.UI
|
||||
{
|
||||
idWorld = gameRun.GetWorld().GetInstanceID();
|
||||
}
|
||||
else if (CECWorld.Instance != null)
|
||||
else if (CECGameRun.Instance?.GetWorld() != null)
|
||||
{
|
||||
idWorld = CECWorld.Instance.GetInstanceID();
|
||||
}
|
||||
idWorld = CECGameRun.Instance.GetWorld().GetInstanceID();
|
||||
}
|
||||
if (IsShow())
|
||||
{ // �ѽ�������Ϣ��ʵʱ����
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace BrewMonster.Scripts.Task.UI
|
||||
public void AppendCommand(int worldid, Task_Region[] pRegions, int size)
|
||||
{
|
||||
List<OBJECT_COORD> instCoord = new List<OBJECT_COORD>(), tempCoord = new List<OBJECT_COORD>();
|
||||
int cur = CECWorld.Instance.GetInstanceID();
|
||||
int cur = CECGameRun.Instance?.GetWorld()?.GetInstanceID() ?? 161;
|
||||
CECInstance pInstance = EC_Game.GetGameRun().GetInstance(cur);
|
||||
string strCurMap = pInstance.GetPath();
|
||||
// find the entrance of instance
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace BrewMonster.UI
|
||||
|
||||
return;
|
||||
UnityGameSession.ReturnToSelectRole();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ using UnityEngine;
|
||||
|
||||
namespace BrewMonster.Scripts.World
|
||||
{
|
||||
public class CECWorld : Singleton<CECWorld>
|
||||
public class CECWorld
|
||||
{
|
||||
protected A3DTerrain2 m_pA3DTerrain;
|
||||
CECOrnamentMan m_pOnmtMan;
|
||||
@@ -93,5 +93,98 @@ namespace BrewMonster.Scripts.World
|
||||
{
|
||||
return EC_ManMessageMono.Instance.GetECManPlayer;
|
||||
}
|
||||
|
||||
|
||||
// Release object
|
||||
public void Release()
|
||||
{
|
||||
// TODO: Release world resources in the correct order, currently just a placeholder to avoid compile errors. The actual release logic should closely follow the original C++ code to ensure proper cleanup and resource management.
|
||||
// Release auto home
|
||||
// ReleaseAutoHome(); // Not open comment, this same in C++
|
||||
// CECIntelligentRoute::Instance().Release(); // TODO
|
||||
|
||||
// Release CDS object
|
||||
// if (m_pCDS)
|
||||
// {
|
||||
// g_pGame->GetA3DEngine()->SetA3DCDS(NULL);
|
||||
// delete m_pCDS;
|
||||
// m_pCDS = NULL;
|
||||
// }
|
||||
|
||||
// Release nature objects
|
||||
// ReleaseNatureObjects(); //TODO
|
||||
|
||||
// Release scene before managers
|
||||
// ReleaseScene();
|
||||
|
||||
// Release managers
|
||||
// ReleaseManagers();
|
||||
|
||||
// force to release all loaded resource
|
||||
// ThreadRemoveAllLoaded();
|
||||
|
||||
// if (m_pPrecinctSet)
|
||||
// {
|
||||
// delete m_pPrecinctSet;
|
||||
// m_pPrecinctSet = NULL;
|
||||
// }
|
||||
//
|
||||
// if (m_pRegionSet)
|
||||
// {
|
||||
// delete m_pRegionSet;
|
||||
// m_pRegionSet = NULL;
|
||||
// }
|
||||
//
|
||||
// if (m_pSceneLights)
|
||||
// {
|
||||
// delete m_pSceneLights;
|
||||
// m_pSceneLights = NULL;
|
||||
// }
|
||||
//
|
||||
// if (m_pAssureMove)
|
||||
// {
|
||||
// m_pAssureMove->ReleaseMap();
|
||||
// delete m_pAssureMove;
|
||||
// m_pAssureMove = NULL;
|
||||
// }
|
||||
//
|
||||
// m_dwBornStamp = 1;
|
||||
}
|
||||
|
||||
// Release current scene
|
||||
void ReleaseScene()
|
||||
{
|
||||
// g_pGame->GetA3DEngine()->SetSky(NULL);
|
||||
//
|
||||
// A3DRELEASE(m_pScene);
|
||||
// A3DRELEASE(m_pGrassLand);
|
||||
// A3DRELEASE(m_pForest);
|
||||
// A3DRELEASE(m_pA3DSky);
|
||||
//
|
||||
// // 1. force to exit loader thread
|
||||
// ExitLoaderThread();
|
||||
//
|
||||
// // 2. release manager
|
||||
// for (int i=0; i < NUM_MANAGER; i++)
|
||||
// {
|
||||
// if (m_aManagers[i])
|
||||
// m_aManagers[i]->OnLeaveGameWorld();
|
||||
// }
|
||||
//
|
||||
// // 3. force to release all loaded resource
|
||||
// ThreadRemoveAllLoaded();
|
||||
//
|
||||
// // Release terrain after loading thread has been ended
|
||||
// A3DRELEASE(m_pA3DTrnCuller);
|
||||
// A3DRELEASE(m_pA3DTerrainWater);
|
||||
// A3DRELEASE(m_pA3DTerrain);
|
||||
// A3DRELEASE(m_pTerrainOutline);
|
||||
// A3DRELEASE(m_pCloudManager);
|
||||
//
|
||||
// m_bWorldLoaded = false;
|
||||
//
|
||||
// // ɾ³ýËæ»úµØÍ¼ÐÅÏ¢
|
||||
// CECRandomMapProcess::DeleteAllRandomMapDataForSingleUser();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5de219a5b9756ae4ebf01e2919b92cde
|
||||
@@ -447,7 +447,7 @@ namespace BrewMonster
|
||||
// Ensure we are not under ground
|
||||
// 确保我们不在地下
|
||||
A3DVECTOR3 vNormal = new A3DVECTOR3();
|
||||
float vTerrainHeight = CECWorld.Instance.GetTerrainHeight(vPos, ref vNormal);
|
||||
float vTerrainHeight = CECGameRun.Instance.GetWorld().GetTerrainHeight(vPos, ref vNormal);
|
||||
if (vPos.y < vTerrainHeight)
|
||||
vPos.y = vTerrainHeight;
|
||||
|
||||
@@ -507,7 +507,7 @@ namespace BrewMonster
|
||||
// Ensure we are not under ground
|
||||
// 确保我们不在地下
|
||||
A3DVECTOR3 vNormal = new A3DVECTOR3();
|
||||
float vTerrainHeight = CECWorld.Instance.GetTerrainHeight(vPos, ref vNormal);
|
||||
float vTerrainHeight = CECGameRun.Instance.GetWorld().GetTerrainHeight(vPos, ref vNormal);
|
||||
if (vPos.y < vTerrainHeight)
|
||||
vPos.y = vTerrainHeight;
|
||||
|
||||
|
||||
@@ -853,7 +853,7 @@ namespace BrewMonster
|
||||
break;
|
||||
|
||||
// Get target object
|
||||
CECObject pObject = CECWorld.Instance.GetObject(idTarget, 0);
|
||||
CECObject pObject = CECGameRun.Instance.GetWorld().GetObject(idTarget, 0);
|
||||
if (pObject == null) break;
|
||||
|
||||
A3DVECTOR3 vHostPos = EC_Utility.ToA3DVECTOR3(transform.position); // GetPos()
|
||||
|
||||
@@ -747,7 +747,7 @@ namespace BrewMonster
|
||||
while (true)
|
||||
{
|
||||
A3DVECTOR3 refake = new A3DVECTOR3();
|
||||
float terrianHeight = CECWorld.Instance.GetTerrainHeight(vTargetPos, ref refake);
|
||||
float terrianHeight = CECGameRun.Instance.GetWorld().GetTerrainHeight(vTargetPos, ref refake);
|
||||
if (terrianHeight > vTargetPos.y + 1E-4f)
|
||||
break;
|
||||
|
||||
@@ -945,7 +945,7 @@ namespace BrewMonster
|
||||
bool bFound = false;
|
||||
vPos = default;
|
||||
|
||||
CECWorld world = CECWorld.Instance;
|
||||
CECWorld world = CECGameRun.Instance.GetWorld();
|
||||
if (world == null)
|
||||
{
|
||||
return false;
|
||||
@@ -1020,7 +1020,7 @@ namespace BrewMonster
|
||||
// ×¢Ò⣺vPos ±»µ÷Õûºó£¬ÓпÉÄÜ´¦ÓÚ͹°üÖУ»Ðè¼ì²é·µ»Ø¸ß¶Èµ÷ÕûÖµ£¬ÒÔ±ÜÃâµ÷Õû¹ý´ó (Beware of large adjustments placing us back into brushes)
|
||||
|
||||
A3DVECTOR3 vTemp = new A3DVECTOR3(vPos);
|
||||
CECWorld world = CECWorld.Instance;
|
||||
CECWorld world = CECGameRun.Instance.GetWorld();
|
||||
if (world == null)
|
||||
{
|
||||
return vTemp.y;
|
||||
@@ -3734,7 +3734,173 @@ namespace BrewMonster
|
||||
//private bool ISNPCID(int id) => ((id & 0x80000000) != 0) && ((id & 0x40000000) == 0);
|
||||
//private bool ISPLAYERID(int id) => id != 0 && (id & 0x80000000) == 0;
|
||||
//private bool ISMATTERID(int id) => ((id) & 0xC0000000) == 0xC0000000;
|
||||
}
|
||||
|
||||
// Release object
|
||||
public void Release()
|
||||
{
|
||||
// TODO: Release all objects created by player, such as inventory, skills, etc.
|
||||
// CECInstanceReenter::Instance().Clear();
|
||||
// CECShoppingItemsMover::Instance().Clear();
|
||||
// CECFashionShopManager::Instance().Clear();
|
||||
// CECShoppingManager::Instance().Clear();
|
||||
// CECUseUniversalTokenCommandManager::Instance().Clear();
|
||||
// CECUniversalTokenHTTPOSNavigatorTicketHandler::Instance().Clear();
|
||||
// RandMallShoppingManager::Instance().Release();
|
||||
// CECFactionPVPModel::Instance().Clear();
|
||||
// CECHostSkillModel::Instance().Release();
|
||||
// CECComboSkillState::Instance().Release();
|
||||
// CECPlayerLevelRankRealmChangeCheck::Instance().Release();
|
||||
// CECHostFashionEquipFromStorageSystem::Instance().Clear();
|
||||
//
|
||||
// m_pSaveLifeTrigger = NULL;
|
||||
// CECQuickBuyPopManager::Instance().ClearPolicies();
|
||||
//
|
||||
// // Ïú»ÙPlayerWrapper
|
||||
// CECAutoPolicy::GetInstance().OnLeaveWorld();
|
||||
//
|
||||
// // Save favorite auction list first
|
||||
// SaveFavorAucItems();
|
||||
//
|
||||
// // Release duel images
|
||||
// ReleaseDuelImages();
|
||||
//
|
||||
// // Release sounds
|
||||
// g_pGame->GetGameRun()->ReleaseSoundTable();
|
||||
// m_pCurMoveSnd = NULL;
|
||||
//
|
||||
// // Release friend manger
|
||||
// if (m_pFriendMan)
|
||||
// {
|
||||
// delete m_pFriendMan;
|
||||
// m_pFriendMan = NULL;
|
||||
// }
|
||||
//
|
||||
// // Release pet corral
|
||||
// if (m_pPetCorral)
|
||||
// {
|
||||
// delete m_pPetCorral;
|
||||
// m_pPetCorral = NULL;
|
||||
// }
|
||||
//
|
||||
// if (m_pPetWords)
|
||||
// {
|
||||
// delete m_pPetWords;
|
||||
// m_pPetWords = NULL;
|
||||
// }
|
||||
//
|
||||
// if (m_pForceMgr)
|
||||
// {
|
||||
// delete m_pForceMgr;
|
||||
// m_pForceMgr = NULL;
|
||||
// }
|
||||
//
|
||||
// if (m_pOnlineAwardCtrl)
|
||||
// {
|
||||
// delete m_pOnlineAwardCtrl;
|
||||
// m_pOnlineAwardCtrl = NULL;
|
||||
// }
|
||||
//
|
||||
// if (m_pOffShopCtrl)
|
||||
// {
|
||||
// delete m_pOffShopCtrl;
|
||||
// m_pOffShopCtrl = NULL;
|
||||
// }
|
||||
//
|
||||
// if (m_pAutoTeam)
|
||||
// {
|
||||
// delete m_pAutoTeam;
|
||||
// m_pAutoTeam = NULL;
|
||||
// }
|
||||
//
|
||||
// if (m_pChariot)
|
||||
// {
|
||||
// delete m_pChariot;
|
||||
// m_pChariot = NULL;
|
||||
// }
|
||||
//
|
||||
// int i;
|
||||
//
|
||||
// // Release all shortcuts
|
||||
// for (i=0; i < NUM_HOSTSCSETS1; i++)
|
||||
// A3DRELEASE(m_aSCSets1[i]);
|
||||
//
|
||||
// for (i=0; i < NUM_HOSTSCSETS2; i++)
|
||||
// A3DRELEASE(m_aSCSets2[i]);
|
||||
//
|
||||
// for (i=0; i < NUM_SYSMODSETS; i++)
|
||||
// A3DRELEASE(m_aSCSetSysMod[i]);
|
||||
//
|
||||
// // Release all inventories
|
||||
// A3DRELEASE(m_pPack);
|
||||
// A3DRELEASE(m_pEquipPack);
|
||||
// A3DRELEASE(m_pTrashBoxPack);
|
||||
// A3DRELEASE(m_pTrashBoxPack2);
|
||||
// A3DRELEASE(m_pTrashBoxPack3);
|
||||
// A3DRELEASE(m_pAccountBoxPack);
|
||||
// A3DRELEASE(m_pGeneralCardPack);
|
||||
// A3DRELEASE(m_pTaskPack);
|
||||
// A3DRELEASE(m_pDealPack);
|
||||
// A3DRELEASE(m_pEPDealPack);
|
||||
// A3DRELEASE(m_pTaskInterface);
|
||||
// A3DRELEASE(m_pSpritePortrait);
|
||||
// A3DRELEASE(m_pBuyPack);
|
||||
// A3DRELEASE(m_pSellPack);
|
||||
// A3DRELEASE(m_pBoothSPack);
|
||||
// A3DRELEASE(m_pBoothBPack);
|
||||
// A3DRELEASE(m_pEPBoothSPack);
|
||||
// A3DRELEASE(m_pEPBoothBPack);
|
||||
// A3DRELEASE(m_pEPEquipPack);
|
||||
// A3DRELEASE(m_pClientGenCardPack);
|
||||
//
|
||||
// for (i=0; i < NUM_NPCIVTR; i++)
|
||||
// {
|
||||
// A3DRELEASE(m_aNPCPacks[i]);
|
||||
// }
|
||||
//
|
||||
// // Release all skills
|
||||
// ReleaseSkills();
|
||||
//
|
||||
// // Clear current combo skill
|
||||
// ClearComboSkill();
|
||||
//
|
||||
// if (m_pWorkMan)
|
||||
// {
|
||||
// delete m_pWorkMan;
|
||||
// m_pWorkMan = NULL;
|
||||
// }
|
||||
//
|
||||
// m_CameraCtrl.Release();
|
||||
//
|
||||
// m_aTeamInvs.RemoveAll();
|
||||
//
|
||||
// g_pGame->GetGFXCaster()->ReleaseGFXEx(m_pMoveTargetGFX);
|
||||
// g_pGame->GetGFXCaster()->ReleaseGFXEx(m_pSelectedGFX);
|
||||
// g_pGame->GetGFXCaster()->ReleaseGFXEx(m_pHoverGFX);
|
||||
// g_pGame->GetGFXCaster()->ReleaseGFXEx(m_pFloatDust);
|
||||
//
|
||||
// m_pMoveTargetGFX = NULL;
|
||||
// m_pSelectedGFX = NULL;
|
||||
// m_pHoverGFX = NULL;
|
||||
// m_pFloatDust = NULL;
|
||||
//
|
||||
// // Clear tab select table
|
||||
// m_aTabSels.RemoveAll(false);
|
||||
//
|
||||
// m_aForceInfo.RemoveAll();
|
||||
//
|
||||
// if (m_pActionSwitcher)
|
||||
// {
|
||||
// delete m_pActionSwitcher;
|
||||
// m_pActionSwitcher = NULL;
|
||||
// }
|
||||
//
|
||||
// CECQShopConfig::Instance().ClearBuyedItem();
|
||||
//
|
||||
// A3DRELEASE(m_pNavigatePlayer);
|
||||
//
|
||||
// CECPlayer::Release();
|
||||
}
|
||||
}
|
||||
public sealed class CECHPTraceSpellMatcher : CECHPWorkMatcher
|
||||
{
|
||||
public override bool Match(CECHPWork pWork, int priority, bool isDelayWork)
|
||||
@@ -3748,5 +3914,8 @@ namespace BrewMonster
|
||||
return trace.GetTraceReason() == Trace_reason.TRACE_SPELL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,285 @@
|
||||
|
||||
using BrewMonster;
|
||||
using UnityEngine;
|
||||
|
||||
public partial class CECGameRun
|
||||
{
|
||||
int m_iGameState; // Game state
|
||||
// Logout flag (C++: m_iLogoutFlag)
|
||||
private int m_iLogoutFlag = -1;
|
||||
|
||||
// Logout
|
||||
public void Logout()
|
||||
{
|
||||
// ASSERT(m_iGameState == GS_GAME);
|
||||
if (m_iGameState != (int)GameState.GS_GAME)
|
||||
{
|
||||
BMLogger.LogError($"Logout called but game state is not GS_GAME, current state: {m_iGameState}");
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Check if we need to call OnLogout for UI and cross server here
|
||||
// overlay::GTOverlay::Instance().Logout();
|
||||
// CECCrossServer::Instance().OnLogout();
|
||||
|
||||
bool bExitApp = false;
|
||||
|
||||
// if (CECUIConfig::Instance().GetLoginUI().bAvoidLoginUI && m_iLogoutFlag != 1){
|
||||
if( 1 == 2 && m_iLogoutFlag != 1){ // TODO: check if we need to avoid login UI based on config and logout flag here
|
||||
bExitApp = true;
|
||||
}else if (m_iLogoutFlag == 0) // Exit application directly
|
||||
{
|
||||
bExitApp = true;
|
||||
}
|
||||
else if (m_iLogoutFlag == 1) // Logout game and re-select role
|
||||
{
|
||||
// TODO: Check if we need to send switch game for mini client here
|
||||
// Origin C++
|
||||
// StartLogin();
|
||||
StartLogin();
|
||||
|
||||
//
|
||||
// // ÏÂÔØÆ÷ÏìÓ¦Í˳öÓÎϷ״̬
|
||||
// if( g_pGame->GetConfigs()->IsMiniClient() )
|
||||
// CECMCDownload::GetInstance().SendSwitchGame(false);
|
||||
//
|
||||
// // Goto select role interface directly
|
||||
// CECLoginUIMan* pLoginUIMan = m_pUIManager->GetLoginUIMan();
|
||||
// if (pLoginUIMan)
|
||||
// {
|
||||
// if(GetSellingRoleID() == 0)
|
||||
// {
|
||||
// pLoginUIMan->LaunchCharacter();
|
||||
// }
|
||||
//
|
||||
// g_pGame->GetGameSession()->ReLogin(true);
|
||||
// pLoginUIMan->SetRoleListReady(false);
|
||||
// if (!CECReconnect::Instance().IsReconnecting()){
|
||||
// CECReconnect::Instance().SetRoleID(0);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ASSERT(pLoginUIMan);
|
||||
// bExitApp = true;
|
||||
// }
|
||||
}
|
||||
else if (m_iLogoutFlag == 2) // Logout game and goto login state
|
||||
{
|
||||
// TODO: Check if we need to send switch game for mini client here
|
||||
// Origin C++
|
||||
// StartLogin();
|
||||
|
||||
// if (CECLoginUIMan* pLoginUIMan = m_pUIManager->GetLoginUIMan()){
|
||||
// g_pGame->GetGameRun()->SetSellingRoleID(0);
|
||||
// g_pGame->GetGameSession()->ReLogin(false);
|
||||
// if (CECCrossServer::Instance().IsWaitLogin()){
|
||||
// pLoginUIMan->LaunchCharacter();
|
||||
// pLoginUIMan->ChangeSceneByRole();
|
||||
// pLoginUIMan->ReclickLoginButton();
|
||||
// }else if (CECReconnect::Instance().IsReconnecting()){
|
||||
// pLoginUIMan->ChangeCameraByScene(CECLoginUIMan::LOGIN_SCENE_SELCHAR);
|
||||
// pLoginUIMan->ReclickLoginButton();
|
||||
// }
|
||||
}
|
||||
else
|
||||
{
|
||||
// ASSERT(NULL);
|
||||
bExitApp = true;
|
||||
}
|
||||
|
||||
|
||||
// if (m_pRandomMapProc)
|
||||
// A3DRELEASE(m_pRandomMapProc);
|
||||
|
||||
// if (bExitApp)
|
||||
// {
|
||||
// // Exit game application
|
||||
// EndGameState(false);
|
||||
// ::PostMessage(g_pGame->GetGameInit().hWnd, WM_QUIT, 0, 0);
|
||||
// }
|
||||
}
|
||||
|
||||
// End current game state
|
||||
void EndGameState(bool bReset = true/* true */)
|
||||
{
|
||||
if (m_iGameState == (int)GameState.GS_NONE)
|
||||
return;
|
||||
|
||||
int iCurState = m_iGameState;
|
||||
m_iGameState = (int)GameState.GS_NONE;
|
||||
|
||||
// TODO: Check if we need to call OnEndLoginState or OnEndGameState based on current state
|
||||
if (iCurState == (int)GameState.GS_LOGIN)
|
||||
OnEndLoginState();
|
||||
else if (iCurState == (int)GameState.GS_GAME)
|
||||
OnEndGameState();
|
||||
|
||||
// Stop background sound and music
|
||||
// CELBackMusic* pBackMusic = g_pGame->GetBackMusic();
|
||||
// if (pBackMusic)
|
||||
// {
|
||||
// pBackMusic->StopMusic(true, true);
|
||||
// pBackMusic->StopBackSFX();
|
||||
// }
|
||||
|
||||
// if (bReset)
|
||||
// g_pGame.Reset();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Start login interface
|
||||
bool StartLogin()
|
||||
{
|
||||
// End current game state
|
||||
EndGameState();
|
||||
|
||||
m_iGameState = (int)GameState.GS_LOGIN;
|
||||
|
||||
// if( !CreateLoginWorld() )
|
||||
// {
|
||||
// a_LogOutput(1, "CECGameRun::StartLogin, Failed to create login world.");
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// // Change UI manager
|
||||
// if (!m_pUIManager->ChangeCurUIManager(CECUIManager::UIMAN_LOGIN))
|
||||
// {
|
||||
// a_LogOutput(1, "CECGameRun::StartLogin, Failed to change UI manager.");
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// m_pUIManager->GetLoginUIMan()->LaunchPreface();
|
||||
//
|
||||
// if (!m_pLogo){
|
||||
// m_pLogo = new A2DSprite;
|
||||
// if (!m_pLogo->Init(g_pGame->GetA3DDevice(), "logo.dds", 0)){
|
||||
// A3DRELEASE(m_pLogo);
|
||||
// }else{
|
||||
// m_pLogo->SetLinearFilter(true);
|
||||
// }
|
||||
// }
|
||||
// if (af_IsFileExist("surfaces\\kr.dds"))
|
||||
// {
|
||||
// if (!m_pClassification){
|
||||
// m_pClassification = new A2DSprite;
|
||||
// if (!m_pClassification->Init(g_pGame->GetA3DDevice(), "kr.dds", 0)){
|
||||
// A3DRELEASE(m_pClassification);
|
||||
// }else{
|
||||
// m_pClassification->SetLinearFilter(true);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // Change cursor to default icon
|
||||
// g_pGame->ChangeCursor(RES_CUR_NORMAL);
|
||||
// // Discard current frame
|
||||
// g_pGame->DiscardFrame();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// End login state
|
||||
void OnEndLoginState()
|
||||
{
|
||||
// Release UI module
|
||||
// m_pUIManager.ChangeCurUIManager(-1);
|
||||
|
||||
// Release World
|
||||
// ReleaseLoginWorld();
|
||||
|
||||
// A3DRELEASE(m_pLogo);
|
||||
// A3DRELEASE(m_pClassification);
|
||||
}
|
||||
|
||||
// End game state
|
||||
void OnEndGameState()
|
||||
{
|
||||
ReleasePendingActions();
|
||||
|
||||
// Release UI module
|
||||
// m_pUIManager.ChangeCurUIManager(-1);
|
||||
|
||||
// Release shortcuts
|
||||
ReleaseShortcuts();
|
||||
|
||||
// Release team manager
|
||||
// A3DRELEASE(m_pTeamMan);
|
||||
if (m_pTeamMan != null)
|
||||
{
|
||||
m_pTeamMan.Release();
|
||||
m_pTeamMan = null;
|
||||
}
|
||||
|
||||
// Release host player before world released
|
||||
ReleaseHostPlayer();
|
||||
|
||||
// Release world
|
||||
ReleaseWorld();
|
||||
|
||||
// Release message manager
|
||||
// A3DRELEASE(m_pMessageMan);
|
||||
|
||||
// g_pGame.ReleaseInGameRes();
|
||||
|
||||
// Return the default memory state
|
||||
// m_pMemSimplify.OnEndGameState();
|
||||
// CECOptimize::Instance().OnEndGameState();
|
||||
}
|
||||
|
||||
// Release shortcuts
|
||||
void ReleaseShortcuts()
|
||||
{
|
||||
// A3DRELEASE(m_pNormalSCS);
|
||||
// A3DRELEASE(m_pTeamSCS);
|
||||
// A3DRELEASE(m_pTradeSCS);
|
||||
// A3DRELEASE(m_pPoseSCS);
|
||||
// A3DRELEASE(m_pFactionSCS);
|
||||
|
||||
m_pNormalSCS = null;
|
||||
m_pTeamSCS = null;
|
||||
m_pTradeSCS = null;
|
||||
m_pPoseSCS = null;
|
||||
m_pFactionSCS = null;
|
||||
}
|
||||
|
||||
// Release host player
|
||||
void ReleaseHostPlayer()
|
||||
{
|
||||
// C++ version:
|
||||
// Release host player
|
||||
// if (m_pHostPlayer)
|
||||
// {
|
||||
// m_pHostPlayer->Release();
|
||||
// delete m_pHostPlayer;
|
||||
// m_pHostPlayer = NULL;
|
||||
// }
|
||||
|
||||
// Release host player
|
||||
if (m_pHostPlayer)
|
||||
{
|
||||
m_pHostPlayer.Release();
|
||||
GameObject.Destroy(m_pHostPlayer.gameObject);
|
||||
m_pHostPlayer = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Release world
|
||||
void ReleaseWorld()
|
||||
{
|
||||
// m_pInputCtrl->ClearKBFilterStack();
|
||||
// m_pInputCtrl->ClearMouFilterStack();
|
||||
//
|
||||
// g_pGame->GetViewport()->SwitchCamera(false);
|
||||
|
||||
if (m_pWorld != null)
|
||||
{
|
||||
// if (m_pHostPlayer)
|
||||
// m_pHostPlayer.SetPlayerMan(NULL);
|
||||
|
||||
this.m_pWorld.Release();
|
||||
// delete m_pWorld;
|
||||
m_pWorld = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b039014c898e4659adb7c90cc570b637
|
||||
timeCreated: 1772439168
|
||||
@@ -13,10 +13,12 @@ using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using PerfectWorld.Scripts.Shop;
|
||||
using Unity.Cinemachine;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public partial class CECGameRun
|
||||
public partial class CECGameRun : ITickable
|
||||
{
|
||||
private static CECGameRun instance;
|
||||
|
||||
@@ -39,9 +41,8 @@ public partial class CECGameRun
|
||||
|
||||
// private GameRunConfig _gameRunConfig;
|
||||
//[SerializeField] private Transform ground;
|
||||
CECHostPlayer hostPlayer;
|
||||
CECHostPlayer m_pHostPlayer;
|
||||
private CECWorld m_pWorld;
|
||||
int m_iGameState; // Game state
|
||||
|
||||
|
||||
protected CECUIManager m_pUIManager; // UI manager
|
||||
@@ -50,13 +51,13 @@ public partial class CECGameRun
|
||||
|
||||
#endregion
|
||||
|
||||
public CECWorld GetWorld()
|
||||
public CECWorld GetWorld()
|
||||
{
|
||||
if(m_pWorld == null)
|
||||
if (m_pWorld == null)
|
||||
{
|
||||
m_pWorld = CECWorld.Instance;
|
||||
m_pWorld = new CECWorld();
|
||||
}
|
||||
return m_pWorld;
|
||||
return m_pWorld;
|
||||
}
|
||||
|
||||
public CECTeamMan GetTeamMan() { return m_pTeamMan; }
|
||||
@@ -77,9 +78,7 @@ public partial class CECGameRun
|
||||
// Cache for SaveConfigsToServer: last sent config data to skip duplicate sends
|
||||
private byte[] m_pCfgDataBuf;
|
||||
private int m_iCfgDataSize;
|
||||
|
||||
// Logout flag (C++: m_iLogoutFlag)
|
||||
private int m_iLogoutFlag = -1;
|
||||
|
||||
// Selling role ID for role trade (C++: SetSellingRoleID/GetSellingRoleID)
|
||||
private int m_iSellingRoleID;
|
||||
|
||||
@@ -116,16 +115,19 @@ public partial class CECGameRun
|
||||
if (!m_InstTab.ContainsKey(161))
|
||||
m_InstTab.Add(161, new CECInstance());
|
||||
AddressableManager.Instance.OnDispose += Dispose;
|
||||
m_pWorld = CECWorld.Instance;
|
||||
if (m_pWorld == null)
|
||||
m_pWorld = new CECWorld();
|
||||
StartGame(0, Vector3.zero);
|
||||
|
||||
|
||||
m_pWorld = CECWorld.Instance;
|
||||
m_pendingLogout = new CECPendingActionArray( false);
|
||||
|
||||
TickInvoker.Instance.RegisterTickable(this);
|
||||
}
|
||||
|
||||
private static void Dispose()
|
||||
{
|
||||
TickInvoker.Instance.UnregisterTickable(instance);
|
||||
instance = null;
|
||||
}
|
||||
|
||||
@@ -172,6 +174,102 @@ public partial class CECGameRun
|
||||
}
|
||||
|
||||
init = true;
|
||||
|
||||
// TODO: Implement the rest of the StartGame logic based on the original C++ code, including:
|
||||
// End current game state
|
||||
EndGameState();
|
||||
//
|
||||
// memset(&m_WallowInfo, 0, sizeof(m_WallowInfo));
|
||||
m_iGameState = (int)GameState.GS_GAME;
|
||||
//
|
||||
// if (!g_pGame->LoadInGameRes())
|
||||
// {
|
||||
// a_LogOutput(1, "CECGameRun::StartGame, Failed to call LoadInGameRes().");
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// // Create message manager
|
||||
// if (!(m_pMessageMan = new CECMessageMan(this)))
|
||||
// {
|
||||
// glb_ErrorOutput(ECERR_NOTENOUGHMEMORY, "CECGameRun::StartGame", __LINE__);
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// // Create default game world
|
||||
// if (!JumpToInstance(idInst, vHostPos))
|
||||
// {
|
||||
// a_LogOutput(1, "CECGameRun::StartGame, Failed to create game world.");
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// // ÉèÖÿç·þ³É¹¦±êʶ£¬ÒÔÀûÓÚ CECGameUIMan ¸ù¾Ý¿ç·þ״̬×öÏàÓ¦³õʼ»¯
|
||||
// if (CECCrossServer::Instance().IsWaitLogin()){
|
||||
// CECCrossServer::Instance().OnLoginSuccess();
|
||||
// }
|
||||
// if (CECReconnect::Instance().IsReconnecting()){
|
||||
// CECReconnect::Instance().OnReconnectSuccess();
|
||||
// }
|
||||
//
|
||||
// // Create host player
|
||||
// if (!CreateHostPlayer())
|
||||
// {
|
||||
// a_LogOutput(1, "CECGameRun::StartGame, Failed to create host player.");
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// // Create team manager
|
||||
// if (!(m_pTeamMan = new CECTeamMan))
|
||||
// {
|
||||
// glb_ErrorOutput(ECERR_NOTENOUGHMEMORY, "CECGameRun::StartGame", __LINE__);
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// // Reset faction manager
|
||||
// g_pGame->GetFactionMan()->Release(false);
|
||||
//
|
||||
// // Create shortcuts
|
||||
// if (!CreateShortcuts())
|
||||
// {
|
||||
// a_LogOutput(1, "CECGameRun::StartGame, Failed to create shortcuts");
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// // Change UI manager
|
||||
// if (!m_pUIManager->ChangeCurUIManager(CECUIManager::UIMAN_INGAME))
|
||||
// {
|
||||
// a_LogOutput(1, "CECGameRun::StartGame, Failed to change UI manager.");
|
||||
// return false;
|
||||
// }
|
||||
// m_pInputFilter->LoadHotKey();
|
||||
//
|
||||
// CECGameUIMan* pGameUIMan = m_pUIManager->GetInGameUIMan();
|
||||
// if (pGameUIMan)
|
||||
// pGameUIMan->ChangeWorldInstance(idInst);
|
||||
//
|
||||
// l_SaveCfgCnt.Reset();
|
||||
//
|
||||
// // Change cursor to default icon
|
||||
// g_pGame->ChangeCursor(RES_CUR_NORMAL);
|
||||
// // Discard current frame
|
||||
// g_pGame->DiscardFrame();
|
||||
//
|
||||
// // Clear frame controller
|
||||
// memset(&l_fc, 0, sizeof (l_fc));
|
||||
//
|
||||
// // ³õʼ»¯ÍøÂçÑÓ³Ù²éѯ
|
||||
// l_bFirstQuery = true;
|
||||
// m_iInGameDelay = 0;
|
||||
// l_DelayQueryCounter.Reset();
|
||||
//
|
||||
// l_QueryServerTime.Reset();
|
||||
//
|
||||
// // clear the selling id
|
||||
// m_SellingRoleID = 0;
|
||||
//
|
||||
// // ÏÂÔØÆ÷ÏìÓ¦½øÈëÓÎϷ״̬
|
||||
// if( g_pGame->GetConfigs()->IsMiniClient() )
|
||||
// CECMCDownload::GetInstance().SendSwitchGame(true);
|
||||
//
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -192,9 +290,14 @@ public partial class CECGameRun
|
||||
}
|
||||
}
|
||||
|
||||
public CECGameRun()
|
||||
{
|
||||
m_iGameState = (int)GameState.GS_NONE;
|
||||
}
|
||||
|
||||
public CECHostPlayer GetHostPlayer()
|
||||
{
|
||||
return hostPlayer;
|
||||
return m_pHostPlayer;
|
||||
}
|
||||
public void InitCharacter(cmd_self_info_1 info)
|
||||
{
|
||||
@@ -218,19 +321,19 @@ public partial class CECGameRun
|
||||
m_InstTab.Add(idInst, new CECInstance());
|
||||
|
||||
// Update global world instance id used by task checks
|
||||
CECWorld.Instance?.SetInstanceID(idInst);
|
||||
CECGameRun.Instance?.GetWorld()?.SetInstanceID(idInst);
|
||||
}
|
||||
}
|
||||
|
||||
CECPlayer.InitStaticRes();
|
||||
hostPlayer = ObjectSpawner.Instance.InstantiateObject(_playerPrefab, setThisAsParent: true).AddComponent<CECHostPlayer>();
|
||||
hostPlayer.InitCharacter(info);
|
||||
m_pHostPlayer = ObjectSpawner.Instance.InstantiateObject(_playerPrefab, setThisAsParent: true).AddComponent<CECHostPlayer>();
|
||||
m_pHostPlayer.InitCharacter(info);
|
||||
|
||||
if (hostPlayer != null)
|
||||
if (m_pHostPlayer != null)
|
||||
{
|
||||
var t = Type.GetType("BrewMonster.UI.SelectedTargetHUDController, Assembly-CSharp");
|
||||
if (t != null && hostPlayer.GetComponent(t) == null)
|
||||
hostPlayer.gameObject.AddComponent(t);
|
||||
if (t != null && m_pHostPlayer.GetComponent(t) == null)
|
||||
m_pHostPlayer.gameObject.AddComponent(t);
|
||||
}
|
||||
}
|
||||
public CECMonster GetMonster()
|
||||
@@ -926,7 +1029,172 @@ public partial class CECGameRun
|
||||
}
|
||||
|
||||
public CECPendingActionArray GetPendingLogOut(){ return m_pendingLogout; }
|
||||
|
||||
// Game tick routine
|
||||
public bool Tick(uint dwDeltaTime)
|
||||
{
|
||||
// if (GetWallowInfo().anti_wallow_active &&
|
||||
// g_pGame->GetGameSession()->IsConnected() &&
|
||||
// GetGameState() == GS_GAME)
|
||||
// {
|
||||
// if (CECUIConfig::Instance().GetGameUI().nWallowHintType != CECUIConfig::GameUI::WHT_KOREA)
|
||||
// {
|
||||
// // ·À³ÁÃÔµ½3Сʱ£¬ÈôAU²»ÌßÈË£¨ÏûÏ¢¶ªÊ§£©£¬Ôò×Ô¶¯ÏÂÏß
|
||||
// int stime = g_pGame->GetServerGMTTime();
|
||||
// int nTime = stime - GetWallowInfo().play_time;
|
||||
// if (nTime >= 3 * 3600)
|
||||
// {
|
||||
// // ÒѾ³¬¹ý3Сʱ
|
||||
// g_pGame->GetGameSession()->SetBreakLinkFlag(CECGameSession::LBR_ANTI_WALLOW);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// DWORD dwTickTime = a_GetTime();
|
||||
//
|
||||
// CECGameSession* pSession = g_pGame->GetGameSession();
|
||||
// pSession->ProcessNewProtocols();
|
||||
// DWORD dwRealTime = g_pGame->GetRealTickTime();
|
||||
|
||||
if (m_iLogoutFlag >= 0)
|
||||
{
|
||||
Logout();
|
||||
m_iLogoutFlag = -1;
|
||||
}
|
||||
|
||||
// CECReconnect::Instance().Tick();
|
||||
//
|
||||
// if (m_pUIManager)
|
||||
// m_bUIHasCursor = m_pUIManager->UIControlCursor();
|
||||
// else
|
||||
// m_bUIHasCursor = false;
|
||||
//
|
||||
// // Deal input first
|
||||
// if (m_pInputCtrl)
|
||||
// m_pInputCtrl->Tick();
|
||||
//
|
||||
// // Tick world
|
||||
// if (!TickGameWorld(dwDeltaTime, g_pGame->GetViewport()))
|
||||
// return false;
|
||||
|
||||
// Tick UI
|
||||
// if (m_pUIManager)
|
||||
// m_pUIManager.Tick();
|
||||
|
||||
// // Tick GFX caster
|
||||
// g_pGame->GetGFXCaster()->Tick(dwDeltaTime);
|
||||
//
|
||||
// // Tick GFX Manager
|
||||
// g_pGame->GetA3DGFXExMan()->Tick(dwDeltaTime);
|
||||
//
|
||||
// // A3DEngine::TickAnimation trigger animation of many objects.
|
||||
// // For example: A3DSky objects, GFX objects etc.
|
||||
// static DWORD dwAnimTime = 0;
|
||||
// dwAnimTime += dwDeltaTime;
|
||||
// while (dwAnimTime >= TIME_TICKANIMATION)
|
||||
// {
|
||||
// dwAnimTime -= TIME_TICKANIMATION;
|
||||
// g_pGame->GetA3DEngine()->TickAnimation();
|
||||
// }
|
||||
//
|
||||
// // Update ear position so that all 3D sounds' positions are correct
|
||||
// static DWORD dwEarTime = 0;
|
||||
// if ((dwEarTime += dwDeltaTime) >= TIME_UPDATEEAR)
|
||||
// {
|
||||
// dwEarTime -= TIME_UPDATEEAR;
|
||||
//
|
||||
// CECHostPlayer* pHostPlayer = NULL;
|
||||
// if (m_pWorld)
|
||||
// pHostPlayer = m_pWorld->GetHostPlayer();
|
||||
//
|
||||
// A3DCamera * pCamera = g_pGame->GetViewport()->GetA3DCamera();
|
||||
//
|
||||
// if (GetGameState() == CECGameRun::GS_GAME && pHostPlayer && pHostPlayer->HostIsReady())
|
||||
// {
|
||||
// AM3DSoundDevice * pAM3DSoundDevice = g_pGame->GetA3DEngine()->GetAMSoundEngine()->GetAM3DSoundDevice();
|
||||
// A3DVECTOR3 vecDir = pCamera->GetDirH();
|
||||
// A3DVECTOR3 vecUp = A3DVECTOR3(0.0f, 1.0f, 0.0f);
|
||||
//
|
||||
// // Now we should adjust the 3d sound device's pos and orientation;
|
||||
// if (pAM3DSoundDevice)
|
||||
// {
|
||||
// pAM3DSoundDevice->SetPosition(pHostPlayer->GetPos() + A3DVECTOR3(0.0f, 0.8f, 0.0f));
|
||||
// pAM3DSoundDevice->SetOrientation(vecDir, vecUp);
|
||||
// pAM3DSoundDevice->UpdateChanges();
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// g_pGame->GetViewport()->GetA3DCamera()->UpdateEar();
|
||||
// }
|
||||
//
|
||||
// // Tick Run-Time debug information
|
||||
// g_pGame->GetRTDebug()->Tick(dwDeltaTime);
|
||||
//
|
||||
// // Save UI configs when time reached
|
||||
// if (m_iGameState == GS_GAME && l_SaveCfgCnt.IncCounter(dwRealTime))
|
||||
// {
|
||||
// l_SaveCfgCnt.Reset();
|
||||
// SaveConfigsToServer();
|
||||
// }
|
||||
//
|
||||
// l_StatCnt.IncCounter(dwDeltaTime);
|
||||
//
|
||||
// pSession->ClearOldProtocols();
|
||||
//
|
||||
// DWORD dwCurrentTick = a_GetTime();
|
||||
// dwTickTime = (dwCurrentTick > dwTickTime) ? (dwCurrentTick - dwTickTime) : 0;
|
||||
// l_Statistic.iTickTime = (int)dwTickTime;
|
||||
//
|
||||
// if (GetGameState() == CECGameRun::GS_GAME && l_fc.iAvgRdTime)
|
||||
// {
|
||||
// // Accumulate tick time
|
||||
// l_fc.iTickCnt++;
|
||||
// l_fc.iTickTime += (int)dwTickTime;
|
||||
// }
|
||||
//
|
||||
// if (GetGameState() == GS_GAME && GetHostPlayer() && GetHostPlayer()->HostIsReady())
|
||||
// {
|
||||
// if (l_bFirstQuery || l_DelayQueryCounter.IncCounter(dwDeltaTime))
|
||||
// {
|
||||
// // µÚÒ»´Î²éѯ£¬»òÕß²éѯ¼ÆÊýÆ÷µ½µã
|
||||
//
|
||||
// // ·¢ËÍÍøÂçÓµ¼·²éѯÐÒé
|
||||
// l_iDelayTimeStamp = timeGetTime();
|
||||
// g_pGame->GetGameSession()->c2s_CmdQueryNetworkDelay(l_iDelayTimeStamp);
|
||||
// l_DelayQueryCounter.Reset();
|
||||
// l_bFirstQuery = false;
|
||||
// }
|
||||
//
|
||||
// if (l_QueryServerTime.IncCounter(dwDeltaTime))
|
||||
// {
|
||||
// g_pGame->GetGameSession()->c2s_CmdSendGetServerTime();
|
||||
// l_QueryServerTime.Reset();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// m_pendingLogout.Update(dwDeltaTime);
|
||||
//
|
||||
// // ÓÅ»¯ÄÚ´æµÄÕ¼ÓÃ
|
||||
// m_pMemSimplify->Tick(dwDeltaTime);
|
||||
//
|
||||
// // ¸üÐÂÏÂÔØ×´Ì¬
|
||||
// CECMCDownload::GetInstance().Tick(dwDeltaTime);
|
||||
//
|
||||
// // ¸üÐÂ×Ô¶¯²ßÂÔ
|
||||
// CECAutoPolicy::GetInstance().Tick(dwDeltaTime);
|
||||
//
|
||||
// if(m_pRandomMapProc)
|
||||
// m_pRandomMapProc->Tick(dwDeltaTime);
|
||||
//
|
||||
// #ifdef _PROFILE_MEMORY
|
||||
// g_TickMemoryHistory();
|
||||
// #endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
public enum GameState
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d68cfcd6293664808ba733553314250a
|
||||
Reference in New Issue
Block a user