550 lines
29 KiB
C#
550 lines
29 KiB
C#
using Audio;
|
|
using Platform;
|
|
using System.Globalization;
|
|
|
|
public class BlockTakeSecureLootContainer : BlockSecureLoot
|
|
{
|
|
public override void Init()
|
|
{
|
|
base.Init();
|
|
this.CanPickup = true;
|
|
|
|
if (this.Properties.Values.ContainsKey("ReplacementBlockName"))
|
|
{
|
|
this.ReplacementBlockName = this.Properties.Values["ReplacementBlockName"];
|
|
}
|
|
|
|
bool flag1 = this.Properties.Values.ContainsKey("isReplacementItem");
|
|
if (flag1)
|
|
{
|
|
StringParsers.TryParseBool(this.Properties.Values["isReplacementItem"], out this.isReplacementItem, 0, -1, true);
|
|
}
|
|
bool flag2 = this.Properties.Values.ContainsKey("numBlocks");
|
|
if (flag2)
|
|
{
|
|
this.numBlocks = Int16.Parse(this.Properties.Values["numBlocks"]);
|
|
}
|
|
this.isSecure = true;
|
|
bool flag3 = this.Properties.Values.ContainsKey("isSecure");
|
|
if (flag3)
|
|
{
|
|
StringParsers.TryParseBool(this.Properties.Values["isSecure"], out this.isSecure, 0, -1, true);
|
|
}
|
|
bool flag4 = this.Properties.Values.ContainsKey("TakeDelay");
|
|
if (flag4)
|
|
{
|
|
this.TakeDelay = StringParsers.ParseFloat(this.Properties.Values["TakeDelay"], 0, -1, NumberStyles.Any);
|
|
}
|
|
bool flag5 = this.Properties.Values.ContainsKey("canPickUpBlock");
|
|
if (flag5)
|
|
{
|
|
StringParsers.TryParseBool(this.Properties.Values["canPickUpBlock"], out this.canPickUpBlock, 0, -1, true);
|
|
}
|
|
bool flag6 = this.Properties.Values.ContainsKey("isLootContainer");
|
|
if (flag6)
|
|
{
|
|
StringParsers.TryParseBool(this.Properties.Values["isLootContainer"], out this.isLootContainer, 0, -1, true);
|
|
}
|
|
}
|
|
|
|
public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
|
{
|
|
TileEntitySecureLootContainer tileEntitySecureLootContainer = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntitySecureLootContainer;
|
|
PlayerActionsLocal playerInput = ((EntityPlayerLocal)_entityFocusing).playerInput;
|
|
string arg = playerInput.Activate.GetBindingXuiMarkupString(XUiUtils.EmptyBindingStyle.EmptyString, XUiUtils.DisplayStyle.Plain, null) + playerInput.PermanentActions.Activate.GetBindingXuiMarkupString(XUiUtils.EmptyBindingStyle.EmptyString, XUiUtils.DisplayStyle.Plain, null);
|
|
if (tileEntitySecureLootContainer == null)
|
|
{
|
|
return "";
|
|
}
|
|
string localizedBlockName = _blockValue.Block.GetLocalizedBlockName();
|
|
|
|
if (this.isSecure)
|
|
{
|
|
PersistentPlayerData playerData = _world.GetGameManager().GetPersistentPlayerList().GetPlayerData(tileEntitySecureLootContainer.GetOwner());
|
|
|
|
string result = "";
|
|
|
|
if (!tileEntitySecureLootContainer.IsLocked())
|
|
{
|
|
result = string.Format(Localization.Get("tooltipUnlocked"), arg, localizedBlockName);
|
|
}
|
|
else if (this.lockPickItem == null && !tileEntitySecureLootContainer.LocalPlayerIsOwner())
|
|
{
|
|
result = string.Format(Localization.Get("tooltipJammed"), arg, localizedBlockName);
|
|
}
|
|
else
|
|
{
|
|
result = string.Format(Localization.Get("tooltipLocked"), arg, localizedBlockName);
|
|
}
|
|
|
|
if (playerData != null)
|
|
{
|
|
result = result + "\n" + Localization.Get("ttowner") + ": [94bd91]" + playerData.PlayerName.DisplayName + "[-]";
|
|
}
|
|
|
|
return result;
|
|
}
|
|
else
|
|
{
|
|
if (!tileEntitySecureLootContainer.bTouched)
|
|
{
|
|
return string.Format(Localization.Get("lootTooltipNew"), arg, localizedBlockName);
|
|
}
|
|
if (tileEntitySecureLootContainer.IsEmpty())
|
|
{
|
|
return string.Format(Localization.Get("lootTooltipEmpty"), arg, localizedBlockName);
|
|
}
|
|
return string.Format(Localization.Get("lootTooltipTouched"), arg, localizedBlockName);
|
|
}
|
|
}
|
|
|
|
public override bool OnBlockActivated(string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
|
{
|
|
if (_blockValue.ischild)
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-OnBlockActivated _blockValue.ischild");
|
|
Vector3i parentPos = _blockValue.Block.multiBlockPos.GetParentPos(_blockPos, _blockValue);
|
|
BlockValue block = _world.GetBlock(parentPos);
|
|
return this.OnBlockActivated(_commandName, _world, _cIdx, parentPos, block, _player);
|
|
}
|
|
TileEntitySecureLootContainer tileEntitySecureLootContainer = _world.GetTileEntity(_cIdx, _blockPos) as TileEntitySecureLootContainer;
|
|
if (tileEntitySecureLootContainer == null)
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-OnBlockActivated 0");
|
|
return false;
|
|
}
|
|
|
|
//Log.Out("BlockTakeSecureLootContainer-OnBlockActivated tileEntitySecureLootContainer.bPlayerStorage: " + tileEntitySecureLootContainer.bPlayerStorage);
|
|
//Log.Out("BlockTakeSecureLootContainer-OnBlockActivated isSecure: " + this.isSecure);
|
|
if (this.isSecure)
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-OnBlockActivated 1");
|
|
PlatformUserIdentifierAbs getContainerOwner = tileEntitySecureLootContainer.GetOwner();
|
|
bool isUserAllowed = tileEntitySecureLootContainer.IsUserAllowed(PlatformManager.InternalLocalUserIdentifier);
|
|
if (_commandName == this.cmds[0].text)
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-OnBlockActivated:Secure/Search");
|
|
|
|
Vector3i blockPos = tileEntitySecureLootContainer.ToWorldPos();
|
|
tileEntitySecureLootContainer.bWasTouched = tileEntitySecureLootContainer.bTouched;
|
|
if (!tileEntitySecureLootContainer.IsLocked() || isUserAllowed)
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-OnBlockActivated 2");
|
|
_world.GetGameManager().TELockServer(_cIdx, blockPos, tileEntitySecureLootContainer.entityId, _player.entityId, null);
|
|
return true;
|
|
}
|
|
Manager.BroadcastPlayByLocalPlayer(_blockPos.ToVector3() + Vector3.one * 0.5f, "Misc/locked");
|
|
return false;
|
|
}
|
|
else if (_commandName == this.cmds[1].text)
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-OnBlockActivated 3");
|
|
tileEntitySecureLootContainer.SetLocked(true);
|
|
Manager.BroadcastPlayByLocalPlayer(_blockPos.ToVector3() + Vector3.one * 0.5f, "Misc/locking");
|
|
GameManager.ShowTooltip(_player as EntityPlayerLocal, "containerLocked");
|
|
return true;
|
|
}
|
|
else if (_commandName == this.cmds[2].text)
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-OnBlockActivated 4");
|
|
tileEntitySecureLootContainer.SetLocked(false);
|
|
Manager.BroadcastPlayByLocalPlayer(_blockPos.ToVector3() + Vector3.one * 0.5f, "Misc/unlocking");
|
|
GameManager.ShowTooltip(_player as EntityPlayerLocal, "containerUnlocked");
|
|
return true;
|
|
}
|
|
else if (_commandName == this.cmds[3].text)
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-OnBlockActivated 5");
|
|
LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(_player as EntityPlayerLocal);
|
|
if (uiforPlayer != null)
|
|
{
|
|
XUiC_KeypadWindow.Open(uiforPlayer, tileEntitySecureLootContainer);
|
|
}
|
|
return true;
|
|
}
|
|
else if (_commandName == this.cmds[4].text)
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-OnBlockActivated 6");
|
|
if (getContainerOwner == null)
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-OnBlockActivated 7");
|
|
LocalPlayerUI playerUI = (_player as EntityPlayerLocal).PlayerUI;
|
|
ItemValue item = ItemClass.GetItem(this.lockPickItem, false);
|
|
if (playerUI.xui.PlayerInventory.GetItemCount(item) == 0)
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-OnBlockActivated 8");
|
|
playerUI.xui.CollectedItemList.AddItemStack(new ItemStack(item, 0), true);
|
|
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttLockpickMissing"));
|
|
return true;
|
|
}
|
|
|
|
bool advancedLockPicking = CustomGameOptions.GetBool("CustomLockPick");
|
|
if (!advancedLockPicking)
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-OnBlockActivated 9");
|
|
LocalPlayerUI playerUi = _player.PlayerUI;
|
|
ItemValue _itemValue = ItemClass.GetItem(this.lockPickItem);
|
|
if (playerUi.xui.PlayerInventory.GetItemCount(_itemValue) == 0)
|
|
{
|
|
playerUi.xui.CollectedItemList.AddItemStack(new ItemStack(_itemValue, 0), true);
|
|
GameManager.ShowTooltip(_player, Localization.Get("ttLockpickMissing"));
|
|
return true;
|
|
}
|
|
_player.AimingGun = false;
|
|
Vector3i worldPos = tileEntitySecureLootContainer.ToWorldPos();
|
|
//tileEntitySecureLootContainer.bWasTouched = tileEntitySecureLootContainer.bTouched;
|
|
_world.GetGameManager().TELockServer(_cIdx, worldPos, tileEntitySecureLootContainer.entityId, _player.entityId, "lockpick");
|
|
return true;
|
|
}
|
|
|
|
// If they have a controller, skip the mini game
|
|
if (PlatformManager.NativePlatform.Input.CurrentInputStyle == PlayerInputManager.InputStyle.Keyboard)
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-OnBlockActivated 10");
|
|
advancedLockPicking = true;
|
|
}
|
|
|
|
if (_player.Buffs.HasCustomVar("LegacyLockPick") && _player.Buffs.GetCustomVar("LegacyLockPick") > 0)
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-OnBlockActivated 11");
|
|
advancedLockPicking = true;
|
|
}
|
|
|
|
//Log.Out("OnBlockActivated, advancedLockPicking: " + advancedLockPicking);
|
|
if (advancedLockPicking)
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-OnBlockActivated 12");
|
|
XUiC_PickLocking.Open(playerUI, tileEntitySecureLootContainer, _blockValue, _blockPos);
|
|
}
|
|
else
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-OnBlockActivated 13");
|
|
playerUI.windowManager.Open("timer", true, false, true);
|
|
XUiC_Timer childByType = playerUI.xui.GetChildByType<XUiC_Timer>();
|
|
TimerEventData timerEventData = new TimerEventData();
|
|
timerEventData.CloseEvent += this.EventData_CloseEvent;
|
|
float alternateTime = -1f;
|
|
if (_player.rand.RandomRange(1f) < EffectManager.GetValue(PassiveEffects.LockPickBreakChance, _player.inventory.holdingItemItemValue, this.lockPickBreakChance, _player, null, new FastTags<TagGroup.Global>(), true, true, true, true, true, 1))
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-OnBlockActivated 14");
|
|
float value = EffectManager.GetValue(PassiveEffects.LockPickTime, _player.inventory.holdingItemItemValue, this.lockPickTime, _player, null, new FastTags<TagGroup.Global>(), true, true, true, true, true, 1);
|
|
float num = value - ((tileEntitySecureLootContainer.PickTimeLeft == -1f) ? (value - 1f) : (tileEntitySecureLootContainer.PickTimeLeft + 1f));
|
|
alternateTime = _player.rand.RandomRange(num + 1f, value - 1f);
|
|
}
|
|
timerEventData.Data = new object[]
|
|
{
|
|
_cIdx,
|
|
_blockValue,
|
|
_blockPos,
|
|
_player,
|
|
item
|
|
};
|
|
timerEventData.Event += this.EventData_Event;
|
|
timerEventData.alternateTime = alternateTime;
|
|
timerEventData.AlternateEvent += this.EventData_CloseEvent;
|
|
childByType.SetTimer(EffectManager.GetValue(PassiveEffects.LockPickTime, _player.inventory.holdingItemItemValue, this.lockPickTime, _player, null, new FastTags<TagGroup.Global>(), true, true, true, true, true, 1), timerEventData, tileEntitySecureLootContainer.PickTimeLeft, "");
|
|
Manager.BroadcastPlayByLocalPlayer(_blockPos.ToVector3() + Vector3.one * 0.5f, "Misc/unlocking");
|
|
}
|
|
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
//Log.Out("OnBlockActivated:Pick has owner");
|
|
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttNotBelongsToSomeone"), string.Empty, "ui_denied", null);
|
|
return false;
|
|
}
|
|
}
|
|
else if (_commandName == this.cmds[5].text)
|
|
{
|
|
XUiC_TriggerProperties.Show(((EntityPlayerLocal)_player).PlayerUI.xui, _cIdx, _blockPos, false, true);
|
|
return true;
|
|
}
|
|
else if (_commandName == this.cmds[6].text)
|
|
{
|
|
bool result;
|
|
//Log.Out("OnBlockActivated:Take before GetOwner");
|
|
//Log.Out("OnBlockActivated:Take after GetOwner");
|
|
if (getContainerOwner == null)
|
|
{
|
|
if (((World)_world).IsWithinTraderArea(_blockPos))
|
|
{
|
|
Manager.PlayInsidePlayerHead("ui_denied");
|
|
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
|
|
return false;
|
|
}
|
|
|
|
//Log.Out("OnBlockActivated:Take has no owner");
|
|
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, this.TakeDelay, null, ReplacementBlockName, numBlocks, isReplacementItem);
|
|
result = true;
|
|
}
|
|
else
|
|
{
|
|
//Log.Out("OnBlockActivated:Take has owner");
|
|
bool isOwner = tileEntitySecureLootContainer.IsOwner(PlatformManager.InternalLocalUserIdentifier);
|
|
bool hasLandClaim = _world.IsMyLandProtectedBlock(_blockPos, _world.GetGameManager().GetPersistentLocalPlayer(), false);
|
|
bool isAdmin = _player.Buffs.HasBuff("god");
|
|
|
|
if (!isOwner && !hasLandClaim)
|
|
{
|
|
if (isAdmin)
|
|
{
|
|
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, this.TakeDelay, null, ReplacementBlockName, numBlocks, isReplacementItem);
|
|
result = true;
|
|
}
|
|
else
|
|
{
|
|
//Log.Out("OnBlockActivated:Take am not owner");
|
|
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttNotBelongsToYou"), string.Empty, "ui_denied", null);
|
|
result = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (((World)_world).IsWithinTraderArea(_blockPos))
|
|
{
|
|
Manager.PlayInsidePlayerHead("ui_denied");
|
|
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
|
|
return false;
|
|
}
|
|
|
|
//Log.Out("OnBlockActivated:Take am owner");
|
|
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, this.TakeDelay, null, ReplacementBlockName, numBlocks, isReplacementItem);
|
|
result = true;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer:-isSecure: False");
|
|
if (_commandName == this.cmds[0].text)
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer:-OnBlockActivated-_commandName == this.cmds[0].text");
|
|
//Log.Out("OnBlockActivated:Insecure/Search");
|
|
if (_player.inventory.IsHoldingItemActionRunning())
|
|
{
|
|
return false;
|
|
}
|
|
_player.AimingGun = false;
|
|
Vector3i blockPos = tileEntitySecureLootContainer.ToWorldPos();
|
|
tileEntitySecureLootContainer.bWasTouched = tileEntitySecureLootContainer.bTouched;
|
|
//Log.Out("OnBlockActivated:Insecure/Search, Before Lock");
|
|
_world.GetGameManager().TELockServer(_cIdx, blockPos, tileEntitySecureLootContainer.entityId, _player.entityId, null);
|
|
//Log.Out("OnBlockActivated:Insecure/Search, After Lock");
|
|
return true;
|
|
}
|
|
else if (_commandName == this.cmds[6].text)
|
|
{
|
|
bool result;
|
|
//Log.Out("OnBlockActivated:Take before GetOwner");
|
|
PlatformUserIdentifierAbs getContainerOwner = tileEntitySecureLootContainer.GetOwner();
|
|
//Log.Out("OnBlockActivated:Take after GetOwner");
|
|
if (getContainerOwner == null)
|
|
{
|
|
if (((World)_world).IsWithinTraderArea(_blockPos))
|
|
{
|
|
Manager.PlayInsidePlayerHead("ui_denied");
|
|
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
|
|
return false;
|
|
}
|
|
|
|
//Log.Out("OnBlockActivated:Take has no owner");
|
|
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, this.TakeDelay, null, ReplacementBlockName, numBlocks, isReplacementItem);
|
|
result = true;
|
|
}
|
|
else
|
|
{
|
|
//Log.Out("OnBlockActivated:Take has owner");
|
|
bool isOwner = tileEntitySecureLootContainer.IsOwner(PlatformManager.InternalLocalUserIdentifier);
|
|
bool hasLandClaim = _world.IsMyLandProtectedBlock(_blockPos, _world.GetGameManager().GetPersistentLocalPlayer(), false);
|
|
if (!isOwner && !hasLandClaim)
|
|
{
|
|
//Log.Out("OnBlockActivated:Take am not owner");
|
|
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttNotBelongsToYou"), string.Empty, "ui_denied", null);
|
|
result = false;
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
if (((World)_world).IsWithinTraderArea(_blockPos))
|
|
{
|
|
Manager.PlayInsidePlayerHead("ui_denied");
|
|
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
|
|
return false;
|
|
}
|
|
|
|
//Log.Out("OnBlockActivated:Take am owner");
|
|
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, this.TakeDelay, null, ReplacementBlockName, numBlocks, isReplacementItem);
|
|
result = true;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void EventData_Event(TimerEventData timerData)
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-EventData_Event START");
|
|
World world = GameManager.Instance.World;
|
|
object[] array = (object[])timerData.Data;
|
|
int clrIdx = (int)array[0];
|
|
BlockValue blockValue = (BlockValue)array[1];
|
|
Vector3i vector3i = (Vector3i)array[2];
|
|
BlockValue block = world.GetBlock(vector3i);
|
|
EntityPlayerLocal entityPlayerLocal = array[3] as EntityPlayerLocal;
|
|
object obj = array[4];
|
|
TileEntitySecureLootContainer tileEntitySecureLootContainer = world.GetTileEntity(clrIdx, vector3i) as TileEntitySecureLootContainer;
|
|
if (tileEntitySecureLootContainer == null)
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-EventData_Event 1");
|
|
return;
|
|
}
|
|
if (tileEntitySecureLootContainer.IsUserAccessing())
|
|
{
|
|
//Log.Out("BlockTakeSecureLootContainer-EventData_Event 2");
|
|
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get("ttCantPickupInUse"), string.Empty, "ui_denied", null);
|
|
return;
|
|
}
|
|
LocalPlayerUI.GetUIForPlayer(entityPlayerLocal);
|
|
if (!this.DowngradeBlock.isair)
|
|
{
|
|
BlockValue blockValue2 = this.DowngradeBlock;
|
|
blockValue2 = BlockPlaceholderMap.Instance.Replace(blockValue2, world.GetGameRandom(), vector3i.x, vector3i.z);
|
|
blockValue2.rotation = block.rotation;
|
|
blockValue2.meta = block.meta;
|
|
world.SetBlockRPC(clrIdx, vector3i, blockValue2, blockValue2.Block.Density);
|
|
}
|
|
Manager.BroadcastPlayByLocalPlayer(vector3i.ToVector3() + Vector3.one * 0.5f, "Misc/unlocking");
|
|
this.ResetEventData(timerData);
|
|
}
|
|
|
|
private void ResetEventData(TimerEventData timerData)
|
|
{
|
|
timerData.AlternateEvent -= this.EventData_CloseEvent;
|
|
timerData.CloseEvent -= this.EventData_CloseEvent;
|
|
timerData.Event -= this.EventData_Event;
|
|
}
|
|
|
|
private void EventData_CloseEvent(TimerEventData timerData)
|
|
{
|
|
object[] array = (object[])timerData.Data;
|
|
Vector3i blockPos = (Vector3i)array[2];
|
|
EntityPlayerLocal entityPlayerLocal = array[3] as EntityPlayerLocal;
|
|
ItemValue itemValue = array[4] as ItemValue;
|
|
LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(entityPlayerLocal);
|
|
Manager.BroadcastPlayByLocalPlayer(blockPos.ToVector3() + Vector3.one * 0.5f, "Misc/locked");
|
|
ItemStack itemStack = new ItemStack(itemValue, 1);
|
|
uiforPlayer.xui.PlayerInventory.RemoveItem(itemStack);
|
|
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get("ttLockpickBroken"));
|
|
uiforPlayer.xui.CollectedItemList.RemoveItemStack(itemStack);
|
|
TileEntitySecureLootContainer tileEntitySecureLootContainer = GameManager.Instance.World.GetTileEntity((int)array[0], blockPos) as TileEntitySecureLootContainer;
|
|
if (tileEntitySecureLootContainer == null)
|
|
{
|
|
return;
|
|
}
|
|
tileEntitySecureLootContainer.PickTimeLeft = Mathf.Max(this.lockPickTime * 0.25f, timerData.timeLeft);
|
|
this.ResetEventData(timerData);
|
|
}
|
|
|
|
public override BlockActivationCommand[] GetBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
|
{
|
|
TileEntitySecureLootContainer tileEntitySecureLootContainer = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntitySecureLootContainer;
|
|
if (tileEntitySecureLootContainer == null)
|
|
{
|
|
return new BlockActivationCommand[0];
|
|
}
|
|
PlatformUserIdentifierAbs internalLocalUserIdentifier = PlatformManager.InternalLocalUserIdentifier;
|
|
PersistentPlayerData playerData = _world.GetGameManager().GetPersistentPlayerList().GetPlayerData(tileEntitySecureLootContainer.GetOwner());
|
|
bool flag = tileEntitySecureLootContainer.LocalPlayerIsOwner();
|
|
bool flag2 = !flag && (playerData != null && playerData.ACL != null) && playerData.ACL.Contains(internalLocalUserIdentifier);
|
|
this.cmds[0].enabled = this.canPickUpBlock;
|
|
this.cmds[1].enabled = (this.isSecure && !tileEntitySecureLootContainer.IsLocked() && (flag || flag2));
|
|
this.cmds[2].enabled = (this.isSecure && tileEntitySecureLootContainer.IsLocked() && flag);
|
|
this.cmds[3].enabled = this.isSecure && ((!tileEntitySecureLootContainer.IsUserAllowed(internalLocalUserIdentifier) && tileEntitySecureLootContainer.HasPassword() && tileEntitySecureLootContainer.IsLocked()) || flag);
|
|
this.cmds[4].enabled = (this.isSecure && this.lockPickItem != null && tileEntitySecureLootContainer.IsLocked() && !flag);
|
|
this.cmds[5].enabled = this.isSecure && _world.IsEditor();
|
|
this.cmds[6].enabled = this.canPickUpBlock && (tileEntitySecureLootContainer.IsEmpty() && tileEntitySecureLootContainer.bTouched);
|
|
return this.cmds;
|
|
}
|
|
|
|
public BlockActivationCommand[] cmds = new BlockActivationCommand[]
|
|
{
|
|
new BlockActivationCommand("Search", "search", false, false),
|
|
new BlockActivationCommand("lock", "lock", false, false),
|
|
new BlockActivationCommand("unlock", "unlock", false, false),
|
|
new BlockActivationCommand("keypad", "keypad", false, false),
|
|
new BlockActivationCommand("pick", "unlock", false, false),
|
|
new BlockActivationCommand("trigger", "wrench", true, false),
|
|
new BlockActivationCommand("take", "hand", false, false),
|
|
};
|
|
|
|
public override int DamageBlock(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, int _damagePoints, int _entityIdThatDamaged, ItemActionAttack.AttackHitInfo _attackHitInfo = null, bool _bUseHarvestTool = false, bool _bBypassMaxDamage = false)
|
|
{
|
|
TileEntitySecureLootContainer tileEntitySecureLootContainer = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntitySecureLootContainer;
|
|
PlatformUserIdentifierAbs getContainerOwner = tileEntitySecureLootContainer.GetOwner();
|
|
if (getContainerOwner == null)
|
|
{
|
|
return this.OnBlockDamaged(_world, _clrIdx, _blockPos, _blockValue, _damagePoints, _entityIdThatDamaged, _attackHitInfo, _bUseHarvestTool, _bBypassMaxDamage, 0);
|
|
}
|
|
else
|
|
{
|
|
bool isOwner = tileEntitySecureLootContainer.IsOwner(PlatformManager.InternalLocalUserIdentifier);
|
|
if (!isOwner)
|
|
{
|
|
EntityAlive entityAlive = _world.GetEntity(_entityIdThatDamaged) as EntityAlive;
|
|
if (entityAlive != null)
|
|
{
|
|
string entityClassName = entityAlive.EntityClass.entityClassName;
|
|
//Log.Out("DamageBlock:entityClassName: " + entityClassName);
|
|
if (entityClassName == "playerMale" || entityClassName == "playerFemale")
|
|
{
|
|
int @playerKillingMode = GameStats.GetInt(EnumGameStats.PlayerKillingMode);
|
|
//Log.Out("DamageBlock:EnumPlayerKillingMode-@playerKillingMode: " + @playerKillingMode);
|
|
if (@playerKillingMode == 0)
|
|
{
|
|
//Log.Out("DamageBlock:EnumPlayerKillingMode: No Killing");
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
//Log.Out("DamageBlock:EnumPlayerKillingMode: Killing Allowed");
|
|
return this.OnBlockDamaged(_world, _clrIdx, _blockPos, _blockValue, _damagePoints, _entityIdThatDamaged, _attackHitInfo, _bUseHarvestTool, _bBypassMaxDamage, 0);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return this.OnBlockDamaged(_world, _clrIdx, _blockPos, _blockValue, _damagePoints, _entityIdThatDamaged, _attackHitInfo, _bUseHarvestTool, _bBypassMaxDamage, 0);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return this.OnBlockDamaged(_world, _clrIdx, _blockPos, _blockValue, _damagePoints, _entityIdThatDamaged, _attackHitInfo, _bUseHarvestTool, _bBypassMaxDamage, 0);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return this.OnBlockDamaged(_world, _clrIdx, _blockPos, _blockValue, _damagePoints, _entityIdThatDamaged, _attackHitInfo, _bUseHarvestTool, _bBypassMaxDamage, 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
public float TakeDelay = RebirthVariables.takeDelay;
|
|
public string ReplacementBlockName = "";
|
|
public int numBlocks = 1;
|
|
public bool isReplacementItem = false;
|
|
public bool isSecure = false;
|
|
public bool isLootContainer = true;
|
|
public bool canPickUpBlock = true;
|
|
}
|