npc leave after die

This commit is contained in:
VDH
2025-10-16 10:53:05 +07:00
parent 36b17caa5a
commit 32e42d2db8
19 changed files with 667 additions and 101 deletions
@@ -62,10 +62,58 @@ public class CECNPCMan : CECObject, IMsgHandler
pNPC.Disappear();
// From npc from active table and add it to disappear table
//NPCLeave(nid, true, false);
NPCLeave(nid, true, false);
m_aDisappearNPCs.Add(pNPC);
}
}
void NPCLeave(int nid, bool bUpdateMMArray = true, bool bRelease = true)
{
// Release NPC
CECNPC pNPC = GetNPC(nid);
if (!pNPC)
return;
/*if (bUpdateMMArray)
RemoveNPCFromMiniMap(pNPC);*/
pNPC.m_iMMIndex = -1;
var hostplayer = GameController.Instance.GetHostPlayer();
// If this NPC is selected by host, cancel the selection
if (pNPC.GetNPCID() == hostplayer.GetSelectedTarget())
hostplayer.SelectTarget(0);
// Remove it from active NPC table
m_NPCTab.Remove(nid);
// Forbid reloading npc's resources
//QueueNPCUndoLoad(nid, pNPC->GetBornStamp());
// Release NPC resource
if (bRelease)
ReleaseNPC(pNPC);
else
{
CECHostPlayer pHost = hostplayer;
if (pHost != null)
pHost.RemoveObjectFromTabSels(pNPC);
}
/* CECPlayerWrapper* pWrapper = CECAutoPolicy::GetInstance().GetPlayerWrapper();
if (pWrapper) pWrapper->OnObjectDisappear(nid);*/
}
void ReleaseNPC(CECNPC pNPC)
{
if (pNPC)
{
// Remove tab-selected array
CECHostPlayer pHost = GameController.Instance.GetHostPlayer();
if (pHost)
pHost.RemoveObjectFromTabSels(pNPC);
pNPC.Release();
Destroy(pNPC);
}
}
private bool TransmitMessage(ECMSG Msg)
{
int nid = 0;
@@ -319,10 +319,10 @@ namespace PerfectWorld.Scripts.Managers
private static void LogPackInternal(byte byPackage, int ivtrSize, IReadOnlyDictionary<int, InventoryItemData> slots)
{
Debug.Log($"[Inventory] === Pack {GetPackageName(byPackage)}({byPackage}) size={ivtrSize}, items={(slots?.Count ?? 0)} ===");
//Debug.Log($"[Inventory] === Pack {GetPackageName(byPackage)}({byPackage}) size={ivtrSize}, items={(slots?.Count ?? 0)} ===");
if (slots == null || slots.Count == 0)
{
Debug.Log("[Inventory] (empty)");
//Debug.Log("[Inventory] (empty)");
return;
}
foreach (var kv in slots)
@@ -330,10 +330,10 @@ namespace PerfectWorld.Scripts.Managers
var it = kv.Value;
string itemName = EC_IvtrItem.ResolveItemName(it.TemplateId);
string extraHex = it.Content != null && it.Content.Length > 0 ? EC_IvtrItem.BytesToHex(it.Content, MaxContentHexToLog) : "";
int extraLen = it.Content?.Length ?? 0;
Debug.Log(
$"[Inventory] pkg={GetPackageName(it.Package)}({it.Package}) slot={it.Slot} tid={it.TemplateId}{(string.IsNullOrEmpty(itemName) ? "" : " \"" + itemName + "\"")} count={it.Count} state={it.State} expire={it.ExpireDate} crc={it.Crc} content_len={extraLen}{(extraLen > 0 ? ", content_hex=" + extraHex : "")}"
);
//int extraLen = it.Content?.Length ?? 0;
//Debug.Log(
// $"[Inventory] pkg={GetPackageName(it.Package)}({it.Package}) slot={it.Slot} tid={it.TemplateId}{(string.IsNullOrEmpty(itemName) ? "" : " \"" + itemName + "\"")} count={it.Count} state={it.State} expire={it.ExpireDate} crc={it.Crc} content_len={extraLen}{(extraLen > 0 ? ", content_hex=" + extraHex : "")}"
//);
}
}
@@ -341,15 +341,13 @@ namespace PerfectWorld.Scripts.Managers
{
if (buffer == null)
{
Debug.LogWarning($"[Inventory] {tag}: buffer is null (hostId={hostId})");
return;
}
int index = 0;
if (buffer.Length < 6)
{
Debug.LogWarning($"[Inventory] {tag}: buffer too small: {buffer.Length} bytes (hostId={hostId})");
LogInventoryRaw(tag, buffer);
//LogInventoryRaw(tag, buffer);
return;
}
@@ -364,13 +362,11 @@ namespace PerfectWorld.Scripts.Managers
contentBytes = (int)contentLength;
}
Debug.Log($"[Inventory] {tag}: hostId={hostId}, totalBytes={buffer.Length}, byPackage={byPackage}, ivtrSize={ivtrSize}, contentLength={contentLength}, actualContentBytes={contentBytes}");
if (contentBytes > 0)
{
byte[] content = new byte[contentBytes];
Buffer.BlockCopy(buffer, index, content, 0, contentBytes);
Debug.Log($"[Inventory] {tag}: content HEX=\n{BitConverter.ToString(content)}");
}
int trailing = buffer.Length - (index + contentBytes);
@@ -378,7 +374,6 @@ namespace PerfectWorld.Scripts.Managers
{
byte[] tail = new byte[trailing];
Buffer.BlockCopy(buffer, index + contentBytes, tail, 0, trailing);
Debug.Log($"[Inventory] {tag}: trailing {trailing} byte(s) HEX=\n{BitConverter.ToString(tail)}");
}
}
@@ -316,17 +316,14 @@ namespace PerfectWorld.Scripts.Managers
if (arr != null && arr.Length > 0)
{
var rawData = string.Join(",", arr.Take(Math.Min(10, arr.Length)));
Debug.Log($"[Inventory] Raw ushort array data (first 10): [{rawData}]");
}
// Vietnamese names are stored as wide chars; decode as Unicode first.
var s = ByteToStringUtils.UshortArrayToUnicodeString(arr);
// Debug log to see what we're getting
Debug.Log($"[Inventory] Unicode decode result: '{s}' (length: {s?.Length ?? 0})");
if (!string.IsNullOrEmpty(s) && !string.IsNullOrWhiteSpace(s)) return s;
// Fallback to legacy CP936 if Unicode was empty
s = ByteToStringUtils.UshortArrayToCP936String(arr);
Debug.Log($"[Inventory] CP936 fallback result: '{s}' (length: {s?.Length ?? 0})");
if (!string.IsNullOrEmpty(s)) return s;
}
// Try calling GetName method if it exists (similar to C++ pIt->GetName())
@@ -1,4 +1,4 @@
using BrewMonster;
using BrewMonster;
using BrewMonster.Network;
using CSNetwork;
using CSNetwork.GPDataType;
@@ -54,14 +54,12 @@ namespace PerfectWorld.Scripts.Managers
{
case int value when value == EC_MsgDef.MSG_MM_MATTERINFO:
{
Debug.Log("MATTERINFO");
//ENABLE LATER: It fetch all matters in the game world, causing performance issues
OnMsgMatterInfo(Msg);
break;
}
case int value when value == EC_MsgDef.MSG_MM_MATTERENTWORLD:
{
Debug.Log("MATTERENTWORLD");
OnMsgMatterEnterWorld(Msg);
break;
}
@@ -1,4 +1,4 @@
using BrewMonster;
using BrewMonster;
using BrewMonster.Network;
using CSNetwork;
using CSNetwork.GPDataType;
@@ -27,7 +27,6 @@ namespace PerfectWorld.Scripts.Managers
public int HandlerId => (int)MANAGER_INDEX.MAN_PLAYER;
public bool ProcessMessage(ECMSG Msg)
{
Debug.Log("HoangDev: ProcessMessageManPlayer :");
if (Msg.iSubID == 0)
{
if (GameController.Instance == null) return true;
@@ -93,7 +92,6 @@ namespace PerfectWorld.Scripts.Managers
break;
}
case CommandID.SELF_INFO_1:
Debug.Log("SELF_INFO_1");
cmd_self_info_1 info = GPDataTypeHelper.FromBytes<cmd_self_info_1>((byte[])Msg.dwParam1);
HostPlayerInfo1(info);
break;
@@ -205,7 +203,6 @@ namespace PerfectWorld.Scripts.Managers
preSize += iSize;
}
Debug.LogError("PLAYER_INFO_1_LIST");
break;
}
}
@@ -686,6 +686,7 @@ public abstract class CECPlayer : CECObject
}
return pFashionConfig.Value;
}
public int GetSelectedTarget() { return m_idSelTarget; }
public float GetTouchRadius() { return m_fTouchRad; }
// Is player in battle
public bool IsInBattle() { return m_iBattleCamp != Player_camp_in_battle.GP_BATTLE_CAMP_NONE; }
+62 -7
View File
@@ -1,11 +1,12 @@
using CSNetwork.GPDataType;
using System.Text;
using System;
using UnityEngine;
using BrewMonster;
using CSNetwork;
using CSNetwork.GPDataType;
using ModelRenderer.Scripts.Common;
using System;
using System.IO;
using System.Text;
using Unity.VisualScripting;
using UnityEngine;
public class CECNPC : CECObject
{
@@ -32,14 +33,16 @@ public class CECNPC : CECObject
protected int m_idSelTarget;
protected int m_iCurWorkType;
protected int m_iCurWork;
protected CECCounter m_DisappearCnt;
protected CECCounter m_TransCnt;
protected uint m_nPolicyActionIntervalTimer;
protected CECCounter m_DisappearCnt= new CECCounter();
protected CECCounter m_TransCnt = new CECCounter();
protected int m_StartDisappearCnt;
protected bool m_bAboutToDie;
protected Vector3 m_vStopDir;
protected ROLEEXTPROP m_ExtProps;
protected CECNPCModelPolicy m_pNPCModelPolicy;
protected CECPolicyAction m_pPolicyAction;
public int m_iMMIndex;
[SerializeField] protected float m_fMoveSpeed;
[SerializeField] protected CharacterController _characterController;
@@ -230,6 +233,58 @@ public class CECNPC : CECObject
//RebuildTraceBrush();
}
}
public void Release()
{
// Release current skill if it exists
/* if (m_pCurSkill)
{
delete m_pCurSkill;
m_pCurSkill = NULL;
}*/
// Clear extend states before model is released
/* ClearShowExtendStates();
::memset(m_aExtStates, 0, sizeof(m_aExtStates));
m_aIconStates.clear();*/
m_pNPCModelPolicy = null;
/*if (m_pPateName)
{
delete m_pPateName;
m_pPateName = NULL;
}
if (m_pPateLastWords1)
{
delete m_pPateLastWords1;
m_pPateLastWords1 = NULL;
}
if (m_pPateLastWords2)
{
delete m_pPateLastWords2;
m_pPateLastWords2 = NULL;
}
if (m_pBubbleTexts)
{
delete m_pBubbleTexts;
m_pBubbleTexts = NULL;
}*/
m_pPolicyAction = null;
m_nPolicyActionIntervalTimer = 0;
/* for (MOEffectMAP::iterator it = m_mapMOEffect.begin(); it != m_mapMOEffect.end(); ++it)
{
A3DGFXExMan* pGFXExMan = g_pGame->GetA3DGFXExMan();
pGFXExMan->CacheReleasedGfx(it->second);
}
m_mapMOEffect.clear();*/
}
public bool MovingTo(float deltaTime)
{
bool reachedDestination = false;
@@ -293,7 +293,6 @@ namespace CSNetwork
private void HandleServerDataSend(gamedatasend protocol)
{
_logger.Info($"### GameDataSend: {protocol.Data.ByteArray[0]}");
int lenghtHeader = Marshal.SizeOf<ushort>();
var pDataBuf = new byte[protocol.Data.ByteArray.Length - lenghtHeader];
var byteArrHeader = new byte[lenghtHeader];
@@ -321,6 +320,9 @@ namespace CSNetwork
//sss
//BMLogger.LogError($"### GameDataSend: CMDID {pCmdHeader}");
int iHostID = _selectedRole.roleid;
BMLogger.LogError("HoangDev: pCmdHeader: " + pCmdHeader);
_logger.Info($"### GameDataSend: " + pCmdHeader);
switch (pCmdHeader)
{
case CommandID.PLAYER_INFO_2:
@@ -422,9 +424,11 @@ namespace CSNetwork
EC_ManMessage.PostMessage(EC_MsgDef.MSG_NM_NPCATKRESULT, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader);
break;
case CommandID.HOST_ATTACKRESULT:
_logger.Info($"HOST_ATTACKRESULT: " + pCmdHeader);
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_ATKRESULT, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader);
break;
case CommandID.HOST_ATTACKED:
_logger.Info($"HOST_ATTACKED: " + pCmdHeader);
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_ATTACKED, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader);
break;
@@ -43,8 +43,6 @@ namespace CSNetwork.Security
/// <returns>A new Octets object containing the decrypted and decompressed data.</returns>
public override Octets Update(Octets data)
{
_logger.Log(LogType.Debug, $"HoangDev: AF co vao dau {data.RawBuffer[0]} - Length: {data.Length}");
if (data == null || data.Length == 0)
{
return new Octets(); // Return empty if input is empty
@@ -57,7 +55,6 @@ namespace CSNetwork.Security
// or just to be safe. Ensure _arcFour.Update returns a *new* Octets.
// *** If ARCFourSecurity.Update modified the input Octets in-place, this would be wrong. ***
// *** Assuming ARCFourSecurity.Update follows the abstract Security pattern and returns new Octets ***
UnityEngine.Debug.Log($"ENCRYPTED: {data.RawBuffer[0]}");
decryptedData = _arcFour.Update(data);
}
@@ -78,7 +75,6 @@ namespace CSNetwork.Security
Octets decompressedData;
try
{
UnityEngine.Debug.Log($"DECRYPTED: {decryptedData.RawBuffer[0]}");
decompressedData = decompressor.Update(decryptedData);
}
catch (Exception ex)
@@ -1,4 +1,4 @@
using BrewMonster;
using BrewMonster;
using CSNetwork;
using CSNetwork.Protocols;
using CSNetwork.Protocols.RPCData;
@@ -211,7 +211,7 @@ namespace BrewMonster.Network
#region Task
public static void c2s_CmdGetAllData(bool byPack, bool byEquip, bool byTask)
{
Debug.Log("[Dat]- SendCmdGetAllData");
//Debug.Log("[Dat]- SendCmdGetAllData");
Instance._gameSession.c2s_SendCmdGetAllData(byPack, byEquip, byTask);
}
#endregion
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: eddd818dd2888a5408b88d01f10fe294
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BrewMonster
{
public class CECPolicyAction
{
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2dd554f9e0272a7448325ff0275c9f8b
@@ -115,7 +115,6 @@ namespace BrewMonster.UI
isDoneNPCRender = false;
Action actLoadChar = () =>
{
Debug.Log(" isDoneNPCRender || !isDoneWorldRende.isDoneNPCRender || !isDoneWorldRende(");
if (!isDoneNPCRender || !isDoneWorldRender)
{
return;
@@ -148,7 +147,7 @@ namespace BrewMonster.UI
{
await Task.Delay(2000);
// Request all known packages: 0=Inventory,1=Equipment,2=Task
UnityGameSession.RequestAllInventoriesAsync(() => { BMLogger.Log("Sent Inventory Detail Requests (all packs)"); }, 0, 1, 2);
UnityGameSession.RequestAllInventoriesAsync(() => { /*BMLogger.Log("Sent Inventory Detail Requests (all packs)");*/ }, 0, 1, 2);
UnityGameSession.RequestCheckSecurityPassWd("");
await Task.Delay(2000);
UnityGameSession.c2s_CmdGetAllData(true, true, false);
@@ -264,7 +264,6 @@ public class pickupItem : MonoBehaviour
bgMaterial.color = new Color(0, 0, 0, 0.7f); // Semi-transparent black
bgRenderer.material = bgMaterial;
Debug.Log($"Created item name text for TID {tid}: {itemName}");
}
public void RemoveMatterCube(int matterId)
@@ -277,7 +276,6 @@ public class pickupItem : MonoBehaviour
Destroy(cube);
}
matterCubes.Remove(matterId);
Debug.Log($"Removed cube for matter {matterId}");
}
}
+51 -41
View File
@@ -1,14 +1,16 @@
using BrewMonster;
using BrewMonster;
using BrewMonster.Network;
using CSNetwork;
using CSNetwork.Common;
using CSNetwork.GPDataType;
using CSNetwork.Protocols;
using CSNetwork.Protocols.RPCData;
using NUnit.Framework;
using PerfectWorld.Scripts.Managers;
using PerfectWorld.Scripts.Player;
using PerfectWorld.Scripts.Task;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
@@ -45,6 +47,7 @@ public class CECHostPlayer : CECPlayer
int m_iJumpCount = 0;
bool m_bJumpInWater = false;
public A3DVECTOR3 m_vVelocity; // Velocity
List<CECObject> m_aTabSels = new List<CECObject>();
float playerSpeed = 5.0f;
float jumpHeight = 1.5f;
@@ -368,33 +371,33 @@ public class CECHostPlayer : CECPlayer
}
private void OnMsgHstHurtResult(ECMSG Msg)
{
/* BMLogger.LogError("HoangDev : OnMsgHstHurtResult");
int cmd = Convert.ToInt32(Msg.dwParam2);
if (cmd == CommandID.BE_HURT)
{
cmd_be_hurt pCmd = (cmd_be_hurt)Msg.dwParam1;
if (pCmd.damage != 0)
Damaged(pCmd->damage);
}
else if (cmd == CommandID.HURT_RESULT)
{
cmd_hurt_result pCmd = (cmd_hurt_result)Msg.dwParam1;
if (pCmd.target_id == m_PlayerInfo.cid)
return; // Host himself will receive BE_HURT, so ignore this.
/* BMLogger.LogError("HoangDev : OnMsgHstHurtResult");
int cmd = Convert.ToInt32(Msg.dwParam2);
if (cmd == CommandID.BE_HURT)
{
cmd_be_hurt pCmd = (cmd_be_hurt)Msg.dwParam1;
if (pCmd.damage != 0)
Damaged(pCmd->damage);
}
else if (cmd == CommandID.HURT_RESULT)
{
cmd_hurt_result pCmd = (cmd_hurt_result)Msg.dwParam1;
if (pCmd.target_id == m_PlayerInfo.cid)
return; // Host himself will receive BE_HURT, so ignore this.
if (UnityGameSession.Instance.GameSession.ISPLAYERID(pCmd.target_id))
{
CECElsePlayer pTarget = m_pPlayerMan.GetElsePlayer(pCmd.target_id);
if (pTarget)
pTarget->Damaged(pCmd->damage);
}
else if (UnityGameSession.Instance.GameSession.ISNPCID(pCmd.target_id))
{
CECNPC pTarget = EC_ManMessageMono.Instance._CECNPCMan.GetNPC(pCmd.target_id);
if (pTarget)
pTarget.Damaged(pCmd.damage);
}
}*/
if (UnityGameSession.Instance.GameSession.ISPLAYERID(pCmd.target_id))
{
CECElsePlayer pTarget = m_pPlayerMan.GetElsePlayer(pCmd.target_id);
if (pTarget)
pTarget->Damaged(pCmd->damage);
}
else if (UnityGameSession.Instance.GameSession.ISNPCID(pCmd.target_id))
{
CECNPC pTarget = EC_ManMessageMono.Instance._CECNPCMan.GetNPC(pCmd.target_id);
if (pTarget)
pTarget.Damaged(pCmd.damage);
}
}*/
}
public void OnMsgHstPickupItem(in ECMSG Msg)
{
@@ -410,9 +413,9 @@ public class CECHostPlayer : CECPlayer
uint iSlotAmount = BitConverter.ToUInt32(data, 12);
byte byPackage = data[16];
byte bySlot = data[17];
Debug.Log($"[Inventory] PICKUP_ITEM: tid={tid}, expire_date={expire_date}, iAmount={iAmount}, iSlotAmount={iSlotAmount}, byPackage={byPackage}, bySlot={bySlot}");
// Notify pickupItem script about successful pickup
pickupItem pickupScript = pickupItem.Instance;
if (pickupScript != null)
@@ -560,13 +563,11 @@ public class CECHostPlayer : CECPlayer
{
case CommandID.OWN_IVTR_DATA:
{
Debug.Log("[Inventory] OWN_IVTR_DATA received");
PerfectWorld.Scripts.Managers.EC_Inventory.LogInventoryPacket("OWN_IVTR_DATA", data, hostId);
break;
}
case CommandID.OWN_IVTR_DETAIL_DATA:
{
Debug.Log("[Inventory] OWN_IVTR_DETAIL_DATA received");
PerfectWorld.Scripts.Managers.EC_Inventory.LogInventoryPacket("OWN_IVTR_DETAIL_DATA", data, hostId);
// Parse and store
if (data != null && data.Length >= 6)
@@ -604,13 +605,13 @@ public class CECHostPlayer : CECPlayer
// Message MSG_HST_SELTARGET handler
void OnMsgHstSelTarget(ECMSG Msg)
{
if (Convert.ToInt32(Msg.dwParam2) == CommandID.SELECT_TARGET)
{
if (Convert.ToInt32(Msg.dwParam2) == CommandID.SELECT_TARGET)
{
var data = (byte[])Msg.dwParam1;
cmd_select_target pCmd = GPDataTypeHelper.FromBytes<cmd_select_target>(data);
m_idSelTarget = pCmd.idTarget;
m_idUCSelTarget = 0;
}
cmd_select_target pCmd = GPDataTypeHelper.FromBytes<cmd_select_target>(data);
m_idSelTarget = pCmd.idTarget;
m_idUCSelTarget = 0;
}
else if (Convert.ToInt32(Msg.dwParam2) == CommandID.UNSELECT)
{
m_idSelTarget = 0;
@@ -648,7 +649,6 @@ public class CECHostPlayer : CECPlayer
transform.position = pos;
SetModelHostPlayer();
m_dwResFlags = (uint)PlayerResourcesReadyFlag.RESFG_ALL;
Debug.LogError("Pos Character = " + pos);
joystick = FindAnyObjectByType<Joystick>();
EventBus.Subscribe<JoystickRealeaseEvent>(JoystickRelease);
EventBus.Subscribe<JoystickPressEvent>(JoystickStartDrag);
@@ -1051,7 +1051,17 @@ public class CECHostPlayer : CECPlayer
return false;
}
public void RemoveObjectFromTabSels(CECObject pObject)
{
for (int i = 0; i < m_aTabSels.Count; i++)
{
if (m_aTabSels[i] == pObject)
{
m_aTabSels.RemoveAt(i);
break;
}
}
}
public bool CanTouchTarget(A3DVECTOR3 vTargetPos, float fTargetRad, int iReason, float fMaxCut = 1.0f)
{
A3DVECTOR3 vector = new A3DVECTOR3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z);
@@ -1091,7 +1101,7 @@ public class CECHostPlayer : CECPlayer
public float GetFlySpeed() { return m_ExtProps.mv.flight_speed; }
public float GetSwimSpeed() { return m_ExtProps.mv.swim_speed; }
bool SelectTarget(int idTarget)
public bool SelectTarget(int idTarget)
{
bool bRet = false;
bool canDo = CanDo(ActionCanDo.CANDO_CHANGESELECT);
@@ -1476,7 +1486,7 @@ public struct GNDINFO
// Behavior id used by CanDo()
public static class ActionCanDo
{
{
public const int CANDO_SITDOWN = 0,
CANDO_MOVETO = 1,
CANDO_MELEE = 2,
+1 -1
View File
@@ -35,7 +35,7 @@ public class CharacterItemUI : MonoBehaviour
nameCharacter.text = roleName;
}
void OnClickBtn()
public void OnClickBtn()
{
onClick?.Invoke(dataItem);
}
+22 -9
View File
@@ -7,17 +7,30 @@ using BrewMonster;
namespace BrewMonster.UI
{
public class SelecScreenCharacter : MonoBehaviour
{
[SerializeField] private GameObject characterItemPrefab;
[SerializeField] private RectTransform parentItems;
public void InitScreen(List<RoleInfo> roleInfos, Action<RoleInfo> OnClickItemChar)
{
foreach(RoleInfo info in roleInfos)
[SerializeField] private GameObject characterItemPrefab;
[SerializeField] private RectTransform parentItems;
public void InitScreen(List<RoleInfo> roleInfos, Action<RoleInfo> OnClickItemChar)
{
CharacterItemUI item = Instantiate(characterItemPrefab, parentItems).GetComponent<CharacterItemUI>();
item.InitItem(info, OnClickItemChar);
#if UNITY_EDITOR
int count = roleInfos.Count;
#endif
foreach (RoleInfo info in roleInfos)
{
CharacterItemUI item = Instantiate(characterItemPrefab, parentItems).GetComponent<CharacterItemUI>();
item.InitItem(info, OnClickItemChar);
#if UNITY_EDITOR
count--;
if (count <= 0)
{
item.OnClickBtn();
}
#endif
}
}
}
}
}
File diff suppressed because one or more lines are too long