Merge branch 'develop' of https://git.brew.monster/Unity/perfect-world-unity into update-in-game
This commit is contained in:
@@ -548,6 +548,9 @@ namespace BrewMonster
|
||||
case int value when value == EC_MsgDef.MSG_HST_PICKUPITEM:
|
||||
OnMsgHstPickupItem(Msg);
|
||||
break;
|
||||
case int value when value == EC_MsgDef.MSG_HST_PRODUCEITEM:
|
||||
OnMsgHstProduceItem(Msg);
|
||||
break;
|
||||
case int value when value == EC_MsgDef.MSG_HST_SELTARGET:
|
||||
OnMsgHstSelTarget(Msg); break;
|
||||
case int value when value == EC_MsgDef.MSG_HST_ATKRESULT: OnMsgHstAttackResult(Msg); break;
|
||||
@@ -2026,9 +2029,100 @@ namespace BrewMonster
|
||||
}
|
||||
|
||||
break;
|
||||
case CommandID.PRODUCE_ONCE:
|
||||
{
|
||||
// Parse cmd_produce_once struct data
|
||||
cmd_produce_once produceCmd = GPDataTypeHelper.FromBytes<cmd_produce_once>(data);
|
||||
|
||||
int produceItemId = produceCmd.type;
|
||||
int produceExpireDate = 0;
|
||||
uint produceAmount = produceCmd.amount;
|
||||
byte producePack = produceCmd.where;
|
||||
byte produceSlot = produceCmd.index;
|
||||
|
||||
// Create new inventory item data
|
||||
var produceNewItem = new EC_IvtrItem
|
||||
{
|
||||
Package = producePack,
|
||||
Slot = produceSlot,
|
||||
m_tid = produceItemId,
|
||||
m_expire_date = produceExpireDate,
|
||||
State = 0,
|
||||
m_iCount = (int)produceAmount,
|
||||
Crc = 0,
|
||||
Content = null
|
||||
};
|
||||
|
||||
// TODO: Handle other pickup item commands if necessary
|
||||
// Add item to inventory
|
||||
var produce_ivt = GetInventory(producePack);
|
||||
if (!produce_ivt.MergeItem(produceItemId, produceExpireDate, (int)produceAmount, out var produceLastSlot, out var produceSlotNum) ||
|
||||
produceLastSlot != produceSlot || produceSlotNum != (int)produceCmd.slot_amount)
|
||||
{
|
||||
Debug.LogWarning($"[PRODUCE_ONCE] Failed to merge item {produceItemId} to package {producePack}, slot {produceSlot}");
|
||||
return;
|
||||
}
|
||||
produce_ivt.SetItem(produceSlot, produceNewItem);
|
||||
|
||||
Debug.Log($"[PRODUCE_ONCE] Successfully added produced item {produceItemId} to package {producePack}, slot {produceSlot} with count {produceAmount}");
|
||||
|
||||
// Trigger UI refresh if an EC_InventoryUI is present in scene
|
||||
var produce_ui = GameObject.FindFirstObjectByType<EC_InventoryUI>();
|
||||
if (produce_ui != null)
|
||||
{
|
||||
produce_ui.RefreshAll();
|
||||
}
|
||||
|
||||
UpdateEquipSkins();
|
||||
|
||||
// Notify DlgProduce about successful produce (NOTIFY_PRODUCE_END_ONE)
|
||||
var dlgProduce = GameObject.FindFirstObjectByType<DlgProduce>();
|
||||
if (dlgProduce != null)
|
||||
{
|
||||
dlgProduce.OnProduceOnce(produceCmd);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnMsgHstProduceItem(in ECMSG Msg)
|
||||
{
|
||||
var data = Msg.dwParam1 as byte[];
|
||||
int cmd = Convert.ToInt32(Msg.dwParam2);
|
||||
|
||||
// Get DlgProduce to notify
|
||||
var dlgProduce = GameObject.FindFirstObjectByType<DlgProduce>();
|
||||
if (dlgProduce == null)
|
||||
{
|
||||
Debug.LogWarning("[OnMsgHstProduceItem] DlgProduce not found");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case CommandID.PRODUCE_START:
|
||||
{
|
||||
cmd_produce_start pCmd = GPDataTypeHelper.FromBytes<cmd_produce_start>(data);
|
||||
Debug.Log($"[PRODUCE_START] type={pCmd.type}, use_time={pCmd.use_time}, count={pCmd.count}");
|
||||
dlgProduce.OnProduceStart(pCmd);
|
||||
}
|
||||
break;
|
||||
case CommandID.PRODUCE_END:
|
||||
{
|
||||
Debug.Log("[PRODUCE_END] Production ended");
|
||||
dlgProduce.OnProduceEnd();
|
||||
}
|
||||
break;
|
||||
case CommandID.PRODUCE_NULL:
|
||||
{
|
||||
cmd_produce_null pCmd = GPDataTypeHelper.FromBytes<cmd_produce_null>(data);
|
||||
Debug.Log($"[PRODUCE_NULL] type={pCmd.type}");
|
||||
dlgProduce.OnProduceNull(pCmd);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Debug.LogWarning($"[OnMsgHstProduceItem] Unknown command: {cmd}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user