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 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.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((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.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.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.Instance.SendPackage(NetPackageManager.GetPackage().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.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.Instance.SendPackage(NetPackageManager.GetPackage().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.Instance.SendPackage(NetPackageManager.GetPackage().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.Instance.SendPackage(NetPackageManager.GetPackage().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.Instance.SendPackage(NetPackageManager.GetPackage().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.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; } }