38 lines
1.9 KiB
C#
38 lines
1.9 KiB
C#
namespace Harmony.BlockCompositeTileEntityPatches
|
|
{
|
|
[HarmonyPatch(typeof(BlockCompositeTileEntity))]
|
|
[HarmonyPatch("GetActivationText")]
|
|
public class GetActivationTextPatch
|
|
{
|
|
public static bool Prefix(BlockCompositeTileEntity __instance, ref string __result, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
|
{
|
|
if (__instance.GetParentPos(_world, _clrIdx, ref _blockPos, ref _blockValue))
|
|
__result = _blockValue.Block.GetActivationText(_world, _blockValue, _clrIdx, _blockPos, _entityFocusing);
|
|
|
|
TileEntityComposite tileEntity = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityComposite;
|
|
|
|
if (tileEntity == null)
|
|
__result = "";
|
|
if (__instance.commands == null)
|
|
__instance.commands = tileEntity.InitBlockActivationCommands();
|
|
if (__instance.commands.Length == 0)
|
|
__result = (string)null;
|
|
PlayerActionsLocal playerInput = ((EntityPlayerLocal)_entityFocusing).playerInput;
|
|
string _activateHotkeyMarkup = playerInput.Activate.GetBindingXuiMarkupString() + playerInput.PermanentActions.Activate.GetBindingXuiMarkupString();
|
|
string localizedBlockName = _blockValue.Block.GetLocalizedBlockName();
|
|
|
|
string ownerText = "";
|
|
|
|
if (tileEntity.TryGetSelfOrFeature(out ILockable lockable))
|
|
{
|
|
PersistentPlayerData playerData = _world.GetGameManager().GetPersistentPlayerList().GetPlayerData(lockable.GetOwner());
|
|
ownerText = "\n" + Localization.Get("ttowner") + ": [94bd91]" + playerData.PlayerName.DisplayName + "[-]";
|
|
}
|
|
|
|
__result = tileEntity.GetActivationText(_world, _blockPos, _blockValue, _entityFocusing, _activateHotkeyMarkup, localizedBlockName) + ownerText;
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|