Upload from upload_mods.ps1

This commit is contained in:
Nathaniel Cosford
2025-06-04 16:44:53 +09:30
commit f1fbbe67bb
1722 changed files with 165268 additions and 0 deletions

View File

@@ -0,0 +1,145 @@
using Audio;
namespace Harmony.BlockLootPatches
{
[HarmonyPatch(typeof(BlockLoot))]
[HarmonyPatch("PlaceBlock")]
public class PlaceBlockPatch
{
public static void Postfix(BlockLoot __instance, WorldBase _world, BlockPlacement.Result _result, EntityAlive _ea)
{
TileEntityLootContainer tileEntityLootContainer = _world.GetTileEntity(_result.clrIdx, _result.blockPos) as TileEntityLootContainer;
if (tileEntityLootContainer != null)
{
tileEntityLootContainer.bPlayerStorage = true;
tileEntityLootContainer.SetModified();
}
}
}
[HarmonyPatch(typeof(BlockLoot))]
[HarmonyPatch("Init")]
public class InitPatch
{
public static void Postfix(BlockLoot __instance, ref BlockActivationCommand[] ___cmds)
{
Array.Resize<BlockActivationCommand>(ref ___cmds, 2);
___cmds[0] = new BlockActivationCommand("Search", "search", false, false);
___cmds[1] = new BlockActivationCommand("take", "hand", false, false);
}
}
[HarmonyPatch(typeof(BlockLoot))]
[HarmonyPatch("HasBlockActivationCommands")]
public class HasBlockActivationCommandsPatch
{
public static void Postfix(BlockLoot __instance, ref bool __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, global::EntityAlive _entityFocusing)
{
__result = RebirthUtilities.CanBeLooted(_blockPos, _blockValue, _clrIdx);
}
}
[HarmonyPatch(typeof(BlockLoot))]
[HarmonyPatch("GetBlockActivationCommands")]
public class GetBlockActivationCommandsPatch
{
public static void Postfix(BlockLoot __instance, ref BlockActivationCommand[] __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, global::EntityAlive _entityFocusing,
BlockActivationCommand[] ___cmds
)
{
TileEntityLootContainer tileEntityLootContainer = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityLootContainer;
bool flag = tileEntityLootContainer == null;
BlockActivationCommand[] result;
if (flag)
{
result = new BlockActivationCommand[0];
}
else
{
bool isEmpty = tileEntityLootContainer.IsEmpty();
bool bTouched = tileEntityLootContainer.bTouched;
//Log.Out("BlockPatches-GetBlockActivationCommands isEmpty: " + isEmpty);
//Log.Out("BlockPatches-GetBlockActivationCommands bTouched: " + bTouched);
//Log.Out("BlockPatches-GetBlockActivationCommands _blockValue.Block.GetBlockName(): " + _blockValue.Block.GetBlockName());
___cmds[0].enabled = true;
___cmds[1].enabled = isEmpty && bTouched && !_blockValue.Block.GetBlockName().ToLower().Contains("repairable") && !(_blockValue.Block.GetBlockName().ToLower() == "cntfetchquestsatchel");
//Log.Out("BlockPatches-GetBlockActivationCommands HAS TAKE DELAY");
}
//Log.Out("BlockPatches-GetBlockActivationCommands END");
__result = ___cmds;
}
}
[HarmonyPatch(typeof(BlockLoot))]
[HarmonyPatch("OnBlockActivated")]
[HarmonyPatch(new Type[] { typeof(string), typeof(WorldBase), typeof(int), typeof(Vector3i), typeof(BlockValue), typeof(EntityPlayerLocal) })]
public class OnBlockActivatedPatch
{
public static bool Prefix(BlockLoot __instance, ref bool __result, string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
{
if (_commandName == "Search" && !RebirthUtilities.CanBeLooted(_blockPos, _blockValue, _cIdx))
{
Manager.PlayInsidePlayerHead("ui_denied");
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
return false;
}
return true;
}
public static void Postfix(BlockLoot __instance, ref bool __result, string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, global::EntityAlive _player)
{
float takeDelay = RebirthVariables.takeDelay;
string replacementBlockName = "";
int numBlocks = 1;
bool isReplacementItem = false;
if (__instance.Properties.Contains("TakeDelay"))
{
__instance.Properties.ParseFloat("TakeDelay", ref takeDelay);
}
if (__instance.Properties.Contains("ReplacementBlockName"))
{
__instance.Properties.ParseString("ReplacementBlockName", ref replacementBlockName);
}
if (__instance.Properties.Contains("numBlocks"))
{
__instance.Properties.ParseInt("numBlocks", ref numBlocks);
}
if (__instance.Properties.Contains("isReplacementItem"))
{
__instance.Properties.ParseBool("isReplacementItem", ref isReplacementItem);
}
//Log.Out("BlockPatches-OnBlockActivated _commandName: " + _commandName);
if (_commandName == "take" && !_blockValue.Block.GetBlockName().ToLower().Contains("repairable"))
{
/*Log.Out("BlockPatches-OnBlockActivated takeDelay: " + takeDelay);
Log.Out("BlockPatches-OnBlockActivated replacementBlockName: " + replacementBlockName);
Log.Out("BlockPatches-OnBlockActivated numBlocks: " + numBlocks);
Log.Out("BlockPatches-OnBlockActivated isReplacementItem: " + isReplacementItem);*/
if (((World)_world).IsWithinTraderArea(_blockPos))
{
bool optionProtectTrader = RebirthVariables.customProtectTraderArea;
if (optionProtectTrader)
{
Manager.PlayInsidePlayerHead("ui_denied");
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
return;
}
}
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, takeDelay, null, replacementBlockName, numBlocks, isReplacementItem);
__result = true;
}
}
}
}