191 lines
6.2 KiB
C#
191 lines
6.2 KiB
C#
using BrewMonster;
|
||
using BrewMonster.Managers;
|
||
using BrewMonster.Scripts.Ornament;
|
||
using CSNetwork.GPDataType;
|
||
using PerfectWorld.Scripts.Managers.BrewMonster.Managers;
|
||
using UnityEngine;
|
||
|
||
|
||
namespace BrewMonster.Scripts.World
|
||
{
|
||
public class CECWorld
|
||
{
|
||
protected A3DTerrain2 m_pA3DTerrain;
|
||
CECOrnamentMan m_pOnmtMan;
|
||
uint m_dwBornStamp = 0;
|
||
CECAssureMove m_pAssureMove; // object used to assure move
|
||
int m_idInst = 161; // id of instance
|
||
|
||
public uint GetBornStamp() { return m_dwBornStamp++; }
|
||
|
||
// Get terrain object
|
||
public A3DTerrain2 GetTerrain()
|
||
{
|
||
return m_pA3DTerrain;
|
||
}
|
||
//TODO: Skill Gfx Manager
|
||
//public CECSkillGfxMan GetSkillGfxMan() { return (CECSkillGfxMan)m_aManagers[MAN_SKILLGFX]; }// Terrain object
|
||
|
||
public CECOrnamentMan GetOrnamentMan()
|
||
{
|
||
return m_pOnmtMan;
|
||
}
|
||
public float GetTerrainHeight(A3DVECTOR3 vPos, ref A3DVECTOR3 pvNormal /* NULL */)
|
||
{
|
||
A3DTerrain2 pTerrain = GetTerrain();
|
||
return pTerrain.GetPosHeight(vPos, ref pvNormal);
|
||
}
|
||
|
||
public float GetWaterHeight(A3DVECTOR3 vPos)
|
||
{
|
||
// TODO: Hook into the actual water system once it is available.
|
||
A3DVECTOR3 dummy = default;
|
||
return GetTerrainHeight(vPos, ref dummy);
|
||
}
|
||
|
||
public CECObject GetObject(int idObject, int iAliveFlag)
|
||
{
|
||
CECObject pObject = null;
|
||
|
||
if (GPDataTypeHelper.ISNPCID(idObject))
|
||
{
|
||
if (!(pObject = EC_ManMessageMono.Instance.CECNPCMan.GetNPC(idObject)))
|
||
return null;
|
||
|
||
if ((iAliveFlag == 1 && ((CECNPC)pObject).IsDead()) ||
|
||
(iAliveFlag == 2 && !((CECNPC)pObject).IsDead()))
|
||
return null;
|
||
}
|
||
else if (GPDataTypeHelper.ISPLAYERID(idObject))
|
||
{
|
||
if (!(pObject = EC_ManMessageMono.Instance.GetECManPlayer.GetPlayer(idObject)))
|
||
return null;
|
||
|
||
if ((iAliveFlag == 1 && ((CECPlayer)pObject).IsDead()) ||
|
||
(iAliveFlag == 2 && !((CECPlayer)pObject).IsDead()))
|
||
return null;
|
||
}
|
||
else if (GPDataTypeHelper.ISMATTERID(idObject))
|
||
pObject = EC_ManMessageMono.Instance.GetECManMatter.GetMatter(idObject);
|
||
|
||
return pObject;
|
||
}
|
||
public int GetInstanceID() { return m_idInst; }
|
||
|
||
// 设置实例ID(地图ID) // Set instance ID (map ID)
|
||
public void SetInstanceID(int idInst)
|
||
{
|
||
m_idInst = idInst;
|
||
|
||
// Sync AutoPF intelligent route data for the new map.
|
||
// 同步新地图的 AutoPF 智能寻路数据。
|
||
BrewMonster.Scripts.CECIntelligentRoute.Instance().ChangeWorldInstance(idInst);
|
||
}
|
||
public CECAssureMove GetAssureMove()
|
||
{ return m_pAssureMove; }
|
||
|
||
public CECNPCMan GetNPCMan()
|
||
{
|
||
return EC_ManMessageMono.Instance.CECNPCMan;
|
||
}
|
||
|
||
public EC_ManPlayer GetPlayerMan()
|
||
{
|
||
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();
|
||
}
|
||
}
|
||
}
|