Allow Aswid stomach to refresh blinking duplicate foods when slots are fully occupied
This commit is contained in:
parent
ad74ca3219
commit
225b7115bc
1 changed files with 47 additions and 1 deletions
|
|
@ -296,10 +296,28 @@ namespace RacesOfValheim
|
||||||
__result = true; // Consente l'uso del 4° slot se disponibile
|
__result = true; // Consente l'uso del 4° slot se disponibile
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
bool canRefresh = false;
|
||||||
|
foreach (object foodObj in foods)
|
||||||
|
{
|
||||||
|
Player.Food f = foodObj as Player.Food;
|
||||||
|
if (f != null && f.m_item.m_shared.m_name == item.m_shared.m_name && f.CanEatAgain())
|
||||||
|
{
|
||||||
|
canRefresh = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canRefresh)
|
||||||
|
{
|
||||||
|
__result = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
__result = false; // Nessuno spazio disponibile, cibo si disintegra
|
__result = false; // Nessuno spazio disponibile, cibo si disintegra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
__result = true; // Spazio nei primi 3 slot
|
__result = true; // Spazio nei primi 3 slot
|
||||||
|
|
@ -353,6 +371,34 @@ namespace RacesOfValheim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool refreshed = false;
|
||||||
|
foreach (object foodObj in m_foods)
|
||||||
|
{
|
||||||
|
Player.Food f = foodObj as Player.Food;
|
||||||
|
if (f != null && f.m_item.m_shared.m_name == item.m_shared.m_name && f.CanEatAgain())
|
||||||
|
{
|
||||||
|
f.m_time = 0f;
|
||||||
|
f.m_item = item;
|
||||||
|
|
||||||
|
var consumeEffects = HarmonyLib.Traverse.Create(__instance).Field("m_consumeItemEffects").GetValue<EffectList>();
|
||||||
|
if (consumeEffects != null) consumeEffects.Create(__instance.transform.position, Quaternion.identity, __instance.transform, 1f, -1);
|
||||||
|
|
||||||
|
var zanim = HarmonyLib.Traverse.Create(__instance).Field("m_zanim").GetValue<ZSyncAnimation>();
|
||||||
|
if (zanim != null) zanim.SetTrigger("eat");
|
||||||
|
|
||||||
|
if (item.m_shared.m_food > 0f) __instance.Heal(item.m_shared.m_food, true);
|
||||||
|
|
||||||
|
refreshed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (refreshed)
|
||||||
|
{
|
||||||
|
__result = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Se pieno e senza 4° slot disponibile, fallisce e disintegra
|
// Se pieno e senza 4° slot disponibile, fallisce e disintegra
|
||||||
__result = false;
|
__result = false;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue