Upload from upload_mods.ps1
This commit is contained in:
247
Scripts/Blocks/Inactive/BlockCampfireRebirthOld.cs
Normal file
247
Scripts/Blocks/Inactive/BlockCampfireRebirthOld.cs
Normal file
@@ -0,0 +1,247 @@
|
||||
using Audio;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
public class BlockCampfireRebirthOld : BlockParticle
|
||||
{
|
||||
public BlockCampfireRebirthOld()
|
||||
{
|
||||
this.HasTileEntity = true;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
if (this.Properties.Values.ContainsKey("TakeDelay"))
|
||||
{
|
||||
this.TakeDelay = StringParsers.ParseFloat(this.Properties.Values["TakeDelay"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.TakeDelay = 2f;
|
||||
}
|
||||
this.WorkstationData = new WorkstationData(base.GetBlockName(), this.Properties);
|
||||
CraftingManager.AddWorkstationData(this.WorkstationData);
|
||||
}
|
||||
|
||||
public override void OnBlockAdded(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
base.OnBlockAdded(world, _chunk, _blockPos, _blockValue);
|
||||
if (_blockValue.ischild)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_chunk.AddTileEntity(new TileEntityWorkstation(_chunk)
|
||||
{
|
||||
localChunkPos = World.toBlock(_blockPos)
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnBlockRemoved(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
base.OnBlockRemoved(world, _chunk, _blockPos, _blockValue);
|
||||
_chunk.RemoveTileEntityAt<TileEntityWorkstation>((World)world, World.toBlock(_blockPos));
|
||||
}
|
||||
|
||||
public override void PlaceBlock(WorldBase _world, BlockPlacement.Result _result, EntityAlive _ea)
|
||||
{
|
||||
base.PlaceBlock(_world, _result, _ea);
|
||||
TileEntityWorkstation tileEntityWorkstation = (TileEntityWorkstation)_world.GetTileEntity(_result.clrIdx, _result.blockPos);
|
||||
if (tileEntityWorkstation != null)
|
||||
{
|
||||
tileEntityWorkstation.IsPlayerPlaced = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnBlockActivated(WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
TileEntityWorkstation tileEntityWorkstation = (TileEntityWorkstation)_world.GetTileEntity(_cIdx, _blockPos);
|
||||
if (tileEntityWorkstation == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_player.AimingGun = false;
|
||||
Vector3i blockPos = tileEntityWorkstation.ToWorldPos();
|
||||
if (tileEntityWorkstation.IsUserAccessing())
|
||||
{
|
||||
_player.PlayOneShot("ui_denied", false);
|
||||
return false;
|
||||
}
|
||||
_world.GetGameManager().TELockServer(_cIdx, blockPos, tileEntityWorkstation.entityId, _player.entityId, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnBlockValueChanged(WorldBase _world, Chunk _chunk, int _clrIdx, Vector3i _blockPos, BlockValue _oldBlockValue, BlockValue _newBlockValue)
|
||||
{
|
||||
base.OnBlockValueChanged(_world, _chunk, _clrIdx, _blockPos, _oldBlockValue, _newBlockValue);
|
||||
this.checkParticles(_world, _clrIdx, _blockPos, _newBlockValue);
|
||||
}
|
||||
|
||||
public override byte GetLightValue(BlockValue _blockValue)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override void checkParticles(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
if (_blockValue.ischild)
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool flag = _world.GetGameManager().HasBlockParticleEffect(_blockPos);
|
||||
if (_blockValue.meta != 0 && !flag)
|
||||
{
|
||||
this.addParticles(_world, _clrIdx, _blockPos.x, _blockPos.y, _blockPos.z, _blockValue);
|
||||
return;
|
||||
}
|
||||
if (_blockValue.meta == 0 && flag)
|
||||
{
|
||||
this.removeParticles(_world, _blockPos.x, _blockPos.y, _blockPos.z, _blockValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsCampfireLit(BlockValue _blockValue)
|
||||
{
|
||||
return _blockValue.meta > 0;
|
||||
}
|
||||
|
||||
public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
return Localization.Get("useCampfire");
|
||||
}
|
||||
|
||||
public override bool OnBlockActivated(string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
if (_commandName == this.cmds[0].text)
|
||||
{
|
||||
return OnBlockActivated(_world, _cIdx, _blockPos, _blockValue, _player);
|
||||
}
|
||||
if (_commandName != this.cmds[1].text)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (((World)_world).IsWithinTraderArea(_blockPos))
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(_player, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.TakeItemWithTimer(_cIdx, _blockPos, _blockValue, _player);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override BlockActivationCommand[] GetBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
bool flag = _world.IsMyLandProtectedBlock(_blockPos, _world.GetGameManager().GetPersistentLocalPlayer(), false);
|
||||
TileEntityWorkstation tileEntityWorkstation = (TileEntityWorkstation)_world.GetTileEntity(_clrIdx, _blockPos);
|
||||
bool flag2 = false;
|
||||
if (tileEntityWorkstation != null)
|
||||
{
|
||||
flag2 = tileEntityWorkstation.IsPlayerPlaced;
|
||||
}
|
||||
this.cmds[1].enabled = (flag && flag2 && this.TakeDelay > 0f);
|
||||
return this.cmds;
|
||||
}
|
||||
|
||||
public void TakeItemWithTimer(int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityAlive _player)
|
||||
{
|
||||
if (_blockValue.damage > 0)
|
||||
{
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttRepairBeforePickup"), string.Empty, "ui_denied", null);
|
||||
return;
|
||||
}
|
||||
LocalPlayerUI playerUI = (_player as EntityPlayerLocal).PlayerUI;
|
||||
playerUI.windowManager.Open("timer", true, false, true);
|
||||
XUiC_Timer childByType = playerUI.xui.GetChildByType<XUiC_Timer>();
|
||||
TimerEventData timerEventData = new TimerEventData();
|
||||
timerEventData.Data = new object[]
|
||||
{
|
||||
_cIdx,
|
||||
_blockValue,
|
||||
_blockPos,
|
||||
_player
|
||||
};
|
||||
timerEventData.Event += this.EventData_Event;
|
||||
timerEventData.CloseEvent += ResetEventData;
|
||||
childByType.SetTimer(this.TakeDelay, timerEventData, -1f, "");
|
||||
}
|
||||
|
||||
private void ResetEventData(TimerEventData timerData)
|
||||
{
|
||||
timerData.Event -= this.EventData_Event;
|
||||
}
|
||||
|
||||
private void EventData_Event(TimerEventData timerData)
|
||||
{
|
||||
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;
|
||||
if (block.damage > 0)
|
||||
{
|
||||
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get("ttRepairBeforePickup"), string.Empty, "ui_denied", null);
|
||||
return;
|
||||
}
|
||||
if (block.type != blockValue.type)
|
||||
{
|
||||
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get("ttBlockMissingPickup"), string.Empty, "ui_denied", null);
|
||||
return;
|
||||
}
|
||||
TileEntityWorkstation tileEntityWorkstation = world.GetTileEntity(clrIdx, vector3i) as TileEntityWorkstation;
|
||||
if (tileEntityWorkstation.IsUserAccessing())
|
||||
{
|
||||
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get("ttCantPickupInUse"), string.Empty, "ui_denied", null);
|
||||
return;
|
||||
}
|
||||
LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(entityPlayerLocal);
|
||||
this.HandleTakeInternalItems(tileEntityWorkstation, uiforPlayer);
|
||||
ItemStack itemStack = new ItemStack(block.ToItemValue(), 1);
|
||||
if (!uiforPlayer.xui.PlayerInventory.AddItem(itemStack))
|
||||
{
|
||||
uiforPlayer.xui.PlayerInventory.DropItem(itemStack);
|
||||
}
|
||||
world.SetBlockRPC(clrIdx, vector3i, BlockValue.Air);
|
||||
}
|
||||
|
||||
protected virtual void HandleTakeInternalItems(TileEntityWorkstation te, LocalPlayerUI playerUI)
|
||||
{
|
||||
ItemStack[] array = te.Output;
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
if (!array[i].IsEmpty() && !playerUI.xui.PlayerInventory.AddItem(array[i]))
|
||||
{
|
||||
playerUI.xui.PlayerInventory.DropItem(array[i]);
|
||||
}
|
||||
}
|
||||
array = te.Tools;
|
||||
for (int j = 0; j < array.Length; j++)
|
||||
{
|
||||
if (!array[j].IsEmpty() && !playerUI.xui.PlayerInventory.AddItem(array[j]))
|
||||
{
|
||||
playerUI.xui.PlayerInventory.DropItem(array[j]);
|
||||
}
|
||||
}
|
||||
array = te.Fuel;
|
||||
for (int k = 0; k < array.Length; k++)
|
||||
{
|
||||
if (!array[k].IsEmpty() && !playerUI.xui.PlayerInventory.AddItem(array[k]))
|
||||
{
|
||||
playerUI.xui.PlayerInventory.DropItem(array[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected int lootList;
|
||||
private float TakeDelay = 2f;
|
||||
public WorkstationData WorkstationData;
|
||||
private BlockActivationCommand[] cmds = new BlockActivationCommand[]
|
||||
{
|
||||
new BlockActivationCommand("open", "assemble", true, false),
|
||||
new BlockActivationCommand("take", "hand", false, false)
|
||||
};
|
||||
}
|
||||
31
Scripts/Blocks/Inactive/BlockClearModelsRebirth.cs
Normal file
31
Scripts/Blocks/Inactive/BlockClearModelsRebirth.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Platform;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BlockClearModelsRebirth : Block
|
||||
{
|
||||
|
||||
public override void OnBlockAdded(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
base.OnBlockAdded(_world, _chunk, _blockPos, _blockValue);
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer) return;
|
||||
if (GameManager.Instance.IsEditMode()) return;
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_chunk.ClrIdx, _blockPos, blockID, (ulong)20UL);
|
||||
}
|
||||
|
||||
public override bool UpdateTick(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bRandomTick, ulong _ticksIfLoaded, GameRandom _rnd)
|
||||
{
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
RebirthUtilities.DestroyBlock(_world, _blockPos, 25, 50, "FuriousRamsaySpawn");
|
||||
RebirthUtilities.DestroyBlock(_world, _blockPos, 25, 50, "FuriousRamsayEntityMonitorBlock");
|
||||
RebirthUtilities.DestroyBlock(_world, _blockPos, 25, 50, "FuriousRamsayAnimalChicken");
|
||||
|
||||
this.DamageBlock(GameManager.Instance.World, 0, _blockPos, _blockValue, Block.list[_blockValue.type].MaxDamage, -1, null, false, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
473
Scripts/Blocks/Inactive/BlockTakeSecureLootSignedContainer.cs
Normal file
473
Scripts/Blocks/Inactive/BlockTakeSecureLootSignedContainer.cs
Normal file
@@ -0,0 +1,473 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Audio;
|
||||
using Platform;
|
||||
using UnityEngine;
|
||||
|
||||
public class BlockTakeSecureLootSignedContainer : BlockSecureLootSigned
|
||||
{
|
||||
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"]);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnBlockActivated(string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
if (_blockValue.ischild)
|
||||
{
|
||||
Vector3i parentPos = _blockValue.Block.multiBlockPos.GetParentPos(_blockPos, _blockValue);
|
||||
BlockValue block = _world.GetBlock(parentPos);
|
||||
return this.OnBlockActivated(_commandName, _world, _cIdx, parentPos, block, _player);
|
||||
}
|
||||
TileEntitySecureLootContainerSigned tileEntitySecureLootContainer = _world.GetTileEntity(_cIdx, _blockPos) as TileEntitySecureLootContainerSigned;
|
||||
if (tileEntitySecureLootContainer == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("BlockTakeLootContainer:isSecure: " + this.isSecure);
|
||||
//Log.Out("BlockTakeLootContainer:OnBlockActivated: " + _indexInBlockActivationCommands);
|
||||
if (this.isSecure)
|
||||
{
|
||||
//Log.Out("BlockTakeLootContainer:isSecure: True");
|
||||
PlatformUserIdentifierAbs getContainerOwner = tileEntitySecureLootContainer.GetOwner();
|
||||
bool isUserAllowed = tileEntitySecureLootContainer.IsUserAllowed(PlatformManager.InternalLocalUserIdentifier);
|
||||
//Log.Out("OnBlockActivated:_indexInBlockActivationCommands: " + _indexInBlockActivationCommands);
|
||||
if (_commandName == this.cmds[0].text)
|
||||
{
|
||||
//Log.Out("OnBlockActivated:Secure/Search");
|
||||
if (!tileEntitySecureLootContainer.IsLocked() || isUserAllowed)
|
||||
{
|
||||
return this.OnBlockActivated(_world, _cIdx, _blockPos, _blockValue, _player);
|
||||
}
|
||||
Manager.BroadcastPlayByLocalPlayer(_blockPos.ToVector3() + Vector3.one * 0.5f, "Misc/locked");
|
||||
return false;
|
||||
}
|
||||
else if (_commandName == this.cmds[1].text)
|
||||
{
|
||||
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("OnBlockActivated:Unlock I am owner");
|
||||
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)
|
||||
{
|
||||
LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(_player as EntityPlayerLocal);
|
||||
if (uiforPlayer != null)
|
||||
{
|
||||
XUiC_KeypadWindow.Open(uiforPlayer, tileEntitySecureLootContainer);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (_commandName == this.cmds[4].text)
|
||||
{
|
||||
if (getContainerOwner == null)
|
||||
{
|
||||
//Log.Out("OnBlockActivated:Pick no owner");
|
||||
LocalPlayerUI playerUI = (_player as EntityPlayerLocal).PlayerUI;
|
||||
ItemValue item = ItemClass.GetItem(this.lockPickItem, false);
|
||||
if (playerUI.xui.PlayerInventory.GetItemCount(item) == 0)
|
||||
{
|
||||
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)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// If they have a controller, skip the mini game
|
||||
if (PlatformManager.NativePlatform.Input.CurrentInputStyle == PlayerInputManager.InputStyle.Keyboard)
|
||||
{
|
||||
//Log.Out("OnBlockActivated: Using a controller");
|
||||
advancedLockPicking = true;
|
||||
}
|
||||
|
||||
if (_player.Buffs.HasCustomVar("LegacyLockPick") && _player.Buffs.GetCustomVar("LegacyLockPick") > 0)
|
||||
{
|
||||
//Log.Out("OnBlockActivated: LegacyLockPick CVar is set");
|
||||
advancedLockPicking = true;
|
||||
}
|
||||
|
||||
//Log.Out("OnBlockActivated, advancedLockPicking: " + advancedLockPicking);
|
||||
if (advancedLockPicking)
|
||||
{
|
||||
//Log.Out("OnBlockActivated, advancedLockPicking 1");
|
||||
XUiC_PickLocking.Open(playerUI, tileEntitySecureLootContainer, _blockValue, _blockPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("OnBlockActivated, advancedLockPicking 2");
|
||||
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))
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (GameManager.Instance.IsEditMode() || !tileEntitySecureLootContainer.IsLocked() || tileEntitySecureLootContainer.IsUserAllowed(PlatformManager.InternalLocalUserIdentifier))
|
||||
{
|
||||
return this.OnBlockActivated(_world, _cIdx, _blockPos, _blockValue, _player, "sign");
|
||||
}
|
||||
Manager.BroadcastPlayByLocalPlayer(_blockPos.ToVector3() + Vector3.one * 0.5f, "Misc/locked");
|
||||
return false;
|
||||
}
|
||||
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);
|
||||
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;
|
||||
}
|
||||
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("BlockTakeLootContainer:isSecure: False");
|
||||
if (_commandName == this.cmds[0].text)
|
||||
{
|
||||
//Log.Out("BlockTakeLootContainer: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;
|
||||
}
|
||||
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_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);
|
||||
TileEntitySecureLootContainerSigned tileEntitySecureLootContainerSigned = GameManager.Instance.World.GetTileEntity((int)array[0], blockPos) as TileEntitySecureLootContainerSigned;
|
||||
if (tileEntitySecureLootContainerSigned == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
tileEntitySecureLootContainerSigned.PickTimeLeft = Mathf.Max(this.lockPickTime * 0.25f, timerData.timeLeft);
|
||||
this.ResetEventData(timerData);
|
||||
}
|
||||
|
||||
private void EventData_Event(TimerEventData timerData)
|
||||
{
|
||||
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 player = array[3] as EntityPlayerLocal;
|
||||
object obj = array[4];
|
||||
TileEntitySecureLootContainerSigned tileEntitySecureLootContainerSigned = world.GetTileEntity(clrIdx, vector3i) as TileEntitySecureLootContainerSigned;
|
||||
if (tileEntitySecureLootContainerSigned == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (tileEntitySecureLootContainerSigned.IsUserAccessing())
|
||||
{
|
||||
GameManager.ShowTooltip(player, Localization.Get("ttCantPickupInUse"), string.Empty, "ui_denied", null);
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
TileEntitySecureLootContainerSigned tileEntitySecureLootContainer = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntitySecureLootContainerSigned;
|
||||
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 override BlockActivationCommand[] GetBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
TileEntitySecureLootContainerSigned tileEntitySecureLootContainerSigned = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntitySecureLootContainerSigned;
|
||||
if (tileEntitySecureLootContainerSigned == null)
|
||||
{
|
||||
return new BlockActivationCommand[0];
|
||||
}
|
||||
PlatformUserIdentifierAbs internalLocalUserIdentifier = PlatformManager.InternalLocalUserIdentifier;
|
||||
PersistentPlayerData playerData = _world.GetGameManager().GetPersistentPlayerList().GetPlayerData(tileEntitySecureLootContainerSigned.GetOwner());
|
||||
bool flag = tileEntitySecureLootContainerSigned.LocalPlayerIsOwner();
|
||||
bool flag2 = !flag && (playerData != null && playerData.ACL != null) && playerData.ACL.Contains(internalLocalUserIdentifier);
|
||||
|
||||
//Log.Out("BlockTakeSecureLootSignedContainer-GetBlockActivationCommands LocalPlayerIsOwner: " + flag);
|
||||
//Log.Out("BlockTakeSecureLootSignedContainer-GetBlockActivationCommands IsLocked: " + tileEntitySecureLootContainerSigned.IsLocked());
|
||||
//Log.Out("BlockTakeSecureLootSignedContainer-GetBlockActivationCommands bTouched: " + tileEntitySecureLootContainerSigned.bTouched);
|
||||
//Log.Out("BlockTakeSecureLootSignedContainer-GetBlockActivationCommands IsUserAllowed: " + tileEntitySecureLootContainerSigned.IsUserAllowed(internalLocalUserIdentifier));
|
||||
//Log.Out("BlockTakeSecureLootSignedContainer-GetBlockActivationCommands Can User Access: " + flag2);
|
||||
|
||||
this.cmds[0].enabled = true;
|
||||
this.cmds[1].enabled = (this.isSecure && !tileEntitySecureLootContainerSigned.IsLocked() && (flag || flag2));
|
||||
this.cmds[2].enabled = (this.isSecure && tileEntitySecureLootContainerSigned.IsLocked() && flag);
|
||||
this.cmds[3].enabled = this.isSecure && ((!tileEntitySecureLootContainerSigned.IsUserAllowed(internalLocalUserIdentifier) && tileEntitySecureLootContainerSigned.HasPassword() && tileEntitySecureLootContainerSigned.IsLocked()) || flag);
|
||||
this.cmds[4].enabled = (this.isSecure && this.lockPickItem != null && tileEntitySecureLootContainerSigned.IsLocked() && !flag);
|
||||
this.cmds[5].enabled = this.isSecure;
|
||||
this.cmds[6].enabled = this.canPickUpBlock && (tileEntitySecureLootContainerSigned.IsEmpty() && tileEntitySecureLootContainerSigned.bTouched);
|
||||
|
||||
//Log.Out("BlockTakeSecureLootSignedContainer-GetBlockActivationCommands this.cmds[0].enabled: " + this.cmds[0].enabled);
|
||||
//Log.Out("BlockTakeSecureLootSignedContainer-GetBlockActivationCommands this.cmds[1].enabled: " + this.cmds[1].enabled);
|
||||
//Log.Out("BlockTakeSecureLootSignedContainer-GetBlockActivationCommands this.cmds[2].enabled: " + this.cmds[2].enabled);
|
||||
//Log.Out("BlockTakeSecureLootSignedContainer-GetBlockActivationCommands this.cmds[3].enabled: " + this.cmds[3].enabled);
|
||||
//Log.Out("BlockTakeSecureLootSignedContainer-GetBlockActivationCommands this.cmds[4].enabled: " + this.cmds[4].enabled);
|
||||
//Log.Out("BlockTakeSecureLootSignedContainer-GetBlockActivationCommands this.cmds[5].enabled: " + this.cmds[5].enabled);
|
||||
//Log.Out("BlockTakeSecureLootSignedContainer-GetBlockActivationCommands this.cmds[6].enabled: " + this.cmds[6].enabled);
|
||||
|
||||
return this.cmds;
|
||||
}
|
||||
|
||||
private 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("edit", "pen", false, false),
|
||||
new BlockActivationCommand("take", "hand", false, false)
|
||||
};
|
||||
|
||||
public float TakeDelay = 3f;
|
||||
public string ReplacementBlockName = "";
|
||||
public int numBlocks = 1;
|
||||
public bool isReplacementItem = false;
|
||||
public bool isSecure = true;
|
||||
public bool canPickUpBlock = true;
|
||||
}
|
||||
213
Scripts/Blocks/Inactive/BlockTempSecureDoorRebirth.cs
Normal file
213
Scripts/Blocks/Inactive/BlockTempSecureDoorRebirth.cs
Normal file
@@ -0,0 +1,213 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Audio;
|
||||
using Platform;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
[Preserve]
|
||||
public class BlockTempSecureDoorRebirth : BlockDoor
|
||||
{
|
||||
public override bool AllowBlockTriggers
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public BlockTempSecureDoorRebirth()
|
||||
{
|
||||
this.HasTileEntity = true;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
this.Properties.ParseString(BlockTempSecureDoorRebirth.PropLockedSound, ref this.lockedSound);
|
||||
this.Properties.ParseString(BlockTempSecureDoorRebirth.PropLockingSound, ref this.lockingSound);
|
||||
this.Properties.ParseString(BlockTempSecureDoorRebirth.PropUnLockingSound, ref this.unlockingSound);
|
||||
}
|
||||
|
||||
public override void PlaceBlock(WorldBase _world, BlockPlacement.Result _result, EntityAlive _ea)
|
||||
{
|
||||
Block block = _result.blockValue.Block;
|
||||
if (block.shape.IsTerrain())
|
||||
{
|
||||
_world.SetBlockRPC(_result.clrIdx, _result.blockPos, _result.blockValue, this.Density);
|
||||
}
|
||||
else if (!block.IsTerrainDecoration)
|
||||
{
|
||||
_world.SetBlockRPC(_result.clrIdx, _result.blockPos, _result.blockValue, MarchingCubes.DensityAir);
|
||||
}
|
||||
else
|
||||
{
|
||||
_world.SetBlockRPC(_result.clrIdx, _result.blockPos, _result.blockValue);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnBlockAdded(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
base.OnBlockAdded(_world, _chunk, _blockPos, _blockValue);
|
||||
if (_world.IsEditor())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_blockValue.ischild)
|
||||
{
|
||||
return;
|
||||
}
|
||||
TileEntityTimedBlockRebirth TileEntityTimedBlockRebirth = _world.GetTileEntity(_chunk.ClrIdx, _blockPos) as TileEntityTimedBlockRebirth;
|
||||
if (TileEntityTimedBlockRebirth != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
TileEntityTimedBlockRebirth = new TileEntityTimedBlockRebirth(_chunk);
|
||||
TileEntityTimedBlockRebirth.SetDisableModifiedCheck(true);
|
||||
TileEntityTimedBlockRebirth.localChunkPos = World.toBlock(_blockPos);
|
||||
TileEntityTimedBlockRebirth.SetDisableModifiedCheck(false);
|
||||
_chunk.AddTileEntity(TileEntityTimedBlockRebirth);
|
||||
|
||||
if (this.Properties.Values.ContainsKey("Duration"))
|
||||
{
|
||||
this.totalDuration = Int32.Parse(this.Properties.Values["Duration"]);
|
||||
}
|
||||
|
||||
this.OnBlockActivated(_world, _chunk.ClrIdx, _blockPos, _blockValue, null);
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_chunk.ClrIdx, _blockPos, this.blockID, 20UL);
|
||||
}
|
||||
|
||||
public override bool FilterIndexType(BlockValue bv)
|
||||
{
|
||||
return !(this.IndexName == "TraderOnOff") || (bv.meta & 4) == 0;
|
||||
}
|
||||
|
||||
public override void OnBlockRemoved(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
base.OnBlockRemoved(world, _chunk, _blockPos, _blockValue);
|
||||
TileEntityTimedBlockRebirth tileTimedBlockPlot = world.GetTileEntity(_chunk.ClrIdx, _blockPos) as TileEntityTimedBlockRebirth;
|
||||
if (tileTimedBlockPlot != null)
|
||||
{
|
||||
tileTimedBlockPlot.OnDestroy();
|
||||
}
|
||||
_chunk.RemoveTileEntityAt<TileEntityTimedBlockRebirth>((World)world, World.toBlock(_blockPos));
|
||||
}
|
||||
|
||||
public override bool HasBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
return _world.GetTileEntity(_clrIdx, _blockPos) is TileEntityTimedBlockRebirth || _world.IsEditor();
|
||||
}
|
||||
|
||||
public override BlockActivationCommand[] GetBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
if (_blockValue.ischild)
|
||||
{
|
||||
Vector3i parentPos = _blockValue.Block.multiBlockPos.GetParentPos(_blockPos, _blockValue);
|
||||
BlockValue block = _world.GetBlock(parentPos);
|
||||
return this.GetBlockActivationCommands(_world, block, _clrIdx, parentPos, _entityFocusing);
|
||||
}
|
||||
TileEntityTimedBlockRebirth TileEntityTimedBlockRebirth = (TileEntityTimedBlockRebirth)_world.GetTileEntity(_clrIdx, _blockPos);
|
||||
if (TileEntityTimedBlockRebirth == null && !_world.IsEditor())
|
||||
{
|
||||
return Array.Empty<BlockActivationCommand>();
|
||||
}
|
||||
((Chunk)_world.ChunkClusters[_clrIdx].GetChunkSync(World.toChunkXZ(_blockPos.x), _blockPos.y, World.toChunkXZ(_blockPos.z))).GetBlockTrigger(World.toBlock(_blockPos));
|
||||
this.cmds[0].enabled = BlockDoor.IsDoorOpen(_blockValue.meta);
|
||||
this.cmds[1].enabled = !BlockDoor.IsDoorOpen(_blockValue.meta);
|
||||
this.cmds[2].enabled = false;
|
||||
this.cmds[3].enabled = false;
|
||||
this.cmds[4].enabled = false;
|
||||
this.cmds[5].enabled = (_world.IsEditor() && !GameUtils.IsWorldEditor());
|
||||
return this.cmds;
|
||||
}
|
||||
|
||||
public override bool OnBlockActivated(string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
if (_blockValue.ischild)
|
||||
{
|
||||
Vector3i parentPos = _blockValue.Block.multiBlockPos.GetParentPos(_blockPos, _blockValue);
|
||||
BlockValue block = _world.GetBlock(parentPos);
|
||||
return this.OnBlockActivated(_commandName, _world, _cIdx, parentPos, block, _player);
|
||||
}
|
||||
TileEntityTimedBlockRebirth TileEntityTimedBlockRebirth = (TileEntityTimedBlockRebirth)_world.GetTileEntity(_cIdx, _blockPos);
|
||||
if (TileEntityTimedBlockRebirth == null && !_world.IsEditor())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(_commandName == "close"))
|
||||
{
|
||||
if (_world.IsEditor())
|
||||
{
|
||||
base.HandleTrigger((EntityPlayer)_player, (World)_world, _cIdx, _blockPos, _blockValue);
|
||||
return this.OnBlockActivated(_world, _cIdx, _blockPos, _blockValue, _player);
|
||||
}
|
||||
Manager.BroadcastPlayByLocalPlayer(_blockPos.ToVector3() + Vector3.one * 0.5f, this.lockedSound);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_world.IsEditor())
|
||||
{
|
||||
base.HandleTrigger((EntityPlayer)_player, (World)_world, _cIdx, _blockPos, _blockValue);
|
||||
return this.OnBlockActivated(_world, _cIdx, _blockPos, _blockValue, _player);
|
||||
}
|
||||
Manager.BroadcastPlayByLocalPlayer(_blockPos.ToVector3() + Vector3.one * 0.5f, this.lockedSound);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
if (_blockValue.ischild)
|
||||
{
|
||||
Vector3i parentPos = _blockValue.Block.multiBlockPos.GetParentPos(_blockPos, _blockValue);
|
||||
BlockValue block = _world.GetBlock(parentPos);
|
||||
return this.GetActivationText(_world, block, _clrIdx, parentPos, _entityFocusing);
|
||||
}
|
||||
TileEntityTimedBlockRebirth TileEntityTimedBlockRebirth = (TileEntityTimedBlockRebirth)_world.GetTileEntity(_clrIdx, _blockPos);
|
||||
if (TileEntityTimedBlockRebirth == null && !_world.IsEditor())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
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);
|
||||
string arg2 = Localization.Get("door");
|
||||
|
||||
return string.Format(Localization.Get("tooltipUnlocked"), arg, arg2);
|
||||
}
|
||||
|
||||
public override void OnTriggered(EntityPlayer _player, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, List<BlockChangeInfo> _blockChanges, BlockTrigger _triggeredBy)
|
||||
{
|
||||
base.OnTriggered(_player, _world, _cIdx, _blockPos, _blockValue, _blockChanges, _triggeredBy);
|
||||
bool flag = !BlockDoor.IsDoorOpen(_blockValue.meta);
|
||||
_blockValue.meta = (byte)((flag ? 1 : 0) | ((int)_blockValue.meta & -2));
|
||||
_blockChanges.Add(new BlockChangeInfo(_cIdx, _blockPos, _blockValue));
|
||||
if (flag)
|
||||
{
|
||||
Manager.BroadcastPlay(_blockPos.ToVector3() + Vector3.one * 0.5f, this.openSound, 0f);
|
||||
return;
|
||||
}
|
||||
Manager.BroadcastPlay(_blockPos.ToVector3() + Vector3.one * 0.5f, this.closeSound, 0f);
|
||||
}
|
||||
|
||||
public int totalDuration = 0;
|
||||
private const int cDoorIsLockedMask = 4;
|
||||
protected string lockedSound = "Misc/locked";
|
||||
protected string lockingSound = "Misc/locking";
|
||||
protected string unlockingSound = "Misc/unlocking";
|
||||
protected static string PropLockedSound = "LockedSound";
|
||||
protected static string PropLockingSound = "LockingSound";
|
||||
protected static string PropUnLockingSound = "UnlockingSound";
|
||||
private BlockActivationCommand[] cmds = new BlockActivationCommand[]
|
||||
{
|
||||
new BlockActivationCommand("close", "door", false, false),
|
||||
new BlockActivationCommand("open", "door", false, false),
|
||||
new BlockActivationCommand("lock", "lock", false, false),
|
||||
new BlockActivationCommand("unlock", "unlock", false, false),
|
||||
new BlockActivationCommand("keypad", "keypad", false, false),
|
||||
new BlockActivationCommand("trigger", "wrench", true, false)
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user