101 lines
4.4 KiB
C#
101 lines
4.4 KiB
C#
using BrewMonster.Network;
|
|
using CSNetwork;
|
|
using CSNetwork.GPDataType;
|
|
using BrewMonster.Scripts;
|
|
using UnityEngine;
|
|
using System.Threading.Tasks;
|
|
using Cysharp.Threading.Tasks;
|
|
namespace BrewMonster
|
|
{
|
|
public partial class CECHostPlayer
|
|
{
|
|
public void OnMsgPlayerChgShape(ECMSG Msg)
|
|
{
|
|
cmd_player_chgshape pCmd = GPDataTypeHelper.FromBytes<cmd_player_chgshape>((byte[])Msg.dwParam1);
|
|
//ASSERT(pCmd && pCmd->idPlayer == m_PlayerInfo.cid);
|
|
TransformShape(pCmd.shape);
|
|
}
|
|
|
|
public async Task TransformShape(byte iShape, bool bLoadAtOnce = false/* =false */)
|
|
{
|
|
SetShape(iShape);
|
|
//a_LogOutput(1, "CECPlayer::TransformShape(iShape=%d)(iShapeType=%d,iShapeID=%d)", iShape, PLAYERMODEL_GETTYPE(iShape), PLAYERMODEL_GETID(iShape));
|
|
|
|
if (!GetMajorModel()) return;
|
|
|
|
if (IsShapeChanged())
|
|
{
|
|
// change to a dummy model, may cause an asynchronous loading
|
|
await QueueLoadDummyModel(m_iShape, bLoadAtOnce);
|
|
}
|
|
else
|
|
{
|
|
// back to major model is a synchronous operation
|
|
ApplyShapeModelChange(GetMajorModel());
|
|
}
|
|
}
|
|
void SetShape(byte iShape)
|
|
{
|
|
// The shape id from the server is a 8-bit number
|
|
// The meaning of each bit:
|
|
// | 7 6 | 5 4 3 2 1 0 |
|
|
// |-TYPE-|-----Model ID-----|
|
|
int iNewShape = (iShape & 0xff); // only accept 8bit
|
|
// �Ծɵ�Shape�������ݽ�������
|
|
FixOldShapeInfo(ref iNewShape);
|
|
|
|
// ְҵ������Model IDҪ��ת��
|
|
if( PLAYERMODEL_GETTYPE(iNewShape) == (int)PLAYERMODEL_TYPE.PLAYERMODEL_PROFESSION )
|
|
{
|
|
int iRealID = _GetProfessionTransformModelID(
|
|
m_iProfession, m_iGender, PLAYERMODEL_GETID(iNewShape));
|
|
iNewShape = 0x40 | iRealID;
|
|
}
|
|
// ��ְҵ������Model IDΪEC_Resource.h���ֵ���ʲ�������
|
|
else
|
|
{
|
|
|
|
}
|
|
|
|
// store the original data into 8~15 bit
|
|
m_iShape = iNewShape | ((iShape & 0xff) << 8);
|
|
}
|
|
void FixOldShapeInfo(ref int iShape)
|
|
{
|
|
// �Ǹ�ʱ��shapeΪ0����û�б�������0����ְҵ����
|
|
if(iShape != 0 && PLAYERMODEL_GETTYPE(iShape) == 0)
|
|
iShape |= 0x40;
|
|
}
|
|
/// <summary>Origin: notify server of force-attack (PVP) state so it accepts/rejects attacks on players. Call when duel starts (true) or ends (false).</summary>
|
|
private void NotifyServerForceAttack(bool bForceAttack)
|
|
{
|
|
byte refuseBless = EC_Utility.glb_BuildRefuseBLSMask();
|
|
UnityGameSession.c2s_SendCmdNotifyForceAttack(glb_BuildPVPMask(bForceAttack), refuseBless);
|
|
}
|
|
|
|
public int _GetProfessionTransformModelID(int nChar, int nGender, int nModelID)
|
|
{
|
|
int result = 0;
|
|
switch (nChar){
|
|
case (int)PROFESSION.PROF_HAG: // ����
|
|
result = (2 == nModelID) ? (int)ModelResourceType.RES_MOD_ORC_FOX2 : (int)ModelResourceType.RES_MOD_ORC_FOX;
|
|
break;
|
|
case (int)PROFESSION.PROF_ORC: // ����
|
|
result = (2 == nModelID) ? (int)ModelResourceType.RES_MOD_ORC_PANDER : (int)ModelResourceType.RES_MOD_ORC_TIGER;
|
|
break;
|
|
case (int)PROFESSION.PROF_MONK: // ��ʦ
|
|
case (int)PROFESSION.PROF_GHOST: // �̿�
|
|
result = ((int)Gender.GENDER_MALE == nGender) ? (int)ModelResourceType.RES_MOD_SHADOW_FISH_M : (int)ModelResourceType.RES_MOD_SHADOW_FISH_F;
|
|
break;
|
|
case (int)PROFESSION.PROF_YEYING: // ҹӰ
|
|
result = ((int)Gender.GENDER_MALE == nGender) ? (int)ModelResourceType.RES_MOD_YEYING_RESHAPE_M : (int)ModelResourceType.RES_MOD_YEYING_RESHAPE_F;
|
|
break;
|
|
case (int)PROFESSION.PROF_YUEXIAN: // ����
|
|
result = ((int)Gender.GENDER_MALE == nGender) ? (int)ModelResourceType.RES_MOD_YUEXIAN_RESHAPE_M : (int)ModelResourceType.RES_MOD_YUEXIAN_RESHAPE_F;
|
|
break;
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
}
|