kolumas
Пользователь
- Сообщения
- 37
- Реакции
- 3
То же самое. Пока автор не выпустил обнову, заменил текст метода CustomTrapThink на это:Поломатость после обновы.
Код:Failed to compile: Argument 7 must be passed with the 'out' keyword | Line: 288, Pos: 195
Код:
public void CustomTrapThink()
{
Item baitItem = null;
int usedLureAmount = 0;
bool isGoldenFish = false;
if (!HasBait())
{
trap.CancelInvoke(CustomTrapThink);
trap.SetFlag(Flags.On, false);
return;
}
foreach (Item current in trap.inventory.itemList)
{
if (IsCustomFish(current)) continue;
float baitValue = current.info.TryGetComponent(out ItemModCompostable component) ? component.BaitValue : 0f;
if (baitValue <= 0f) continue;
baitItem = current;
usedLureAmount = 1;
break;
}
baitItem?.UseItem(usedLureAmount);
// Проверка успеха ловли
if (Random.Range(0f, 1f) <= trap.trapSuccessRate)
return;
try
{
trap.bypassItemFilter = true;
if (_instance._config.FishDropTrap.DropChance > 0 && Random.Range(0, 100) < _instance._config.FishDropTrap.DropChance)
{
isGoldenFish = true;
Item goldenFish = _instance._config.CustomItem.CreateItem();
if (trap.LastLootedByPlayer != null)
goldenFish.SetItemOwnership(trap.LastLootedByPlayer, ItemOwnershipPhrases.SurvivalTrap);
if (!goldenFish.MoveToContainer(trap.inventory))
goldenFish.Drop(transform.position, Vector3.zero, Quaternion.identity);
}
else
{
// Создаем обычную рыбу если не выпала золотая
Item fish = ItemManager.CreateByName("fish.troutsmall", 1);
if (trap.LastLootedByPlayer != null)
fish.SetItemOwnership(trap.LastLootedByPlayer, ItemOwnershipPhrases.SurvivalTrap);
if (!fish.MoveToContainer(trap.inventory))
fish.Drop(transform.position, Vector3.zero, Quaternion.identity);
}
}
finally
{
trap.bypassItemFilter = false;
}
OnTrappedWildlife(true, isGoldenFish);
}