99 lines
4.3 KiB
C#
99 lines
4.3 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace Harmony.ItemClassRebirth
|
|
{
|
|
internal class ItemClassPatches
|
|
{
|
|
[HarmonyPatch(typeof(ItemClass))]
|
|
[HarmonyPatch("ExecuteAction")]
|
|
public class ExecuteActionPatch
|
|
{
|
|
public static bool Prefix(ItemClass __instance, int _actionIdx, ItemInventoryData _data, bool _bReleased, PlayerActionsLocal _playerActions, FastTags<TagGroup.Global> ___stopBleed)
|
|
{
|
|
//Log.Out("itemClassPatches-ExecuteAction START");
|
|
ItemAction curAction = __instance.Actions[_actionIdx];
|
|
if (curAction == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (!(curAction is ItemActionDynamicMelee))
|
|
{
|
|
//Log.Out("itemClassPatches-ExecuteAction 1");
|
|
global::ItemActionData actionData = _data.actionData[_actionIdx];
|
|
bool flag2 = _bReleased || !curAction.IsActionRunning(actionData);
|
|
if (!flag2)
|
|
{
|
|
//Log.Out("itemClassPatches-ExecuteAction IsWeaponAvailableRebirth A flag2: " + flag2);
|
|
return false;
|
|
}
|
|
|
|
string strRequirement = "";
|
|
|
|
List<IRequirement> executionRequirements2 = curAction.ExecutionRequirements;
|
|
if (executionRequirements2 != null && !_bReleased)
|
|
{
|
|
//Log.Out("itemClassPatches-ExecuteAction executionRequirements2.Count: " + executionRequirements2.Count);
|
|
|
|
_data.holdingEntity.MinEventContext.ItemValue = _data.itemValue;
|
|
for (int j = 0; j < executionRequirements2.Count; j++)
|
|
{
|
|
//Log.Out("itemClassPatches-ExecuteAction j: " + j);
|
|
|
|
List<string> list = new List<string>();
|
|
executionRequirements2[j].GetInfoStrings(ref list);
|
|
if (list.Count > 0)
|
|
{
|
|
strRequirement = list[0];
|
|
//Log.Out("itemClassPatches-ExecuteAction strRequirement: " + strRequirement);
|
|
}
|
|
|
|
bool isValid = executionRequirements2[j].IsValid(_data.holdingEntity.MinEventContext);
|
|
|
|
//Log.Out("itemClassPatches-ExecuteAction isValid: " + isValid);
|
|
|
|
if (!isValid)
|
|
{
|
|
flag2 = false;
|
|
|
|
//Log.Out("itemClassPatches-ExecuteAction executionRequirements2: " + executionRequirements2[j]);
|
|
|
|
if (executionRequirements2[j] is IsWeaponAvailableRebirth)
|
|
{
|
|
//Log.Out("itemClassPatches-ExecuteAction IsWeaponAvailableRebirth");
|
|
strRequirement = ".FuriousRamsayCantUse";
|
|
}
|
|
else if (executionRequirements2[j] is CanConsume)
|
|
{
|
|
//Log.Out("itemClassPatches-ExecuteAction GetItemName: " + __instance.GetItemName());
|
|
|
|
if (!RebirthUtilities.CanHeal(__instance.GetItemName(), _data.holdingEntity, _data.holdingEntity))
|
|
{
|
|
strRequirement = "stat 'Health'% LT 1";
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//Log.Out("itemClassPatches-ExecuteAction IsWeaponAvailableRebirth B flag2: " + flag2);
|
|
|
|
if (!flag2)
|
|
{
|
|
//Log.Out("itemClassPatches-ExecuteAction 2");
|
|
RebirthUtilities.DisplayRequirementCaption(_data.holdingEntity, strRequirement);
|
|
|
|
return false;
|
|
}
|
|
|
|
//Log.Out("itemClassPatches-ExecuteAction 3");
|
|
return true;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
} |