Upload from upload_mods.ps1
This commit is contained in:
16
Scripts/Blocks/BlockCampfireRebirth.cs
Normal file
16
Scripts/Blocks/BlockCampfireRebirth.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
#nullable disable
|
||||
[Preserve]
|
||||
public class BlockCampfireRebirth : BlockWorkstationRebirth
|
||||
{
|
||||
public override string GetActivationText(
|
||||
WorldBase _world,
|
||||
BlockValue _blockValue,
|
||||
int _clrIdx,
|
||||
Vector3i _blockPos,
|
||||
EntityAlive _entityFocusing)
|
||||
{
|
||||
return Localization.Get("useCampfire");
|
||||
}
|
||||
}
|
||||
689
Scripts/Blocks/BlockCoopRebirth.cs
Normal file
689
Scripts/Blocks/BlockCoopRebirth.cs
Normal file
@@ -0,0 +1,689 @@
|
||||
using Audio;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
public class BlockCoopRebirth : Block
|
||||
{
|
||||
protected float nextStageRate;
|
||||
public string nextStage;
|
||||
public string baseBlock;
|
||||
public string contentName;
|
||||
public ulong TickRate = 100UL;
|
||||
public string[] gatherResources;
|
||||
public string[] gatherResourcesCount;
|
||||
private List<EntityAlive> entsInRange;
|
||||
public float maxRange;
|
||||
public System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
|
||||
//public bool hasNest = false;
|
||||
public string uniqueID;
|
||||
public Vector3i myPosition = Vector3i.zero;
|
||||
|
||||
public override bool HasBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private BlockActivationCommand[] cmds = new BlockActivationCommand[]
|
||||
{
|
||||
new BlockActivationCommand("Search", "search", true, false)
|
||||
};
|
||||
|
||||
public override void OnBlockLoaded(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-OnBlockLoaded START");
|
||||
base.OnBlockLoaded(_world, _clrIdx, _blockPos, _blockValue);
|
||||
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-OnBlockLoaded 1");
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(_blockPos);
|
||||
_world.GetWBT().AddScheduledBlockUpdate(chunk.ClrIdx, _blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void addTileEntity(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
TileEntityChickenCoopRebirth tileEntityChickenCoop = new TileEntityChickenCoopRebirth(_chunk);
|
||||
tileEntityChickenCoop.localChunkPos = World.toBlock(_blockPos);
|
||||
_chunk.AddTileEntity(tileEntityChickenCoop);
|
||||
}
|
||||
|
||||
protected virtual void removeTileEntity(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-removeTileEntity START");
|
||||
_chunk.RemoveTileEntityAt<TileEntityChickenCoopRebirth>((World)world, World.toBlock(_blockPos));
|
||||
}
|
||||
|
||||
public override void OnBlockRemoved(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-OnBlockRemoved START");
|
||||
base.OnBlockRemoved(world, _chunk, _blockPos, _blockValue);
|
||||
TileEntityChickenCoopRebirth tileEntityChickenCoop = world.GetTileEntity(_chunk.ClrIdx, _blockPos) as TileEntityChickenCoopRebirth;
|
||||
if (tileEntityChickenCoop != null)
|
||||
{
|
||||
tileEntityChickenCoop.OnDestroy();
|
||||
}
|
||||
this.removeTileEntity(world, _chunk, _blockPos, _blockValue);
|
||||
}
|
||||
|
||||
public override void OnBlockAdded(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-OnBlockAdded START");
|
||||
base.OnBlockAdded(_world, _chunk, _blockPos, _blockValue);
|
||||
this.addTileEntity(_world, _chunk, _blockPos, _blockValue);
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer) return;
|
||||
if (GameManager.Instance.IsEditMode()) return;
|
||||
|
||||
//Log.Out("BlockCoopRebirth-OnBlockAdded 1");
|
||||
|
||||
_blockValue.meta = 0;
|
||||
|
||||
//_world.SetBlockRPC(_blockPos, _blockValue);
|
||||
|
||||
//Log.Out("============================ON BLOCK ADDED=================================");
|
||||
//Log.Out("BlockCoopRebirth-OnBlockAdded MY POSITION: " + _blockPos);
|
||||
|
||||
//Log.Out("BlockCoopRebirth-OnBlockAdded this.GetTickRate(): " + this.GetTickRate());
|
||||
watch.Reset();
|
||||
watch.Start();
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_chunk.ClrIdx, _blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
|
||||
public override bool UpdateTick(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bRandomTick, ulong _ticksIfLoaded, GameRandom _rnd)
|
||||
{
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick START block: " + _blockValue.Block.GetBlockName());
|
||||
|
||||
ulong GameTimerTicks = 0UL;
|
||||
ulong TotalTimerTicks = 0UL;
|
||||
ulong CurrentTimerTicks = 0UL;
|
||||
ulong TicksOverThreshold = 0UL;
|
||||
ulong CurrentStageRate = this.GetTickRate();
|
||||
|
||||
bool bHasNest = false;
|
||||
TileEntityChickenCoopRebirth tileEntityChickenCoop = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityChickenCoopRebirth;
|
||||
|
||||
watch.Stop();
|
||||
|
||||
if (tileEntityChickenCoop != null)
|
||||
{
|
||||
bHasNest = tileEntityChickenCoop.hasNest;
|
||||
tileEntityChickenCoop.bUpdating = false;
|
||||
GameTimerTicks = tileEntityChickenCoop.GameTimerTicks;
|
||||
tileEntityChickenCoop.GameTimerTicks = GameTimer.Instance.ticks;
|
||||
TotalTimerTicks = GameTimer.Instance.ticks;
|
||||
CurrentTimerTicks = TotalTimerTicks - GameTimerTicks;
|
||||
|
||||
tileEntityChickenCoop.AccumulatedTicks = tileEntityChickenCoop.AccumulatedTicks + CurrentTimerTicks;
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageUpdateCoopRebirth>().Setup(_clrIdx, _blockPos, _blockValue.Block.blockID, tileEntityChickenCoop.AccumulatedTicks), false, -1, -1, -1, null, 192);
|
||||
|
||||
if (tileEntityChickenCoop.AccumulatedTicks > CurrentStageRate)
|
||||
{
|
||||
TicksOverThreshold = tileEntityChickenCoop.AccumulatedTicks - CurrentStageRate;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick Execution Time: " + watch.ElapsedMilliseconds + " ms");
|
||||
//Log.Out("==============================UPDATE TICK===================================");
|
||||
//Log.Out("BLOCK POSITION: " + _blockPos);
|
||||
//Log.Out("BLOCK this.maxRange: " + this.maxRange);
|
||||
|
||||
this.entsInRange = GameManager.Instance.World.GetLivingEntitiesInBounds(null, new Bounds(_blockPos, Vector3.one * (this.maxRange * 2f)));
|
||||
bool foundEntity = false;
|
||||
for (int j = 0; j < this.entsInRange.Count; j++)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick j: " + j + " class: " + this.entsInRange[j].EntityClass.entityClassName);
|
||||
|
||||
if (this.entsInRange[j] != null && this.entsInRange[j] is EntityAnimalChickenRebirth && this.entsInRange[j].EntityName.ToLower().Trim() != "chicken")
|
||||
{
|
||||
EntityAnimalChickenRebirth myEntity = (EntityAnimalChickenRebirth)this.entsInRange[j];
|
||||
|
||||
//Log.Out("COOP Position: " + _blockPos);
|
||||
//Log.Out("myEntity.homePos: " + myEntity.HomePosition);
|
||||
//Log.Out("myEntity NAME: " + myEntity.EntityName);
|
||||
//Log.Out("myEntity.entityId: " + myEntity.entityId);
|
||||
if (myEntity.HomePosition == _blockPos && !myEntity.IsDead())
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick FOUND ENTITY: " + myEntity.EntityName);
|
||||
foundEntity = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.entsInRange.Clear();
|
||||
|
||||
if (foundEntity)
|
||||
{
|
||||
//Log.Out("============================HAS ASSOCIATED ENTITY=================================");
|
||||
bool bflag = false;
|
||||
|
||||
if (this.GetBlockName() == "FuriousRamsayChickenCoop000")
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick A1");
|
||||
if (bHasNest)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick A2");
|
||||
bflag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bflag = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick A3");
|
||||
bflag = true;
|
||||
}
|
||||
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick bflag A : " + bflag);
|
||||
|
||||
if (tileEntityChickenCoop != null)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick B1");
|
||||
//Log.Out("Ticks: " + tileEntityChickenCoop.AccumulatedTicks + " / " + CurrentStageRate);
|
||||
if (tileEntityChickenCoop.AccumulatedTicks >= CurrentStageRate)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick B2");
|
||||
bflag = bflag & true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick B3");
|
||||
bflag = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick bflag B : " + bflag);
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick this.nextStage: " + this.nextStage);
|
||||
|
||||
if (bflag && this.nextStage != "")
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick this.nextStage: " + this.nextStage);
|
||||
//Log.Out("Found associated entity. REPLACING BLOCK: " + _blockPos);
|
||||
// Get Next Block
|
||||
|
||||
BlockValue blockValue = Block.GetBlockValue(this.nextStage, true);
|
||||
|
||||
string strNextStageRate = blockValue.Block.Properties.Values["NextStageRate"];
|
||||
|
||||
string strNextStage = blockValue.Block.Properties.Values["NextStage"];
|
||||
|
||||
if (!blockValue.Block.GetBlockName().Contains("4"))
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick bflag C");
|
||||
float flNextStageRate = StringParsers.ParseFloat(strNextStageRate, 0, -1, NumberStyles.Any);
|
||||
|
||||
if (RebirthVariables.testChickenCoops)
|
||||
{
|
||||
flNextStageRate = RebirthVariables.testChickenCoopsRate;
|
||||
}
|
||||
|
||||
ulong CurrentStageTotal = (ulong)(flNextStageRate * 20) + CurrentStageRate;
|
||||
if (tileEntityChickenCoop.AccumulatedTicks >= CurrentStageTotal)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick GOING TO END STAGE");
|
||||
blockValue = Block.GetBlockValue(blockValue.Block.Properties.Values["NextStage"], true);
|
||||
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick A blockValue.Block.Properties.Values[NextStage]: " + blockValue.Block.Properties.Values["NextStage"]);
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick A blockValue.Block.blockName: " + blockValue.Block.blockName);
|
||||
|
||||
strNextStageRate = blockValue.Block.Properties.Values["NextStageRate"];
|
||||
strNextStage = blockValue.Block.Properties.Values["NextStage"];
|
||||
flNextStageRate = StringParsers.ParseFloat(strNextStageRate, 0, -1, NumberStyles.Any);
|
||||
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick strNextStageRate: " + strNextStageRate);
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick strNextStage: " + strNextStage);
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick flNextStageRate: " + flNextStageRate);
|
||||
|
||||
if (RebirthVariables.testChickenCoops)
|
||||
{
|
||||
flNextStageRate = RebirthVariables.testChickenCoopsRate;
|
||||
}
|
||||
|
||||
ulong NextStageTotal = (ulong)(flNextStageRate * 20) + (ulong)(Convert.ToUInt64(strNextStageRate) * 20f);
|
||||
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick NextStageTotal: " + NextStageTotal);
|
||||
|
||||
if (tileEntityChickenCoop.AccumulatedTicks >= NextStageTotal + CurrentStageTotal && blockValue.Block.Properties.Values["NextStage"] != "")
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick bflag C1");
|
||||
blockValue = Block.GetBlockValue(blockValue.Block.Properties.Values["NextStage"], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(_blockPos);
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, _blockPos.x, _blockPos.y, _blockPos.z, FastTags<TagGroup.Global>.none, false);
|
||||
blockValue.rotation = this.convertRotation(_blockValue, blockValue);
|
||||
blockValue.meta = _blockValue.meta;
|
||||
blockValue.damage = _blockValue.damage;
|
||||
blockValue.meta2 = 0;
|
||||
_blockValue = blockValue;
|
||||
|
||||
_blockValue.meta = (byte)(_blockValue.meta + 1 & 15);
|
||||
_blockValue = _blockValue.Block.OnBlockPlaced(_world, _clrIdx, _blockPos, _blockValue, _rnd);
|
||||
|
||||
Block block3 = blockValue.Block;
|
||||
_world.SetBlockRPC(_clrIdx, _blockPos, blockValue);
|
||||
DynamicMeshManager.ChunkChanged(_blockPos, -1, _blockValue.type);
|
||||
|
||||
tileEntityChickenCoop = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityChickenCoopRebirth;
|
||||
|
||||
if (tileEntityChickenCoop != null)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick bflag D");
|
||||
if (TicksOverThreshold > 0)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick bflag D1");
|
||||
tileEntityChickenCoop.AccumulatedTicks = TicksOverThreshold;
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageUpdateCoopRebirth>().Setup(_clrIdx, _blockPos, _blockValue.Block.blockID, tileEntityChickenCoop.AccumulatedTicks), false, -1, -1, -1, null, 192);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick bflag D2");
|
||||
tileEntityChickenCoop.AccumulatedTicks = 0;
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageUpdateCoopRebirth>().Setup(_clrIdx, _blockPos, _blockValue.Block.blockID, tileEntityChickenCoop.AccumulatedTicks), false, -1, -1, -1, null, 192);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("============================NO ASSOCIATED ENTITY=================================");
|
||||
this.entsInRange = GameManager.Instance.World.GetLivingEntitiesInBounds(null, new Bounds(_blockPos, Vector3.one * (this.maxRange * 2f)));
|
||||
|
||||
foundEntity = false;
|
||||
|
||||
for (int j = 0; j < this.entsInRange.Count; j++)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick j: " + j + " class: " + this.entsInRange[j].EntityClass.entityClassName);
|
||||
|
||||
if (this.entsInRange[j] != null && this.entsInRange[j] is EntityAnimalChickenRebirth && this.entsInRange[j].EntityName.ToLower().Trim() != "chicken")
|
||||
{
|
||||
EntityAnimalChickenRebirth myEntity = (EntityAnimalChickenRebirth)this.entsInRange[j];
|
||||
|
||||
//Log.Out("COOP Position: " + _blockPos);
|
||||
//Log.Out("myEntity.homePos: " + myEntity.HomePosition);
|
||||
//Log.Out("myEntity NAME: " + myEntity.EntityName);
|
||||
//Log.Out("myEntity.entityId: " + myEntity.entityId);
|
||||
if (myEntity.HomePosition == Vector3i.zero && !myEntity.IsDead())
|
||||
{
|
||||
myEntity.HomePosition = _blockPos;
|
||||
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageUpdateChickenHomeRebirth>().Setup(_blockPos, myEntity.entityId), false, -1, -1, -1, null, 192);
|
||||
|
||||
//Log.Out("BlockCoopRebirth-UpdateTick FOUND ENTITY: " + myEntity.EntityName);
|
||||
foundEntity = true;
|
||||
|
||||
if (tileEntityChickenCoop != null)
|
||||
{
|
||||
tileEntityChickenCoop.GameTimerTicks = GameTimer.Instance.ticks;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.entsInRange.Clear();
|
||||
}
|
||||
|
||||
watch.Reset();
|
||||
watch.Start();
|
||||
|
||||
if (tileEntityChickenCoop != null)
|
||||
{
|
||||
//Log.Out("Ticks: " + tileEntityChickenCoop.AccumulatedTicks + " / " + CurrentStageRate + " (" + this.TickRate + ")");
|
||||
if (tileEntityChickenCoop.AccumulatedTicks <= CurrentStageRate)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
tileEntityChickenCoop.AccumulatedTicks = 0UL;
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageUpdateCoopRebirth>().Setup(_clrIdx, _blockPos, _blockValue.Block.blockID, tileEntityChickenCoop.AccumulatedTicks), false, -1, -1, -1, null, 192);
|
||||
}
|
||||
}
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
string activationText = Localization.Get("ttGatherNothing");
|
||||
|
||||
string myEntityName = "";
|
||||
|
||||
//Log.Out("=========================GET ACTIVATION TEXT==============================");
|
||||
|
||||
TileEntityChickenCoopRebirth tileEntityChickenCoop = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityChickenCoopRebirth;
|
||||
bool canShowCycleTime = true;
|
||||
ulong GameTimerTicks = 0UL;
|
||||
ulong TotalTimerTicks = 0UL;
|
||||
ulong CurrentTimerTicks = 0UL;
|
||||
float TempTimerTicks = 0;
|
||||
ulong CurrentStageRate = this.GetTickRate();
|
||||
|
||||
if (tileEntityChickenCoop == null)
|
||||
{
|
||||
canShowCycleTime = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameTimerTicks = tileEntityChickenCoop.GameTimerTicks;
|
||||
TotalTimerTicks = GameTimer.Instance.ticks;
|
||||
CurrentTimerTicks = TotalTimerTicks - GameTimerTicks;
|
||||
|
||||
if (tileEntityChickenCoop.AccumulatedTicks <= CurrentStageRate)
|
||||
{
|
||||
TempTimerTicks = (CurrentStageRate - tileEntityChickenCoop.AccumulatedTicks) / 1200;
|
||||
}
|
||||
else
|
||||
{
|
||||
TempTimerTicks = -1;
|
||||
}
|
||||
|
||||
//Log.Out("GameTimer.Instance.ticks: " + TotalTimerTicks);
|
||||
//Log.Out("GameTimerTicks: " + GameTimerTicks);
|
||||
//Log.Out("CurrentTimerTicks - GameTimer.Instance.ticks - GameTimerTicks: " + CurrentTimerTicks);
|
||||
//Log.Out("this.GetTickRate(): " + this.GetTickRate());
|
||||
//Log.Out("TempTimerTicks - (this.GetTickRate() - CurrentTimerTicks)/1200: " + TempTimerTicks);
|
||||
}
|
||||
|
||||
this.entsInRange = GameManager.Instance.World.GetLivingEntitiesInBounds(null, new Bounds(_blockPos, Vector3.one * (this.maxRange * 2f)));
|
||||
|
||||
for (int j = 0; j < this.entsInRange.Count; j++)
|
||||
{
|
||||
if (this.entsInRange[j] != null && this.entsInRange[j] is EntityAnimalChickenRebirth)
|
||||
{
|
||||
EntityAnimalChickenRebirth myEntity = (EntityAnimalChickenRebirth)this.entsInRange[j];
|
||||
|
||||
//Log.Out("COOP Position: " + _blockPos);
|
||||
//Log.Out("myEntity.homePos: " + myEntity.HomePosition);
|
||||
//Log.Out("myEntity NAME: " + myEntity.EntityName);
|
||||
//Log.Out("myEntity.entityId: " + myEntity.entityId);
|
||||
if (myEntity.HomePosition == _blockPos && !myEntity.IsDead())
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-GetActivationText FOUND ENTITY: " + myEntity.EntityName);
|
||||
myEntityName = myEntity.EntityName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.entsInRange.Clear();
|
||||
|
||||
if (this.GetBlockName() == "FuriousRamsayChickenCoop000" || this.GetBlockName() == "FuriousRamsayChickenCoop001")
|
||||
{
|
||||
if (myEntityName == "")
|
||||
{
|
||||
activationText = "[b0b0b0]" + Localization.Get("ttOccupant") + "[-]: [c45851]" + Localization.Get("ttnone") + "[-]\n" + activationText;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.GetBlockName() == "FuriousRamsayChickenCoop000")
|
||||
{
|
||||
activationText = "[b0b0b0]" + Localization.Get("ttOccupant") + "[-]: [59b5b4]" + myEntityName + "[-]\n" + activationText;
|
||||
}
|
||||
else
|
||||
{
|
||||
string timerText = "";
|
||||
|
||||
if (TempTimerTicks > 1)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-GetActivationText 1");
|
||||
timerText = " " + (int)TempTimerTicks + "[-] " + Localization.Get("ttMinutes") + "";
|
||||
}
|
||||
else if (TempTimerTicks == 1)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-GetActivationText 2");
|
||||
timerText = " " + (int)TempTimerTicks + "[-] " + Localization.Get("ttMinute") + "";
|
||||
}
|
||||
else if (TempTimerTicks == 0)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-GetActivationText 3");
|
||||
//timerText = " less than 1[-] " + Localization.Get("ttMinute") + "";
|
||||
}
|
||||
else if (TempTimerTicks < 0)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-GetActivationText 4");
|
||||
timerText = " " + Localization.Get("ttCalculating");
|
||||
}
|
||||
|
||||
ulong seconds = ((CurrentStageRate - tileEntityChickenCoop.AccumulatedTicks) / 20) % 60;
|
||||
|
||||
if (seconds > 1)
|
||||
{
|
||||
timerText = timerText + " [d6d97e]" + seconds + "[-] " + Localization.Get("ttSeconds");
|
||||
}
|
||||
else
|
||||
{
|
||||
timerText = timerText + " [d6d97e]" + seconds + "[-] " + Localization.Get("ttSecond");
|
||||
}
|
||||
//Log.Out("timerText A: " + timerText);
|
||||
|
||||
if (canShowCycleTime)
|
||||
{
|
||||
activationText = "[b0b0b0]" + Localization.Get("ttOccupant") + "[-]: [59b5b4]" + myEntityName + "[-]\n" + activationText + " - " + Localization.Get("ttNextCycle") + "[87db7f]" + timerText;
|
||||
}
|
||||
else
|
||||
{
|
||||
activationText = "[b0b0b0]" + Localization.Get("ttOccupant") + "[-]: [59b5b4]" + myEntityName + "[-]\n" + activationText;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (activationText);
|
||||
}
|
||||
|
||||
activationText = Localization.Get("ttGather") + " " + Localization.Get(this.contentName);
|
||||
|
||||
if (myEntityName == "")
|
||||
{
|
||||
activationText = "[b0b0b0]" + Localization.Get("ttOccupant") + "[-]: [c45851]" + Localization.Get("ttnone") + "[-]\n" + activationText;
|
||||
}
|
||||
else
|
||||
{
|
||||
string timerText = "";
|
||||
|
||||
if (TempTimerTicks > 1)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-GetActivationText 5");
|
||||
timerText = " " + (int)TempTimerTicks + "[-] " + Localization.Get("ttMinutes") + "";
|
||||
}
|
||||
else if (TempTimerTicks == 1)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-GetActivationText 6");
|
||||
timerText = " " + (int)TempTimerTicks + "[-] " + Localization.Get("ttMinute") + "";
|
||||
}
|
||||
else if (TempTimerTicks == 0)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-GetActivationText 7");
|
||||
//timerText = " less than 1[-] " + Localization.Get("ttMinute") + "";
|
||||
}
|
||||
else if (TempTimerTicks < 0)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-GetActivationText 8");
|
||||
timerText = " " + Localization.Get("ttCalculating");
|
||||
}
|
||||
|
||||
ulong seconds = ((CurrentStageRate - tileEntityChickenCoop.AccumulatedTicks) / 20) % 60;
|
||||
|
||||
if (seconds > 1)
|
||||
{
|
||||
timerText = timerText + " [d6d97e]" + seconds + "[-] " + Localization.Get("ttSeconds");
|
||||
}
|
||||
else
|
||||
{
|
||||
timerText = timerText + " [d6d97e]" + seconds + "[-] " + Localization.Get("ttSecond");
|
||||
}
|
||||
//Log.Out("timerText B: " + timerText);
|
||||
|
||||
if (this.GetBlockName() == "FuriousRamsayChickenCoop004")
|
||||
{
|
||||
activationText = "[b0b0b0]" + Localization.Get("ttOccupant") + "[-]: [59b5b4]" + myEntityName + "[-]\n" + activationText;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (canShowCycleTime)
|
||||
{
|
||||
activationText = "[b0b0b0]" + Localization.Get("ttOccupant") + "[-]: [59b5b4]" + myEntityName + "[-]\n" + activationText + " - " + Localization.Get("ttNextCycle") + "[87db7f]" + timerText;
|
||||
}
|
||||
else
|
||||
{
|
||||
activationText = "[b0b0b0]" + Localization.Get("ttOccupant") + "[-]: [59b5b4]" + myEntityName + "[-]\n" + activationText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (activationText);
|
||||
}
|
||||
|
||||
public override bool OnBlockActivated(WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
//Log.Out("BlockCoopRebirth-OnBlockActivated START");
|
||||
|
||||
//Log.Out("BlockCoopRebirth-OnBlockActivated this.gatherResources.Length: " + this.gatherResources.Length);
|
||||
//Log.Out("BlockCoopRebirth-OnBlockActivated this.gatherResourcesCount.Length: " + this.gatherResourcesCount.Length);
|
||||
|
||||
if (this.gatherResources[0] != "")
|
||||
{
|
||||
for (int i = 0; i < this.gatherResources.Length; i++)
|
||||
{
|
||||
string text = (this.gatherResourcesCount != null && this.gatherResourcesCount.Length > i) ? this.gatherResourcesCount[i] : "1";
|
||||
|
||||
//Log.Out("this.gatherResources[i], i=" + i + ", resource: " + this.gatherResources[i]);
|
||||
//Log.Out("this.gatherResourcesCount[i], i=" + i + ", count: " + this.gatherResourcesCount[i]);
|
||||
//Log.Out("text: " + text);
|
||||
|
||||
ItemValue newItem = ItemClass.GetItem(this.gatherResources[i], false);
|
||||
ItemClass itemClass = newItem.ItemClass;
|
||||
|
||||
int num;
|
||||
if (text.Contains("-"))
|
||||
{
|
||||
string[] array = text.Split(new char[]
|
||||
{
|
||||
'-'
|
||||
});
|
||||
int min = StringParsers.ParseSInt32(array[0], 0, -1, NumberStyles.Integer);
|
||||
int maxExclusive = StringParsers.ParseSInt32(array[1], 0, -1, NumberStyles.Integer) + 1;
|
||||
num = _player.rand.RandomRange(min, maxExclusive);
|
||||
}
|
||||
else
|
||||
{
|
||||
num = StringParsers.ParseSInt32(text, 0, -1, NumberStyles.Integer);
|
||||
}
|
||||
|
||||
//Log.Out("num: " + num);
|
||||
|
||||
ItemStack @is = new ItemStack(new ItemValue(itemClass.Id, false), num);
|
||||
(_player as EntityPlayerLocal).bag.AddItem(@is);
|
||||
}
|
||||
}
|
||||
|
||||
BlockValue blockValue = Block.GetBlockValue(this.baseBlock, true);
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(_blockPos);
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, _blockPos.x, _blockPos.y, _blockPos.z, FastTags<TagGroup.Global>.none, false);
|
||||
blockValue.rotation = this.convertRotation(_blockValue, blockValue);
|
||||
blockValue.meta = _blockValue.meta;
|
||||
blockValue.damage = _blockValue.damage;
|
||||
blockValue.meta2 = 0;
|
||||
_blockValue = blockValue;
|
||||
|
||||
_blockValue.meta = (byte)(_blockValue.meta + 1 & 15);
|
||||
|
||||
GameRandom gameRandom = _world.GetGameRandom();
|
||||
_blockValue = _blockValue.Block.OnBlockPlaced(_world, _cIdx, _blockPos, _blockValue, gameRandom);
|
||||
|
||||
BlockValue blockValue2 = Block.GetBlockValue(this.baseBlock, true);
|
||||
|
||||
Block block3 = blockValue.Block;
|
||||
_world.SetBlockRPC(_cIdx, _blockPos, blockValue);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(_blockPos, _player.entityId, _blockValue.type);
|
||||
|
||||
Manager.PlayInsidePlayerHead("open_garbage");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
if (this.Properties.Values.ContainsKey("ContentName"))
|
||||
{
|
||||
this.contentName = this.Properties.Values["ContentName"];
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("NextStageRate"))
|
||||
{
|
||||
this.nextStageRate = StringParsers.ParseFloat(this.Properties.Values["NextStageRate"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("MaxEntityRange"))
|
||||
{
|
||||
this.maxRange = StringParsers.ParseFloat(this.Properties.Values["MaxEntityRange"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("BaseBlock"))
|
||||
{
|
||||
this.baseBlock = this.Properties.Values["BaseBlock"];
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("NextStage"))
|
||||
{
|
||||
this.nextStage = this.Properties.Values["NextStage"];
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("TickRate"))
|
||||
{
|
||||
this.TickRate = (ulong)StringParsers.ParseFloat(this.Properties.Values["TickRate"], 0, -1, NumberStyles.Any) * 20;
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("GatherResources"))
|
||||
{
|
||||
this.gatherResources = this.Properties.Values["GatherResources"].Replace(" ", "").Split(new char[]
|
||||
{
|
||||
','
|
||||
});
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("GatherResourcesCount"))
|
||||
{
|
||||
this.gatherResourcesCount = this.Properties.Values["GatherResourcesCount"].Replace(" ", "").Split(new char[]
|
||||
{
|
||||
','
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private byte convertRotation(BlockValue _oldBV, BlockValue _newBV)
|
||||
{
|
||||
return _oldBV.rotation;
|
||||
}
|
||||
|
||||
public override ulong GetTickRate()
|
||||
{
|
||||
ulong nextStageRate = (ulong)(this.nextStageRate * 20f);
|
||||
|
||||
if (RebirthVariables.testChickenCoops)
|
||||
{
|
||||
nextStageRate = (ulong)RebirthVariables.testChickenCoopsRate * 20;
|
||||
}
|
||||
|
||||
return nextStageRate;
|
||||
}
|
||||
|
||||
public BlockCoopRebirth()
|
||||
{
|
||||
this.HasTileEntity = true;
|
||||
}
|
||||
|
||||
public override bool OnBlockActivated(string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
return _commandName == this.cmds[0].text && this.OnBlockActivated(_world, _cIdx, _blockPos, _blockValue, _player);
|
||||
}
|
||||
|
||||
public override BlockActivationCommand[] GetBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
return this.cmds;
|
||||
}
|
||||
}
|
||||
2186
Scripts/Blocks/BlockDeployableStructureRebirth.cs
Normal file
2186
Scripts/Blocks/BlockDeployableStructureRebirth.cs
Normal file
@@ -0,0 +1,2186 @@
|
||||
public class BlockDeployableStructureRebirth : Block
|
||||
{
|
||||
public ulong TickRate = 20UL;
|
||||
public int iteration = 0;
|
||||
public Vector3i blockPos;
|
||||
public byte blockRotation = 1;
|
||||
public string structureType = "";
|
||||
|
||||
public override bool CanPlaceBlockAt(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bOmitCollideCheck = false)
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-CanPlaceBlockAt START");
|
||||
if (GameManager.Instance.IsEditMode())
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-CanPlaceBlockAt 1");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool bCanPlaceBlock = base.CanPlaceBlockAt(_world, _clrIdx, _blockPos, _blockValue, _bOmitCollideCheck);
|
||||
|
||||
if (this.Properties.Values.ContainsKey("Structure"))
|
||||
{
|
||||
this.structureType = this.Properties.Values["Structure"];
|
||||
}
|
||||
|
||||
if (this.structureType == "TempDefense")
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-CanPlaceBlockAt 2");
|
||||
if (RebirthUtilities.overlapsWithOtherBlocks(_world, _blockPos, 3, 3))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool hasLandClaim = false;
|
||||
|
||||
if (!(bCanPlaceBlock && !hasLandClaim))
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-CanPlaceBlockAt 3");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void LateInit()
|
||||
{
|
||||
base.LateInit();
|
||||
}
|
||||
|
||||
public override void OnBlockAdded(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-OnBlockAdded START");
|
||||
base.OnBlockAdded(_world, _chunk, _blockPos, _blockValue);
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer) return;
|
||||
if (GameManager.Instance.IsEditMode()) return;
|
||||
|
||||
//Log.Out("BlockDeployableStructureRebirth-OnBlockAdded rotation: " + _blockValue.rotation);
|
||||
|
||||
_blockValue.meta = 0;
|
||||
iteration = 0;
|
||||
|
||||
if (this.Properties.Values.ContainsKey("Structure"))
|
||||
{
|
||||
this.structureType = this.Properties.Values["Structure"];
|
||||
}
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_chunk.ClrIdx, _blockPos, this.blockID, 20UL);
|
||||
}
|
||||
|
||||
public override bool UpdateTick(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bRandomTick, ulong _ticksIfLoaded, GameRandom _rnd)
|
||||
{
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick START");
|
||||
|
||||
byte rotationNew = 0;
|
||||
TileEntitySecure tileEntitySecure;
|
||||
|
||||
if (structureType == "MineShaft")
|
||||
{
|
||||
if (iteration == 0) // CREATE THE HOLE
|
||||
{
|
||||
BlockValue blockValue;
|
||||
|
||||
// DEFAULT ROTATION IS 1
|
||||
if (_blockValue.rotation == 24)
|
||||
{
|
||||
_blockValue.rotation = 0;
|
||||
}
|
||||
if (_blockValue.rotation == 25)
|
||||
{
|
||||
_blockValue.rotation = 1;
|
||||
}
|
||||
if (_blockValue.rotation == 26)
|
||||
{
|
||||
_blockValue.rotation = 2;
|
||||
}
|
||||
if (_blockValue.rotation == 27)
|
||||
{
|
||||
_blockValue.rotation = 3;
|
||||
}
|
||||
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 0");
|
||||
|
||||
blockPos = _blockPos;
|
||||
blockRotation = _blockValue.rotation;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
// SHAFT BLOCKS
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("FuriousRamsayAir", blockRotation, 0, blockPos.x, blockPos.y + 3, blockPos.z,
|
||||
3, 3, 0,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("FuriousRamsayAir", blockRotation, 0, blockPos.x, blockPos.y, blockPos.z,
|
||||
1, 3, 1,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("woodShapes:cube", blockRotation, 0, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
10, 1, 0,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("FuriousRamsayAir", blockRotation, 0, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
9, 2, 1,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, blockPos, this.blockID, this.TickRate);
|
||||
|
||||
}
|
||||
else if (iteration == 1)
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 1");
|
||||
|
||||
BlockValue blockValue;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("woodShapes:cube", blockRotation, 0, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
10, 2, 1,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
blockValue = Block.GetBlockValue("woodShapes:cube", true);
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 1;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 1;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 1;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
else if (iteration == 2)
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 2");
|
||||
|
||||
BlockValue blockValue;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
blockValue = Block.GetBlockValue("woodShapes:barsCorner", true);
|
||||
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 2;
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 3;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 2;
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 3;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("woodHatch", true);
|
||||
blockValue.rotation = 3;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("woodShapes:bars", true);
|
||||
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 2;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 2;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("woodShapes:cube", true);
|
||||
blockValue.rotation = 0;
|
||||
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("woodShapes:ladderSquare", true);
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z + 2;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 3;
|
||||
posX = blockPos.x - 2;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 2;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z - 2;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("wallTorchLightPlayer", true);
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
else if (iteration == 3)
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 3");
|
||||
|
||||
BlockValue blockValue;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("FuriousRamsayAir", blockRotation, 0, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
9, 1, 0,
|
||||
_world, chunk
|
||||
);
|
||||
RebirthUtilities.ReplaceBlocks("FuriousRamsayAir", blockRotation, 0, blockPos.x, blockPos.y - 7, blockPos.z,
|
||||
3, 5, 2,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayAir", true);
|
||||
blockValue.rotation = 0;
|
||||
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 9;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
else if (iteration == 4)
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 4");
|
||||
|
||||
BlockValue blockValue;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
blockValue = Block.GetBlockValue("woodShapes:cube", true);
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("wallTorchLightPlayer", true);
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z + 2;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 3;
|
||||
posX = blockPos.x - 2;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 2;
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z - 2;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("woodHatch", true);
|
||||
blockValue.rotation = 3;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 9;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("woodShapes:ladderSquare", blockRotation, 1, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
8, 1, 0,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
blockValue = Block.GetBlockValue("woodShapes:ladderSquare", true);
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
}
|
||||
}
|
||||
if (structureType == "MineShaftCobble")
|
||||
{
|
||||
if (iteration == 0) // CREATE THE HOLE
|
||||
{
|
||||
BlockValue blockValue;
|
||||
|
||||
// DEFAULT ROTATION IS 1
|
||||
if (_blockValue.rotation == 24)
|
||||
{
|
||||
_blockValue.rotation = 0;
|
||||
}
|
||||
if (_blockValue.rotation == 25)
|
||||
{
|
||||
_blockValue.rotation = 1;
|
||||
}
|
||||
if (_blockValue.rotation == 26)
|
||||
{
|
||||
_blockValue.rotation = 2;
|
||||
}
|
||||
if (_blockValue.rotation == 27)
|
||||
{
|
||||
_blockValue.rotation = 3;
|
||||
}
|
||||
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 0");
|
||||
|
||||
blockPos = _blockPos;
|
||||
blockRotation = _blockValue.rotation;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
// SHAFT BLOCKS
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("FuriousRamsayAir", blockRotation, 0, blockPos.x, blockPos.y + 3, blockPos.z,
|
||||
3, 3, 0,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("FuriousRamsayAir", blockRotation, 0, blockPos.x, blockPos.y, blockPos.z,
|
||||
1, 3, 1,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("cobblestoneShapes:cube", blockRotation, 0, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
10, 1, 0,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("FuriousRamsayAir", blockRotation, 0, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
9, 2, 1,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, blockPos, this.blockID, this.TickRate);
|
||||
|
||||
}
|
||||
else if (iteration == 1)
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 1");
|
||||
|
||||
BlockValue blockValue;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("cobblestoneShapes:cube", blockRotation, 0, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
10, 2, 1,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
blockValue = Block.GetBlockValue("cobblestoneShapes:cube", true);
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 1;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 1;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 1;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
else if (iteration == 2)
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 2");
|
||||
|
||||
BlockValue blockValue;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
blockValue = Block.GetBlockValue("cobblestoneShapes:barsCorner", true);
|
||||
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 2;
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 3;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 2;
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 3;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("ironHatchWhite", true);
|
||||
blockValue.rotation = 3;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("cobblestoneShapes:bars", true);
|
||||
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 2;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 2;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("cobblestoneShapes:cube", true);
|
||||
blockValue.rotation = 0;
|
||||
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("woodShapes:ladderSquare", true);
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z + 2;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 3;
|
||||
posX = blockPos.x - 2;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 2;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z - 2;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("wallTorchLightPlayer", true);
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
else if (iteration == 3)
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 3");
|
||||
|
||||
BlockValue blockValue;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("FuriousRamsayAir", blockRotation, 0, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
9, 1, 0,
|
||||
_world, chunk
|
||||
);
|
||||
RebirthUtilities.ReplaceBlocks("FuriousRamsayAir", blockRotation, 0, blockPos.x, blockPos.y - 7, blockPos.z,
|
||||
3, 5, 2,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayAir", true);
|
||||
blockValue.rotation = 0;
|
||||
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 9;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
else if (iteration == 4)
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 4");
|
||||
|
||||
BlockValue blockValue;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
blockValue = Block.GetBlockValue("cobblestoneShapes:cube", true);
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("wallTorchLightPlayer", true);
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z + 2;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 3;
|
||||
posX = blockPos.x - 2;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 2;
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z - 2;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("ironHatchWhite", true);
|
||||
blockValue.rotation = 3;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 9;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("woodShapes:ladderSquare", blockRotation, 1, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
8, 1, 0,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
blockValue = Block.GetBlockValue("woodShapes:ladderSquare", true);
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
}
|
||||
}
|
||||
else if (structureType == "MineShaftExtension")
|
||||
{
|
||||
if (iteration == 0) // CREATE THE HOLE
|
||||
{
|
||||
BlockValue blockValue;
|
||||
|
||||
// DEFAULT ROTATION IS 1
|
||||
if (_blockValue.rotation == 24)
|
||||
{
|
||||
_blockValue.rotation = 0;
|
||||
}
|
||||
if (_blockValue.rotation == 25)
|
||||
{
|
||||
_blockValue.rotation = 1;
|
||||
}
|
||||
if (_blockValue.rotation == 26)
|
||||
{
|
||||
_blockValue.rotation = 2;
|
||||
}
|
||||
if (_blockValue.rotation == 27)
|
||||
{
|
||||
_blockValue.rotation = 3;
|
||||
}
|
||||
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 0");
|
||||
|
||||
blockPos = _blockPos;
|
||||
blockRotation = _blockValue.rotation;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
// SHAFT BLOCKS
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("woodShapes:cube", blockRotation, 0, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
10, 1, 0,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("FuriousRamsayAir", blockRotation, 0, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
9, 2, 1,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, blockPos, this.blockID, this.TickRate);
|
||||
|
||||
}
|
||||
else if (iteration == 1)
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 1");
|
||||
|
||||
BlockValue blockValue;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("woodShapes:cube", blockRotation, 0, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
10, 2, 1,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
else if (iteration == 2)
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 2");
|
||||
|
||||
BlockValue blockValue;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
blockValue = Block.GetBlockValue("woodShapes:cube", true);
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("FuriousRamsayAir", blockRotation, 0, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
9, 1, 0,
|
||||
_world, chunk
|
||||
);
|
||||
RebirthUtilities.ReplaceBlocks("FuriousRamsayAir", blockRotation, 0, blockPos.x, blockPos.y - 7, blockPos.z,
|
||||
3, 5, 2,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayAir", true);
|
||||
blockValue.rotation = 0;
|
||||
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 9;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
else if (iteration == 3)
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 3");
|
||||
|
||||
BlockValue blockValue;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
blockValue = Block.GetBlockValue("woodShapes:cube", true);
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("wallTorchLightPlayer", true);
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z + 2;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 3;
|
||||
posX = blockPos.x - 2;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 2;
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z - 2;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("woodHatch", true);
|
||||
blockValue.rotation = 3;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 9;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("woodShapes:ladderSquare", blockRotation, 1, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
8, 1, 0,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayAir", true);
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
}
|
||||
}
|
||||
else if (structureType == "MineShaftExtensionCobble")
|
||||
{
|
||||
if (iteration == 0) // CREATE THE HOLE
|
||||
{
|
||||
BlockValue blockValue;
|
||||
|
||||
// DEFAULT ROTATION IS 1
|
||||
if (_blockValue.rotation == 24)
|
||||
{
|
||||
_blockValue.rotation = 0;
|
||||
}
|
||||
if (_blockValue.rotation == 25)
|
||||
{
|
||||
_blockValue.rotation = 1;
|
||||
}
|
||||
if (_blockValue.rotation == 26)
|
||||
{
|
||||
_blockValue.rotation = 2;
|
||||
}
|
||||
if (_blockValue.rotation == 27)
|
||||
{
|
||||
_blockValue.rotation = 3;
|
||||
}
|
||||
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 0");
|
||||
|
||||
blockPos = _blockPos;
|
||||
blockRotation = _blockValue.rotation;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
// SHAFT BLOCKS
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("cobblestoneShapes:cube", blockRotation, 0, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
10, 1, 0,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("FuriousRamsayAir", blockRotation, 0, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
9, 2, 1,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, blockPos, this.blockID, this.TickRate);
|
||||
|
||||
}
|
||||
else if (iteration == 1)
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 1");
|
||||
|
||||
BlockValue blockValue;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("cobblestoneShapes:cube", blockRotation, 0, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
10, 2, 1,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
else if (iteration == 2)
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 2");
|
||||
|
||||
BlockValue blockValue;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
blockValue = Block.GetBlockValue("cobblestoneShapes:cube", true);
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("FuriousRamsayAir", blockRotation, 0, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
9, 1, 0,
|
||||
_world, chunk
|
||||
);
|
||||
RebirthUtilities.ReplaceBlocks("FuriousRamsayAir", blockRotation, 0, blockPos.x, blockPos.y - 7, blockPos.z,
|
||||
3, 5, 2,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayAir", true);
|
||||
blockValue.rotation = 0;
|
||||
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 9;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
else if (iteration == 3)
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 3");
|
||||
|
||||
BlockValue blockValue;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
blockValue = Block.GetBlockValue("cobblestoneShapes:cube", true);
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 10;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("wallTorchLightPlayer", true);
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z + 2;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 3;
|
||||
posX = blockPos.x - 2;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue.rotation = 2;
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y - 8;
|
||||
posZ = blockPos.z - 2;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("ironHatchWhite", true);
|
||||
blockValue.rotation = 3;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y - 9;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("woodShapes:ladderSquare", blockRotation, 1, blockPos.x, blockPos.y - 1, blockPos.z,
|
||||
8, 1, 0,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayAir", true);
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
}
|
||||
}
|
||||
else if (structureType == "TempDefense")
|
||||
{
|
||||
if (iteration == 0)
|
||||
{
|
||||
BlockValue blockValue;
|
||||
|
||||
// DEFAULT ROTATION IS 1
|
||||
if (_blockValue.rotation == 24)
|
||||
{
|
||||
_blockValue.rotation = 0;
|
||||
}
|
||||
if (_blockValue.rotation == 25)
|
||||
{
|
||||
_blockValue.rotation = 1;
|
||||
}
|
||||
if (_blockValue.rotation == 26)
|
||||
{
|
||||
_blockValue.rotation = 2;
|
||||
}
|
||||
if (_blockValue.rotation == 27)
|
||||
{
|
||||
_blockValue.rotation = 3;
|
||||
}
|
||||
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 0");
|
||||
|
||||
blockPos = _blockPos;
|
||||
blockRotation = _blockValue.rotation;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
// SHAFT BLOCKS
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("FuriousRamsayTemporaryCobblestoneLVL" + iteration + ":cube", blockRotation, 0, blockPos.x, blockPos.y, blockPos.z,
|
||||
1, 3, 2,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayTemporaryscrapHatch_v3", true);
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x - 2;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick posX, posY, posZ: " + posX + ", " + posY + ", " + posZ);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayTemporaryscrapHatch_v3", true);
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z - 2;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick posX, posY, posZ: " + posX + ", " + posY + ", " + posZ);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayTemporaryscrapHatch_v3", true);
|
||||
blockValue.rotation = 3;
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick posX, posY, posZ: " + posX + ", " + posY + ", " + posZ);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayTemporaryscrapHatch_v3", true);
|
||||
blockValue.rotation = 2;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z + 2;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick posX, posY, posZ: " + posX + ", " + posY + ", " + posZ);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, blockPos, this.blockID, this.TickRate);
|
||||
|
||||
}
|
||||
else if (iteration == 1)
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 1");
|
||||
|
||||
BlockValue blockValue;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayTemporaryConcreteLVL" + iteration + ":barsCorner", true);
|
||||
blockValue.rotation = 2;
|
||||
posX = blockPos.x - 2;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z + 2;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayTemporaryConcreteLVL" + iteration + ":barsCorner", true);
|
||||
blockValue.rotation = 1;
|
||||
posX = blockPos.x - 2;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z - 2;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayTemporaryConcreteLVL" + iteration + ":barsCorner", true);
|
||||
blockValue.rotation = 0;
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z - 2;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayTemporaryConcreteLVL" + iteration + ":barsCorner", true);
|
||||
blockValue.rotation = 3;
|
||||
posX = blockPos.x + 2;
|
||||
posY = blockPos.y + 1;
|
||||
posZ = blockPos.z + 2;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
else if (iteration == 2)
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 2");
|
||||
|
||||
BlockValue blockValue;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
RebirthUtilities.ReplaceBlocks("FuriousRamsayTemporaryCobblestoneLVL" + iteration + ":cube", blockRotation, 0, blockPos.x, blockPos.y + 2, blockPos.z,
|
||||
1, 3, 2,
|
||||
_world, chunk
|
||||
);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
else if (iteration == 3)
|
||||
{
|
||||
//Log.Out("BlockDeployableStructureRebirth-UpdateTick 3");
|
||||
|
||||
BlockValue blockValue;
|
||||
|
||||
int posX = blockPos.x;
|
||||
int posY = blockPos.y;
|
||||
int posZ = blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayTemporaryCobblestoneLVL" + iteration + ":bars", true);
|
||||
blockValue.rotation = 10;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayTemporaryCobblestoneLVL" + iteration + ":bars", true);
|
||||
blockValue.rotation = 10;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayTemporaryCobblestoneLVL" + iteration + ":bars", true);
|
||||
blockValue.rotation = 10;
|
||||
posX = blockPos.x + 1;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayTemporaryCobblestoneLVL" + iteration + ":bars", true);
|
||||
blockValue.rotation = 10;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayTemporaryCobblestoneLVL" + iteration + ":bars", true);
|
||||
blockValue.rotation = 10;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayTemporaryCobblestoneLVL" + iteration + ":bars", true);
|
||||
blockValue.rotation = 10;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayTemporaryCobblestoneLVL" + iteration + ":bars", true);
|
||||
blockValue.rotation = 10;
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z - 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayTemporaryCobblestoneLVL" + iteration + ":bars", true);
|
||||
blockValue.rotation = 10;
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayTemporaryCobblestoneLVL" + iteration + ":bars", true);
|
||||
blockValue.rotation = 10;
|
||||
posX = blockPos.x - 1;
|
||||
posY = blockPos.y + 2;
|
||||
posZ = blockPos.z + 1;
|
||||
rotationNew = blockValue.rotation;
|
||||
RebirthUtilities.ConvertRotatedPosition(1, blockRotation, blockPos.x, blockPos.z, ref posX, ref posZ, ref rotationNew);
|
||||
blockValue.rotation = rotationNew;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
blockValue = Block.GetBlockValue("FuriousRamsayTemporaryDefenseBlock:billboard", true);
|
||||
blockValue.rotation = 8;
|
||||
posX = blockPos.x;
|
||||
posY = blockPos.y;
|
||||
posZ = blockPos.z;
|
||||
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(blockPos, -1, _blockValue.type);
|
||||
|
||||
iteration++;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
}
|
||||
|
||||
public override ulong GetTickRate()
|
||||
{
|
||||
return (ulong)(1 * 20f);
|
||||
}
|
||||
}
|
||||
65
Scripts/Blocks/BlockElectricWireSDX.cs
Normal file
65
Scripts/Blocks/BlockElectricWireSDX.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using Audio;
|
||||
|
||||
public class BlockElectricWireSDX : BlockElectricWire
|
||||
{
|
||||
|
||||
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 as EntityPlayerLocal, 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;
|
||||
}
|
||||
259
Scripts/Blocks/BlockFarmPlotRebirth.cs
Normal file
259
Scripts/Blocks/BlockFarmPlotRebirth.cs
Normal file
@@ -0,0 +1,259 @@
|
||||
using Audio;
|
||||
using System.Globalization;
|
||||
|
||||
public class BlockFarmPlotRebirth : Block
|
||||
{
|
||||
private float TakeDelay = RebirthVariables.takeDelay;
|
||||
private int waterMax = 6;
|
||||
private bool canPickUpBlock = true;
|
||||
public ulong TickRate = 1200UL;
|
||||
|
||||
public override bool HasBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int OnBlockDamaged(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, int _damagePoints, int _entityIdThatDamaged, ItemActionAttack.AttackHitInfo _attackHitInfo, bool _bUseHarvestTool, bool _bBypassMaxDamage, int _recDepth = 0)
|
||||
{
|
||||
EntityAlive entityAlive = _world.GetEntity(_entityIdThatDamaged) as EntityAlive;
|
||||
if (entityAlive is EntityPlayer)
|
||||
{
|
||||
EntityPlayer entityPlayer = (EntityPlayer)entityAlive;
|
||||
if (entityPlayer)
|
||||
{
|
||||
if (entityPlayer.inventory.holdingItem.GetItemName().ToLower() == "meleehandplayer")
|
||||
{
|
||||
//return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnBlockDamaged(_world, _clrIdx, _blockPos, _blockValue, _damagePoints, _entityIdThatDamaged, _attackHitInfo, _bUseHarvestTool, _bBypassMaxDamage, 0);
|
||||
}
|
||||
|
||||
private BlockActivationCommand[] cmds = new BlockActivationCommand[]
|
||||
{
|
||||
new BlockActivationCommand("cancel", "x", false, false),
|
||||
new BlockActivationCommand("take", "hand", false)
|
||||
};
|
||||
|
||||
public override ulong GetTickRate()
|
||||
{
|
||||
this.TickRate = (ulong)StringParsers.ParseFloat(this.Properties.Values["TickRate"], 0, -1, NumberStyles.Any) * 20UL;
|
||||
//Log.Out("BlockFarmPlotRebirth-GetTickRate this.TickRate: " + this.TickRate);
|
||||
return this.TickRate;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
this.canPickUpBlock = true;
|
||||
bool flag = this.Properties.Values.ContainsKey("TakeDelay");
|
||||
if (flag)
|
||||
{
|
||||
this.TakeDelay = StringParsers.ParseFloat(this.Properties.Values["TakeDelay"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
bool flag2 = this.Properties.Values.ContainsKey("canPickUpBlock");
|
||||
if (flag2)
|
||||
{
|
||||
StringParsers.TryParseBool(this.Properties.Values["canPickUpBlock"], out this.canPickUpBlock, 0, -1, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void addTileEntity(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
TileEntityFarmPlotRebirth tileEntityFarmPlot = new TileEntityFarmPlotRebirth(_chunk);
|
||||
tileEntityFarmPlot.localChunkPos = World.toBlock(_blockPos);
|
||||
tileEntityFarmPlot.waterCount = 0;
|
||||
_chunk.AddTileEntity(tileEntityFarmPlot);
|
||||
//Log.Out("BlockFarmPlotRebirth-addTileEntity _blockPos: " + _blockPos);
|
||||
}
|
||||
|
||||
protected virtual void removeTileEntity(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockFarmPlotRebirth-removeTileEntity START");
|
||||
_chunk.RemoveTileEntityAt<TileEntityFarmPlotRebirth>((World)world, World.toBlock(_blockPos));
|
||||
}
|
||||
|
||||
public override void OnBlockRemoved(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockFarmPlotRebirth-OnBlockRemoved START");
|
||||
base.OnBlockRemoved(world, _chunk, _blockPos, _blockValue);
|
||||
TileEntityFarmPlotRebirth tileEntityFarmPlot = world.GetTileEntity(_chunk.ClrIdx, _blockPos) as TileEntityFarmPlotRebirth;
|
||||
if (tileEntityFarmPlot != null)
|
||||
{
|
||||
tileEntityFarmPlot.OnDestroy();
|
||||
}
|
||||
this.removeTileEntity(world, _chunk, _blockPos, _blockValue);
|
||||
}
|
||||
|
||||
public override void OnBlockAdded(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockFarmPlotRebirth-OnBlockAdded START");
|
||||
base.OnBlockAdded(_world, _chunk, _blockPos, _blockValue);
|
||||
this.addTileEntity(_world, _chunk, _blockPos, _blockValue);
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
//Log.Out("BlockFarmPlotRebirth-OnBlockAdded 1");
|
||||
return;
|
||||
}
|
||||
|
||||
if (GameManager.Instance.IsEditMode())
|
||||
{
|
||||
//Log.Out("BlockFarmPlotRebirth-OnBlockAdded 2");
|
||||
return;
|
||||
}
|
||||
|
||||
_blockValue.meta = 0;
|
||||
|
||||
//Log.Out("BlockFarmPlotRebirth-OnBlockAdded Tick");
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_chunk.ClrIdx, _blockPos, this.blockID, this.GetTickRate());
|
||||
}
|
||||
|
||||
public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
string activationText = ""; //Localization.Get("ttNoRainWater");
|
||||
|
||||
TileEntityFarmPlotRebirth tileEntity = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityFarmPlotRebirth;
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
string color = "e3dc5b";
|
||||
string colorMax = "5ed680";
|
||||
if (tileEntity.waterCount == tileEntity.waterMax)
|
||||
{
|
||||
color = colorMax;
|
||||
}
|
||||
|
||||
if (RebirthVariables.customAdvancedFarming)
|
||||
{
|
||||
activationText = Localization.Get("ttWaterContent") + " [[" + color + "]" + tileEntity.waterCount + "[-]/[" + colorMax + "]" + tileEntity.waterMax + "[-]]";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockFarmPlotRebirth-GetActivationText ADD TILE ENTITY");
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(_blockPos);
|
||||
|
||||
this.addTileEntity(_world, chunk, _blockPos, _blockValue);
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, this.GetTickRate());
|
||||
}
|
||||
|
||||
return (activationText);
|
||||
}
|
||||
|
||||
public override bool OnBlockActivated(string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
bool ischild = _blockValue.ischild;
|
||||
bool result = false;
|
||||
|
||||
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
|
||||
{
|
||||
TileEntityFarmPlotRebirth tileEntity = _world.GetTileEntity(_cIdx, _blockPos) as TileEntityFarmPlotRebirth;
|
||||
if (tileEntity != null)
|
||||
{
|
||||
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 as EntityPlayerLocal, 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 BlockFarmPlotRebirth()
|
||||
{
|
||||
this.HasTileEntity = true;
|
||||
}
|
||||
|
||||
public override BlockActivationCommand[] GetBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
this.cmds[0].enabled = false; // this.canPickUpBlock;
|
||||
this.cmds[1].enabled = false; // this.canPickUpBlock;
|
||||
return this.cmds;
|
||||
}
|
||||
|
||||
public override bool UpdateTick(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bRandomTick, ulong _ticksIfLoaded, GameRandom _rnd)
|
||||
{
|
||||
//Log.Out("BlockFarmPlotRebirth-UpdateTick START");
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
//Log.Out("BlockFarmPlotRebirth-UpdateTick 0");
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntityFarmPlotRebirth tileEntity = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityFarmPlotRebirth;
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
//Log.Out("BlockFarmPlotRebirth-UpdateTick 1");
|
||||
bool flag3 = this.Properties.Values.ContainsKey("WaterMax");
|
||||
if (flag3)
|
||||
{
|
||||
this.Properties.ParseInt(this.Properties.Values["WaterMax"], ref this.waterMax);
|
||||
tileEntity.waterMax = this.waterMax;
|
||||
}
|
||||
|
||||
float num = WeatherManager.Instance.GetCurrentTemperatureValue();
|
||||
float numRain = 0;
|
||||
|
||||
if (num == 0)
|
||||
{
|
||||
//Log.Out("BlockFarmPlotRebirth-UpdateTick 1a");
|
||||
numRain = RebirthUtilities.GetWeatherInfo(_blockPos, "wet") * 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockFarmPlotRebirth-UpdateTick 1b");
|
||||
numRain = 10 * WeatherManager.Instance.GetCurrentRainfallValue();
|
||||
}
|
||||
|
||||
//Log.Out("BlockFarmPlotRebirth-UpdateTick numRain: " + numRain);
|
||||
|
||||
if (numRain > 0)
|
||||
{
|
||||
tileEntity.waterCount++;
|
||||
//Log.Out("BlockFarmPlotRebirth-UpdateTick tileEntity.waterCount: " + tileEntity.waterCount);
|
||||
if (tileEntity.waterCount > tileEntity.waterMax)
|
||||
{
|
||||
//Log.Out("BlockFarmPlotRebirth-UpdateTick 3");
|
||||
tileEntity.waterCount = tileEntity.waterMax;
|
||||
}
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage((NetPackage)NetPackageManager.GetPackage<NetPackageUpdateFarmPlotRebirth>().Setup(_clrIdx, _blockPos, tileEntity.waterCount));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockFarmPlotRebirth-UpdateTick 4");
|
||||
}
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, this.GetTickRate());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
46
Scripts/Blocks/BlockFeedRebirth.cs
Normal file
46
Scripts/Blocks/BlockFeedRebirth.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
public class BlockFeedRebirth : BlockLoot
|
||||
{
|
||||
protected float updateRate = 5;
|
||||
public string contentName = "";
|
||||
public string strNestResource = "FuriousRamsayWoodStick";
|
||||
public int numNestResourceQuantity = 5;
|
||||
private List<EntityAlive> entsInRange;
|
||||
public float maxRange = 10;
|
||||
public System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
if (this.Properties.Values.ContainsKey("UpdateRate"))
|
||||
{
|
||||
this.updateRate = StringParsers.ParseFloat(this.Properties.Values["UpdateRate"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("MaxEntityRange"))
|
||||
{
|
||||
this.maxRange = StringParsers.ParseFloat(this.Properties.Values["MaxEntityRange"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
|
||||
if (this.Properties.Values.ContainsKey("NestResource"))
|
||||
{
|
||||
this.strNestResource = this.Properties.Values["NestResource"];
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("NestResourceQuantity"))
|
||||
{
|
||||
this.numNestResourceQuantity = (int)StringParsers.ParseFloat(this.Properties.Values["NestResourceQuantity"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
}
|
||||
|
||||
private byte convertRotation(BlockValue _oldBV, BlockValue _newBV)
|
||||
{
|
||||
return _oldBV.rotation;
|
||||
}
|
||||
|
||||
public override ulong GetTickRate()
|
||||
{
|
||||
//Log.Out("BlockFeedRebirth-GetTickRate this.GetTickRate(): " + (ulong)(this.updateRate * 20f));
|
||||
return (ulong)(this.updateRate * 20f);
|
||||
}
|
||||
}
|
||||
63
Scripts/Blocks/BlockForgeRebirth.cs
Normal file
63
Scripts/Blocks/BlockForgeRebirth.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
#nullable disable
|
||||
[Preserve]
|
||||
public class BlockForgeRebirth : BlockWorkstationRebirth
|
||||
{
|
||||
public BlockForgeRebirth() => this.CraftingParticleLightIntensity = 1.6f;
|
||||
|
||||
public override void OnBlockEntityTransformAfterActivated(
|
||||
WorldBase _world,
|
||||
Vector3i _blockPos,
|
||||
int _cIdx,
|
||||
BlockValue _blockValue,
|
||||
BlockEntityData _ebcd)
|
||||
{
|
||||
base.OnBlockEntityTransformAfterActivated(_world, _blockPos, _cIdx, _blockValue, _ebcd);
|
||||
this.MaterialUpdate(_world, _blockPos, _blockValue);
|
||||
}
|
||||
|
||||
[PublicizedFrom(EAccessModifier.Protected)]
|
||||
public override void checkParticles(
|
||||
WorldBase _world,
|
||||
int _clrIdx,
|
||||
Vector3i _blockPos,
|
||||
BlockValue _blockValue)
|
||||
{
|
||||
base.checkParticles(_world, _clrIdx, _blockPos, _blockValue);
|
||||
if (_blockValue.ischild)
|
||||
return;
|
||||
this.MaterialUpdate(_world, _blockPos, _blockValue);
|
||||
}
|
||||
|
||||
public override string GetActivationText(
|
||||
WorldBase _world,
|
||||
BlockValue _blockValue,
|
||||
int _clrIdx,
|
||||
Vector3i _blockPos,
|
||||
EntityAlive _entityFocusing)
|
||||
{
|
||||
return Localization.Get("useForge");
|
||||
}
|
||||
|
||||
[PublicizedFrom(EAccessModifier.Private)]
|
||||
public void MaterialUpdate(WorldBase _world, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
Chunk chunkFromWorldPos = (Chunk)_world.GetChunkFromWorldPos(_blockPos);
|
||||
if (chunkFromWorldPos == null)
|
||||
return;
|
||||
BlockEntityData blockEntity = chunkFromWorldPos.GetBlockEntity(_blockPos);
|
||||
if (blockEntity == null || !blockEntity.bHasTransform)
|
||||
return;
|
||||
Renderer[] componentsInChildren = (Renderer[])blockEntity.transform.GetComponentsInChildren<MeshRenderer>(true);
|
||||
if (componentsInChildren.Length == 0)
|
||||
return;
|
||||
Material material = componentsInChildren[0].material;
|
||||
if (!(bool)material)
|
||||
return;
|
||||
float num = _blockValue.meta == (byte)0 ? 0.0f : 20f;
|
||||
material.SetFloat("_EmissionMultiply", num);
|
||||
for (int index = 1; index < componentsInChildren.Length; ++index)
|
||||
componentsInChildren[index].material = material;
|
||||
}
|
||||
}
|
||||
155
Scripts/Blocks/BlockHamRadio.cs
Normal file
155
Scripts/Blocks/BlockHamRadio.cs
Normal file
@@ -0,0 +1,155 @@
|
||||
using Audio;
|
||||
using Platform;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using static RebirthManager;
|
||||
using static SleeperVolume;
|
||||
|
||||
public class BlockHamRadio : Block
|
||||
{
|
||||
public override void OnTriggered(EntityPlayer _player, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, List<BlockChangeInfo> _blockChanges, BlockTrigger _triggeredBy)
|
||||
{
|
||||
//Log.Out("BlockHamRadio-OnTriggered START");
|
||||
base.OnTriggered(_player, _world, _cIdx, _blockPos, _blockValue, _blockChanges, _triggeredBy);
|
||||
|
||||
if (!this.DowngradeBlock.isair)
|
||||
{
|
||||
BlockValue blockValue = this.DowngradeBlock;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), _blockPos.x, _blockPos.z);
|
||||
blockValue.rotation = _blockValue.rotation;
|
||||
blockValue.meta = _blockValue.meta;
|
||||
_world.SetBlockRPC(_cIdx, _blockPos, blockValue, blockValue.Block.Density);
|
||||
}
|
||||
Manager.BroadcastPlayByLocalPlayer(_blockPos.ToVector3() + Vector3.one * 0.5f, "Misc/unlocking");
|
||||
}
|
||||
|
||||
public override bool IsWaterBlocked(IBlockAccess _world, Vector3i _blockPos, BlockValue _blockValue, BlockFaceFlag _sides)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool AllowBlockTriggers
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
//Log.Out("BlockHamRadio-Init START");
|
||||
base.Init();
|
||||
//this.CanPickup = 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 string GetActivationText(
|
||||
WorldBase _world,
|
||||
BlockValue _blockValue,
|
||||
int _clrIdx,
|
||||
Vector3i _blockPos,
|
||||
EntityAlive _entityFocusing)
|
||||
{
|
||||
//Log.Out("BlockHamRadio-GetActivationText START");
|
||||
Block block = _blockValue.Block;
|
||||
if (!this.CanPickup && (double)EffectManager.GetValue(PassiveEffects.BlockPickup, _entity: _entityFocusing, tags: _blockValue.Block.Tags) <= 0.0)
|
||||
{
|
||||
//Log.Out("BlockHamRadio-GetActivationText 1");
|
||||
return (string)null;
|
||||
}
|
||||
if (!_world.CanPickupBlockAt(_blockPos, _world.GetGameManager().GetPersistentLocalPlayer()))
|
||||
{
|
||||
//Log.Out("BlockHamRadio-GetActivationText 2");
|
||||
return (string)null;
|
||||
}
|
||||
string _key = block.GetBlockName();
|
||||
if (!string.IsNullOrEmpty(block.PickedUpItemValue))
|
||||
{
|
||||
//Log.Out("BlockHamRadio-GetActivationText 3");
|
||||
_key = block.PickedUpItemValue;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(block.PickupTarget))
|
||||
{
|
||||
//Log.Out("BlockHamRadio-GetActivationText 4");
|
||||
_key = block.PickupTarget;
|
||||
}
|
||||
//Log.Out("BlockHamRadio-GetActivationText END");
|
||||
return string.Format(Localization.Get("pickupPrompt"), (object)Localization.Get(_key));
|
||||
}
|
||||
|
||||
public override bool OnBlockActivated(string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
//Log.Out("BlockHamRadio-OnBlockActivated START, _commandName: " + _commandName);
|
||||
if (_blockValue.ischild)
|
||||
{
|
||||
//Log.Out("BlockHamRadio:isSecure _blockValue.ischild");
|
||||
Vector3i parentPos = _blockValue.Block.multiBlockPos.GetParentPos(_blockPos, _blockValue);
|
||||
BlockValue block = _world.GetBlock(parentPos);
|
||||
return this.OnBlockActivated(_commandName, _world, _cIdx, parentPos, block, _player);
|
||||
}
|
||||
|
||||
if (_commandName == this.cmds[0].text)
|
||||
{
|
||||
//Log.Out("BlockHamRadio:OnBlockActivated-_commandName == this.cmds[1].text");
|
||||
|
||||
var uiforPlayer = LocalPlayerUI.GetUIForPlayer(_player);
|
||||
|
||||
if (uiforPlayer != null)
|
||||
{
|
||||
uiforPlayer.windowManager.Open("ManageNPCs", true, false, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (_commandName == this.cmds[1].text)
|
||||
{
|
||||
//Log.Out("BlockHamRadio:OnBlockActivated-_commandName == this.cmds[0].text");
|
||||
bool isWithinTraderArea = ((World)_world).GetTraderAreaAt(_blockPos) != null;
|
||||
|
||||
if (isWithinTraderArea)
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
|
||||
return false;
|
||||
}
|
||||
|
||||
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, this.TakeDelay, null, "", 1, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("OnBlockActivated:Insecure/Other");
|
||||
//Log.Out("BlockHamRadio:OnBlockActivated-_indexInBlockActivationCommands == other");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override BlockActivationCommand[] GetBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
//Log.Out("BlockHamRadio-GetBlockActivationCommands START");
|
||||
this.cmds[0].enabled = true;
|
||||
this.cmds[1].enabled = this.canPickUpBlock;
|
||||
return this.cmds;
|
||||
}
|
||||
|
||||
public BlockActivationCommand[] cmds = new BlockActivationCommand[]
|
||||
{
|
||||
new BlockActivationCommand("TeleportHires", "followers", false, false),
|
||||
new BlockActivationCommand("take", "hand", false, false),
|
||||
};
|
||||
|
||||
|
||||
public float TakeDelay = RebirthVariables.takeDelay;
|
||||
public bool canPickUpBlock = true;
|
||||
}
|
||||
341
Scripts/Blocks/BlockModelTreeRebirth.cs
Normal file
341
Scripts/Blocks/BlockModelTreeRebirth.cs
Normal file
@@ -0,0 +1,341 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class BlockModelTreeRebirth : BlockPlantGrowing
|
||||
{
|
||||
|
||||
private List<ItemStack> itemsDropped = new List<ItemStack>();
|
||||
|
||||
public void DropItemsOnEvent2(WorldBase _world, BlockValue _blockValue, EnumDropEvent _eEvent, float _overallProb, Vector3 _dropPos, Vector3 _randomPosAdd, float _lifetime, int _entityId, bool _bGetSameItemIfNoneFound)
|
||||
{
|
||||
|
||||
//Log.Out("BlockModelTreeRebirth-DropItemsOnEvent2 START");
|
||||
|
||||
bool downgradeBlock = RebirthVariables.customReplantTrees;
|
||||
|
||||
//Log.Out("DropItemsOnEvent2 flDowngradeBlock: " + flDowngradeBlock);
|
||||
|
||||
GameRandom gameRandom = _world.GetGameRandom();
|
||||
this.itemsDropped.Clear();
|
||||
List<Block.SItemDropProb> list;
|
||||
if (!this.itemsToDrop.TryGetValue(_eEvent, out list))
|
||||
{
|
||||
if (_bGetSameItemIfNoneFound)
|
||||
{
|
||||
ItemValue itemValue = _blockValue.ToItemValue();
|
||||
this.itemsDropped.Add(new ItemStack(itemValue, 1));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
|
||||
//Log.Out("DropItemsOnEvent2 doppedItem: " + list[i].name);
|
||||
|
||||
if (!(downgradeBlock && list[i].name.Contains("treePlanted")))
|
||||
{
|
||||
Block.SItemDropProb sitemDropProb = list[i];
|
||||
int num = gameRandom.RandomRange(sitemDropProb.minCount, sitemDropProb.maxCount + 1);
|
||||
if (num > 0)
|
||||
{
|
||||
if (sitemDropProb.stickChance < 0.001f || gameRandom.RandomFloat > sitemDropProb.stickChance)
|
||||
{
|
||||
if (sitemDropProb.name.Equals("[recipe]"))
|
||||
{
|
||||
List<Recipe> recipes = CraftingManager.GetRecipes(_blockValue.Block.GetBlockName());
|
||||
if (recipes.Count > 0)
|
||||
{
|
||||
for (int j = 0; j < recipes[0].ingredients.Count; j++)
|
||||
{
|
||||
if (recipes[0].ingredients[j].count / 2 > 0)
|
||||
{
|
||||
ItemStack item = new ItemStack(recipes[0].ingredients[j].itemValue, recipes[0].ingredients[j].count / 2);
|
||||
this.itemsDropped.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemValue itemValue2 = sitemDropProb.name.Equals("*") ? _blockValue.ToItemValue() : new ItemValue(ItemClass.GetItem(sitemDropProb.name, false).type, false);
|
||||
if (!itemValue2.IsEmpty() && sitemDropProb.prob > gameRandom.RandomFloat)
|
||||
{
|
||||
this.itemsDropped.Add(new ItemStack(itemValue2, num));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_overallProb >= 0.999f || gameRandom.RandomFloat < _overallProb)
|
||||
{
|
||||
BlockValue blockValue = Block.GetBlockValue(sitemDropProb.name, false);
|
||||
Vector3i vector3i = World.worldToBlockPos(_dropPos);
|
||||
if (!blockValue.isair && _world.GetBlock(vector3i).isair)
|
||||
{
|
||||
_world.SetBlockRPC(vector3i, blockValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int k = 0; k < this.itemsDropped.Count; k++)
|
||||
{
|
||||
if (_overallProb >= 0.999f || gameRandom.RandomFloat < _overallProb)
|
||||
{
|
||||
ItemClass itemClass = this.itemsDropped[k].itemValue.ItemClass;
|
||||
_lifetime = ((_lifetime > 0.001f) ? _lifetime : ((itemClass != null) ? itemClass.GetLifetimeOnDrop() : 0f));
|
||||
if (_lifetime > 0.001f)
|
||||
{
|
||||
_world.GetGameManager().ItemDropServer(this.itemsDropped[k], _dropPos, _randomPosAdd, _entityId, _lifetime, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BlockModelTreeRebirth()
|
||||
{
|
||||
this.fertileLevel = 1;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
if (this.Properties.Values.ContainsKey("UpwardsCount"))
|
||||
{
|
||||
this.upwardsCount = int.Parse(this.Properties.Values["UpwardsCount"]);
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("FallOver"))
|
||||
{
|
||||
this.bFallOver = StringParsers.ParseBool(this.Properties.Values["FallOver"], 0, -1, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.bFallOver = true;
|
||||
}
|
||||
this.IsTerrainDecoration = true;
|
||||
this.CanDecorateOnSlopes = true;
|
||||
this.CanPlayersSpawnOn = false;
|
||||
this.CanMobsSpawnOn = false;
|
||||
}
|
||||
|
||||
public override bool UpdateTick(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bRandomTick, ulong _ticksIfLoaded, GameRandom _rnd)
|
||||
{
|
||||
return !_blockValue.ischild && base.UpdateTick(_world, _clrIdx, _blockPos, _blockValue, _bRandomTick, _ticksIfLoaded, _rnd);
|
||||
}
|
||||
|
||||
public override void OnNeighborBlockChange(WorldBase _world, int _clrIdx, Vector3i _myBlockPos, BlockValue _myBlockValue, Vector3i _blockPosThatChanged, BlockValue _newNeighborBlockValue, BlockValue _oldNeighborBlockValue)
|
||||
{
|
||||
|
||||
////Log.Out("BlockModelTreeRebirth-OnNeighborBlockChange START");
|
||||
|
||||
if (!_myBlockValue.ischild)
|
||||
{
|
||||
base.OnNeighborBlockChange(_world, _clrIdx, _myBlockPos, _myBlockValue, _blockPosThatChanged, _newNeighborBlockValue, _oldNeighborBlockValue);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnBlockValueChanged(WorldBase _world, Chunk _chunk, int _clrIdx, Vector3i _blockPos, BlockValue _oldBlockValue, BlockValue _newBlockValue)
|
||||
{
|
||||
|
||||
////Log.Out("BlockModelTreeRebirth-OnBlockValueChanged START");
|
||||
|
||||
if (!_newBlockValue.ischild)
|
||||
{
|
||||
base.OnBlockValueChanged(_world, _chunk, _clrIdx, _blockPos, _oldBlockValue, _newBlockValue);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CheckPlantAlive(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
return this.isPlantGrowingRandom || _world.IsRemote() || base.CheckPlantAlive(_world, _clrIdx, _blockPos, _blockValue);
|
||||
}
|
||||
|
||||
public override bool CanPlaceBlockAt(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bOmitCollideCheck = false)
|
||||
{
|
||||
|
||||
//Log.Out("BlockModelTreeRebirth-CanPlaceBlockAt START");
|
||||
|
||||
if (!base.CanPlaceBlockAt(_world, _clrIdx, _blockPos, _blockValue, _bOmitCollideCheck))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int i = _blockPos.x - 3; i <= _blockPos.x + 3; i++)
|
||||
{
|
||||
for (int j = _blockPos.z - 3; j <= _blockPos.z + 3; j++)
|
||||
{
|
||||
for (int k = _blockPos.y - 6; k <= _blockPos.y + 6; k++)
|
||||
{
|
||||
if (_world.GetBlock(_clrIdx, new Vector3i(i, k, j)).Block is BlockModelTreeRebirth)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnBlockRemoved(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockModelTreeRebirth-OnBlockRemoved START");
|
||||
if (!_blockValue.ischild)
|
||||
{
|
||||
this.shape.OnBlockRemoved(_world, _chunk, _blockPos, _blockValue);
|
||||
if (this.isMultiBlock)
|
||||
{
|
||||
this.multiBlockPos.RemoveChilds(_world, _blockPos, _blockValue);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (this.isMultiBlock)
|
||||
{
|
||||
this.multiBlockPos.RemoveParentBlock(_world, _blockPos, _blockValue);
|
||||
}
|
||||
this.removeAllTrunks(_world, _chunk, _blockPos, _blockValue, -1, false);
|
||||
}
|
||||
|
||||
private void removeAllTrunks(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue, int _entityid, bool _bDropItemsAndStartParticle)
|
||||
{
|
||||
//Log.Out("BlockModelTreeRebirth-removeAllTrunks START");
|
||||
|
||||
if (_chunk == null)
|
||||
{
|
||||
//Log.Out("BlockModelTreeRebirth-removeAllTrunks 1");
|
||||
_chunk = (Chunk)_world.GetChunkFromWorldPos(_blockPos);
|
||||
}
|
||||
if (_chunk == null)
|
||||
{
|
||||
//Log.Out("BlockModelTreeRebirth-removeAllTrunks 2");
|
||||
return;
|
||||
}
|
||||
if (_bDropItemsAndStartParticle)
|
||||
{
|
||||
//Log.Out("BlockModelTreeRebirth-removeAllTrunks 3");
|
||||
this.dropItems(_world, _blockPos, _blockValue, _entityid);
|
||||
float lightBrightness = _world.GetLightBrightness(_blockPos);
|
||||
this.SpawnDestroyParticleEffect(_world, _blockValue, _blockPos, lightBrightness, base.GetColorForSide(_blockValue, BlockFace.Top), _entityid);
|
||||
}
|
||||
}
|
||||
|
||||
private void dropItems(WorldBase _world, Vector3i _blockPos, BlockValue _blockValue, int _entityId)
|
||||
{
|
||||
//Log.Out("BlockModelTreeRebirth-dropItems START");
|
||||
|
||||
DropItemsOnEvent2(_world, _blockValue, EnumDropEvent.Destroy, 1f, World.blockToTransformPos(_blockPos), new Vector3(0.5f, 0f, 0.5f), 0f, _entityId, true);
|
||||
}
|
||||
|
||||
public override Block.DestroyedResult OnBlockDestroyedByExplosion(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, int _playerThatStartedExpl)
|
||||
{
|
||||
|
||||
//Log.Out("BlockModelTreeRebirth-OnBlockDestroyedByExplosion START");
|
||||
|
||||
this.startToFall(_world, _clrIdx, _blockPos, _blockValue, -1);
|
||||
return Block.DestroyedResult.Keep;
|
||||
}
|
||||
|
||||
public override void OnBlockStartsToFall(WorldBase _world, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockModelTreeRebirth-OnBlockStartsToFall START");
|
||||
|
||||
if (_blockValue.ischild)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this.OnBlockDestroyedBy(_world, 0, _blockPos, _blockValue, -1, false) != Block.DestroyedResult.Keep)
|
||||
{
|
||||
base.OnBlockStartsToFall(_world, _blockPos, _blockValue);
|
||||
return;
|
||||
}
|
||||
float lightBrightness = _world.GetLightBrightness(_blockPos);
|
||||
this.SpawnDestroyParticleEffect(_world, _blockValue, _blockPos, lightBrightness, base.GetColorForSide(_blockValue, BlockFace.Top), -1);
|
||||
}
|
||||
|
||||
public override void SpawnDestroyParticleEffect(WorldBase _world, BlockValue _blockValue, Vector3i _blockPos, float _lightValue, Color _color, int _entityIdThatCaused)
|
||||
{
|
||||
//Log.Out("BlockModelTreeRebirth-SpawnDestroyParticleEffect START");
|
||||
|
||||
base.SpawnDestroyParticleEffect(_world, _blockValue, _blockPos, _lightValue, _color, _entityIdThatCaused);
|
||||
_world.GetGameManager().PlaySoundAtPositionServer(_blockPos.ToVector3(), "trunkbreak", 0, 100);
|
||||
}
|
||||
|
||||
public override bool ShowModelOnFall()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override BlockValue OnBlockPlaced(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, GameRandom _rnd)
|
||||
{
|
||||
//Log.Out("BlockModelTreeRebirth-OnBlockPlaced START");
|
||||
|
||||
_blockValue.rotation = BiomeBlockDecoration.GetRandomRotation(_rnd.RandomFloat, 7);
|
||||
return _blockValue;
|
||||
}
|
||||
|
||||
public override Block.DestroyedResult OnBlockDestroyedBy(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, int _entityId, bool _bUseHarvestTool)
|
||||
{
|
||||
bool downgradeBlock = RebirthVariables.customReplantTrees;
|
||||
|
||||
if (!this.bFallOver && downgradeBlock)
|
||||
{
|
||||
//Log.Out("OnBlockDestroyedBy 2");
|
||||
return Block.DestroyedResult.Downgrade;
|
||||
}
|
||||
if (!this.startToFall(_world, _clrIdx, _blockPos, _blockValue, _entityId) && downgradeBlock)
|
||||
{
|
||||
//Log.Out("OnBlockDestroyedBy 3");
|
||||
return Block.DestroyedResult.Downgrade;
|
||||
}
|
||||
|
||||
//Log.Out("OnBlockDestroyedBy 4");
|
||||
return Block.DestroyedResult.Keep;
|
||||
}
|
||||
|
||||
private bool startToFall(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, int _entityId)
|
||||
{
|
||||
//Log.Out("BlockModelTreeRebirth-startToFall START");
|
||||
|
||||
Transform transform;
|
||||
if (!DecoManager.Instance.IsEnabled || !_blockValue.Block.IsDistantDecoration)
|
||||
{
|
||||
BlockEntityData blockEntity = ((Chunk)_world.GetChunkFromWorldPos(_blockPos)).GetBlockEntity(_blockPos);
|
||||
if (blockEntity == null || !blockEntity.bHasTransform)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
transform = blockEntity.transform;
|
||||
}
|
||||
else
|
||||
{
|
||||
transform = DecoManager.Instance.GetDecorationTransform(_blockPos, false);
|
||||
}
|
||||
if (transform == null)
|
||||
{
|
||||
_world.SetBlockRPC(_blockPos, BlockValue.Air);
|
||||
return false;
|
||||
}
|
||||
_blockValue.damage = _blockValue.Block.MaxDamage;
|
||||
_world.SetBlocksRPC(new List<BlockChangeInfo>
|
||||
{
|
||||
new BlockChangeInfo(_blockPos, _blockValue, false, true)
|
||||
});
|
||||
Entity entity = _world.GetEntity(_entityId);
|
||||
EntityCreationData entityCreationData = new EntityCreationData();
|
||||
entityCreationData.entityClass = "fallingTree".GetHashCode();
|
||||
entityCreationData.blockPos = _blockPos;
|
||||
entityCreationData.fallTreeDir = ((entity != null) ? (transform.position + Origin.position - entity.GetPosition()) : new Vector3(_world.GetGameRandom().RandomFloat, 0f, _world.GetGameRandom().RandomFloat));
|
||||
entityCreationData.fallTreeDir.y = 0f;
|
||||
entityCreationData.fallTreeDir = entityCreationData.fallTreeDir.normalized;
|
||||
entityCreationData.pos = transform.position + Origin.position;
|
||||
entityCreationData.rot = transform.rotation.eulerAngles;
|
||||
entityCreationData.id = -1;
|
||||
_world.GetGameManager().RequestToSpawnEntityServer(entityCreationData);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool IsExplosionAffected()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private int upwardsCount;
|
||||
private bool bFallOver;
|
||||
}
|
||||
986
Scripts/Blocks/BlockPlantGrowingRebirth.cs
Normal file
986
Scripts/Blocks/BlockPlantGrowingRebirth.cs
Normal file
@@ -0,0 +1,986 @@
|
||||
using System.Globalization;
|
||||
|
||||
public class BlockPlantGrowingRebirth : BlockPlant
|
||||
{
|
||||
protected float nextStageRate;
|
||||
public string nextStage;
|
||||
public ulong TickRate = 100UL;
|
||||
//public System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
|
||||
protected int lightLevelGrow = 3;
|
||||
protected static string PropGrowingFertileLevel = "PlantGrowing.FertileLevel";
|
||||
protected static string PropGrowingLightLevelStay = "PlantGrowing.LightLevelStay";
|
||||
protected static string PropGrowingLightLevelGrow = "PlantGrowing.LightLevelGrow";
|
||||
public byte sunLight = 0;
|
||||
public byte blockLight = 0;
|
||||
public int minTemp = 45;
|
||||
|
||||
public override bool HasBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-HasBlockActivationCommands START");
|
||||
bool flag = _world.GetTileEntity(_clrIdx, _blockPos) is TileEntityPlantGrowingRebirth;
|
||||
bool flag2 = this.CanPickup;
|
||||
if (EffectManager.GetValue(PassiveEffects.BlockPickup, null, 0f, _entityFocusing, null, _blockValue.Block.Tags, true, true, true, true, true, 1, false) > 0f)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-HasBlockActivationCommands 1");
|
||||
flag2 = true;
|
||||
}
|
||||
return flag2 || flag;
|
||||
}
|
||||
|
||||
private BlockActivationCommand[] cmds = new BlockActivationCommand[]
|
||||
{
|
||||
new BlockActivationCommand("Search", "search", true, false)
|
||||
};
|
||||
|
||||
public override void OnBlockLoaded(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
base.OnBlockLoaded(_world, _clrIdx, _blockPos, _blockValue);
|
||||
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(_blockPos);
|
||||
_world.GetWBT().AddScheduledBlockUpdate(chunk.ClrIdx, _blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
}
|
||||
|
||||
public override void LateInit()
|
||||
{
|
||||
base.LateInit();
|
||||
if (this.Properties.Values.ContainsKey(PropGrowingFertileLevel))
|
||||
{
|
||||
this.fertileLevel = int.Parse(this.Properties.Values[PropGrowingFertileLevel]);
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey(PropGrowingLightLevelStay))
|
||||
{
|
||||
this.lightLevelStay = int.Parse(this.Properties.Values[PropGrowingLightLevelStay]);
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey(PropGrowingLightLevelGrow))
|
||||
{
|
||||
this.lightLevelGrow = int.Parse(this.Properties.Values[PropGrowingLightLevelGrow]);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanGrowOn(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValueOfPlant)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanGrowOn START");
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanGrowOn fertileLevel: " + fertileLevel);
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanGrowOn block fertile level: " + _world.GetBlock(_clrIdx, _blockPos).Block.blockMaterial.FertileLevel);
|
||||
|
||||
bool bFertileLevel = this.fertileLevel == 0;
|
||||
bool bFertileLevel2 = _world.GetBlock(_clrIdx, _blockPos).Block.blockMaterial.FertileLevel >= this.fertileLevel;
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanGrowOn bFertileLevel: " + bFertileLevel);
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanGrowOn bFertileLevel2: " + bFertileLevel2);
|
||||
|
||||
return bFertileLevel || bFertileLevel2;
|
||||
}
|
||||
|
||||
public override bool CanPlaceBlockAt(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bOmitCollideCheck = false)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt START");
|
||||
if (GameManager.Instance.IsEditMode())
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt 1");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool bCanPlaceBlock = base.CanPlaceBlockAt(_world, _clrIdx, _blockPos, _blockValue, _bOmitCollideCheck);
|
||||
bool bCanGrow = this.CanGrowOn(_world, _clrIdx, _blockPos - Vector3i.up, _blockValue);
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt bCanPlaceBlock: " + bCanPlaceBlock);
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt bCanGrow: " + bCanGrow);
|
||||
|
||||
if (!(bCanPlaceBlock && bCanGrow))
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt 2");
|
||||
return false;
|
||||
}
|
||||
Vector3i blockPos = _blockPos + Vector3i.up;
|
||||
ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx];
|
||||
if (chunkCluster != null)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt 3");
|
||||
byte light = chunkCluster.GetLight(blockPos, Chunk.LIGHT_TYPE.SUN);
|
||||
byte light2 = chunkCluster.GetLight(blockPos, Chunk.LIGHT_TYPE.BLOCK);
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt light: " + light);
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt light2: " + light2);
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt this.lightLevelStay: " + this.lightLevelStay);
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt this.lightLevelGrow: " + this.lightLevelGrow);
|
||||
|
||||
if ((int)light < this.lightLevelStay || (int)light < this.lightLevelGrow)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt 4");
|
||||
if ((int)light2 < this.lightLevelStay || (int)light2 < this.lightLevelGrow)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt 5");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual void addTileEntity(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
TileEntityPlantGrowingRebirth tileEntityPlantGrowing = new TileEntityPlantGrowingRebirth(_chunk);
|
||||
tileEntityPlantGrowing.localChunkPos = World.toBlock(_blockPos);
|
||||
_chunk.AddTileEntity(tileEntityPlantGrowing);
|
||||
}
|
||||
|
||||
protected virtual void removeTileEntity(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-removeTileEntity START");
|
||||
_chunk.RemoveTileEntityAt<TileEntityPlantGrowingRebirth>((World)world, World.toBlock(_blockPos));
|
||||
}
|
||||
|
||||
public override void OnBlockRemoved(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-OnBlockRemoved START, BLOCK: " + _blockValue.Block.GetBlockName());
|
||||
base.OnBlockRemoved(world, _chunk, _blockPos, _blockValue);
|
||||
TileEntityPlantGrowingRebirth tileEntityPlantGrowing = world.GetTileEntity(_chunk.ClrIdx, _blockPos) as TileEntityPlantGrowingRebirth;
|
||||
if (tileEntityPlantGrowing != null)
|
||||
{
|
||||
tileEntityPlantGrowing.OnDestroy();
|
||||
}
|
||||
this.removeTileEntity(world, _chunk, _blockPos, _blockValue);
|
||||
}
|
||||
|
||||
public override void OnBlockAdded(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-OnBlockAdded START, BLOCK: " + _blockValue.Block.GetBlockName());
|
||||
base.OnBlockAdded(_world, _chunk, _blockPos, _blockValue);
|
||||
this.addTileEntity(_world, _chunk, _blockPos, _blockValue);
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer) return;
|
||||
if (GameManager.Instance.IsEditMode()) return;
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-OnBlockAdded 1");
|
||||
|
||||
_blockValue.meta = 0;
|
||||
|
||||
//Log.Out("============================ON BLOCK ADDED=================================");
|
||||
//Log.Out("BlockPlantGrowingRebirth-OnBlockAdded MY POSITION: " + _blockPos);
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-OnBlockAdded this.GetTickRate(): " + this.GetTickRate());
|
||||
//watch.Reset();
|
||||
//watch.Start();
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_chunk.ClrIdx, _blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
|
||||
public override bool UpdateTick(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bRandomTick, ulong _ticksIfLoaded, GameRandom _rnd)
|
||||
{
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick START, _blockPos: " + _blockPos + " / BLOCK: " + _blockValue.Block.GetBlockName());
|
||||
|
||||
ulong GameTimerTicks = 0UL;
|
||||
ulong TotalTimerTicks = 0UL;
|
||||
ulong CurrentTimerTicks = 0UL;
|
||||
ulong TicksOverThreshold = 0UL;
|
||||
ulong CurrentStageRate = this.GetTickRate();
|
||||
|
||||
TileEntityPlantGrowingRebirth tileEntityPlantGrowing = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityPlantGrowingRebirth;
|
||||
|
||||
//watch.Stop();
|
||||
|
||||
bool advancedFarming = RebirthVariables.customAdvancedFarming;
|
||||
int cropGrowthTime = RebirthVariables.customAdvancedFarmingTime * 60;
|
||||
|
||||
if (RebirthVariables.testCropGrowth)
|
||||
{
|
||||
cropGrowthTime = 1;
|
||||
}
|
||||
|
||||
bool bflag = false;
|
||||
|
||||
string currentBiome = "";
|
||||
|
||||
BiomeDefinition biome = GameManager.Instance.World.GetBiome(_blockPos.x, _blockPos.z);
|
||||
if (biome != null)
|
||||
{
|
||||
currentBiome = biome.m_sBiomeName;
|
||||
}
|
||||
|
||||
if (currentBiome == "wasteland")
|
||||
{
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, this.TickRate);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick sBiomeName: " + currentBiome);
|
||||
|
||||
if (tileEntityPlantGrowing != null)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1");
|
||||
tileEntityPlantGrowing.bUpdating = false;
|
||||
GameTimerTicks = tileEntityPlantGrowing.GameTimerTicks;
|
||||
tileEntityPlantGrowing.GameTimerTicks = GameTimer.Instance.ticks;
|
||||
TotalTimerTicks = GameTimer.Instance.ticks;
|
||||
CurrentTimerTicks = TotalTimerTicks - GameTimerTicks;
|
||||
|
||||
bool bHasSunLight = true;
|
||||
bool bHasBlockLight = true;
|
||||
|
||||
Vector3i blockPos = _blockPos + Vector3i.up;
|
||||
ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx];
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(_blockPos);
|
||||
|
||||
if (chunkCluster != null && advancedFarming)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1a");
|
||||
byte light = chunkCluster.GetLight(blockPos, Chunk.LIGHT_TYPE.SUN);
|
||||
byte light2 = chunkCluster.GetLight(blockPos, Chunk.LIGHT_TYPE.BLOCK);
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick sun light: " + light);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick block light: " + light2);
|
||||
|
||||
if ((int)light < this.lightLevelStay || (int)light < this.lightLevelGrow)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1b");
|
||||
bHasSunLight = false;
|
||||
}
|
||||
if ((int)light2 < this.lightLevelStay || (int)light2 < this.lightLevelGrow)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1c");
|
||||
bHasBlockLight = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool bIsNight = false;
|
||||
if (!GameManager.Instance.World.IsDaytime())
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1d");
|
||||
bIsNight = true;
|
||||
}
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip() && RebirthUtilities.IsHiveDayActive())
|
||||
{
|
||||
bHasSunLight = false;
|
||||
bIsNight = true;
|
||||
}
|
||||
|
||||
float num = WeatherManager.Instance.GetCurrentTemperatureValue();
|
||||
float numClouds = 0;
|
||||
float numRain = 0;
|
||||
|
||||
if (num == 0)
|
||||
{
|
||||
num = RebirthUtilities.GetWeatherInfo(_blockPos, "temp");
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick numTemp: " + num);
|
||||
numClouds = RebirthUtilities.GetWeatherInfo(_blockPos, "clouds") / 10;
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick numClouds: " + numClouds);
|
||||
numRain = RebirthUtilities.GetWeatherInfo(_blockPos, "wet") * 10;
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick numRain: " + numRain);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick LOCAL numTemp: " + num);
|
||||
numRain = 10 * WeatherManager.Instance.GetCurrentRainfallValue();
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick LOCAL numRain: " + numRain);
|
||||
numClouds = 10 * WeatherManager.Instance.GetCurrentCloudThicknessPercent();
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick LOCAL numClouds: " + numClouds);
|
||||
}
|
||||
|
||||
num = num - (numRain + numClouds);
|
||||
|
||||
//bool hasHeat = RebirthUtilities.CheckForHeat(_world, _clrIdx, _blockPos, "campfire", 6, 3, 1);
|
||||
//bool hasHeat2 = RebirthUtilities.CheckForHeat(_world, _clrIdx, _blockPos, "cntWoodBurningStove_PickedUp", 10, 5, 1);
|
||||
bool hasHeat = RebirthUtilities.CheckForHeat(_blockPos, 6, "12", "campfire");
|
||||
bool hasHeat2 = RebirthUtilities.CheckForHeat(_blockPos, 10, "12", "cntWoodBurningStove_PickedUp");
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick hasHeat: " + hasHeat);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick hasHeat2: " + hasHeat2);
|
||||
|
||||
if (hasHeat)
|
||||
{
|
||||
num = num + 30;
|
||||
}
|
||||
else if (hasHeat2)
|
||||
|
||||
{
|
||||
num = num + 50;
|
||||
}
|
||||
|
||||
if (!bHasSunLight)
|
||||
{
|
||||
if (currentBiome == "pine_forest")
|
||||
{
|
||||
if (bIsNight)
|
||||
{
|
||||
num = num + 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = num - 5;
|
||||
}
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick pine_forest Temperature: " + num);
|
||||
}
|
||||
if (currentBiome == "desert")
|
||||
{
|
||||
if (bIsNight)
|
||||
{
|
||||
num = num - 20;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = num - 10;
|
||||
}
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick desert Temperature: " + num);
|
||||
}
|
||||
if (currentBiome == "snow")
|
||||
{
|
||||
if (bIsNight)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
num = num + 10;
|
||||
}
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick snow Temperature: " + num);
|
||||
}
|
||||
if (currentBiome == "wasteland")
|
||||
{
|
||||
if (bIsNight)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
num = num + 5;
|
||||
}
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick wasteland Temperature: " + num);
|
||||
}
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick Is Inside Temperature: " + num);
|
||||
}
|
||||
|
||||
if (num < minTemp && advancedFarming)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1e num: " + num);
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, this.TickRate);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!tileEntityPlantGrowing.bWatered && advancedFarming)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1f");
|
||||
|
||||
//int hasWaterInTank = RebirthUtilities.CheckForWater(_world, _clrIdx, _blockPos, "FuriousRamsayWaterTank", 4, 1, 0);
|
||||
//int hasWaterInCollector = RebirthUtilities.CheckForWater(_world, _clrIdx, _blockPos, "FuriousRamsayDewCollector", 4, 1, 0);
|
||||
|
||||
int hasWaterInTank = RebirthUtilities.CheckForWater(_blockPos, 4, "250", "FuriousRamsayWaterTank");
|
||||
int hasWaterInCollector = RebirthUtilities.CheckForWater(_blockPos, 4, "250", "FuriousRamsayDewCollector");
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick hasWaterInTank: " + hasWaterInTank);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick hasWaterInCollector: " + hasWaterInCollector);
|
||||
|
||||
int depletion = 1;
|
||||
|
||||
bool isHeatResistant = false;
|
||||
string plantName = _blockValue.Block.GetBlockName();
|
||||
|
||||
if (plantName.ToLower().Contains("yucca") ||
|
||||
plantName.ToLower().Contains("cotton") ||
|
||||
plantName.ToLower().Contains("coffee") ||
|
||||
plantName.ToLower().Contains("aloe")
|
||||
)
|
||||
{
|
||||
isHeatResistant = true;
|
||||
}
|
||||
|
||||
if (num >= 80 && !isHeatResistant)
|
||||
{
|
||||
depletion = depletion * 2;
|
||||
}
|
||||
|
||||
Vector3i farmPlotPos = _blockPos;
|
||||
farmPlotPos.y = farmPlotPos.y - 1;
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick X farmPlotPos: " + farmPlotPos);
|
||||
|
||||
BlockValue blockFarmPlot = _world.GetBlock(_clrIdx, farmPlotPos);
|
||||
|
||||
TileEntity tileEntity = _world.GetTileEntity(_clrIdx, farmPlotPos);
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick X tileEntity: " + tileEntity.GetTileEntityType());
|
||||
}
|
||||
|
||||
TileEntityFarmPlotRebirth tileEntityFarmPlotRebirth;
|
||||
if (tileEntity is TileEntityFarmPlotRebirth)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1g");
|
||||
tileEntityFarmPlotRebirth = (TileEntityFarmPlotRebirth)tileEntity;
|
||||
|
||||
if (tileEntityFarmPlotRebirth.waterCount >= depletion)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick deplete from farm plot");
|
||||
tileEntityFarmPlotRebirth.waterCount = tileEntityFarmPlotRebirth.waterCount - depletion;
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage((NetPackage)NetPackageManager.GetPackage<NetPackageUpdateFarmPlotRebirth>().Setup(_clrIdx, farmPlotPos, tileEntityFarmPlotRebirth.waterCount));
|
||||
depletion = 0;
|
||||
tileEntityPlantGrowing.bWatered = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!tileEntityPlantGrowing.bWatered)
|
||||
{
|
||||
if (hasWaterInCollector >= depletion)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1h");
|
||||
RebirthUtilities.DepleteWater(_world, _clrIdx, _blockPos, "FuriousRamsayDewCollector", 4, 1, 0, depletion);
|
||||
tileEntityPlantGrowing.bWatered = true;
|
||||
}
|
||||
if (hasWaterInTank >= depletion)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1h");
|
||||
RebirthUtilities.DepleteWater(_world, _clrIdx, _blockPos, "FuriousRamsayWaterTank", 4, 1, 0, depletion);
|
||||
tileEntityPlantGrowing.bWatered = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1i");
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, this.TickRate);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1j");
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick GameTimerTicks: " + GameTimerTicks);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick GameTimer.Instance.ticks: " + GameTimer.Instance.ticks);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick CurrentTimerTicks: " + CurrentTimerTicks);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick this.TickRate: " + this.TickRate);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick this.GetTickRate(): " + CurrentStageRate);
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick bHasSunLight: " + bHasSunLight);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick bHasBlockLight: " + bHasBlockLight);
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1k");
|
||||
|
||||
if (_blockValue.Block.GetBlockName().ToLower().Contains("mushroom"))
|
||||
{
|
||||
bHasBlockLight = true;
|
||||
}
|
||||
|
||||
if ((((bHasSunLight && !bIsNight) || bHasBlockLight) && advancedFarming) || !advancedFarming)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1l");
|
||||
bool hasObserverTank = RebirthUtilities.HasObserver(_world, _clrIdx, _blockPos, "FuriousRamsayWaterTank", 4, 1, 0);
|
||||
bool hasObserverCollector = RebirthUtilities.HasObserver(_world, _clrIdx, _blockPos, "FuriousRamsayDewCollector", 4, 1, 0);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick hasObserverTank: " + hasObserverTank);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick hasObserverCollector: " + hasObserverCollector);
|
||||
|
||||
if (hasObserverTank || hasObserverCollector)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1m");
|
||||
tileEntityPlantGrowing.AccumulatedTicks = tileEntityPlantGrowing.AccumulatedTicks + this.TickRate;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1n");
|
||||
tileEntityPlantGrowing.AccumulatedTicks = tileEntityPlantGrowing.AccumulatedTicks + CurrentTimerTicks;
|
||||
}
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageUpdatePlantedCropRebirth>().Setup(_clrIdx, _blockPos, _blockValue.Block.blockID, tileEntityPlantGrowing.AccumulatedTicks), false, -1, -1, -1, null, 192);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick AccumulatedTicks A: " + tileEntityPlantGrowing.AccumulatedTicks);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1o");
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, this.TickRate);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tileEntityPlantGrowing.AccumulatedTicks > CurrentStageRate)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1p");
|
||||
TicksOverThreshold = tileEntityPlantGrowing.AccumulatedTicks - CurrentStageRate;
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick TicksOverThreshold: " + TicksOverThreshold);
|
||||
}
|
||||
|
||||
if (tileEntityPlantGrowing.AccumulatedTicks >= CurrentStageRate)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 2");
|
||||
bflag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 3");
|
||||
bflag = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick tileEntityPlantGrowing == null");
|
||||
}
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick bflag: " + bflag);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick this.nextStage: " + this.nextStage);
|
||||
|
||||
if (bflag && this.nextStage != "")
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 4");
|
||||
BlockValue blockValue = Block.GetBlockValue(this.nextStage, true);
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick GetBlockName: " + blockValue.Block.GetBlockName());
|
||||
|
||||
string strNextStageRate = blockValue.Block.Properties.Values["NextStageRate"];
|
||||
string strNextStage = blockValue.Block.Properties.Values["NextStage"];
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick strNextStageRate: " + strNextStageRate);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick strNextStage: " + strNextStage);
|
||||
|
||||
if (!blockValue.Block.GetBlockName().Contains("3"))
|
||||
{
|
||||
float flNextStageRate = StringParsers.ParseFloat(strNextStageRate, 0, -1, NumberStyles.Any);
|
||||
|
||||
if (advancedFarming)
|
||||
{
|
||||
flNextStageRate = cropGrowthTime;
|
||||
}
|
||||
|
||||
if (tileEntityPlantGrowing.AccumulatedTicks >= (flNextStageRate * 20) + CurrentStageRate)
|
||||
{
|
||||
blockValue = Block.GetBlockValue(blockValue.Block.Properties.Values["NextStage"], true);
|
||||
}
|
||||
}
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(_blockPos);
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, _blockPos.x, _blockPos.y, _blockPos.z, FastTags<TagGroup.Global>.none, false);
|
||||
blockValue.meta = _blockValue.meta;
|
||||
blockValue.damage = _blockValue.damage;
|
||||
blockValue.meta2 = 0;
|
||||
_blockValue = blockValue;
|
||||
|
||||
_blockValue.meta = (byte)(_blockValue.meta + 1 & 15);
|
||||
_blockValue = _blockValue.Block.OnBlockPlaced(_world, _clrIdx, _blockPos, _blockValue, _rnd);
|
||||
|
||||
Block block3 = blockValue.Block;
|
||||
|
||||
_world.SetBlockRPC(_clrIdx, _blockPos, blockValue);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(_blockPos, -1, _blockValue.type);
|
||||
|
||||
tileEntityPlantGrowing = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityPlantGrowingRebirth;
|
||||
|
||||
if (tileEntityPlantGrowing != null)
|
||||
{
|
||||
if (TicksOverThreshold > 0)
|
||||
{
|
||||
tileEntityPlantGrowing.AccumulatedTicks = TicksOverThreshold;
|
||||
}
|
||||
else
|
||||
{
|
||||
tileEntityPlantGrowing.AccumulatedTicks = 0;
|
||||
}
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick AccumulatedTicks B: " + tileEntityPlantGrowing.AccumulatedTicks);
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageUpdatePlantedCropRebirth>().Setup(_clrIdx, _blockPos, _blockValue.Block.blockID, tileEntityPlantGrowing.AccumulatedTicks), false, -1, -1, -1, null, 192);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//watch.Reset();
|
||||
//watch.Start();
|
||||
|
||||
if (tileEntityPlantGrowing != null)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 5");
|
||||
|
||||
if (tileEntityPlantGrowing.AccumulatedTicks <= CurrentStageRate)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 6");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 7");
|
||||
tileEntityPlantGrowing.AccumulatedTicks = 0UL;
|
||||
}
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageUpdatePlantedCropRebirth>().Setup(_clrIdx, _blockPos, _blockValue.Block.blockID, tileEntityPlantGrowing.AccumulatedTicks), false, -1, -1, -1, null, 192); ;
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick tileEntityPlantGrowing.AccumulatedTicks C: " + tileEntityPlantGrowing.AccumulatedTicks);
|
||||
}
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 8 ADD SCHEDULED BLOCK UPDATE");
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick END");
|
||||
return true;
|
||||
}
|
||||
|
||||
public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText START");
|
||||
string activationText = Localization.Get("ttGatherNothing");
|
||||
|
||||
bool advancedFarming = RebirthVariables.customAdvancedFarming;
|
||||
|
||||
string myEntityName = "";
|
||||
string key = this.GetBlockName();
|
||||
string blockLocalization = Localization.Get(key);
|
||||
|
||||
|
||||
if (key.Contains("1"))
|
||||
{
|
||||
blockLocalization = string.Format(Localization.Get("pickupPrompt"), Localization.Get(key));
|
||||
}
|
||||
|
||||
//Log.Out("=========================GET ACTIVATION TEXT==============================");
|
||||
//Log.Out("key: " + key + "(" + blockLocalization + ")");
|
||||
|
||||
TileEntityPlantGrowingRebirth tileEntityPlantGrowing = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityPlantGrowingRebirth;
|
||||
bool canShowCycleTime = true;
|
||||
ulong GameTimerTicks = 0UL;
|
||||
ulong TotalTimerTicks = 0UL;
|
||||
ulong CurrentTimerTicks = 0UL;
|
||||
float TempTimerTicks = 0;
|
||||
ulong CurrentStageRate = this.GetTickRate();
|
||||
|
||||
if (tileEntityPlantGrowing == null)
|
||||
{
|
||||
canShowCycleTime = false;
|
||||
//Log.Out("=========================NO TILE ENTITY==============================");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 1");
|
||||
GameTimerTicks = tileEntityPlantGrowing.GameTimerTicks;
|
||||
TotalTimerTicks = GameTimer.Instance.ticks;
|
||||
CurrentTimerTicks = TotalTimerTicks - GameTimerTicks;
|
||||
|
||||
if (tileEntityPlantGrowing.AccumulatedTicks <= CurrentStageRate)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 2");
|
||||
TempTimerTicks = (CurrentStageRate - tileEntityPlantGrowing.AccumulatedTicks) / 1200;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 3");
|
||||
TempTimerTicks = -1;
|
||||
}
|
||||
|
||||
//Log.Out("GameTimerTicks: " + GameTimerTicks);
|
||||
//Log.Out("GameTimer.Instance.ticks: " + TotalTimerTicks);
|
||||
//Log.Out("CurrentTimerTicks = GameTimer.Instance.ticks - GameTimerTicks: " + CurrentTimerTicks);
|
||||
//Log.Out("this.GetTickRate(): " + CurrentStageRate);
|
||||
//Log.Out("TempTimerTicks = (this.GetTickRate() - CurrentTimerTicks)/1200: " + TempTimerTicks);
|
||||
//Log.Out("tileEntityPlantGrowing.AccumulatedTicks: " + tileEntityPlantGrowing.AccumulatedTicks);
|
||||
}
|
||||
|
||||
if (key.Contains("3"))
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 4");
|
||||
activationText = Localization.Get(key.Replace("Player", "") + "Desc");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 5");
|
||||
string timerText = "";
|
||||
|
||||
if (TempTimerTicks > 1)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 6");
|
||||
timerText = " " + (int)TempTimerTicks + "[-] " + Localization.Get("ttMinutes") + "";
|
||||
}
|
||||
else if (TempTimerTicks == 1)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 7");
|
||||
timerText = " " + (int)TempTimerTicks + "[-] " + Localization.Get("ttMinute") + "";
|
||||
}
|
||||
else if (TempTimerTicks == 0)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 8");
|
||||
//timerText = " less than 1[-] " + Localization.Get("ttMinute") + "";
|
||||
}
|
||||
else if (TempTimerTicks < 0)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 9 RELAUNCHING UPDATE TICK");
|
||||
timerText = " " + Localization.Get("ttCalculating");
|
||||
}
|
||||
ulong seconds = ((CurrentStageRate - tileEntityPlantGrowing.AccumulatedTicks) / 20) % 60;
|
||||
|
||||
if (seconds > 1)
|
||||
{
|
||||
timerText = timerText + " [d6d97e]" + seconds + "[-] " + Localization.Get("ttSeconds");
|
||||
}
|
||||
else
|
||||
{
|
||||
timerText = timerText + " [d6d97e]" + seconds + "[-] " + Localization.Get("ttSecond");
|
||||
}
|
||||
|
||||
//Log.Out("canShowCycleTime: " + canShowCycleTime);
|
||||
if (canShowCycleTime)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 10");
|
||||
if (key.Contains("1"))
|
||||
{
|
||||
activationText = blockLocalization + "\n" + Localization.Get("ttNextCycle1") + timerText;
|
||||
}
|
||||
else
|
||||
{
|
||||
activationText = blockLocalization + "\n" + Localization.Get("ttNextCycle2") + timerText;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 11");
|
||||
activationText = blockLocalization;
|
||||
}
|
||||
}
|
||||
|
||||
bool bHasSunLight = true;
|
||||
bool bHasBlockLight = true;
|
||||
|
||||
Vector3i blockPos = _blockPos + Vector3i.up;
|
||||
ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx];
|
||||
if (chunkCluster != null)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 12");
|
||||
|
||||
byte sunLightSource = 0;
|
||||
byte blockLightSource = 0;
|
||||
|
||||
sunLightSource = chunkCluster.GetLight(blockPos, Chunk.LIGHT_TYPE.SUN);
|
||||
blockLightSource = chunkCluster.GetLight(blockPos, Chunk.LIGHT_TYPE.BLOCK);
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText sun light: " + sunLightSource);
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText this.lightLevelStay: " + this.lightLevelStay);
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText this.lightLevelGrow: " + this.lightLevelGrow);
|
||||
|
||||
if ((int)sunLightSource < this.lightLevelStay || (int)sunLightSource < this.lightLevelGrow)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 13");
|
||||
bHasSunLight = false;
|
||||
}
|
||||
if ((int)blockLightSource < this.lightLevelStay || (int)blockLightSource < this.lightLevelGrow)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 14");
|
||||
bHasBlockLight = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool bIsNight = false;
|
||||
if (!GameManager.Instance.World.IsDaytime())
|
||||
{
|
||||
bIsNight = true;
|
||||
}
|
||||
|
||||
if (_blockValue.Block.GetBlockName().ToLower().Contains("mushroom"))
|
||||
{
|
||||
bHasBlockLight = true;
|
||||
}
|
||||
|
||||
int numDay = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime) % 7;
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip() && numDay != 2)
|
||||
{
|
||||
bHasSunLight = false;
|
||||
bIsNight = true;
|
||||
}
|
||||
|
||||
if (!((bHasSunLight && !bIsNight) || bHasBlockLight) && advancedFarming)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 17");
|
||||
activationText = blockLocalization + "\n" + Localization.Get("ttNeedLight");
|
||||
}
|
||||
|
||||
int hasWaterInTank = RebirthUtilities.CheckForWater(_world, _clrIdx, _blockPos, "FuriousRamsayWaterTank", 4, 1, 0);
|
||||
int hasWaterInCollector = RebirthUtilities.CheckForWater(_world, _clrIdx, _blockPos, "FuriousRamsayDewCollector", 4, 1, 0);
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText hasWater: " + hasWater);
|
||||
|
||||
int depletion = 1;
|
||||
|
||||
string currentBiome = "";
|
||||
|
||||
BiomeDefinition biome = GameManager.Instance.World.GetBiome(_blockPos.x, _blockPos.z);
|
||||
if (biome != null)
|
||||
{
|
||||
currentBiome = biome.m_sBiomeName;
|
||||
}
|
||||
|
||||
if (currentBiome == "desert")
|
||||
{
|
||||
depletion = depletion * 2;
|
||||
}
|
||||
|
||||
Vector3i farmPlotPos = _blockPos;
|
||||
farmPlotPos.y = farmPlotPos.y - 1;
|
||||
BlockValue blockFarmPlot = _world.GetBlock(_clrIdx, farmPlotPos);
|
||||
|
||||
TileEntity tileEntity = _world.GetTileEntity(_clrIdx, farmPlotPos);
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(farmPlotPos);
|
||||
|
||||
int waterFarmPlot = 0;
|
||||
|
||||
TileEntityFarmPlotRebirth tileEntityFarmPlotRebirth;
|
||||
if (tileEntity is TileEntityFarmPlotRebirth)
|
||||
{
|
||||
tileEntityFarmPlotRebirth = (TileEntityFarmPlotRebirth)tileEntity;
|
||||
|
||||
waterFarmPlot = tileEntityFarmPlotRebirth.waterCount;
|
||||
}
|
||||
|
||||
if ((waterFarmPlot < depletion) && advancedFarming)
|
||||
{
|
||||
if (hasWaterInTank == -1 && hasWaterInCollector == -1)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 18");
|
||||
activationText = blockLocalization + "\n" + Localization.Get("ttNeedWater");
|
||||
}
|
||||
else if (hasWaterInTank == 0 || hasWaterInCollector == 0)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 19");
|
||||
activationText = blockLocalization + "\n" + Localization.Get("ttNoWaterInTank");
|
||||
}
|
||||
|
||||
if (currentBiome == "wasteland")
|
||||
{
|
||||
activationText = blockLocalization + "\n" + Localization.Get("ttNoGrowWasteland");
|
||||
}
|
||||
}
|
||||
|
||||
float num = WeatherManager.Instance.GetCurrentTemperatureValue();
|
||||
float numClouds = 0;
|
||||
float numRain = 0;
|
||||
|
||||
if (num == 0)
|
||||
{
|
||||
num = RebirthUtilities.GetWeatherInfo(_blockPos, "temp");
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick numTemp: " + num);
|
||||
numClouds = RebirthUtilities.GetWeatherInfo(_blockPos, "clouds") / 5;
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick numClouds: " + numClouds);
|
||||
numRain = RebirthUtilities.GetWeatherInfo(_blockPos, "wet") * 10;
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick numRain: " + numRain);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick LOCAL numTemp: " + num);
|
||||
numRain = 10 * WeatherManager.Instance.GetCurrentRainfallValue();
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick LOCAL numRain: " + numRain);
|
||||
numClouds = 10 * WeatherManager.Instance.GetCurrentCloudThicknessPercent();
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick LOCAL numClouds: " + numClouds);
|
||||
}
|
||||
|
||||
num = num - (numRain + numClouds);
|
||||
|
||||
bool hasHeat = RebirthUtilities.CheckForHeat(_world, _clrIdx, _blockPos, "campfire", 6, 3, 1);
|
||||
bool hasHeat2 = RebirthUtilities.CheckForHeat(_world, _clrIdx, _blockPos, "cntWoodBurningStove_PickedUp", 10, 5, 1);
|
||||
|
||||
if (hasHeat)
|
||||
{
|
||||
num = num + 20;
|
||||
}
|
||||
else if (hasHeat2)
|
||||
|
||||
{
|
||||
num = num + 40;
|
||||
}
|
||||
|
||||
if (bIsNight)
|
||||
{
|
||||
num = num - 10;
|
||||
}
|
||||
|
||||
if (!bHasSunLight)
|
||||
{
|
||||
if (currentBiome == "pine_forest")
|
||||
{
|
||||
num = num - 5;
|
||||
}
|
||||
if (currentBiome == "desert")
|
||||
{
|
||||
num = num - 10;
|
||||
}
|
||||
if (currentBiome == "snow")
|
||||
{
|
||||
num = num + 10;
|
||||
}
|
||||
if (currentBiome == "wasteland")
|
||||
{
|
||||
num = num + 5;
|
||||
}
|
||||
}
|
||||
|
||||
string color = "[6bafb0]";
|
||||
|
||||
if ((num < minTemp) && advancedFarming)
|
||||
{
|
||||
activationText = blockLocalization + "\n" + Localization.Get("ttNoGrowTooCold");
|
||||
color = "[e0dd7e]";
|
||||
}
|
||||
|
||||
bool isHeatResistant = false;
|
||||
string plantName = _blockValue.Block.GetBlockName();
|
||||
|
||||
if (plantName.ToLower().Contains("yucca") ||
|
||||
plantName.ToLower().Contains("cotton") ||
|
||||
plantName.ToLower().Contains("coffee") ||
|
||||
plantName.ToLower().Contains("aloe")
|
||||
)
|
||||
{
|
||||
isHeatResistant = true;
|
||||
}
|
||||
|
||||
if ((num >= 80 && !isHeatResistant) && advancedFarming)
|
||||
{
|
||||
activationText = activationText + Localization.Get("ttUsesMoreWater");
|
||||
color = "[d47474]";
|
||||
}
|
||||
|
||||
if (advancedFarming)
|
||||
{
|
||||
activationText = activationText + "\n(" + Localization.Get("ttCropTempStart") + minTemp + Localization.Get("ttCropTempEnd") + ": " + color + num.ToString("0.00") + "[-] " + Localization.Get("ttTempUnit") + ")";
|
||||
}
|
||||
|
||||
return (activationText);
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
if (this.Properties.Values.ContainsKey("NextStageRate"))
|
||||
{
|
||||
this.nextStageRate = StringParsers.ParseFloat(this.Properties.Values["NextStageRate"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("NextStage"))
|
||||
{
|
||||
this.nextStage = this.Properties.Values["NextStage"];
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("TickRate"))
|
||||
{
|
||||
this.TickRate = (ulong)StringParsers.ParseFloat(this.Properties.Values["TickRate"], 0, -1, NumberStyles.Any) * 20;
|
||||
}
|
||||
}
|
||||
|
||||
public override ulong GetTickRate()
|
||||
{
|
||||
bool advancedFarming = RebirthVariables.customAdvancedFarming;
|
||||
int cropGrowthTime = RebirthVariables.customAdvancedFarmingTime * 60;
|
||||
|
||||
if (RebirthVariables.testCropGrowth)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
ulong stageRate = (ulong)(this.nextStageRate * 20f);
|
||||
|
||||
stageRate = (ulong)(cropGrowthTime * 20f);
|
||||
|
||||
return stageRate;
|
||||
}
|
||||
|
||||
public BlockPlantGrowingRebirth()
|
||||
{
|
||||
this.HasTileEntity = true;
|
||||
}
|
||||
|
||||
public override bool OnBlockActivated(string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
return _commandName == this.cmds[0].text && this.OnBlockActivated(_world, _cIdx, _blockPos, _blockValue, _player);
|
||||
}
|
||||
|
||||
public override BlockActivationCommand[] GetBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
return this.cmds;
|
||||
}
|
||||
}
|
||||
64
Scripts/Blocks/BlockPoweredSDX.cs
Normal file
64
Scripts/Blocks/BlockPoweredSDX.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
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;
|
||||
}
|
||||
64
Scripts/Blocks/BlockRebirth.cs
Normal file
64
Scripts/Blocks/BlockRebirth.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
public class BlockRebirth : Block
|
||||
{
|
||||
public override bool IsElevator()
|
||||
{
|
||||
if (this.GetBlockName() == "terrDesertGround" ||
|
||||
this.GetBlockName() == "terrForestGround" ||
|
||||
this.GetBlockName() == "terrSnow" ||
|
||||
this.GetBlockName() == "terrDirt")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool IsElevator(int rotation)
|
||||
{
|
||||
if (this.GetBlockName() == "terrDesertGround" ||
|
||||
this.GetBlockName() == "terrForestGround" ||
|
||||
this.GetBlockName() == "terrSnow" ||
|
||||
this.GetBlockName() == "terrDirt")
|
||||
{
|
||||
return climbableRotations[rotation] > 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static byte[] climbableRotations = new byte[]
|
||||
{
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
};
|
||||
}
|
||||
299
Scripts/Blocks/BlockRespawnRebirth.cs
Normal file
299
Scripts/Blocks/BlockRespawnRebirth.cs
Normal file
@@ -0,0 +1,299 @@
|
||||
using System.Globalization;
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
[Preserve]
|
||||
public class BlockRespawnRebirth : BlockPlant
|
||||
{
|
||||
public BlockRespawnRebirth()
|
||||
{
|
||||
this.fertileLevel = 5;
|
||||
}
|
||||
|
||||
public override void LateInit()
|
||||
{
|
||||
base.LateInit();
|
||||
int vehicleRespawn = RebirthVariables.customVehicleRespawn;
|
||||
|
||||
if (this.Properties.Values.ContainsKey(BlockRespawnRebirth.PropGrowingNextPlant))
|
||||
{
|
||||
this.nextPlant = ItemClass.GetItem(this.Properties.Values[BlockRespawnRebirth.PropGrowingNextPlant], false).ToBlockValue();
|
||||
|
||||
if (vehicleRespawn == 0)
|
||||
{
|
||||
this.nextPlant = ItemClass.GetItem("FuriousRamsayAir", false).ToBlockValue();
|
||||
}
|
||||
|
||||
if (this.nextPlant.Equals(BlockValue.Air))
|
||||
{
|
||||
throw new Exception("Block with name '" + this.Properties.Values[BlockRespawnRebirth.PropGrowingNextPlant] + "' not found!");
|
||||
}
|
||||
}
|
||||
this.growOnTop = BlockValue.Air;
|
||||
if (this.Properties.Values.ContainsKey(BlockRespawnRebirth.PropGrowingIsGrowOnTopEnabled) && StringParsers.ParseBool(this.Properties.Values[BlockRespawnRebirth.PropGrowingIsGrowOnTopEnabled], 0, -1, true))
|
||||
{
|
||||
this.bGrowOnTopEnabled = true;
|
||||
if (this.Properties.Values.ContainsKey(BlockRespawnRebirth.PropGrowingGrowOnTop))
|
||||
{
|
||||
this.growOnTop = ItemClass.GetItem(this.Properties.Values[BlockRespawnRebirth.PropGrowingGrowOnTop], false).ToBlockValue();
|
||||
if (this.growOnTop.Equals(BlockValue.Air))
|
||||
{
|
||||
throw new Exception("Block with name '" + this.Properties.Values[BlockRespawnRebirth.PropGrowingGrowOnTop] + "' not found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey(BlockRespawnRebirth.PropGrowingGrowthRate))
|
||||
{
|
||||
this.growthRate = StringParsers.ParseFloat(this.Properties.Values[BlockRespawnRebirth.PropGrowingGrowthRate], 0, -1, NumberStyles.Any);
|
||||
|
||||
if (vehicleRespawn > 0)
|
||||
{
|
||||
this.growthRate = vehicleRespawn * 60;
|
||||
}
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey(BlockRespawnRebirth.PropGrowingGrowthDeviation))
|
||||
{
|
||||
this.growthDeviation = StringParsers.ParseFloat(this.Properties.Values[BlockRespawnRebirth.PropGrowingGrowthDeviation], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey(BlockRespawnRebirth.PropGrowingFertileLevel))
|
||||
{
|
||||
this.fertileLevel = int.Parse(this.Properties.Values[BlockRespawnRebirth.PropGrowingFertileLevel]);
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey(BlockRespawnRebirth.PropGrowingLightLevelStay))
|
||||
{
|
||||
this.lightLevelStay = int.Parse(this.Properties.Values[BlockRespawnRebirth.PropGrowingLightLevelStay]);
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey(BlockRespawnRebirth.PropGrowingLightLevelGrow))
|
||||
{
|
||||
this.lightLevelGrow = int.Parse(this.Properties.Values[BlockRespawnRebirth.PropGrowingLightLevelGrow]);
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey(BlockRespawnRebirth.PropGrowingGrowIfAnythinOnTop))
|
||||
{
|
||||
this.isPlantGrowingIfAnythingOnTop = StringParsers.ParseBool(this.Properties.Values[BlockRespawnRebirth.PropGrowingGrowIfAnythinOnTop], 0, -1, true);
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey(BlockRespawnRebirth.PropGrowingIsRandom))
|
||||
{
|
||||
this.isPlantGrowingRandom = StringParsers.ParseBool(this.Properties.Values[BlockRespawnRebirth.PropGrowingIsRandom], 0, -1, true);
|
||||
}
|
||||
if (this.growthRate > 0f)
|
||||
{
|
||||
this.BlockTag = BlockTags.GrowablePlant;
|
||||
this.IsRandomlyTick = true;
|
||||
return;
|
||||
}
|
||||
this.IsRandomlyTick = false;
|
||||
}
|
||||
|
||||
public override bool CanPlaceBlockAt(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bOmitCollideCheck = false)
|
||||
{
|
||||
if (GameManager.Instance.IsEditMode())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!base.CanPlaceBlockAt(_world, _clrIdx, _blockPos, _blockValue, _bOmitCollideCheck))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Vector3i blockPos = _blockPos + Vector3i.up;
|
||||
ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx];
|
||||
if (chunkCluster != null)
|
||||
{
|
||||
byte light = chunkCluster.GetLight(blockPos, Chunk.LIGHT_TYPE.SUN);
|
||||
if ((int)light < this.lightLevelStay || (int)light < this.lightLevelGrow)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool CanGrowOn(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValueOfPlant)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void PlaceBlock(WorldBase _world, BlockPlacement.Result _result, EntityAlive _ea)
|
||||
{
|
||||
base.PlaceBlock(_world, _result, _ea);
|
||||
if (_ea is EntityPlayerLocal)
|
||||
{
|
||||
_ea.Progression.AddLevelExp((int)_result.blockValue.Block.blockMaterial.Experience, "_xpOther", Progression.XPTypes.Other, true);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnBlockAdded(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
base.OnBlockAdded(_world, _chunk, _blockPos, _blockValue);
|
||||
if (!_world.IsRemote())
|
||||
{
|
||||
this.addScheduledTick(_world, _chunk.ClrIdx, _blockPos);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void addScheduledTick(WorldBase _world, int _clrIdx, Vector3i _blockPos)
|
||||
{
|
||||
if (!this.isPlantGrowingRandom)
|
||||
{
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, this.GetTickRate());
|
||||
return;
|
||||
}
|
||||
int num = (int)this.GetTickRate();
|
||||
int num2 = (int)((float)num * this.growthDeviation);
|
||||
int num3 = num / 2;
|
||||
int max = num + num3;
|
||||
GameRandom gameRandom = _world.GetGameRandom();
|
||||
int num4;
|
||||
int num5;
|
||||
do
|
||||
{
|
||||
float randomGaussian = gameRandom.RandomGaussian;
|
||||
num4 = Mathf.RoundToInt((float)num + (float)num2 * randomGaussian);
|
||||
num5 = Mathf.Clamp(num4, num3, max);
|
||||
}
|
||||
while (num5 != num4);
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, (ulong)((long)num5));
|
||||
}
|
||||
|
||||
public override ulong GetTickRate()
|
||||
{
|
||||
ulong rate = (ulong)(this.growthRate * 20f * 60f);
|
||||
|
||||
if (RebirthVariables.testVehicleRespawns)
|
||||
{
|
||||
rate = 1u;
|
||||
}
|
||||
|
||||
return rate;
|
||||
}
|
||||
|
||||
public override bool UpdateTick(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bRandomTick, ulong _ticksIfLoaded, GameRandom _rnd)
|
||||
{
|
||||
if (this.nextPlant.isair)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!this.CheckPlantAlive(_world, _clrIdx, _blockPos, _blockValue))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (_bRandomTick)
|
||||
{
|
||||
this.addScheduledTick(_world, _clrIdx, _blockPos);
|
||||
return true;
|
||||
}
|
||||
ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx];
|
||||
if (chunkCluster == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
Vector3i blockPos = _blockPos + Vector3i.up;
|
||||
if ((int)chunkCluster.GetLight(blockPos, Chunk.LIGHT_TYPE.SUN) < this.lightLevelGrow)
|
||||
{
|
||||
this.addScheduledTick(_world, _clrIdx, _blockPos);
|
||||
return true;
|
||||
}
|
||||
BlockValue block = _world.GetBlock(_clrIdx, _blockPos + Vector3i.up);
|
||||
if (!this.isPlantGrowingIfAnythingOnTop && !block.isair)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
BlockPlant blockPlant = this.nextPlant.Block as BlockPlant;
|
||||
if (blockPlant != null && !blockPlant.CanGrowOn(_world, _clrIdx, _blockPos + Vector3i.down, this.nextPlant))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
_blockValue.type = this.nextPlant.type;
|
||||
BiomeDefinition biome = ((World)_world).GetBiome(_blockPos.x, _blockPos.z);
|
||||
if (biome != null && biome.Replacements.ContainsKey(_blockValue.type))
|
||||
{
|
||||
_blockValue.type = biome.Replacements[_blockValue.type];
|
||||
}
|
||||
BlockValue blockValue = BlockPlaceholderMap.Instance.Replace(_blockValue, _world.GetGameRandom(), _blockPos.x, _blockPos.z, false);
|
||||
blockValue.rotation = _blockValue.rotation;
|
||||
blockValue.meta = _blockValue.meta;
|
||||
blockValue.meta2 = 0;
|
||||
_blockValue = blockValue;
|
||||
if (this.bGrowOnTopEnabled)
|
||||
{
|
||||
_blockValue.meta = ((byte)(_blockValue.meta + 1 & 15));
|
||||
}
|
||||
if (this.isPlantGrowingRandom || _ticksIfLoaded <= this.GetTickRate() || !_blockValue.Block.UpdateTick(_world, _clrIdx, _blockPos, _blockValue, false, _ticksIfLoaded - this.GetTickRate(), _rnd))
|
||||
{
|
||||
_world.SetBlockRPC(_clrIdx, _blockPos, _blockValue);
|
||||
}
|
||||
if (!this.growOnTop.isair && _blockPos.y + 1 < 255 && block.isair)
|
||||
{
|
||||
_blockValue.type = this.growOnTop.type;
|
||||
_blockValue = _blockValue.Block.OnBlockPlaced(_world, _clrIdx, _blockPos, _blockValue, _rnd);
|
||||
Block block2 = _blockValue.Block;
|
||||
if (_blockValue.damage >= block2.blockMaterial.MaxDamage)
|
||||
{
|
||||
_blockValue.damage = block2.blockMaterial.MaxDamage - 1;
|
||||
}
|
||||
if (this.isPlantGrowingRandom || _ticksIfLoaded <= this.GetTickRate() || !block2.UpdateTick(_world, _clrIdx, _blockPos + Vector3i.up, _blockValue, false, _ticksIfLoaded - this.GetTickRate(), _rnd))
|
||||
{
|
||||
_world.SetBlockRPC(_clrIdx, _blockPos + Vector3i.up, _blockValue);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public BlockValue ForceNextGrowStage(World _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
BlockValue block = _world.GetBlock(_clrIdx, _blockPos + Vector3i.up);
|
||||
if (!this.isPlantGrowingIfAnythingOnTop && !block.isair)
|
||||
{
|
||||
return _blockValue;
|
||||
}
|
||||
_blockValue.type = this.nextPlant.type;
|
||||
BiomeDefinition biome = _world.GetBiome(_blockPos.x, _blockPos.z);
|
||||
if (biome != null && biome.Replacements.ContainsKey(_blockValue.type))
|
||||
{
|
||||
_blockValue.type = biome.Replacements[_blockValue.type];
|
||||
}
|
||||
BlockValue blockValue = BlockPlaceholderMap.Instance.Replace(_blockValue, _world.GetGameRandom(), _blockPos.x, _blockPos.z, false);
|
||||
blockValue.rotation = _blockValue.rotation;
|
||||
blockValue.meta = _blockValue.meta;
|
||||
blockValue.meta2 = 0;
|
||||
_blockValue = blockValue;
|
||||
if (this.bGrowOnTopEnabled)
|
||||
{
|
||||
_blockValue.meta = ((byte)(_blockValue.meta + 1 & 15));
|
||||
}
|
||||
if (!this.growOnTop.isair && _blockPos.y + 1 < 255 && block.isair)
|
||||
{
|
||||
_blockValue.type = this.growOnTop.type;
|
||||
_blockValue = _blockValue.Block.OnBlockPlaced(_world, _clrIdx, _blockPos, _blockValue, _world.GetGameRandom());
|
||||
Block block2 = _blockValue.Block;
|
||||
if (_blockValue.damage >= block2.blockMaterial.MaxDamage)
|
||||
{
|
||||
_blockValue.damage = block2.blockMaterial.MaxDamage - 1;
|
||||
}
|
||||
_world.SetBlockRPC(_clrIdx, _blockPos + Vector3i.up, _blockValue);
|
||||
}
|
||||
return _blockValue;
|
||||
}
|
||||
|
||||
public virtual float GetGrowthRate()
|
||||
{
|
||||
return this.growthRate;
|
||||
}
|
||||
|
||||
protected static string PropGrowingNextPlant = "PlantGrowing.Next";
|
||||
protected static string PropGrowingGrowthRate = "PlantGrowing.GrowthRate";
|
||||
protected static string PropGrowingGrowthDeviation = "PlantGrowing.GrowthDeviation";
|
||||
protected static string PropGrowingFertileLevel = "PlantGrowing.FertileLevel";
|
||||
protected static string PropGrowingGrowOnTop = "PlantGrowing.GrowOnTop";
|
||||
protected static string PropGrowingIsGrowOnTopEnabled = "PlantGrowing.IsGrowOnTopEnabled";
|
||||
protected static string PropGrowingLightLevelStay = "PlantGrowing.LightLevelStay";
|
||||
protected static string PropGrowingLightLevelGrow = "PlantGrowing.LightLevelGrow";
|
||||
protected static string PropGrowingIsRandom = "PlantGrowing.IsRandom";
|
||||
protected static string PropGrowingGrowIfAnythinOnTop = "PlantGrowing.GrowIfAnythinOnTop";
|
||||
protected BlockValue nextPlant;
|
||||
protected BlockValue growOnTop;
|
||||
protected bool bGrowOnTopEnabled;
|
||||
protected float growthRate;
|
||||
protected float growthDeviation = 0.25f;
|
||||
protected int lightLevelGrow = 8;
|
||||
protected bool isPlantGrowingRandom = true;
|
||||
protected bool isPlantGrowingIfAnythingOnTop = true;
|
||||
}
|
||||
860
Scripts/Blocks/BlockSecureLootGatherer.cs
Normal file
860
Scripts/Blocks/BlockSecureLootGatherer.cs
Normal file
@@ -0,0 +1,860 @@
|
||||
using Audio;
|
||||
using Platform;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
public class BlockSecureLootGatherer : Block
|
||||
{
|
||||
public override void OnTriggered(EntityPlayer _player, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, List<BlockChangeInfo> _blockChanges, BlockTrigger _triggeredBy)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-OnTriggered START");
|
||||
base.OnTriggered(_player, _world, _cIdx, _blockPos, _blockValue, _blockChanges, _triggeredBy);
|
||||
|
||||
if (!this.DowngradeBlock.isair)
|
||||
{
|
||||
BlockValue blockValue = this.DowngradeBlock;
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), _blockPos.x, _blockPos.z);
|
||||
blockValue.rotation = _blockValue.rotation;
|
||||
blockValue.meta = _blockValue.meta;
|
||||
_world.SetBlockRPC(_cIdx, _blockPos, blockValue, blockValue.Block.Density);
|
||||
}
|
||||
Manager.BroadcastPlayByLocalPlayer(_blockPos.ToVector3() + Vector3.one * 0.5f, "Misc/unlocking");
|
||||
}
|
||||
|
||||
public override bool IsWaterBlocked(IBlockAccess _world, Vector3i _blockPos, BlockValue _blockValue, BlockFaceFlag _sides)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool AllowBlockTriggers
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public BlockSecureLootGatherer()
|
||||
{
|
||||
this.HasTileEntity = true;
|
||||
}
|
||||
|
||||
public override ulong GetTickRate()
|
||||
{
|
||||
System.Random random = new System.Random();
|
||||
autoLootTick = random.Next(7, 15);
|
||||
|
||||
return (ulong)(20f * autoLootTick);
|
||||
}
|
||||
|
||||
public override bool CanPlaceBlockAt(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bOmitCollideCheck = false)
|
||||
{
|
||||
bool bCanPlaceBlock = base.CanPlaceBlockAt(_world, _clrIdx, _blockPos, _blockValue, _bOmitCollideCheck);
|
||||
|
||||
bool blockExists = RebirthUtilities.BlockExists(_blockPos, 15, 20, "FuriousRamsayLootGatherer");
|
||||
|
||||
if (!bCanPlaceBlock || blockExists)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void PlaceBlock(WorldBase _world, BlockPlacement.Result _result, EntityAlive _ea)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-PlaceBlock START");
|
||||
base.PlaceBlock(_world, _result, _ea);
|
||||
TileEntitySecureLootContainerRebirth tileEntitySecureLootContainer = _world.GetTileEntity(_result.clrIdx, _result.blockPos) as TileEntitySecureLootContainerRebirth;
|
||||
if (tileEntitySecureLootContainer != null)
|
||||
{
|
||||
tileEntitySecureLootContainer.SetEmpty();
|
||||
if (_ea != null && _ea.entityType == EntityType.Player)
|
||||
{
|
||||
tileEntitySecureLootContainer.bPlayerStorage = true;
|
||||
tileEntitySecureLootContainer.SetOwner(PlatformManager.InternalLocalUserIdentifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void OnBlockAdded(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-OnBlockAdded START");
|
||||
base.OnBlockAdded(_world, _chunk, _blockPos, _blockValue);
|
||||
if (_blockValue.ischild)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-OnBlockAdded 1");
|
||||
return;
|
||||
}
|
||||
if (!(_world.GetTileEntity(_chunk.ClrIdx, _blockPos) is TileEntitySecureLootContainerRebirth))
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-OnBlockAdded 2");
|
||||
TileEntitySecureLootContainerRebirth tileEntitySecureLootContainer = new TileEntitySecureLootContainerRebirth(_chunk);
|
||||
tileEntitySecureLootContainer.localChunkPos = World.toBlock(_blockPos);
|
||||
tileEntitySecureLootContainer.lootListName = this.lootList;
|
||||
tileEntitySecureLootContainer.SetContainerSize(LootContainer.GetLootContainer(this.lootList, true).size, true);
|
||||
_chunk.AddTileEntity(tileEntitySecureLootContainer);
|
||||
}
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-OnBlockAdded 3");
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_chunk.ClrIdx, _blockPos, this.blockID, this.GetTickRate());
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnBlockRemoved(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-OnBlockRemoved START");
|
||||
base.OnBlockRemoved(world, _chunk, _blockPos, _blockValue);
|
||||
}
|
||||
|
||||
public override Block.DestroyedResult OnBlockDestroyedBy(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, int _entityId, bool _bUseHarvestTool)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-OnBlockDestroyedBy START");
|
||||
TileEntitySecureLootContainerRebirth tileEntitySecureLootContainer = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntitySecureLootContainerRebirth;
|
||||
if (tileEntitySecureLootContainer != null)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-OnBlockDestroyedBy 1");
|
||||
tileEntitySecureLootContainer.OnDestroy();
|
||||
}
|
||||
return Block.DestroyedResult.Downgrade;
|
||||
}
|
||||
|
||||
public override bool UpdateTick(WorldBase world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bRandomTick, ulong _ticksIfLoaded, GameRandom _rnd)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-UpdateTick START");
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("BlockSecureLootGatherer-UpdateTick 1");
|
||||
|
||||
TileEntitySecureLootContainerRebirth tileEntitySecureLootContainer = world.GetTileEntity(_clrIdx, _blockPos) as TileEntitySecureLootContainerRebirth;
|
||||
|
||||
if (tileEntitySecureLootContainer != null)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-UpdateTick tileEntityLootContainer tileEntitySecureLootContainer.isLootGatheringActivated: " + tileEntitySecureLootContainer.isLootGatheringActivated);
|
||||
|
||||
if (tileEntitySecureLootContainer.isLootGatheringActivated)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-UpdateTick isLootGatheringActivated is TRUE");
|
||||
|
||||
PersistentPlayerData playerData = world.GetGameManager().GetPersistentPlayerList().GetPlayerData(tileEntitySecureLootContainer.GetOwner());
|
||||
|
||||
EntityPlayer entityPlayer = (EntityPlayer)world.GetEntity(playerData.EntityId);
|
||||
if (entityPlayer == null)
|
||||
{
|
||||
world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, this.GetTickRate());
|
||||
return true;
|
||||
}
|
||||
|
||||
int minMax = 75;
|
||||
|
||||
World _world = GameManager.Instance.World;
|
||||
List<Entity> entitiesInBounds = _world.GetEntitiesInBounds(typeof(EntityLootContainer), BoundsUtils.BoundsForMinMax(_blockPos.x - minMax, _blockPos.y - 50, _blockPos.z - minMax, _blockPos.x + minMax, _blockPos.y + 30, _blockPos.z + minMax), new List<Entity>());
|
||||
|
||||
if (entitiesInBounds != null && entitiesInBounds.Count > 0)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-UpdateTick isLootGatheringActivated entitiesInBounds.Count > 0");
|
||||
|
||||
for (int i = 0; i < entitiesInBounds.Count; i++)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-UpdateTick entitiesInBounds[i].EntityClass.entityClassName: " + entitiesInBounds[i].EntityClass.entityClassName);
|
||||
//Log.Out("BlockSecureLootGatherer-UpdateTick entitiesInBounds[i].lootContainer.items.Length: " + entitiesInBounds[i].lootContainer.items.Length);
|
||||
|
||||
if (entitiesInBounds[i].lootContainer != null)
|
||||
{
|
||||
bool isUserAccessing = entitiesInBounds[i].lootContainer.IsUserAccessing();
|
||||
|
||||
if (!isUserAccessing)
|
||||
{
|
||||
entitiesInBounds[i].lootContainer.SetUserAccessing(true);
|
||||
//entitiesInBounds[i].lootContainer.bTouched = true;
|
||||
//entitiesInBounds[i].lootContainer.worldTimeTouched = world.GetWorldTime();
|
||||
|
||||
float containerMod = 0f;
|
||||
float containerBonus = 0f;
|
||||
|
||||
//Log.Out("BlockSecureLootGatherer-UpdateTick entitiesInBounds[i].lootContainer.EntityId: " + entitiesInBounds[i].lootContainer.EntityId);
|
||||
|
||||
float lootStage = (float)entityPlayer.GetHighestPartyLootStage(containerMod, containerBonus);
|
||||
//Log.Out("BlockSecureLootGatherer-UpdateTick lootStage: " + lootStage);
|
||||
|
||||
GameManager.Instance.lootManager.LootContainerOpened(entitiesInBounds[i].lootContainer, entityPlayer.entityId, entitiesInBounds[i].EntityTags);
|
||||
|
||||
//Log.Out("BlockSecureLootGatherer-UpdateTick EntityTags: " + entitiesInBounds[i].EntityTags);
|
||||
|
||||
bool addItems = false;
|
||||
bool addedAllItems = true;
|
||||
|
||||
foreach (ItemStack itemStack in entitiesInBounds[i].lootContainer.GetItems())
|
||||
{
|
||||
if (!itemStack.IsEmpty())
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-UpdateTick Item Name: " + itemStack.itemValue.ItemClass.GetItemName());
|
||||
//Log.Out("BlockSecureLootGatherer-UpdateTick Item Count: " + itemStack.count);
|
||||
|
||||
if (tileEntitySecureLootContainer.HasItem(itemStack.itemValue))
|
||||
{
|
||||
ValueTuple<bool, bool> tryStack = tileEntitySecureLootContainer.TryStackItem(_clrIdx, itemStack);
|
||||
//Log.Out("BlockSecureLootGatherer-UpdateTick tryStack: " + tryStack);
|
||||
if (!tryStack.Item1)
|
||||
{
|
||||
bool tryAdd = tileEntitySecureLootContainer.AddItem(itemStack);
|
||||
//Log.Out("BlockSecureLootGatherer-UpdateTick tryAdd: " + tryAdd);
|
||||
if (tryAdd)
|
||||
{
|
||||
addItems = true;
|
||||
entitiesInBounds[i].lootContainer.RemoveItem(itemStack.itemValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
addedAllItems = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
addItems = true;
|
||||
entitiesInBounds[i].lootContainer.RemoveItem(itemStack.itemValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool tryAdd = tileEntitySecureLootContainer.AddItem(itemStack);
|
||||
//Log.Out("BlockSecureLootGatherer-UpdateTick tryAdd: " + tryAdd);
|
||||
if (tryAdd)
|
||||
{
|
||||
addItems = true;
|
||||
entitiesInBounds[i].lootContainer.RemoveItem(itemStack.itemValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
addedAllItems = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
entitiesInBounds[i].lootContainer.SetUserAccessing(false);
|
||||
|
||||
if (addItems && addedAllItems)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-UpdateTick REMOVED BAG: " + entitiesInBounds[i].EntityClass.entityClassName);
|
||||
entitiesInBounds[i].DamageEntity(new DamageSource(EnumDamageSource.Internal, EnumDamageTypes.Suicide), 99999, false, 1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entitiesInBounds = _world.GetEntitiesInBounds(typeof(EntityEnemy), BoundsUtils.BoundsForMinMax(_blockPos.x - minMax, _blockPos.y - 50, _blockPos.z - minMax, _blockPos.x + minMax, _blockPos.y + 30, _blockPos.z + minMax), new List<Entity>());
|
||||
|
||||
if (entitiesInBounds.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < entitiesInBounds.Count; i++)
|
||||
{
|
||||
if (entitiesInBounds[i].IsDead())
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-UpdateTick REMOVED CORPSE: " + entitiesInBounds[i].EntityClass.entityClassName);
|
||||
entitiesInBounds[i].DamageEntity(new DamageSource(EnumDamageSource.Internal, EnumDamageTypes.Suicide), 99999, false, 1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, this.GetTickRate());
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-Init START");
|
||||
base.Init();
|
||||
if (!this.Properties.Values.ContainsKey(BlockSecureLootGatherer.PropLootList))
|
||||
{
|
||||
throw new Exception("Block with name " + base.GetBlockName() + " doesnt have a loot list");
|
||||
}
|
||||
this.lootList = this.Properties.Values[BlockSecureLootGatherer.PropLootList];
|
||||
if (this.Properties.Values.ContainsKey(BlockSecureLootGatherer.PropLockPickTime))
|
||||
{
|
||||
this.lockPickTime = StringParsers.ParseFloat(this.Properties.Values[BlockSecureLootGatherer.PropLockPickTime], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.lockPickTime = 15f;
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey(BlockSecureLootGatherer.PropLockPickItem))
|
||||
{
|
||||
this.lockPickItem = this.Properties.Values[BlockSecureLootGatherer.PropLockPickItem];
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey(BlockSecureLootGatherer.PropLockPickBreakChance))
|
||||
{
|
||||
this.lockPickBreakChance = StringParsers.ParseFloat(this.Properties.Values[BlockSecureLootGatherer.PropLockPickBreakChance], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.lockPickBreakChance = 0f;
|
||||
}
|
||||
this.Properties.ParseFloat(BlockSecureLootGatherer.PropLootStageMod, ref this.LootStageMod);
|
||||
this.Properties.ParseFloat(BlockSecureLootGatherer.PropLootStageBonus, ref this.LootStageBonus);
|
||||
|
||||
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);
|
||||
}
|
||||
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)
|
||||
{
|
||||
TileEntitySecureLootContainerRebirth tileEntitySecureLootContainer = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntitySecureLootContainerRebirth;
|
||||
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)
|
||||
{
|
||||
if (!tileEntitySecureLootContainer.IsLocked())
|
||||
{
|
||||
return string.Format(Localization.Get("tooltipUnlocked"), arg, localizedBlockName);
|
||||
}
|
||||
if (this.lockPickItem == null && !tileEntitySecureLootContainer.LocalPlayerIsOwner())
|
||||
{
|
||||
return string.Format(Localization.Get("tooltipJammed"), arg, localizedBlockName);
|
||||
}
|
||||
return string.Format(Localization.Get("tooltipLocked"), arg, localizedBlockName);
|
||||
}
|
||||
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(WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-OnBlockActivated START");
|
||||
if (_blockValue.ischild)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-OnBlockActivated 1");
|
||||
Vector3i parentPos = _blockValue.Block.multiBlockPos.GetParentPos(_blockPos, _blockValue);
|
||||
BlockValue block = _world.GetBlock(parentPos);
|
||||
return this.OnBlockActivated(_world, _cIdx, parentPos, block, _player);
|
||||
}
|
||||
TileEntitySecureLootContainerRebirth tileEntitySecureLootContainer = _world.GetTileEntity(_cIdx, _blockPos) as TileEntitySecureLootContainerRebirth;
|
||||
if (tileEntitySecureLootContainer == null)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-OnBlockActivated 2");
|
||||
return false;
|
||||
}
|
||||
_player.AimingGun = false;
|
||||
Vector3i blockPos = tileEntitySecureLootContainer.ToWorldPos();
|
||||
tileEntitySecureLootContainer.bWasTouched = tileEntitySecureLootContainer.bTouched;
|
||||
_world.GetGameManager().TELockServer(_cIdx, blockPos, tileEntitySecureLootContainer.entityId, _player.entityId, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool OnBlockActivated(string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-OnBlockActivated START");
|
||||
if (_blockValue.ischild)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer:isSecure _blockValue.ischild");
|
||||
Vector3i parentPos = _blockValue.Block.multiBlockPos.GetParentPos(_blockPos, _blockValue);
|
||||
BlockValue block = _world.GetBlock(parentPos);
|
||||
return this.OnBlockActivated(_commandName, _world, _cIdx, parentPos, block, _player);
|
||||
}
|
||||
TileEntitySecureLootContainerRebirth tileEntitySecureLootContainer = _world.GetTileEntity(_cIdx, _blockPos) as TileEntitySecureLootContainerRebirth;
|
||||
if (tileEntitySecureLootContainer == null)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer:isSecure 0");
|
||||
return false;
|
||||
}
|
||||
//Log.Out("BlockSecureLootGatherer:isSecure: " + this.isSecure);
|
||||
if (this.isSecure)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer:isSecure: True");
|
||||
PlatformUserIdentifierAbs getContainerOwner = tileEntitySecureLootContainer.GetOwner();
|
||||
bool isUserAllowed = tileEntitySecureLootContainer.IsUserAllowed(PlatformManager.InternalLocalUserIdentifier);
|
||||
//Log.Out("OnBlockActivated:_indexInBlockActivationCommands: " + _commandName);
|
||||
if (_commandName == this.cmds[0].text)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-OnBlockActivated:Secure/Search");
|
||||
|
||||
Vector3i blockPos = tileEntitySecureLootContainer.ToWorldPos();
|
||||
tileEntitySecureLootContainer.bWasTouched = tileEntitySecureLootContainer.bTouched;
|
||||
if (!tileEntitySecureLootContainer.IsLocked() || isUserAllowed)
|
||||
{
|
||||
_world.GetGameManager().TELockServer(_cIdx, blockPos, tileEntitySecureLootContainer.entityId, _player.entityId, null);
|
||||
return true;
|
||||
//return base.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)
|
||||
{
|
||||
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 = false;
|
||||
|
||||
// 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)
|
||||
{
|
||||
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);
|
||||
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");
|
||||
//Log.Out("OnBlockActivated: ReplacementBlockName: " + ReplacementBlockName);
|
||||
//Log.Out("OnBlockActivated: GetBlockName: " + _blockValue.Block.GetBlockName());
|
||||
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, this.TakeDelay, null, ReplacementBlockName, numBlocks, isReplacementItem);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else if (_commandName == this.cmds[7].text)
|
||||
{
|
||||
tileEntitySecureLootContainer.SetLootGatheringActivated(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (_commandName == this.cmds[8].text)
|
||||
{
|
||||
tileEntitySecureLootContainer.SetLootGatheringActivated(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer:isSecure: False");
|
||||
if (_commandName == this.cmds[0].text)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer: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
|
||||
{
|
||||
//Log.Out("OnBlockActivated:Insecure/Other");
|
||||
//Log.Out("BlockSecureLootGatherer:OnBlockActivated-_indexInBlockActivationCommands == other");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
object obj = array[4];
|
||||
TileEntitySecureLootContainerRebirth tileEntitySecureLootContainer = world.GetTileEntity(clrIdx, vector3i) as TileEntitySecureLootContainerRebirth;
|
||||
if (tileEntitySecureLootContainer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (tileEntitySecureLootContainer.IsUserAccessing())
|
||||
{
|
||||
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);
|
||||
TileEntitySecureLootContainerRebirth tileEntitySecureLootContainer = GameManager.Instance.World.GetTileEntity((int)array[0], blockPos) as TileEntitySecureLootContainerRebirth;
|
||||
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)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-GetBlockActivationCommands START");
|
||||
TileEntitySecureLootContainerRebirth tileEntitySecureLootContainer = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntitySecureLootContainerRebirth;
|
||||
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);
|
||||
|
||||
//Log.Out("BlockSecureLootGatherer-GetBlockActivationCommands flag: " + flag);
|
||||
//Log.Out("BlockSecureLootGatherer-GetBlockActivationCommands flag2: " + flag2);
|
||||
//Log.Out("BlockSecureLootGatherer-GetBlockActivationCommands this.canPickUpBlock: " + this.canPickUpBlock);
|
||||
//Log.Out("BlockSecureLootGatherer-GetBlockActivationCommands this.isSecure: " + this.isSecure);
|
||||
//Log.Out("BlockSecureLootGatherer-GetBlockActivationCommands tileEntitySecureLootContainer.IsLocked(): " + tileEntitySecureLootContainer.IsLocked());
|
||||
//Log.Out("BlockSecureLootGatherer-GetBlockActivationCommands this.isLootGatheringActivated: " + this.isLootGatheringActivated);
|
||||
|
||||
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);
|
||||
this.cmds[7].enabled = (!tileEntitySecureLootContainer.isLootGatheringActivated && this.isSecure && (flag || flag2));
|
||||
this.cmds[8].enabled = (tileEntitySecureLootContainer.isLootGatheringActivated && this.isSecure && (flag || flag2));
|
||||
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),
|
||||
new BlockActivationCommand("ActivateLootGathering", "loot_sack_green", false, false),
|
||||
new BlockActivationCommand("DeactivateLootGathering", "loot_sack_red", 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)
|
||||
{
|
||||
//Log.Out("BlockSecureLootGatherer-DamageBlock START");
|
||||
TileEntitySecureLootContainerRebirth tileEntitySecureLootContainer = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntitySecureLootContainerRebirth;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static string PropLootList = "LootList";
|
||||
protected static string PropLootStageMod = "LootStageMod";
|
||||
protected static string PropLootStageBonus = "LootStageBonus";
|
||||
protected static string PropLockPickTime = "LockPickTime";
|
||||
protected static string PropLockPickItem = "LockPickItem";
|
||||
protected static string PropLockPickBreakChance = "LockPickBreakChance";
|
||||
protected string lootList;
|
||||
protected float lockPickTime;
|
||||
protected string lockPickItem;
|
||||
protected float lockPickBreakChance;
|
||||
public float LootStageMod;
|
||||
public float LootStageBonus;
|
||||
public float TakeDelay = RebirthVariables.takeDelay;
|
||||
public string ReplacementBlockName = "FuriousRamsayLootGatherer";
|
||||
public int numBlocks = 1;
|
||||
public bool isReplacementItem = false;
|
||||
public bool isSecure = false;
|
||||
public bool isLootContainer = true;
|
||||
public bool canPickUpBlock = true;
|
||||
public GameRandom Random;
|
||||
public int autoLootTick = 10;
|
||||
}
|
||||
379
Scripts/Blocks/BlockSpawnEntityRebirth.cs
Normal file
379
Scripts/Blocks/BlockSpawnEntityRebirth.cs
Normal file
@@ -0,0 +1,379 @@
|
||||
public class BlockSpawnEntityRebirth : BlockMotionSensor
|
||||
{
|
||||
private int OwnerID = -1;
|
||||
private float _tickRate = 10UL;
|
||||
private int _maxSpawned = 1;
|
||||
private int _numberToSpawn = 1;
|
||||
private int _spawnRadius = 0;
|
||||
private int _spawnArea = 15;
|
||||
|
||||
private string _entityGroup = "";
|
||||
private string _signText = "";
|
||||
|
||||
private EntityAlive entityPlaced;
|
||||
|
||||
public override void OnBlockPlaceBefore(WorldBase _world, ref BlockPlacement.Result _bpResult, EntityAlive _ea, GameRandom _rnd)
|
||||
{
|
||||
entityPlaced = _ea;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
if (Properties.Values.ContainsKey("TickRate"))
|
||||
Properties.ParseFloat("TickRate", ref _tickRate);
|
||||
if (Properties.Values.ContainsKey("MaxSpawned"))
|
||||
Properties.ParseInt("MaxSpawned", ref _maxSpawned);
|
||||
if (Properties.Values.ContainsKey("NumberToSpawn"))
|
||||
Properties.ParseInt("NumberToSpawn", ref _numberToSpawn);
|
||||
if (Properties.Values.ContainsKey("SpawnRadius"))
|
||||
Properties.ParseInt("SpawnRadius", ref _spawnRadius);
|
||||
if (Properties.Values.ContainsKey("SpawnArea"))
|
||||
Properties.ParseInt("SpawnArea", ref _spawnArea);
|
||||
if (Properties.Values.ContainsKey("EntityGroup"))
|
||||
_entityGroup = Properties.Values["EntityGroup"];
|
||||
|
||||
if (Properties.Values.ContainsKey("Config"))
|
||||
_signText = Properties.Values["Config"];
|
||||
|
||||
}
|
||||
public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
public override bool CanPlaceBlockAt(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bOmitCollideCheck = false)
|
||||
{
|
||||
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
}
|
||||
|
||||
if (_blockPos.y > 253)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!GameManager.Instance.IsEditMode() && ((World)_world).IsWithinTraderArea(_blockPos))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Block block = _blockValue.Block;
|
||||
return (!block.isMultiBlock || _blockPos.y + block.multiBlockPos.dim.y < 254) && (GameManager.Instance.IsEditMode() || _bOmitCollideCheck || !this.overlapsWithOtherBlock(_world, _clrIdx, _blockPos, _blockValue));
|
||||
}
|
||||
|
||||
private bool overlapsWithOtherBlock(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
if (!this.isMultiBlock)
|
||||
{
|
||||
int type = _world.GetBlock(_clrIdx, _blockPos).type;
|
||||
return type != 0 && !Block.list[type].blockMaterial.IsGroundCover && !_world.IsWater(_blockPos);
|
||||
}
|
||||
byte rotation = _blockValue.rotation;
|
||||
for (int i = this.multiBlockPos.Length - 1; i >= 0; i--)
|
||||
{
|
||||
Vector3i pos = _blockPos + this.multiBlockPos.Get(i, _blockValue.type, (int)rotation);
|
||||
int type2 = _world.GetBlock(_clrIdx, pos).type;
|
||||
if (type2 != 0 && !Block.list[type2].blockMaterial.IsGroundCover && !_world.IsWater(pos))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnBlockAdded(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-OnBlockAdded _blockValue.rotation: " + _blockValue.rotation);
|
||||
|
||||
//Log.Out("BlockSpawnEntityRebirth-OnBlockAdded 1");
|
||||
base.OnBlockAdded(_world, _chunk, _blockPos, _blockValue);
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer) return;
|
||||
if (GameManager.Instance.IsEditMode()) return;
|
||||
|
||||
//Log.Out("BlockSpawnEntityRebirth-OnBlockAdded 2");
|
||||
var entityId = -1;
|
||||
var text = RebirthUtilities.GetValueFromKey(_signText, "ec");
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-OnBlockAdded 3");
|
||||
var group = RebirthUtilities.GetValueFromKey(_signText, "eg");
|
||||
if (string.IsNullOrEmpty(group))
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-OnBlockAdded 4");
|
||||
if (string.IsNullOrEmpty(_entityGroup))
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-OnBlockAdded 5");
|
||||
return;
|
||||
}
|
||||
group = _entityGroup;
|
||||
}
|
||||
var ClassID = 0;
|
||||
entityId = EntityGroups.GetRandomFromGroup(group, ref ClassID);
|
||||
if (entityId == 0) // Invalid group.
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-OnBlockAdded 6");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-OnBlockAdded 7");
|
||||
entityId = text.GetHashCode();
|
||||
}
|
||||
|
||||
// Match the rotation, and create the stub for the entity
|
||||
var entityCreationData = new EntityCreationData();
|
||||
entityCreationData.id = -1;
|
||||
entityCreationData.entityClass = entityId;
|
||||
entityCreationData.pos = _blockPos.ToVector3() + new Vector3(0.5f, 0.25f, 0.5f);
|
||||
|
||||
//Log.Out("BlockSpawnEntityRebirth-OnBlockAdded entityCreationData.rot.Y: " + entityCreationData.rot.y);
|
||||
|
||||
// We need to check if this is a block entity or not, and match the rotation of the entity to the block, in case its a model preview.
|
||||
var rotation = new Vector3(0f, (float)(45f * (_blockValue.rotation & 3)), 0f);
|
||||
//Log.Out("BlockSpawnEntityRebirth-OnBlockAdded flRotY: " + flRotY);
|
||||
|
||||
var blockEntity = _chunk.GetBlockEntity(_blockPos);
|
||||
if (blockEntity != null && blockEntity.bHasTransform)
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-OnBlockAdded 8");
|
||||
//Log.Out("BlockSpawnEntityRebirth-OnBlockAdded blockEntity != null");
|
||||
rotation = blockEntity.transform.rotation.eulerAngles;
|
||||
}
|
||||
|
||||
entityCreationData.rot = rotation;
|
||||
_chunk.AddEntityStub(entityCreationData);
|
||||
|
||||
//Log.Out("BlockSpawnEntityRebirth-OnBlockAdded entityCreationData.rot.Y 2: " + entityCreationData.rot.y);
|
||||
|
||||
// We'll use the Meta value as the spawn counter.
|
||||
_blockValue.meta = 0;
|
||||
GameManager.Instance.World.SetBlockRPC(_blockPos, _blockValue);
|
||||
|
||||
// Set up the tick delay to be pretty short, as we'll just destroy the block anyway.
|
||||
_world.GetWBT().AddScheduledBlockUpdate(0, _blockPos, blockID, (ulong)1UL);
|
||||
}
|
||||
|
||||
private void DestroySelf(Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
var keep = RebirthUtilities.GetValueFromKey(_signText, "keep");
|
||||
if (string.IsNullOrEmpty(keep))
|
||||
DamageBlock(GameManager.Instance.World, 0, _blockPos, _blockValue, Block.list[_blockValue.type].MaxDamage, -1, null, false);
|
||||
else
|
||||
GameManager.Instance.World.GetWBT().AddScheduledBlockUpdate(0, _blockPos, blockID, (ulong)10000UL);
|
||||
}
|
||||
|
||||
public void ApplySignData(EntityAlive entity, Vector3i _blockPos)
|
||||
{
|
||||
// Read the sign for expected values.
|
||||
var Task = RebirthUtilities.GetValueFromKey(_signText, "task");
|
||||
var Buff = RebirthUtilities.GetValueFromKey(_signText, "buff");
|
||||
var PathingCode = RebirthUtilities.GetValueFromKey(_signText, "pc");
|
||||
var setLeader = RebirthUtilities.GetValueFromKey(_signText, "leader");
|
||||
|
||||
if (Task.ToLower() == "stay")
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-ApplySignData SET TO STAY");
|
||||
entity.Buffs.SetCustomVar("CurrentOrder", (int)EntityUtilities.Orders.Stay);
|
||||
}
|
||||
if (Task.ToLower() == "wander")
|
||||
{
|
||||
entity.Buffs.AddBuff("buffOrderWander");
|
||||
}
|
||||
if (Task.ToLower() == "guard")
|
||||
{
|
||||
entity.Buffs.AddBuff("buffOrderGuard");
|
||||
}
|
||||
if (Task.ToLower() == "follow")
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-ApplySignData SET TO FOLLOW");
|
||||
entity.Buffs.SetCustomVar("CurrentOrder", (int)EntityUtilities.Orders.Follow);
|
||||
}
|
||||
|
||||
// Set up the pathing cube if available
|
||||
if (!string.IsNullOrEmpty(PathingCode))
|
||||
{
|
||||
if (StringParsers.TryParseFloat(PathingCode, out var pathingCode))
|
||||
entity.Buffs.SetCustomVar("PathingCode", pathingCode);
|
||||
}
|
||||
|
||||
// We are using the tile entity to transfer the owner ID from the client to the player.
|
||||
var tileEntity = GameManager.Instance.World.GetTileEntity(0, _blockPos) as TileEntityPoweredTrigger;
|
||||
if (tileEntity != null)
|
||||
{
|
||||
var persistentPlayerList = GameManager.Instance.GetPersistentPlayerList();
|
||||
var playerData = persistentPlayerList.GetPlayerData(tileEntity.GetOwner());
|
||||
if (playerData != null)
|
||||
OwnerID = playerData.EntityId;
|
||||
|
||||
// Set up ownership, but only after the entity is spawned.
|
||||
if (OwnerID > 0 && !string.IsNullOrEmpty(setLeader))
|
||||
{
|
||||
/*EntityUtilities.SetLeaderAndOwner(entity.entityId, (int)OwnerID, false);
|
||||
//npc.currentOrder = (int)EntityUtilities.Orders.Follow;
|
||||
|
||||
EntityPlayer player = entity.world.GetEntity(OwnerID) as EntityPlayer;
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
float NPCMode = player.Buffs.GetCustomVar("varNPCModMode");
|
||||
|
||||
if (NPCMode == 0)
|
||||
{
|
||||
entity.Buffs.AddBuff("buffNPCModFullControlMode");
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.Buffs.AddBuff("buffNPCModThreatControlMode");
|
||||
}
|
||||
}
|
||||
|
||||
RebirthManager.AddHire((int)OwnerID,
|
||||
entity.entityId,
|
||||
entity.EntityName,
|
||||
entity.EntityClass.entityClassName,
|
||||
entity.position,
|
||||
entity.rotation,
|
||||
new Vector3(0, 0, 0),
|
||||
new Vector3(0, 0, 0),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
true
|
||||
);
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool UpdateTick(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bRandomTick, ulong _ticksIfLoaded, GameRandom _rnd)
|
||||
{
|
||||
Vector3 myVector = new Vector3(1, 2, 1);
|
||||
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-UpdateTick 1");
|
||||
if (_blockValue.meta >= _maxSpawned)
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-UpdateTick 2");
|
||||
DestroySelf(_blockPos, _blockValue);
|
||||
return false;
|
||||
}
|
||||
var chunkCluster = _world.ChunkClusters[_clrIdx];
|
||||
if (chunkCluster == null)
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-UpdateTick 3");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((Chunk)chunkCluster.GetChunkFromWorldPos(_blockPos) == null)
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-UpdateTick 4");
|
||||
return false;
|
||||
}
|
||||
|
||||
var entityId = -1;
|
||||
var text = RebirthUtilities.GetValueFromKey(_signText, "ec");
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-UpdateTick 5");
|
||||
var group = RebirthUtilities.GetValueFromKey(_signText, "eg");
|
||||
if (string.IsNullOrEmpty(group))
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-UpdateTick 6");
|
||||
if (string.IsNullOrEmpty(_entityGroup))
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-UpdateTick 7");
|
||||
DestroySelf(_blockPos, _blockValue);
|
||||
return false;
|
||||
}
|
||||
group = _entityGroup;
|
||||
}
|
||||
|
||||
var ClassID = 0;
|
||||
entityId = EntityGroups.GetRandomFromGroup(group, ref ClassID);
|
||||
if (entityId == 0) // Invalid group.
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-UpdateTick 8");
|
||||
// Destroy the block after creating the entity.
|
||||
DestroySelf(_blockPos, _blockValue);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-UpdateTick 9");
|
||||
entityId = text.GetHashCode();
|
||||
}
|
||||
|
||||
// Match the rotation of the block for the entity, so it faces in the same direction.
|
||||
var transformPos = _blockPos.ToVector3() + new Vector3(0.5f, 0.25f, 0.5f);
|
||||
if (_spawnRadius > 0)
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-UpdateTick 10");
|
||||
var areaSize = new Vector3(_spawnArea, _spawnArea, _spawnArea);
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
if (!GameManager.Instance.World.FindRandomSpawnPointNearPosition(_blockPos, 15, out x, out y, out z, areaSize, true))
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-UpdateTick 11");
|
||||
return true;
|
||||
}
|
||||
transformPos.x = x;
|
||||
transformPos.y = y;
|
||||
transformPos.z = z;
|
||||
}
|
||||
// We need to check if this is a block entity or not, and match the rotation of the entity to the block, in case its a model preview.
|
||||
var rotation = new Vector3(0f, (float)(45f * (_blockValue.rotation & 3)), 0f);
|
||||
var blockEntity = ((Chunk)_world.GetChunkFromWorldPos(_blockPos)).GetBlockEntity(_blockPos);
|
||||
if (blockEntity != null && blockEntity.bHasTransform)
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-UpdateTick 12");
|
||||
rotation = blockEntity.transform.rotation.eulerAngles;
|
||||
}
|
||||
|
||||
var entity = EntityFactory.CreateEntity(entityId, transformPos, rotation) as EntityAlive;
|
||||
if (entity == null)
|
||||
{
|
||||
//Log.Out($"No entity created: {_signText}");
|
||||
return false;
|
||||
}
|
||||
entity.SetSpawnerSource(EnumSpawnerSource.StaticSpawner);
|
||||
GameManager.Instance.World.SpawnEntityInWorld(entity);
|
||||
|
||||
if (entity is EntityAliveV2)
|
||||
{
|
||||
ApplySignData(entity as EntityAlive, _blockPos);
|
||||
}
|
||||
|
||||
/*var tileEntity = GameManager.Instance.World.GetTileEntity(0, _blockPos) as TileEntityPoweredTrigger;
|
||||
if (tileEntity != null)
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-UpdateTick 13");
|
||||
var persistentPlayerList = GameManager.Instance.GetPersistentPlayerList();
|
||||
var playerData = persistentPlayerList.GetPlayerData(tileEntity.GetOwner());
|
||||
if (playerData != null)
|
||||
{
|
||||
//Log.Out("BlockSpawnEntityRebirth-UpdateTick 14");
|
||||
//entity.Buffs.SetCustomVar("Owner", playerData.EntityId);
|
||||
//entity.Buffs.SetCustomVar("Leader", playerData.EntityId);
|
||||
//entity.Buffs.SetCustomVar("$FR_NPC_Stay", 1);
|
||||
}
|
||||
}*/
|
||||
|
||||
_blockValue.meta++;
|
||||
GameManager.Instance.World.SetBlockRPC(_blockPos, _blockValue);
|
||||
}
|
||||
|
||||
//Log.Out("BlockSpawnEntityRebirth-UpdateTick 15");
|
||||
DestroySelf(_blockPos, _blockValue);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
65
Scripts/Blocks/BlockSpawnPoint.cs
Normal file
65
Scripts/Blocks/BlockSpawnPoint.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
public class BlockSpawnPoint : Block
|
||||
{
|
||||
private float TakeDelay = RebirthVariables.takeDelay;
|
||||
private int waterMax = 6;
|
||||
private bool canPickUpBlock = true;
|
||||
public ulong TickRate = 1200UL;
|
||||
|
||||
public override bool HasBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual void addTileEntity(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
TileEntitySpawnPoint tileEntity = new TileEntitySpawnPoint(_chunk);
|
||||
tileEntity.localChunkPos = World.toBlock(_blockPos);
|
||||
_chunk.AddTileEntity(tileEntity);
|
||||
//Log.Out("BlockSpawnPoint-addTileEntity _blockPos: " + _blockPos);
|
||||
}
|
||||
|
||||
protected virtual void removeTileEntity(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockSpawnPoint-removeTileEntity START");
|
||||
_chunk.RemoveTileEntityAt<TileEntitySpawnPoint>((World)world, World.toBlock(_blockPos));
|
||||
}
|
||||
|
||||
public override void OnBlockRemoved(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockSpawnPoint-OnBlockRemoved START");
|
||||
base.OnBlockRemoved(world, _chunk, _blockPos, _blockValue);
|
||||
TileEntitySpawnPoint tileEntity = world.GetTileEntity(_chunk.ClrIdx, _blockPos) as TileEntitySpawnPoint;
|
||||
if (tileEntity != null)
|
||||
{
|
||||
tileEntity.OnDestroy();
|
||||
}
|
||||
this.removeTileEntity(world, _chunk, _blockPos, _blockValue);
|
||||
}
|
||||
|
||||
public override void OnBlockAdded(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockSpawnPoint-OnBlockAdded START");
|
||||
base.OnBlockAdded(_world, _chunk, _blockPos, _blockValue);
|
||||
this.addTileEntity(_world, _chunk, _blockPos, _blockValue);
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
//Log.Out("BlockSpawnPoint-OnBlockAdded 1");
|
||||
return;
|
||||
}
|
||||
|
||||
if (GameManager.Instance.IsEditMode())
|
||||
{
|
||||
//Log.Out("BlockSpawnPoint-OnBlockAdded 2");
|
||||
return;
|
||||
}
|
||||
|
||||
_blockValue.meta = 0;
|
||||
}
|
||||
|
||||
public BlockSpawnPoint()
|
||||
{
|
||||
this.HasTileEntity = true;
|
||||
}
|
||||
|
||||
}
|
||||
198
Scripts/Blocks/BlockTakeDamage.cs
Normal file
198
Scripts/Blocks/BlockTakeDamage.cs
Normal file
@@ -0,0 +1,198 @@
|
||||
using Platform;
|
||||
using System.Globalization;
|
||||
|
||||
public class BlockTakeDamage : BlockDamage
|
||||
{
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
this.CanPickup = true;
|
||||
bool flag2 = this.Properties.Values.ContainsKey("TakeDelay");
|
||||
if (flag2)
|
||||
{
|
||||
this.TakeDelay = StringParsers.ParseFloat(this.Properties.Values["TakeDelay"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
bool flag3 = this.Properties.Values.ContainsKey("ShowBlockName");
|
||||
if (flag3)
|
||||
{
|
||||
StringParsers.TryParseBool(this.Properties.Values["ShowBlockName"], out this.showBlockName, 0, -1, true);
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("ReplacementBlockName"))
|
||||
{
|
||||
this.ReplacementBlockName = this.Properties.Values["ReplacementBlockName"];
|
||||
}
|
||||
bool flag4 = this.Properties.Values.ContainsKey("isReplacementItem");
|
||||
if (flag4)
|
||||
{
|
||||
StringParsers.TryParseBool(this.Properties.Values["isReplacementItem"], out this.isReplacementItem, 0, -1, true);
|
||||
}
|
||||
bool flag5 = this.Properties.Values.ContainsKey("numBlocks");
|
||||
if (flag5)
|
||||
{
|
||||
this.numBlocks = Int16.Parse(this.Properties.Values["numBlocks"]);
|
||||
}
|
||||
bool flag6 = this.Properties.Values.ContainsKey("canPickUpBlock");
|
||||
if (flag6)
|
||||
{
|
||||
StringParsers.TryParseBool(this.Properties.Values["canPickUpBlock"], out this.canPickUpBlock, 0, -1, true);
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
bool flag = this.showBlockName;
|
||||
string result;
|
||||
if (flag)
|
||||
{
|
||||
result = Localization.Get(_blockValue.Block.GetBlockName());
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void PlaceBlock(WorldBase _world, BlockPlacement.Result _result, EntityAlive _ea)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:PlaceBlock-Init");
|
||||
base.PlaceBlock(_world, _result, _ea);
|
||||
TileEntitySecureBlockRebirth tileEntitySecure = _world.GetTileEntity(_result.clrIdx, _result.blockPos) as TileEntitySecureBlockRebirth;
|
||||
if (tileEntitySecure != null)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:PlaceBlock-tileEntitySecure Not Null");
|
||||
tileEntitySecure.SetEmpty();
|
||||
if (_ea != null && _ea.entityType == EntityType.Player)
|
||||
{
|
||||
tileEntitySecure.bPlayerStorage = true;
|
||||
tileEntitySecure.SetOwner(PlatformManager.InternalLocalUserIdentifier);
|
||||
//Log.Out("BlockTakeBase:PlaceBlock-Owner Set");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnBlockAdded(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockAdded-Init");
|
||||
base.OnBlockAdded(_world, _chunk, _blockPos, _blockValue);
|
||||
if (_world.IsEditor())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_blockValue.ischild)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockAdded-ischild");
|
||||
return;
|
||||
}
|
||||
TileEntitySecureBlockRebirth tileEntity = _world.GetTileEntity(_chunk.ClrIdx, _blockPos) as TileEntitySecureBlockRebirth;
|
||||
if (tileEntity != null)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockAdded-tile entity exists");
|
||||
return;
|
||||
}
|
||||
//Log.Out("BlockTakeBase:OnBlockAdded-create tile entity");
|
||||
tileEntity = new TileEntitySecureBlockRebirth(_chunk);
|
||||
tileEntity.SetDisableModifiedCheck(true);
|
||||
tileEntity.localChunkPos = World.toBlock(_blockPos);
|
||||
tileEntity.SetLocked((_blockValue.meta & 4) > 0);
|
||||
tileEntity.SetDisableModifiedCheck(false);
|
||||
_chunk.AddTileEntity(tileEntity);
|
||||
}
|
||||
|
||||
public override bool OnBlockActivated(string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockActivated, Shape: " + this.shape.GetName());
|
||||
bool ischild = _blockValue.ischild;
|
||||
bool result = false;
|
||||
if (ischild)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockActivated-IsChild");
|
||||
Vector3i parentPos = _blockValue.Block.multiBlockPos.GetParentPos(_blockPos, _blockValue);
|
||||
BlockValue block = _world.GetBlock(parentPos);
|
||||
result = this.OnBlockActivated(_commandName, _world, _cIdx, parentPos, block, _player);
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntitySecureBlockRebirth tileEntitySecure = _world.GetTileEntity(_cIdx, _blockPos) as TileEntitySecureBlockRebirth;
|
||||
if (tileEntitySecure == null)
|
||||
{
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated 0");
|
||||
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, this.TakeDelay, null, ReplacementBlockName, numBlocks, isReplacementItem);
|
||||
result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockActivated-tileEntitySecure == null");
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttNotBelongsToYou"), string.Empty, "ui_denied", null);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//Log.Out("BlockTakeBase:OnBlockActivated-_commandName: " + _commandName);
|
||||
if (_commandName == this.cmds[0].text)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
else if (_commandName == this.cmds[1].text)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockActivated-_indexInBlockActivationCommands == 1");
|
||||
bool isOwner = tileEntitySecure.IsOwner(PlatformManager.InternalLocalUserIdentifier);
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated tileEntitySecure.ownerID: " + tileEntitySecure.ownerID);
|
||||
if (!isOwner)
|
||||
{
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated 1");
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated 2");
|
||||
if (tileEntitySecure.ownerID != null)
|
||||
{
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated 3");
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttNotBelongsToYou"), string.Empty, "ui_denied", null);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated 4");
|
||||
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, this.TakeDelay, null, ReplacementBlockName, numBlocks, isReplacementItem);
|
||||
}
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated 5");
|
||||
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, this.TakeDelay, null, ReplacementBlockName, numBlocks, isReplacementItem);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated 6");
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public override BlockActivationCommand[] GetBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
this.cmds[0].enabled = this.canPickUpBlock;
|
||||
this.cmds[1].enabled = this.canPickUpBlock;
|
||||
return this.cmds;
|
||||
}
|
||||
|
||||
private BlockActivationCommand[] cmds = new BlockActivationCommand[]
|
||||
{
|
||||
new BlockActivationCommand("cancel", "x", false, false),
|
||||
new BlockActivationCommand("take", "hand", false, false)
|
||||
};
|
||||
|
||||
private float TakeDelay = RebirthVariables.takeDelay;
|
||||
private bool showBlockName;
|
||||
private string ReplacementBlockName = "";
|
||||
private int numBlocks = 1;
|
||||
private bool isReplacementItem = false;
|
||||
public bool canPickUpBlock = true;
|
||||
|
||||
}
|
||||
191
Scripts/Blocks/BlockTakeMine.cs
Normal file
191
Scripts/Blocks/BlockTakeMine.cs
Normal file
@@ -0,0 +1,191 @@
|
||||
using Audio;
|
||||
using Platform;
|
||||
using System.Globalization;
|
||||
|
||||
public class BlockTakeMine : BlockMine
|
||||
{
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
bool flag2 = this.Properties.Values.ContainsKey("TakeDelay");
|
||||
if (flag2)
|
||||
{
|
||||
this.TakeDelay = StringParsers.ParseFloat(this.Properties.Values["TakeDelay"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
bool flag3 = this.Properties.Values.ContainsKey("ShowBlockName");
|
||||
if (flag3)
|
||||
{
|
||||
StringParsers.TryParseBool(this.Properties.Values["ShowBlockName"], out this.showBlockName, 0, -1, true);
|
||||
}
|
||||
bool flag4 = this.Properties.Values.ContainsKey("canPickUpBlock");
|
||||
if (flag4)
|
||||
{
|
||||
StringParsers.TryParseBool(this.Properties.Values["canPickUpBlock"], out this.canPickUpBlock, 0, -1, true);
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
bool flag = this.showBlockName;
|
||||
string result;
|
||||
if (flag)
|
||||
{
|
||||
result = Localization.Get(_blockValue.Block.GetBlockName());
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void PlaceBlock(WorldBase _world, BlockPlacement.Result _result, EntityAlive _ea)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:PlaceBlock-Init");
|
||||
base.PlaceBlock(_world, _result, _ea);
|
||||
TileEntitySecureBlockRebirth tileEntitySecure = _world.GetTileEntity(_result.clrIdx, _result.blockPos) as TileEntitySecureBlockRebirth;
|
||||
if (tileEntitySecure != null)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:PlaceBlock-tileEntitySecure Not Null");
|
||||
tileEntitySecure.SetEmpty();
|
||||
if (_ea != null && _ea.entityType == EntityType.Player)
|
||||
{
|
||||
tileEntitySecure.bPlayerStorage = true;
|
||||
tileEntitySecure.SetOwner(PlatformManager.InternalLocalUserIdentifier);
|
||||
//Log.Out("BlockTakeBase:PlaceBlock-Owner Set");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnBlockAdded(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockAdded-Init");
|
||||
base.OnBlockAdded(_world, _chunk, _blockPos, _blockValue);
|
||||
if (_world.IsEditor())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_blockValue.ischild)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockAdded-ischild");
|
||||
return;
|
||||
}
|
||||
TileEntitySecureBlockRebirth tileEntity = _world.GetTileEntity(_chunk.ClrIdx, _blockPos) as TileEntitySecureBlockRebirth;
|
||||
if (tileEntity != null)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockAdded-tile entity exists");
|
||||
return;
|
||||
}
|
||||
//Log.Out("BlockTakeBase:OnBlockAdded-create tile entity");
|
||||
tileEntity = new TileEntitySecureBlockRebirth(_chunk);
|
||||
tileEntity.SetDisableModifiedCheck(true);
|
||||
tileEntity.localChunkPos = World.toBlock(_blockPos);
|
||||
tileEntity.SetLocked((_blockValue.meta & 4) > 0);
|
||||
tileEntity.SetDisableModifiedCheck(false);
|
||||
_chunk.AddTileEntity(tileEntity);
|
||||
}
|
||||
|
||||
public override bool OnBlockActivated(string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockActivated, Shape: " + this.shape.GetName());
|
||||
bool ischild = _blockValue.ischild;
|
||||
bool result = false;
|
||||
if (ischild)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockActivated-IsChild");
|
||||
Vector3i parentPos = _blockValue.Block.multiBlockPos.GetParentPos(_blockPos, _blockValue);
|
||||
BlockValue block = _world.GetBlock(parentPos);
|
||||
result = this.OnBlockActivated(_commandName, _world, _cIdx, parentPos, block, _player);
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntitySecureBlockRebirth tileEntitySecure = _world.GetTileEntity(_cIdx, _blockPos) as TileEntitySecureBlockRebirth;
|
||||
if (tileEntitySecure == null)
|
||||
{
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockActivated 0");
|
||||
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, this.TakeDelay, null, ReplacementBlockName, numBlocks, isReplacementItem);
|
||||
result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockActivated-tileEntitySecure == null");
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttNotBelongsToYou"), string.Empty, "ui_denied", null);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//Log.Out("BlockTakeBase:OnBlockActivated-_commandName: " + _commandName);
|
||||
if (_commandName == this.cmds[0].text)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
else if (_commandName == this.cmds[1].text)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockActivated-_indexInBlockActivationCommands == 1");
|
||||
bool isOwner = tileEntitySecure.IsOwner(PlatformManager.InternalLocalUserIdentifier);
|
||||
|
||||
ProgressionValue progressionValue = _player.Progression.GetProgressionValue("perkInfiltrator");
|
||||
|
||||
//Log.Out("BlockTakeBase:OnBlockActivated-isOwner: " + isOwner);
|
||||
if (!isOwner && progressionValue != null && progressionValue.calculatedLevel < 3)
|
||||
{
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, this.TakeDelay, null, ReplacementBlockName, numBlocks, isReplacementItem);
|
||||
result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated 1");
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttNotBelongsToYou"), string.Empty, "ui_denied", null);
|
||||
result = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated 2");
|
||||
if (((World)_world).IsWithinTraderArea(_blockPos))
|
||||
{
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated 3");
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttBelongsToTrader"), string.Empty, "ui_denied", null);
|
||||
return false;
|
||||
}
|
||||
|
||||
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, this.TakeDelay, null, ReplacementBlockName, numBlocks, isReplacementItem);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated 4");
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public override BlockActivationCommand[] GetBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
this.cmds[0].enabled = this.canPickUpBlock;
|
||||
this.cmds[1].enabled = this.canPickUpBlock;
|
||||
return this.cmds;
|
||||
}
|
||||
|
||||
private BlockActivationCommand[] cmds = new BlockActivationCommand[]
|
||||
{
|
||||
new BlockActivationCommand("cancel", "x", false, false),
|
||||
new BlockActivationCommand("take", "hand", false, false)
|
||||
};
|
||||
|
||||
private float TakeDelay = RebirthVariables.takeDelay;
|
||||
private bool showBlockName;
|
||||
private string ReplacementBlockName = "";
|
||||
private int numBlocks = 1;
|
||||
private bool isReplacementItem = false;
|
||||
public bool canPickUpBlock = true;
|
||||
}
|
||||
549
Scripts/Blocks/BlockTakeSecureLootContainer.cs
Normal file
549
Scripts/Blocks/BlockTakeSecureLootContainer.cs
Normal file
@@ -0,0 +1,549 @@
|
||||
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;
|
||||
}
|
||||
198
Scripts/Blocks/BlockTakeTrap.cs
Normal file
198
Scripts/Blocks/BlockTakeTrap.cs
Normal file
@@ -0,0 +1,198 @@
|
||||
using Platform;
|
||||
using System.Globalization;
|
||||
|
||||
public class BlockTakeTrap : BlockTrunkTip
|
||||
{
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
this.CanPickup = true;
|
||||
bool flag2 = this.Properties.Values.ContainsKey("TakeDelay");
|
||||
if (flag2)
|
||||
{
|
||||
this.TakeDelay = StringParsers.ParseFloat(this.Properties.Values["TakeDelay"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
bool flag3 = this.Properties.Values.ContainsKey("ShowBlockName");
|
||||
if (flag3)
|
||||
{
|
||||
StringParsers.TryParseBool(this.Properties.Values["ShowBlockName"], out this.showBlockName, 0, -1, true);
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("ReplacementBlockName"))
|
||||
{
|
||||
this.ReplacementBlockName = this.Properties.Values["ReplacementBlockName"];
|
||||
}
|
||||
bool flag4 = this.Properties.Values.ContainsKey("isReplacementItem");
|
||||
if (flag4)
|
||||
{
|
||||
StringParsers.TryParseBool(this.Properties.Values["isReplacementItem"], out this.isReplacementItem, 0, -1, true);
|
||||
}
|
||||
bool flag5 = this.Properties.Values.ContainsKey("numBlocks");
|
||||
if (flag5)
|
||||
{
|
||||
this.numBlocks = Int16.Parse(this.Properties.Values["numBlocks"]);
|
||||
}
|
||||
bool flag6 = this.Properties.Values.ContainsKey("canPickUpBlock");
|
||||
if (flag6)
|
||||
{
|
||||
StringParsers.TryParseBool(this.Properties.Values["canPickUpBlock"], out this.canPickUpBlock, 0, -1, true);
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
bool flag = this.showBlockName;
|
||||
string result;
|
||||
if (flag)
|
||||
{
|
||||
result = Localization.Get(_blockValue.Block.GetBlockName());
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void PlaceBlock(WorldBase _world, BlockPlacement.Result _result, EntityAlive _ea)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:PlaceBlock-Init");
|
||||
base.PlaceBlock(_world, _result, _ea);
|
||||
TileEntitySecureBlockRebirth tileEntitySecure = _world.GetTileEntity(_result.clrIdx, _result.blockPos) as TileEntitySecureBlockRebirth;
|
||||
if (tileEntitySecure != null)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:PlaceBlock-tileEntitySecure Not Null");
|
||||
tileEntitySecure.SetEmpty();
|
||||
if (_ea != null && _ea.entityType == EntityType.Player)
|
||||
{
|
||||
tileEntitySecure.bPlayerStorage = true;
|
||||
tileEntitySecure.SetOwner(PlatformManager.InternalLocalUserIdentifier);
|
||||
//Log.Out("BlockTakeBase:PlaceBlock-Owner Set");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnBlockAdded(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockAdded-Init");
|
||||
base.OnBlockAdded(_world, _chunk, _blockPos, _blockValue);
|
||||
if (_world.IsEditor())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_blockValue.ischild)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockAdded-ischild");
|
||||
return;
|
||||
}
|
||||
TileEntitySecureBlockRebirth tileEntity = _world.GetTileEntity(_chunk.ClrIdx, _blockPos) as TileEntitySecureBlockRebirth;
|
||||
if (tileEntity != null)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockAdded-tile entity exists");
|
||||
return;
|
||||
}
|
||||
//Log.Out("BlockTakeBase:OnBlockAdded-create tile entity");
|
||||
tileEntity = new TileEntitySecureBlockRebirth(_chunk);
|
||||
tileEntity.SetDisableModifiedCheck(true);
|
||||
tileEntity.localChunkPos = World.toBlock(_blockPos);
|
||||
tileEntity.SetLocked((_blockValue.meta & 4) > 0);
|
||||
tileEntity.SetDisableModifiedCheck(false);
|
||||
_chunk.AddTileEntity(tileEntity);
|
||||
}
|
||||
|
||||
public override bool OnBlockActivated(string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockActivated, Shape: " + this.shape.GetName());
|
||||
bool ischild = _blockValue.ischild;
|
||||
bool result = false;
|
||||
if (ischild)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockActivated-IsChild");
|
||||
Vector3i parentPos = _blockValue.Block.multiBlockPos.GetParentPos(_blockPos, _blockValue);
|
||||
BlockValue block = _world.GetBlock(parentPos);
|
||||
result = this.OnBlockActivated(_commandName, _world, _cIdx, parentPos, block, _player);
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntitySecureBlockRebirth tileEntitySecure = _world.GetTileEntity(_cIdx, _blockPos) as TileEntitySecureBlockRebirth;
|
||||
if (tileEntitySecure == null)
|
||||
{
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated 0");
|
||||
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, this.TakeDelay, null, ReplacementBlockName, numBlocks, isReplacementItem);
|
||||
result = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockActivated-tileEntitySecure == null");
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttNotBelongsToYou"), string.Empty, "ui_denied", null);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//Log.Out("BlockTakeBase:OnBlockActivated-_commandName: " + _commandName);
|
||||
if (_commandName == this.cmds[0].text)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
else if (_commandName == this.cmds[1].text)
|
||||
{
|
||||
//Log.Out("BlockTakeBase:OnBlockActivated-_indexInBlockActivationCommands == 1");
|
||||
bool isOwner = tileEntitySecure.IsOwner(PlatformManager.InternalLocalUserIdentifier);
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated tileEntitySecure.ownerID: " + tileEntitySecure.ownerID);
|
||||
if (!isOwner)
|
||||
{
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated 1");
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated 2");
|
||||
if (tileEntitySecure.ownerID != null)
|
||||
{
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated 3");
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttNotBelongsToYou"), string.Empty, "ui_denied", null);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated 4");
|
||||
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, this.TakeDelay, null, ReplacementBlockName, numBlocks, isReplacementItem);
|
||||
}
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated 5");
|
||||
RebirthUtilities.TakeItemWithTimer(_world, _cIdx, _blockPos, _blockValue, _player, this.TakeDelay, null, ReplacementBlockName, numBlocks, isReplacementItem);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockTakeBase-OnBlockActivated 6");
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public override BlockActivationCommand[] GetBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
this.cmds[0].enabled = this.canPickUpBlock;
|
||||
this.cmds[1].enabled = this.canPickUpBlock;
|
||||
return this.cmds;
|
||||
}
|
||||
|
||||
private BlockActivationCommand[] cmds = new BlockActivationCommand[]
|
||||
{
|
||||
new BlockActivationCommand("cancel", "x", false, false),
|
||||
new BlockActivationCommand("take", "hand", false, false)
|
||||
};
|
||||
|
||||
private float TakeDelay = RebirthVariables.takeDelay;
|
||||
private bool showBlockName;
|
||||
private string ReplacementBlockName = "";
|
||||
private int numBlocks = 1;
|
||||
private bool isReplacementItem = false;
|
||||
public bool canPickUpBlock = true;
|
||||
|
||||
}
|
||||
138
Scripts/Blocks/BlockTempBlockRebirth.cs
Normal file
138
Scripts/Blocks/BlockTempBlockRebirth.cs
Normal file
@@ -0,0 +1,138 @@
|
||||
public class BlockTempBlockRebirth : Block
|
||||
{
|
||||
public int totalDuration = 0;
|
||||
|
||||
public override bool AllowBlockTriggers
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public BlockTempBlockRebirth()
|
||||
{
|
||||
this.HasTileEntity = true;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
}
|
||||
|
||||
protected virtual void addTileEntity(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
TileEntityTimedBlockRebirth tileTimedBlockPlot = new TileEntityTimedBlockRebirth(_chunk);
|
||||
tileTimedBlockPlot.localChunkPos = World.toBlock(_blockPos);
|
||||
tileTimedBlockPlot.duration = 0;
|
||||
_chunk.AddTileEntity(tileTimedBlockPlot);
|
||||
}
|
||||
|
||||
protected virtual void removeTileEntity(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
_chunk.RemoveTileEntityAt<TileEntityTimedBlockRebirth>((World)world, World.toBlock(_blockPos));
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
this.removeTileEntity(world, _chunk, _blockPos, _blockValue);
|
||||
}
|
||||
|
||||
public override void OnBlockAdded(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
base.OnBlockAdded(_world, _chunk, _blockPos, _blockValue);
|
||||
this.addTileEntity(_world, _chunk, _blockPos, _blockValue);
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer) return;
|
||||
if (GameManager.Instance.IsEditMode()) return;
|
||||
|
||||
_blockValue.meta = 0;
|
||||
|
||||
if (this.Properties.Values.ContainsKey("Duration"))
|
||||
{
|
||||
this.totalDuration = Int32.Parse(this.Properties.Values["Duration"]);
|
||||
}
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_chunk.ClrIdx, _blockPos, this.blockID, 20UL);
|
||||
}
|
||||
|
||||
public override bool UpdateTick(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bRandomTick, ulong _ticksIfLoaded, GameRandom _rnd)
|
||||
{
|
||||
TileEntityTimedBlockRebirth tileTimedBlockPlot = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityTimedBlockRebirth;
|
||||
if (tileTimedBlockPlot != null)
|
||||
{
|
||||
tileTimedBlockPlot.duration++;
|
||||
//Log.Out("BlockTimedBlockRebirth-UpdateTick _blockPos: " + _blockPos);
|
||||
//Log.Out("BlockTimedBlockRebirth-UpdateTick tileTimedBlockPlot.duration: " + tileTimedBlockPlot.duration);
|
||||
|
||||
if (tileTimedBlockPlot.duration < this.totalDuration)
|
||||
{
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, 20UL);
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockValue blockValue;
|
||||
|
||||
int posX = _blockPos.x;
|
||||
int posY = _blockPos.y;
|
||||
int posZ = _blockPos.z;
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(_blockPos);
|
||||
|
||||
//Log.Out("BlockTimedBlockRebirth-UpdateTick _blockValue.Block.GetBlockName()" + _blockValue.Block.GetBlockName());
|
||||
|
||||
if (_blockValue.Block.GetBlockName() == "FuriousRamsayTemporaryDefenseBlock:billboard")
|
||||
{
|
||||
//Log.Out("BlockTimedBlockRebirth-UpdateTick FuriousRamsayTemporaryDefenseBlock" + _blockPos);
|
||||
posX = _blockPos.x - 2;
|
||||
posY = _blockPos.y;
|
||||
posZ = _blockPos.z;
|
||||
blockValue = Block.GetBlockValue("air", true);
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
//Log.Out("BlockTimedBlockRebirth-UpdateTick posX, posY, posZ: " + posX + ", " + posY + ", " + posZ);
|
||||
|
||||
posX = _blockPos.x + 2;
|
||||
posY = _blockPos.y;
|
||||
posZ = _blockPos.z;
|
||||
blockValue = Block.GetBlockValue("air", true);
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
//Log.Out("BlockTimedBlockRebirth-UpdateTick posX, posY, posZ: " + posX + ", " + posY + ", " + posZ);
|
||||
|
||||
posX = _blockPos.x;
|
||||
posY = _blockPos.y;
|
||||
posZ = _blockPos.z - 2;
|
||||
blockValue = Block.GetBlockValue("air", true);
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
//Log.Out("BlockTimedBlockRebirth-UpdateTick posX, posY, posZ: " + posX + ", " + posY + ", " + posZ);
|
||||
|
||||
posX = _blockPos.x;
|
||||
posY = _blockPos.y;
|
||||
posZ = _blockPos.z + 2;
|
||||
blockValue = Block.GetBlockValue("air", true);
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
//Log.Out("BlockTimedBlockRebirth-UpdateTick posX, posY, posZ: " + posX + ", " + posY + ", " + posZ);
|
||||
}
|
||||
posX = _blockPos.x;
|
||||
posY = _blockPos.y;
|
||||
posZ = _blockPos.z;
|
||||
|
||||
blockValue = Block.GetBlockValue("air", true);
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, posX, posY, posZ, FastTags<TagGroup.Global>.none, false);
|
||||
_world.SetBlockRPC(_clrIdx, new Vector3i(posX, posY, posZ), blockValue);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
105
Scripts/Blocks/BlockTimedBlockRebirth.cs
Normal file
105
Scripts/Blocks/BlockTimedBlockRebirth.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
public class BlockTimedBlockRebirth : Block
|
||||
{
|
||||
public int totalDuration = 0;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
this.explosion = new ExplosionData(this.Properties);
|
||||
}
|
||||
|
||||
protected virtual void addTileEntity(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
TileEntityTimedBlockRebirth tileTimedBlockPlot = new TileEntityTimedBlockRebirth(_chunk);
|
||||
tileTimedBlockPlot.localChunkPos = World.toBlock(_blockPos);
|
||||
tileTimedBlockPlot.duration = 0;
|
||||
_chunk.AddTileEntity(tileTimedBlockPlot);
|
||||
}
|
||||
|
||||
protected virtual void removeTileEntity(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
_chunk.RemoveTileEntityAt<TileEntityTimedBlockRebirth>((World)world, World.toBlock(_blockPos));
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
this.removeTileEntity(world, _chunk, _blockPos, _blockValue);
|
||||
}
|
||||
|
||||
public override void OnBlockAdded(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
base.OnBlockAdded(_world, _chunk, _blockPos, _blockValue);
|
||||
this.addTileEntity(_world, _chunk, _blockPos, _blockValue);
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer) return;
|
||||
if (GameManager.Instance.IsEditMode()) return;
|
||||
|
||||
_blockValue.meta = 0;
|
||||
|
||||
if (this.Properties.Values.ContainsKey("Duration"))
|
||||
{
|
||||
this.totalDuration = Int32.Parse(this.Properties.Values["Duration"]);
|
||||
}
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_chunk.ClrIdx, _blockPos, this.blockID, 20UL);
|
||||
}
|
||||
|
||||
public override Block.DestroyedResult OnBlockDestroyedByExplosion(WorldBase _world, int _clrIdx, Vector3i _pos, BlockValue _blockValue, int _playerIdx)
|
||||
{
|
||||
if (_world.GetGameRandom().RandomFloat < 0.33f)
|
||||
{
|
||||
this.explode(_world, _clrIdx, _pos.ToVector3(), _playerIdx);
|
||||
return Block.DestroyedResult.Remove;
|
||||
}
|
||||
return Block.DestroyedResult.Keep;
|
||||
}
|
||||
|
||||
private void explode(WorldBase _world, int _clrIdx, Vector3 _pos, int _entityId)
|
||||
{
|
||||
ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx];
|
||||
if (chunkCluster != null)
|
||||
{
|
||||
//Log.Out("BlockTimedBlockRebirth-explode 1");
|
||||
_pos = chunkCluster.ToWorldPosition(_pos + new Vector3(0.5f, 0.5f, 0.5f));
|
||||
}
|
||||
//Log.Out("BlockTimedBlockRebirth-explode 2");
|
||||
_world.GetGameManager().ExplosionServer(_clrIdx, _pos, World.worldToBlockPos(_pos), Quaternion.identity, this.explosion, -1, 0.1f, true, null);
|
||||
}
|
||||
|
||||
public override bool UpdateTick(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bRandomTick, ulong _ticksIfLoaded, GameRandom _rnd)
|
||||
{
|
||||
TileEntityTimedBlockRebirth tileTimedBlockPlot = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityTimedBlockRebirth;
|
||||
if (tileTimedBlockPlot != null)
|
||||
{
|
||||
tileTimedBlockPlot.duration++;
|
||||
//Log.Out("BlockTimedBlockRebirth-UpdateTick _blockPos: " + _blockPos);
|
||||
//Log.Out("BlockTimedBlockRebirth-UpdateTick tileTimedBlockPlot.duration: " + tileTimedBlockPlot.duration);
|
||||
|
||||
if (tileTimedBlockPlot.duration < this.totalDuration)
|
||||
{
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, 20UL);
|
||||
}
|
||||
else if (tileTimedBlockPlot.duration >= this.totalDuration && tileTimedBlockPlot.duration < (this.totalDuration + 6))
|
||||
{
|
||||
GameManager.Instance.PlaySoundAtPositionServer(new Vector3((float)_blockPos.x, (float)_blockPos.y, (float)_blockPos.z), this.TriggerSound, 0, 5);
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, 20UL);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockTimedBlockRebirth-UpdateTick 3");
|
||||
this.explode(_world, _clrIdx, _blockPos.ToVector3(), -1);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected ExplosionData explosion;
|
||||
private string TriggerSound = "charge_beep";
|
||||
}
|
||||
277
Scripts/Blocks/BlockWaterTankRebirth.cs
Normal file
277
Scripts/Blocks/BlockWaterTankRebirth.cs
Normal file
@@ -0,0 +1,277 @@
|
||||
using Audio;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
public class BlockWaterTankRebirth : Block
|
||||
{
|
||||
private float TakeDelay = RebirthVariables.takeDelay;
|
||||
private int waterMax = 100;
|
||||
private bool canPickUpBlock = true;
|
||||
public ulong TickRate = 3000UL;
|
||||
|
||||
private BlockActivationCommand[] cmds = new BlockActivationCommand[]
|
||||
{
|
||||
new BlockActivationCommand("cancel", "x", false, false),
|
||||
new BlockActivationCommand("take", "hand", false)
|
||||
};
|
||||
|
||||
public override bool HasBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
//Log.Out("BlockWaterTankRebirth-Init START");
|
||||
base.Init();
|
||||
this.canPickUpBlock = true;
|
||||
bool flag = this.Properties.Values.ContainsKey("TakeDelay");
|
||||
if (flag)
|
||||
{
|
||||
this.TakeDelay = StringParsers.ParseFloat(this.Properties.Values["TakeDelay"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
bool flag2 = this.Properties.Values.ContainsKey("canPickUpBlock");
|
||||
if (flag2)
|
||||
{
|
||||
StringParsers.TryParseBool(this.Properties.Values["canPickUpBlock"], out this.canPickUpBlock, 0, -1, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void addTileEntity(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockWaterTankRebirth-addTileEntity START");
|
||||
TileEntityWaterTankRebirth tileEntityWaterTank = new TileEntityWaterTankRebirth(_chunk);
|
||||
tileEntityWaterTank.localChunkPos = World.toBlock(_blockPos);
|
||||
tileEntityWaterTank.waterCount = 0;
|
||||
tileEntityWaterTank.timeLapsed = RebirthUtilities.TotalGameSecondsPassed();
|
||||
_chunk.AddTileEntity(tileEntityWaterTank);
|
||||
}
|
||||
|
||||
protected virtual void removeTileEntity(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockWaterTankRebirth-removeTileEntity START");
|
||||
_chunk.RemoveTileEntityAt<TileEntityWaterTankRebirth>((World)world, World.toBlock(_blockPos));
|
||||
|
||||
/*int minMax = 100;
|
||||
List<Entity> entitiesInBounds = GameManager.Instance.World.GetEntitiesInBounds(typeof(EntityChunkObserver), BoundsUtils.BoundsForMinMax(_blockPos.x - minMax, _blockPos.y - 20, _blockPos.z - minMax, _blockPos.x + minMax, _blockPos.y + 20, _blockPos.z + minMax), new List<Entity>());
|
||||
|
||||
if (entitiesInBounds != null && entitiesInBounds.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < entitiesInBounds.Count; i++)
|
||||
{
|
||||
if (entitiesInBounds[i].EntityClass.entityClassName == "FuriousRamsayObserver")
|
||||
{
|
||||
var entity = entitiesInBounds[i] as EntityAlive;
|
||||
entity.bWillRespawn = false;
|
||||
GameManager.Instance.World.RemoveEntity(entity.entityId, EnumRemoveEntityReason.Unloaded);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public override void OnBlockRemoved(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockWaterTankRebirth-OnBlockRemoved START");
|
||||
base.OnBlockRemoved(world, _chunk, _blockPos, _blockValue);
|
||||
TileEntityWaterTankRebirth tileEntityWaterTank = world.GetTileEntity(_chunk.ClrIdx, _blockPos) as TileEntityWaterTankRebirth;
|
||||
if (tileEntityWaterTank != null)
|
||||
{
|
||||
tileEntityWaterTank.OnDestroy();
|
||||
}
|
||||
this.removeTileEntity(world, _chunk, _blockPos, _blockValue);
|
||||
}
|
||||
|
||||
public override void OnBlockAdded(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockWaterTankRebirth-OnBlockAdded START");
|
||||
base.OnBlockAdded(_world, _chunk, _blockPos, _blockValue);
|
||||
this.addTileEntity(_world, _chunk, _blockPos, _blockValue);
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer) return;
|
||||
if (GameManager.Instance.IsEditMode()) return;
|
||||
|
||||
_blockValue.meta = 0;
|
||||
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_chunk.ClrIdx, _blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
|
||||
public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
//Log.Out("BlockWaterTankRebirth-GetActivationText START");
|
||||
string activationText = Localization.Get("ttTankEmpty");
|
||||
|
||||
TileEntityWaterTankRebirth tileEntity = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityWaterTankRebirth;
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
if (tileEntity.waterCount > 0)
|
||||
{
|
||||
string color = "e3dc5b";
|
||||
string colorMax = "5ed680";
|
||||
|
||||
if (this.Properties.Values.ContainsKey("MaxWater"))
|
||||
{
|
||||
this.waterMax = Int16.Parse(this.Properties.Values["MaxWater"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.waterMax = tileEntity.waterMax;
|
||||
}
|
||||
|
||||
if (tileEntity.waterCount == this.waterMax)
|
||||
{
|
||||
color = colorMax;
|
||||
|
||||
}
|
||||
activationText = Localization.Get("ttWaterContent") + " [[" + color + "]" + tileEntity.waterCount + "[-]/[" + colorMax + "]" + this.waterMax + "[-]]";
|
||||
}
|
||||
}
|
||||
|
||||
return (activationText);
|
||||
}
|
||||
|
||||
public override bool OnBlockActivated(string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
//Log.Out("BlockWaterTankRebirth-OnBlockActivated START");
|
||||
bool ischild = _blockValue.ischild;
|
||||
bool result = false;
|
||||
|
||||
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
|
||||
{
|
||||
TileEntityWaterTankRebirth tileEntity = _world.GetTileEntity(_cIdx, _blockPos) as TileEntityWaterTankRebirth;
|
||||
if (tileEntity != null)
|
||||
{
|
||||
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 as EntityPlayerLocal, 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 BlockWaterTankRebirth()
|
||||
{
|
||||
this.HasTileEntity = true;
|
||||
}
|
||||
|
||||
public override BlockActivationCommand[] GetBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
//Log.Out("BlockWaterTankRebirth-GetBlockActivationCommands START");
|
||||
this.cmds[0].enabled = this.canPickUpBlock;
|
||||
this.cmds[1].enabled = this.canPickUpBlock;
|
||||
return this.cmds;
|
||||
}
|
||||
|
||||
public override bool UpdateTick(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bRandomTick, ulong _ticksIfLoaded, GameRandom _rnd)
|
||||
{
|
||||
TileEntityWaterTankRebirth tileEntity = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityWaterTankRebirth;
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
//Log.Out("BlockWaterTankRebirth-UpdateTick tileEntity.timeLapsed: " + tileEntity.timeLapsed);
|
||||
|
||||
int totalSecondsPassed = RebirthUtilities.TotalGameSecondsPassed();
|
||||
|
||||
int timeLapsed = (int)((totalSecondsPassed - tileEntity.timeLapsed) / 0.86f) + 1;
|
||||
|
||||
tileEntity.timeLapsed = totalSecondsPassed;
|
||||
|
||||
int cycle = (int)(this.TickRate / 20);
|
||||
|
||||
int numIterations = timeLapsed / cycle;
|
||||
|
||||
if (numIterations == 0 && totalSecondsPassed > (cycle / 2))
|
||||
{
|
||||
numIterations = 1;
|
||||
}
|
||||
|
||||
//Log.Out("BlockWaterTankRebirth-UpdateTick totalSecondsPassed: " + totalSecondsPassed);
|
||||
//Log.Out("BlockWaterTankRebirth-UpdateTick timeLapsed: " + timeLapsed);
|
||||
//Log.Out("BlockWaterTankRebirth-UpdateTick cycle: " + cycle);
|
||||
//Log.Out("BlockWaterTankRebirth-UpdateTick numIterations: " + numIterations);
|
||||
|
||||
for (int i = 0; i < numIterations; i++)
|
||||
{
|
||||
if (this.blockName == "FuriousRamsayDewCollector")
|
||||
{
|
||||
BiomeDefinition biomeAt = null;
|
||||
|
||||
if (!_world.IsEditor())
|
||||
{
|
||||
biomeAt = _world.ChunkCache.ChunkProvider.GetBiomeProvider().GetBiomeAt((int)_blockPos.x, (int)_blockPos.z);
|
||||
}
|
||||
|
||||
if (biomeAt != null)
|
||||
{
|
||||
System.Random rnd = new System.Random();
|
||||
int randomInt = rnd.Next(0, 100 + 1);
|
||||
int randomPerc = 0;
|
||||
|
||||
if (biomeAt.m_sBiomeName == "forest" || biomeAt.m_sBiomeName == "pine_forest")
|
||||
{
|
||||
//Log.Out("BlockWaterTankRebirth-UpdateTick FOREST");
|
||||
randomPerc = rnd.Next(80, 100 + 1);
|
||||
}
|
||||
else if (biomeAt.m_sBiomeName == "desert")
|
||||
{
|
||||
//Log.Out("BlockWaterTankRebirth-UpdateTick DESERT");
|
||||
randomPerc = rnd.Next(40, 60 + 1);
|
||||
}
|
||||
else if (biomeAt.m_sBiomeName == "snow")
|
||||
{
|
||||
//Log.Out("BlockWaterTankRebirth-UpdateTick SNOW");
|
||||
randomPerc = rnd.Next(40, 60 + 1);
|
||||
}
|
||||
else if (biomeAt.m_sBiomeName == "burnt_forest")
|
||||
{
|
||||
//Log.Out("BlockWaterTankRebirth-UpdateTick BURNT");
|
||||
randomPerc = rnd.Next(60, 80 + 1);
|
||||
}
|
||||
else if (biomeAt.m_sBiomeName == "wasteland")
|
||||
{
|
||||
//Log.Out("BlockWaterTankRebirth-UpdateTick WASTELAND");
|
||||
randomPerc = rnd.Next(40, 60 + 1);
|
||||
}
|
||||
|
||||
//Log.Out("BlockWaterTankRebirth-UpdateTick randomPerc: " + randomPerc);
|
||||
//Log.Out("BlockWaterTankRebirth-UpdateTick randomInt: " + randomInt);
|
||||
|
||||
if (randomPerc >= randomInt && tileEntity.waterCount < Int16.Parse(this.Properties.Values["MaxWater"]))
|
||||
{
|
||||
tileEntity.waterCount++;
|
||||
tileEntity.setModified();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, this.TickRate);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
457
Scripts/Blocks/BlockWorkstationRebirth.cs
Normal file
457
Scripts/Blocks/BlockWorkstationRebirth.cs
Normal file
@@ -0,0 +1,457 @@
|
||||
using Platform;
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
#nullable disable
|
||||
[Preserve]
|
||||
public class BlockWorkstationRebirth : BlockParticle
|
||||
{
|
||||
[PublicizedFrom(EAccessModifier.Protected)]
|
||||
public float TakeDelay;
|
||||
public WorkstationData WorkstationData;
|
||||
[PublicizedFrom(EAccessModifier.Private)]
|
||||
public string[] toolTransformNames;
|
||||
[PublicizedFrom(EAccessModifier.Protected)]
|
||||
public float CraftingParticleLightIntensity;
|
||||
[PublicizedFrom(EAccessModifier.Protected)]
|
||||
public new BlockActivationCommand[] cmds = new BlockActivationCommand[2]
|
||||
{
|
||||
new BlockActivationCommand("open", "campfire", true),
|
||||
new BlockActivationCommand("take", "hand", false)
|
||||
};
|
||||
|
||||
public BlockWorkstationRebirth() => this.HasTileEntity = true;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
//Log.Out("BlockWorkstation-Init START");
|
||||
base.Init();
|
||||
this.TakeDelay = 2f;
|
||||
this.Properties.ParseFloat("TakeDelay", ref this.TakeDelay);
|
||||
string optionalValue = "1,2,3";
|
||||
this.Properties.ParseString("Workstation.ToolNames", ref optionalValue);
|
||||
this.toolTransformNames = optionalValue.Split(',', StringSplitOptions.None);
|
||||
this.WorkstationData = new WorkstationData(this.GetBlockName(), this.Properties);
|
||||
CraftingManager.AddWorkstationData(this.WorkstationData);
|
||||
}
|
||||
|
||||
public override void OnBlockAdded(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockWorkstation-OnBlockAdded START");
|
||||
base.OnBlockAdded(world, _chunk, _blockPos, _blockValue);
|
||||
if (_blockValue.ischild)
|
||||
{
|
||||
//Log.Out("BlockWorkstation-OnBlockAdded IS CHILD");
|
||||
return;
|
||||
}
|
||||
TileEntityWorkstationRebirth _te = new TileEntityWorkstationRebirth(_chunk);
|
||||
_te.localChunkPos = World.toBlock(_blockPos);
|
||||
_chunk.AddTileEntity((TileEntity)_te);
|
||||
}
|
||||
|
||||
public override void OnBlockRemoved(
|
||||
WorldBase world,
|
||||
Chunk _chunk,
|
||||
Vector3i _blockPos,
|
||||
BlockValue _blockValue)
|
||||
{
|
||||
base.OnBlockRemoved(world, _chunk, _blockPos, _blockValue);
|
||||
|
||||
TileEntity tileEntity = world.GetTileEntity(_blockPos);
|
||||
|
||||
if (tileEntity is TileEntityWorkstationRebirth)
|
||||
{
|
||||
_chunk.RemoveTileEntityAt<TileEntityWorkstationRebirth>((World)world, World.toBlock(_blockPos));
|
||||
}
|
||||
else if (tileEntity is TileEntityWorkstation)
|
||||
{
|
||||
_chunk.RemoveTileEntityAt<TileEntityWorkstation>((World)world, World.toBlock(_blockPos));
|
||||
}
|
||||
}
|
||||
|
||||
public override void PlaceBlock(WorldBase _world, BlockPlacement.Result _result, EntityAlive _ea)
|
||||
{
|
||||
//Log.Out("BlockWorkstation-PlaceBlock START");
|
||||
base.PlaceBlock(_world, _result, _ea);
|
||||
TileEntityWorkstationRebirth tileEntity = (TileEntityWorkstationRebirth)_world.GetTileEntity(_result.blockPos);
|
||||
if (tileEntity == null)
|
||||
{
|
||||
//Log.Out("BlockWorkstation-PlaceBlock CANNOT FIND TILE ENTITY");
|
||||
return;
|
||||
}
|
||||
tileEntity.IsPlayerPlaced = true;
|
||||
tileEntity.SetOwner(PlatformManager.InternalLocalUserIdentifier);
|
||||
}
|
||||
|
||||
public override bool OnBlockActivated(
|
||||
WorldBase _world,
|
||||
int _cIdx,
|
||||
Vector3i _blockPos,
|
||||
BlockValue _blockValue,
|
||||
EntityPlayerLocal _player)
|
||||
{
|
||||
//Log.Out("BlockWorkstation-OnBlockActivated A START");
|
||||
|
||||
TileEntity tileEntity = _player.world.GetTileEntity(_blockPos);
|
||||
|
||||
if (!(tileEntity is TileEntityWorkstationRebirth ||
|
||||
tileEntity is TileEntityWorkstation))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_player.AimingGun = false;
|
||||
Vector3i worldPos = tileEntity.ToWorldPos();
|
||||
_world.GetGameManager().TELockServer(_cIdx, worldPos, tileEntity.entityId, _player.entityId);
|
||||
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) => 0;
|
||||
|
||||
[PublicizedFrom(EAccessModifier.Protected)]
|
||||
public override void checkParticles(
|
||||
WorldBase _world,
|
||||
int _clrIdx,
|
||||
Vector3i _blockPos,
|
||||
BlockValue _blockValue)
|
||||
{
|
||||
if (_blockValue.ischild)
|
||||
return;
|
||||
bool flag = GameManager.Instance.HasBlockParticleEffect(_blockPos);
|
||||
if (_blockValue.meta != (byte)0 && !flag)
|
||||
{
|
||||
this.addParticles(_world, _clrIdx, _blockPos.x, _blockPos.y, _blockPos.z, _blockValue);
|
||||
if ((double)this.CraftingParticleLightIntensity <= 0.0)
|
||||
return;
|
||||
this.UpdateVisible(_world, _blockPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(_blockValue.meta == (byte)0 & flag))
|
||||
return;
|
||||
this.removeParticles(_world, _blockPos.x, _blockPos.y, _blockPos.z, _blockValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsLit(BlockValue _blockValue) => _blockValue.meta > (byte)0;
|
||||
|
||||
public override string GetActivationText(
|
||||
WorldBase _world,
|
||||
BlockValue _blockValue,
|
||||
int _clrIdx,
|
||||
Vector3i _blockPos,
|
||||
EntityAlive _entityFocusing)
|
||||
{
|
||||
return Localization.Get("useWorkstation");
|
||||
}
|
||||
|
||||
public override bool OnBlockActivated(
|
||||
string _commandName,
|
||||
WorldBase _world,
|
||||
int _cIdx,
|
||||
Vector3i _blockPos,
|
||||
BlockValue _blockValue,
|
||||
EntityPlayerLocal _player)
|
||||
{
|
||||
//Log.Out("BlockWorkstation-OnBlockActivated B START");
|
||||
switch (_commandName)
|
||||
{
|
||||
case "open":
|
||||
return this.OnBlockActivated(_world, _cIdx, _blockPos, _blockValue, _player);
|
||||
case "take":
|
||||
this.TakeItemWithTimer(_cIdx, _blockPos, _blockValue, (EntityAlive)_player);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HasBlockActivationCommands(
|
||||
WorldBase _world,
|
||||
BlockValue _blockValue,
|
||||
int _clrIdx,
|
||||
Vector3i _blockPos,
|
||||
EntityAlive _entityFocusing)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override BlockActivationCommand[] GetBlockActivationCommands(
|
||||
WorldBase _world,
|
||||
BlockValue _blockValue,
|
||||
int _clrIdx,
|
||||
Vector3i _blockPos,
|
||||
EntityAlive _entityFocusing)
|
||||
{
|
||||
bool flag1 = _world.IsMyLandProtectedBlock(_blockPos, _world.GetGameManager().GetPersistentLocalPlayer());
|
||||
|
||||
TileEntity tileEntity = _world.GetTileEntity(_blockPos);
|
||||
|
||||
bool flag2 = false;
|
||||
bool flag3 = false;
|
||||
|
||||
if (tileEntity is TileEntityWorkstationRebirth)
|
||||
{
|
||||
TileEntityWorkstationRebirth tileEntityWS = (TileEntityWorkstationRebirth)tileEntity;
|
||||
if (tileEntity != null)
|
||||
{
|
||||
flag2 = tileEntityWS.IsPlayerPlaced;
|
||||
}
|
||||
|
||||
PersistentPlayerData playerData = _world.GetGameManager().GetPersistentPlayerList().GetPlayerData(tileEntityWS.GetOwner());
|
||||
|
||||
if (playerData != null)
|
||||
{
|
||||
flag3 = true;
|
||||
}
|
||||
}
|
||||
else if (tileEntity is TileEntityWorkstation)
|
||||
{
|
||||
TileEntityWorkstation tileEntityWS = (TileEntityWorkstation)tileEntity;
|
||||
if (tileEntity != null)
|
||||
{
|
||||
flag2 = tileEntityWS.IsPlayerPlaced;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("BlockWorkstationRebirth-GetBlockActivationCommands flag1: " + flag1);
|
||||
//Log.Out("BlockWorkstationRebirth-GetBlockActivationCommands flag2: " + flag2);
|
||||
//Log.Out("BlockWorkstationRebirth-GetBlockActivationCommands flag3: " + flag3);
|
||||
|
||||
this.cmds[1].enabled = flag3 || (flag1 & flag2 && (double)this.TakeDelay > 0.0);
|
||||
return this.cmds;
|
||||
}
|
||||
|
||||
[PublicizedFrom(EAccessModifier.Private)]
|
||||
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");
|
||||
else
|
||||
{
|
||||
TileEntity tileEntity = _player.world.GetTileEntity(_blockPos);
|
||||
|
||||
bool take = false;
|
||||
|
||||
if (tileEntity is TileEntityWorkstationRebirth)
|
||||
{
|
||||
TileEntityWorkstationRebirth tileEntityWS = (TileEntityWorkstationRebirth)tileEntity;
|
||||
if (!(GameManager.Instance.World.GetTileEntity(_blockPos) as TileEntityWorkstationRebirth).IsEmpty)
|
||||
{
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttWorkstationNotEmpty"), string.Empty, "ui_denied");
|
||||
}
|
||||
else
|
||||
{
|
||||
take = true;
|
||||
}
|
||||
}
|
||||
else if (tileEntity is TileEntityWorkstation)
|
||||
{
|
||||
TileEntityWorkstation tileEntityWS = (TileEntityWorkstation)tileEntity;
|
||||
if (!(GameManager.Instance.World.GetTileEntity(_blockPos) as TileEntityWorkstation).IsEmpty)
|
||||
{
|
||||
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttWorkstationNotEmpty"), string.Empty, "ui_denied");
|
||||
}
|
||||
else
|
||||
{
|
||||
take = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (take)
|
||||
{
|
||||
LocalPlayerUI playerUi = (_player as EntityPlayerLocal).PlayerUI;
|
||||
playerUi.windowManager.Open("timer", true);
|
||||
XUiC_Timer childByType = playerUi.xui.GetChildByType<XUiC_Timer>();
|
||||
TimerEventData _eventData = new TimerEventData();
|
||||
_eventData.Data = (object)new object[4]
|
||||
{
|
||||
(object) _cIdx,
|
||||
(object) _blockValue,
|
||||
(object) _blockPos,
|
||||
(object) _player
|
||||
};
|
||||
_eventData.Event += new TimerEventHandler(this.EventData_Event);
|
||||
childByType.SetTimer(this.TakeDelay, _eventData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[PublicizedFrom(EAccessModifier.Private)]
|
||||
public void EventData_Event(TimerEventData timerData)
|
||||
{
|
||||
World world = GameManager.Instance.World;
|
||||
object[] data = (object[])timerData.Data;
|
||||
int _clrIdx = (int)data[0];
|
||||
BlockValue blockValue = (BlockValue)data[1];
|
||||
Vector3i vector3i = (Vector3i)data[2];
|
||||
BlockValue block = world.GetBlock(vector3i);
|
||||
EntityPlayerLocal entityPlayerLocal = data[3] as EntityPlayerLocal;
|
||||
if (block.damage > 0)
|
||||
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get("ttRepairBeforePickup"), string.Empty, "ui_denied");
|
||||
else if (block.type != blockValue.type)
|
||||
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get("ttBlockMissingPickup"), string.Empty, "ui_denied");
|
||||
else
|
||||
{
|
||||
TileEntity tileEntity = entityPlayerLocal.world.GetTileEntity(vector3i);
|
||||
|
||||
bool proceeed = false;
|
||||
|
||||
if (tileEntity is TileEntityWorkstationRebirth)
|
||||
{
|
||||
TileEntityWorkstationRebirth tileEntityWS = (TileEntityWorkstationRebirth)tileEntity;
|
||||
|
||||
if (tileEntityWS.IsUserAccessing())
|
||||
{
|
||||
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get("ttCantPickupInUse"), string.Empty, "ui_denied");
|
||||
}
|
||||
else
|
||||
{
|
||||
proceeed = true;
|
||||
}
|
||||
}
|
||||
else if (tileEntity is TileEntityWorkstation)
|
||||
{
|
||||
TileEntityWorkstation tileEntityWS = (TileEntityWorkstation)tileEntity;
|
||||
|
||||
if (tileEntityWS.IsUserAccessing())
|
||||
{
|
||||
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get("ttCantPickupInUse"), string.Empty, "ui_denied");
|
||||
}
|
||||
else
|
||||
{
|
||||
proceeed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (proceeed)
|
||||
{
|
||||
LocalPlayerUI uiForPlayer = LocalPlayerUI.GetUIForPlayer(entityPlayerLocal);
|
||||
ItemStack itemStack = new ItemStack(block.ToItemValue(), 1);
|
||||
if (!uiForPlayer.xui.PlayerInventory.AddItem(itemStack))
|
||||
uiForPlayer.xui.PlayerInventory.DropItem(itemStack);
|
||||
world.SetBlockRPC(_clrIdx, vector3i, BlockValue.Air);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnBlockEntityTransformBeforeActivated(
|
||||
WorldBase _world,
|
||||
Vector3i _blockPos,
|
||||
BlockValue _blockValue,
|
||||
BlockEntityData _ebcd)
|
||||
{
|
||||
base.OnBlockEntityTransformBeforeActivated(_world, _blockPos, _blockValue, _ebcd);
|
||||
this.UpdateVisible(_world, _blockPos);
|
||||
}
|
||||
|
||||
public void UpdateVisible(WorldBase _world, Vector3i _blockPos)
|
||||
{
|
||||
TileEntity tileEntity = _world.GetTileEntity(_blockPos);
|
||||
|
||||
if (tileEntity is TileEntityWorkstationRebirth ||
|
||||
tileEntity is TileEntityWorkstation)
|
||||
{
|
||||
this.UpdateVisible(tileEntity);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateVisible(TileEntity tileEntity)
|
||||
{
|
||||
if (tileEntity is TileEntityWorkstationRebirth)
|
||||
{
|
||||
TileEntityWorkstationRebirth _te = (TileEntityWorkstationRebirth)tileEntity;
|
||||
|
||||
BlockEntityData blockEntity = _te.GetChunk().GetBlockEntity(_te.ToWorldPos());
|
||||
if (blockEntity == null)
|
||||
return;
|
||||
Transform transform1 = blockEntity.transform;
|
||||
if (!(bool)(UnityEngine.Object)transform1)
|
||||
return;
|
||||
ItemStack[] tools = _te.Tools;
|
||||
int num = Utils.FastMin(tools.Length, this.toolTransformNames.Length);
|
||||
for (int index = 0; index < num; ++index)
|
||||
{
|
||||
Transform transform2 = transform1.Find(this.toolTransformNames[index]);
|
||||
if ((bool)(UnityEngine.Object)transform2)
|
||||
transform2.gameObject.SetActive(!tools[index].IsEmpty());
|
||||
}
|
||||
Transform transform3 = transform1.Find("craft");
|
||||
if (!(bool)(UnityEngine.Object)transform3)
|
||||
return;
|
||||
bool isCrafting = _te.IsCrafting;
|
||||
transform3.gameObject.SetActive(isCrafting);
|
||||
if ((double)this.CraftingParticleLightIntensity <= 0.0)
|
||||
return;
|
||||
Transform blockParticleEffect = GameManager.Instance.GetBlockParticleEffect(_te.ToWorldPos());
|
||||
if ((bool)(UnityEngine.Object)blockParticleEffect)
|
||||
{
|
||||
Light componentInChildren = blockParticleEffect.GetComponentInChildren<Light>();
|
||||
if (!(bool)(UnityEngine.Object)componentInChildren)
|
||||
return;
|
||||
componentInChildren.intensity = isCrafting ? this.CraftingParticleLightIntensity : 1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isCrafting)
|
||||
return;
|
||||
_te.SetVisibleChanged();
|
||||
}
|
||||
}
|
||||
else if (tileEntity is TileEntityWorkstation)
|
||||
{
|
||||
TileEntityWorkstation _te = (TileEntityWorkstation)tileEntity;
|
||||
|
||||
BlockEntityData blockEntity = _te.GetChunk().GetBlockEntity(_te.ToWorldPos());
|
||||
if (blockEntity == null)
|
||||
return;
|
||||
Transform transform1 = blockEntity.transform;
|
||||
if (!(bool)(UnityEngine.Object)transform1)
|
||||
return;
|
||||
ItemStack[] tools = _te.Tools;
|
||||
int num = Utils.FastMin(tools.Length, this.toolTransformNames.Length);
|
||||
for (int index = 0; index < num; ++index)
|
||||
{
|
||||
Transform transform2 = transform1.Find(this.toolTransformNames[index]);
|
||||
if ((bool)(UnityEngine.Object)transform2)
|
||||
transform2.gameObject.SetActive(!tools[index].IsEmpty());
|
||||
}
|
||||
Transform transform3 = transform1.Find("craft");
|
||||
if (!(bool)(UnityEngine.Object)transform3)
|
||||
return;
|
||||
bool isCrafting = _te.IsCrafting;
|
||||
transform3.gameObject.SetActive(isCrafting);
|
||||
if ((double)this.CraftingParticleLightIntensity <= 0.0)
|
||||
return;
|
||||
Transform blockParticleEffect = GameManager.Instance.GetBlockParticleEffect(_te.ToWorldPos());
|
||||
if ((bool)(UnityEngine.Object)blockParticleEffect)
|
||||
{
|
||||
Light componentInChildren = blockParticleEffect.GetComponentInChildren<Light>();
|
||||
if (!(bool)(UnityEngine.Object)componentInChildren)
|
||||
return;
|
||||
componentInChildren.intensity = isCrafting ? this.CraftingParticleLightIntensity : 1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isCrafting)
|
||||
return;
|
||||
_te.SetVisibleChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
};
|
||||
}
|
||||
482
Scripts/Blocks/NPCs/BlockSpawnCompanionRebirth.cs
Normal file
482
Scripts/Blocks/NPCs/BlockSpawnCompanionRebirth.cs
Normal file
@@ -0,0 +1,482 @@
|
||||
using static RebirthManager;
|
||||
//using static RebirthManager;
|
||||
|
||||
public class BlockSpawnCompanionRebirth : BlockMotionSensor
|
||||
{
|
||||
private int OwnerID = -1;
|
||||
private float _tickRate = 10UL;
|
||||
private int _maxSpawned = 1;
|
||||
private int _numberToSpawn = 1;
|
||||
private int _spawnRadius = 0;
|
||||
private int _spawnArea = 15;
|
||||
private float _spawnScale = 1f;
|
||||
|
||||
private string _entityGroup = "";
|
||||
private string _signText = "";
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
if (Properties.Values.ContainsKey("TickRate"))
|
||||
Properties.ParseFloat("TickRate", ref _tickRate);
|
||||
if (Properties.Values.ContainsKey("MaxSpawned"))
|
||||
Properties.ParseInt("MaxSpawned", ref _maxSpawned);
|
||||
if (Properties.Values.ContainsKey("NumberToSpawn"))
|
||||
Properties.ParseInt("NumberToSpawn", ref _numberToSpawn);
|
||||
if (Properties.Values.ContainsKey("SpawnRadius"))
|
||||
Properties.ParseInt("SpawnRadius", ref _spawnRadius);
|
||||
if (Properties.Values.ContainsKey("SpawnArea"))
|
||||
Properties.ParseInt("SpawnArea", ref _spawnArea);
|
||||
if (Properties.Values.ContainsKey("EntityGroup"))
|
||||
_entityGroup = Properties.Values["EntityGroup"];
|
||||
if (Properties.Values.ContainsKey("SpawnScale"))
|
||||
Properties.ParseFloat("SpawnScale", ref _spawnScale);
|
||||
|
||||
if (Properties.Values.ContainsKey("Config"))
|
||||
_signText = Properties.Values["Config"];
|
||||
|
||||
}
|
||||
public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
public override bool CanPlaceBlockAt(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bOmitCollideCheck = false)
|
||||
{
|
||||
string restrictiveHire = RebirthVariables.customRestrictHires;
|
||||
|
||||
/*if (restrictiveHire == "nofollowers")
|
||||
{
|
||||
return false;
|
||||
}*/
|
||||
|
||||
//Log.Out("========================================================================================");
|
||||
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (primaryPlayer.Buffs.HasBuff("FuriousRamsayCompanionCooldown"))
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 1");
|
||||
return false;
|
||||
}
|
||||
|
||||
float flWitchDoctorLevel = RebirthUtilities.GetPerkLevel(primaryPlayer, "furiousramsayattwitchdoctor");
|
||||
float flBerserkerLevel = RebirthUtilities.GetPerkLevel(primaryPlayer, "furiousramsayattberserker");
|
||||
float charismaticNature = RebirthUtilities.GetPerkLevel(primaryPlayer, "perkCharismaticNature");
|
||||
|
||||
bool isActiveClass9 = RebirthUtilities.IsClassActive(9);
|
||||
bool isActiveClass10 = RebirthUtilities.IsClassActive(10);
|
||||
|
||||
if (!isActiveClass9 && _blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeHorrorPanther_FR")
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 2");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isActiveClass9 && _blockValue.Block.GetBlockName().Contains("FuriousRamsaySpawnCubeSkeleton"))
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 3");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isActiveClass10 && _blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeRagePanther_FR")
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 4");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isDog = false;
|
||||
bool isPanther = false;
|
||||
bool isSkeleton = false;
|
||||
bool isZombie = false;
|
||||
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt GetBlockName(): " + _blockValue.Block.GetBlockName());
|
||||
|
||||
if (_blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeHorrorPanther_FR" || _blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeRagePanther_FR")
|
||||
{
|
||||
isPanther = true;
|
||||
}
|
||||
|
||||
if (_blockValue.Block.GetBlockName().Contains("FuriousRamsaySpawnCubeSkeleton"))
|
||||
{
|
||||
isSkeleton = true;
|
||||
}
|
||||
|
||||
if (_blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeZombie007_FR")
|
||||
{
|
||||
isZombie = true;
|
||||
}
|
||||
|
||||
if (_blockValue.Block.GetBlockName() == "FuriousRamsaySpawnPantherCube001_FR" ||
|
||||
_blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeShepherdDog001_FR" ||
|
||||
_blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubePitbullDog001_FR" ||
|
||||
_blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeLabradorDog001_FR" ||
|
||||
_blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeHuskyDog001_FR" ||
|
||||
_blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeGoldenRetrieverDog001_FR" ||
|
||||
_blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeDobermanDog001_FR" ||
|
||||
_blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeDalmatianDog001_FR" ||
|
||||
_blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeBullTerrierDog001_FR"
|
||||
)
|
||||
{
|
||||
isDog = true;
|
||||
}
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 5");
|
||||
|
||||
int numDogCompanions = 0;
|
||||
int numWitchDoctorSkeletonCompanions = 0;
|
||||
int numWitchDoctorZombieCompanions = 0;
|
||||
int numWitchDoctorCompanions = 0;
|
||||
int numBerserkerCompanions = 0;
|
||||
|
||||
foreach (hireInfo hire in playerHires)
|
||||
{
|
||||
if (hire.playerID == primaryPlayer.entityId)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt hire.className: " + hire.className);
|
||||
|
||||
/*var companion = GameManager.Instance.World.GetEntity(hire.hireID) as EntityAlive;
|
||||
if (companion != null)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt companion.EntityClass.entityClassName: " + companion.EntityClass.entityClassName);
|
||||
|
||||
if (companion.EntityClass.entityClassName == "FuriousRamsayNPCHorrorPanther")
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD WD COMPANION");
|
||||
numWitchDoctorCompanions++;
|
||||
}
|
||||
|
||||
if (companion.EntityClass.entityClassName == "FuriousRamsayNPCRagePanther")
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD BK COMPANION");
|
||||
numBerserkerCompanions++;
|
||||
}
|
||||
|
||||
if (companion.EntityClass.entityClassName == "FuriousRamsaySkeleton1NoHireCore" ||
|
||||
companion.EntityClass.entityClassName == "FuriousRamsaySkeleton2NoHireCore" ||
|
||||
companion.EntityClass.entityClassName == "FuriousRamsaySkeleton3NoHireCore" ||
|
||||
companion.EntityClass.entityClassName == "FuriousRamsaySkeleton4NoHireCore" ||
|
||||
companion.EntityClass.entityClassName == "FuriousRamsaySkeleton5NoHireCore"
|
||||
)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD SK COMPANION");
|
||||
numWitchDoctorSkeletonCompanions++;
|
||||
}
|
||||
|
||||
if (companion.EntityClass.entityClassName == "FuriousRamsayZombie007a"
|
||||
)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD ZB COMPANION");
|
||||
numWitchDoctorZombieCompanions++;
|
||||
}
|
||||
|
||||
if (companion.EntityClass.entityClassName == "FuriousRamsayNPCPanther001_FR" ||
|
||||
companion.EntityClass.entityClassName == "FuriousRamsayNPCShepherd001_FR" ||
|
||||
companion.EntityClass.entityClassName == "FuriousRamsayNPCPitbull001_FR" ||
|
||||
companion.EntityClass.entityClassName == "FuriousRamsayNPCLabrador001_FR" ||
|
||||
companion.EntityClass.entityClassName == "FuriousRamsayNPCHusky001_FR" ||
|
||||
companion.EntityClass.entityClassName == "FuriousRamsayNPCGoldenRetriever001_FR" ||
|
||||
companion.EntityClass.entityClassName == "FuriousRamsayNPCDoberman001_FR" ||
|
||||
companion.EntityClass.entityClassName == "FuriousRamsayNPCDalmatian001_FR" ||
|
||||
companion.EntityClass.entityClassName == "FuriousRamsayNPCBullTerrier001_FR"
|
||||
)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD ANIMAL COMPANION");
|
||||
numDogCompanions++;
|
||||
}
|
||||
}*/
|
||||
if (hire.className == "FuriousRamsayNPCHorrorPanther")
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD WD COMPANION");
|
||||
numWitchDoctorCompanions++;
|
||||
}
|
||||
|
||||
if (hire.className == "FuriousRamsayNPCRagePanther")
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD BK COMPANION");
|
||||
numBerserkerCompanions++;
|
||||
}
|
||||
|
||||
if (hire.className == "FuriousRamsaySkeleton1NoHireCore" ||
|
||||
hire.className == "FuriousRamsaySkeleton2NoHireCore" ||
|
||||
hire.className == "FuriousRamsaySkeleton3NoHireCore" ||
|
||||
hire.className == "FuriousRamsaySkeleton4NoHireCore" ||
|
||||
hire.className == "FuriousRamsaySkeleton5NoHireCore"
|
||||
)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD SK COMPANION");
|
||||
numWitchDoctorSkeletonCompanions++;
|
||||
}
|
||||
|
||||
if (hire.className == "FuriousRamsayZombie007minion"
|
||||
)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD ZB COMPANION");
|
||||
numWitchDoctorZombieCompanions++;
|
||||
}
|
||||
|
||||
if (hire.className == "FuriousRamsayNPCPanther001_FR" ||
|
||||
hire.className == "FuriousRamsayNPCShepherd001_FR" ||
|
||||
hire.className == "FuriousRamsayNPCPitbull001_FR" ||
|
||||
hire.className == "FuriousRamsayNPCLabrador001_FR" ||
|
||||
hire.className == "FuriousRamsayNPCHusky001_FR" ||
|
||||
hire.className == "FuriousRamsayNPCGoldenRetriever001_FR" ||
|
||||
hire.className == "FuriousRamsayNPCDoberman001_FR" ||
|
||||
hire.className == "FuriousRamsayNPCDalmatian001_FR" ||
|
||||
hire.className == "FuriousRamsayNPCBullTerrier001_FR"
|
||||
)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD ANIMAL COMPANION");
|
||||
numDogCompanions++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt numWitchDoctorCompanions: " + numWitchDoctorCompanions);
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt numBerserkerCompanions: " + numBerserkerCompanions);
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt numWitchDoctorSkeletonCompanions: " + numWitchDoctorSkeletonCompanions);
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt numWitchDoctorZombieCompanions: " + numWitchDoctorZombieCompanions);
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt numDogCompanions: " + numDogCompanions);
|
||||
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt isDog: " + isDog);
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt isPanther: " + isPanther);
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt isSkeleton: " + isSkeleton);
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt isZombie: " + isZombie);
|
||||
|
||||
int numTotalCompanions = numDogCompanions + numWitchDoctorZombieCompanions + numWitchDoctorSkeletonCompanions + numBerserkerCompanions + numWitchDoctorCompanions;
|
||||
|
||||
if (numTotalCompanions >= charismaticNature + 1)
|
||||
{
|
||||
//if (restrictiveHire != "none" || (RebirthVariables.customScenario == "purge" && RebirthVariables.customRestrictCompanionHires != "none"))
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt Already at max number of companions, restrictiveHire: " + restrictiveHire);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isActiveClass9 && !isActiveClass10 && isPanther)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt Panther with no WitchDoctor or Berserker");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isActiveClass9 && (isSkeleton || isZombie))
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt Skeleton or Zombie with no WitchDoctor");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (numDogCompanions >= 3)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 1");
|
||||
//if (restrictiveHire != "none" || (RebirthVariables.customScenario == "purge" && RebirthVariables.customRestrictCompanionHires != "none"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isActiveClass9)
|
||||
{
|
||||
if (flWitchDoctorLevel < 5 && (numDogCompanions > 1) && (numWitchDoctorSkeletonCompanions + numWitchDoctorZombieCompanions + numWitchDoctorCompanions) == 1 && isPanther)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 2");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (flWitchDoctorLevel < 6 && (numDogCompanions > 1) && (numWitchDoctorSkeletonCompanions + numWitchDoctorZombieCompanions + numWitchDoctorCompanions) == 1 && isSkeleton)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 3a");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (flWitchDoctorLevel < 4 && isZombie)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 3b");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (flWitchDoctorLevel < 5 && numWitchDoctorCompanions == 1 && isPanther)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 3c");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (flWitchDoctorLevel < 6 && numWitchDoctorSkeletonCompanions == 1 && isSkeleton)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 3d");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (flWitchDoctorLevel < 7 && numWitchDoctorZombieCompanions == 1 && isZombie)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 3e");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (flWitchDoctorLevel < 7 && (numDogCompanions > 1) && (numWitchDoctorSkeletonCompanions + numWitchDoctorZombieCompanions + numWitchDoctorCompanions) == 1 && isZombie)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 3f");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (flWitchDoctorLevel < 5 && ((numWitchDoctorCompanions + numWitchDoctorZombieCompanions + numWitchDoctorSkeletonCompanions) >= 1) && !isDog)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 4");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (numDogCompanions + numWitchDoctorCompanions > 2)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 5");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (numWitchDoctorCompanions + numWitchDoctorSkeletonCompanions >= 2)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 6a");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (numWitchDoctorCompanions + numWitchDoctorZombieCompanions >= 2)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 6b");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (numWitchDoctorCompanions >= 2)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 7");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((numWitchDoctorZombieCompanions + numWitchDoctorSkeletonCompanions + numWitchDoctorCompanions + numDogCompanions) == 2 && (numDogCompanions < 2))
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 7a");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (numDogCompanions >= 2 && (isZombie || isSkeleton || isPanther))
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 7n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isActiveClass10)
|
||||
{
|
||||
if (flBerserkerLevel < 5 && numBerserkerCompanions == 1 && isPanther)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 8");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (numDogCompanions + numBerserkerCompanions > 2)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 9");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (numBerserkerCompanions >= 2)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 10");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (numDogCompanions >= 2 && isPanther)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 7n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_blockPos.y > 253)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 6");
|
||||
return false;
|
||||
}
|
||||
|
||||
Block block = _blockValue.Block;
|
||||
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt !block.isMultiBlock: " + !block.isMultiBlock);
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt _blockPos.y + block.multiBlockPos.dim.y < 254: " + (_blockPos.y + block.multiBlockPos.dim.y < 254));
|
||||
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt _bOmitCollideCheck: " + _bOmitCollideCheck);
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt !overlapsWithOtherBlock: " + !this.overlapsWithOtherBlock(_world, _clrIdx, _blockPos, _blockValue));
|
||||
|
||||
bool result = (!block.isMultiBlock || _blockPos.y + block.multiBlockPos.dim.y < 254) && (GameManager.Instance.IsEditMode() || _bOmitCollideCheck || !this.overlapsWithOtherBlock(_world, _clrIdx, _blockPos, _blockValue));
|
||||
|
||||
//Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt result: " + result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private bool overlapsWithOtherBlock(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
if (!this.isMultiBlock)
|
||||
{
|
||||
int type = _world.GetBlock(_clrIdx, _blockPos).type;
|
||||
return type != 0 && !Block.list[type].blockMaterial.IsGroundCover && !_world.IsWater(_blockPos);
|
||||
}
|
||||
byte rotation = _blockValue.rotation;
|
||||
for (int i = this.multiBlockPos.Length - 1; i >= 0; i--)
|
||||
{
|
||||
Vector3i pos = _blockPos + this.multiBlockPos.Get(i, _blockValue.type, (int)rotation);
|
||||
int type2 = _world.GetBlock(_clrIdx, pos).type;
|
||||
if (type2 != 0 && !Block.list[type2].blockMaterial.IsGroundCover && !_world.IsWater(pos))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void PlaceBlock(WorldBase _world, BlockPlacement.Result _result, EntityAlive _ea)
|
||||
{
|
||||
//Log.Out("BlockSpawnCompanionRebirth-PlaceBlock START");
|
||||
base.PlaceBlock(_world, _result, _ea);
|
||||
|
||||
int entityID = _ea.entityId;
|
||||
string strEntity = RebirthUtilities.GetValueFromKey(_signText, "ec"); ;
|
||||
int numEntities = 1;
|
||||
string strDistance = "";
|
||||
string entityPos = (_result.blockPos.ToVector3() + new Vector3(0.5f, 0.25f, 0.5f)).ToString();
|
||||
string entityRot = "";
|
||||
string strSpawner = "static";
|
||||
string strHeight = "";
|
||||
string strDirection = "";
|
||||
float numStartScale = _spawnScale;
|
||||
int numRotation = -1;
|
||||
bool randomRotation = true;
|
||||
bool atPlayerLevel = false;
|
||||
bool attackPlayer = false;
|
||||
int entityPlayerID = _ea.entityId;
|
||||
int minion = 1;
|
||||
string strSound = "";
|
||||
int maxEntities = 20;
|
||||
int checkMaxEntities = 0;
|
||||
int minMax = 40;
|
||||
int repeat = 1;
|
||||
int allNames = 1;
|
||||
int isBoss = -1;
|
||||
int handParticle = -1;
|
||||
string lootListName = "";
|
||||
string lootDropClass = "";
|
||||
int lootDropChance = 1;
|
||||
string navIcon = "";
|
||||
string buffList = "";
|
||||
bool forceRespawn = false;
|
||||
|
||||
//Log.Out("BlockSpawnCompanionRebirth-PlaceBlock numStartScale: " + numStartScale);
|
||||
|
||||
var rotation = new Vector3(0f, (float)(90f * (_result.blockValue.rotation & 3)), 0f);
|
||||
|
||||
entityRot = rotation.ToString();
|
||||
|
||||
EntityNPCRebirth entity = (EntityNPCRebirth)RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, entityPos, entityRot, strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList, false, forceRespawn);
|
||||
|
||||
DamageBlock(GameManager.Instance.World, 0, _result.blockPos, _result.blockValue, Block.list[_result.blockValue.type].MaxDamage, -1, null, false, false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user