[The Escapists 2 + Unity + dnSpy] Спавн итемов.
Спавн итемов удалось сделать через dnSpy.
При клике на любой предмет на меню крафта он создается в инвентаре, а если там занято, то выкидывается на карту.
Я переписал метод клика на рецепт, вот он оригинальный
Скрытый текст
// Token: 0x060069FA RID: 27130 RVA: 0x00254874 File Offset: 0x00252A74
private void OnRecipeSlotClicked(int recipeSlotID)
{
if (recipeSlotID == this.m_CurrentClickedRecipeID)
{
if (!T17RewiredStandaloneInputModule.IsCurrentActiveModuleUsingController())
{
this.m_CurrentClickedRecipeID = -1;
}
return;
}
if (!this.CheckHasItemsForRecipe(recipeSlotID))
{
this.m_CurrentClickedRecipeID = -1;
return;
}
CraftManager.Recipe recipeByID = CraftManager.GetInstance().GetRecipeByID(recipeSlotID);
if (recipeByID != null && (!recipeByID.m_bHidden || recipeByID.m_bDiscovered))
{
this.FillSlots(recipeSlotID);
this.m_CurrentClickedRecipeID = recipeSlotID;
return;
}
this.m_CurrentClickedRecipeID = -1;
}
На этот
Скрытый текст
private void OnRecipeSlotClicked(int recipeSlotID)
{
int itemDataID = CraftManager.GetInstance().GetCurrentRecipes()[recipeSlotID].m_Product.m_ItemDataID;
Character character = base.CurrentGamePlayer.GetComponent();
ItemManager.GetInstance().AssignItemRPC(character.m_NetView.ownerId, itemDataID, new ItemManager.ItemManagerEvent(this.OnStandingAnimItemSpawn), ref character.m_StandingStillEquipID, -1);
}
private void OnStandingAnimItemSpawn(Item item, int eventID)
{
if (base.CurrentGamePlayer.GetComponent().m_StandingStillEquipID == eventID)
{
Player player = base.CurrentGamePlayer;
bool flag = false;
if (player.GetEquippedItem() == null)
{
flag = player.SetEquippedItem(item, true, false, RPC_CallContexts.Master);
}
if (!flag)
{
item.DropItemInLevel(player, player.transform.position);
}
}
}
Скрытый текст
Для спавна заменить Assembly-CSharp.dll из архива, сделав копию предварительно
-
3
4 Комментария
Рекомендуемые комментарии
Пожалуйста, войдите, чтобы комментировать
Вы сможете оставить комментарий после входа в
Войти