62 lines
2.2 KiB
C#
62 lines
2.2 KiB
C#
using BrewMonster;
|
|
using CSNetwork.GPDataType;
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using UnityEngine;
|
|
using static CECNPC;
|
|
|
|
public class CECNPCServer : CECNPC
|
|
{
|
|
NPC_ESSENCE? m_pDBEssence;
|
|
MONSTER_ESSENCE? m_pMonEssence;
|
|
public override void SetUpCECNPC(CECNPCMan pNPCMan)
|
|
{
|
|
base.SetUpCECNPC(pNPCMan);
|
|
m_iCID = (int)Class_ID.OCID_MONSTER;
|
|
m_pDBEssence = null;
|
|
}
|
|
public override bool Init(int tid, in info_npc info, ReadOnlySpan<byte> packet, int infoOffset)
|
|
{
|
|
base.Init(tid, info, packet, infoOffset);
|
|
//BrewMonster.BMLogger.Log("HoangDev: MonsterInit");
|
|
var pDB = ElementDataManProvider.GetElementDataMan();
|
|
DATA_TYPE DataType = default;
|
|
var data = pDB.get_data_ptr((uint)tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
|
|
m_pDBEssence = data != null ? (NPC_ESSENCE?)data : null;
|
|
|
|
var data1 = pDB.get_data_ptr(m_pDBEssence.Value.id_src_monster, ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
|
|
|
|
if (data1 == null)
|
|
{
|
|
if ((data1 = (MONSTER_ESSENCE?)pDB.get_data_ptr(4249, ID_SPACE.ID_SPACE_ESSENCE, ref DataType)) == null)
|
|
{
|
|
BMLogger.LogError("HoangDEv : CECNPCServer::Init, server NPC reference to null monster data");
|
|
return false;
|
|
}
|
|
}
|
|
m_pMonEssence = (MONSTER_ESSENCE?)data1;
|
|
|
|
m_fTouchRad = m_pMonEssence.Value.size;
|
|
m_BasicProps.iLevel = m_pMonEssence.Value.level;
|
|
QueueLoadNPCModel();
|
|
|
|
/* float fExt = m_fTouchRad * 1.5f;
|
|
m_cdr.vExts.Set(fExt, fExt, fExt);
|
|
m_pNPCModelPolicy.SetDefaultPickAABBExt(m_cdr.vExts);*/
|
|
|
|
// If NPC doesn't have specific name, use the name in database
|
|
if ((info.state & (int)PlayerNPCState.GP_STATE_NPC_NAME) == 0)
|
|
{
|
|
m_strName = Encoding.Unicode.GetString(MemoryMarshal.AsBytes<ushort>(m_pDBEssence.Value.name));
|
|
m_npcUI.SetName(m_strName);
|
|
}
|
|
|
|
transform.forward = EC_Utility.glb_DecompressDirH(info.dir);
|
|
transform.position = EC_Utility.ToVector3(info.pos);
|
|
|
|
StartWork((int)WorkType.WT_NOTHING, (int)WorkID.WORK_STAND);
|
|
return true;
|
|
}
|
|
}
|