65 lines
2.3 KiB
C#
65 lines
2.3 KiB
C#
using Audio;
|
|
|
|
public class BlockPoweredSDX : BlockPowered
|
|
{
|
|
public override bool OnBlockActivated(string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
|
{
|
|
bool ischild = _blockValue.ischild;
|
|
bool result;
|
|
if (ischild)
|
|
{
|
|
Vector3i parentPos = _blockValue.Block.multiBlockPos.GetParentPos(_blockPos, _blockValue);
|
|
BlockValue block = _world.GetBlock(parentPos);
|
|
result = this.OnBlockActivated(_commandName, _world, _cIdx, parentPos, block, _player);
|
|
}
|
|
else
|
|
{
|
|
if (_commandName == this.cmds[0].text)
|
|
{
|
|
result = false;
|
|
}
|
|
else if (_commandName == this.cmds[1].text)
|
|
{
|
|
if (((World)_world).IsWithinTraderArea(_blockPos))
|
|
{
|
|
Manager.PlayInsidePlayerHead("ui_denied");
|
|
GameManager.ShowTooltip(_player, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
|
|
return false;
|
|
}
|
|
|
|
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, this.TakeDelay, null, "", 1, false);
|
|
result = true;
|
|
}
|
|
else
|
|
{
|
|
result = false;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
|
{
|
|
return "";
|
|
}
|
|
|
|
public override BlockActivationCommand[] GetBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
|
{
|
|
bool flag = _world.IsMyLandProtectedBlock(_blockPos, _world.GetGameManager().GetPersistentLocalPlayer(), false);
|
|
|
|
this.cmds[0].enabled = (flag && this.canPickUpBlock);
|
|
this.cmds[1].enabled = (flag && this.canPickUpBlock);
|
|
return this.cmds;
|
|
}
|
|
|
|
private BlockActivationCommand[] cmds = new BlockActivationCommand[]
|
|
{
|
|
new BlockActivationCommand("cancel", "x", false, false),
|
|
new BlockActivationCommand("take", "hand", false, false)
|
|
};
|
|
|
|
public bool canPickUpBlock = true;
|
|
}
|