private void RemoveScript(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockEntityData _ebcd) { if (_world.IsRemote()) { return; } if (_ebcd == null) { _ebcd = _world.ChunkClusters[_clrIdx].GetBlockEntity(_blockPos); } if (_ebcd == null || _ebcd.transform == null) { return; } GameObject = _ebcd.transform.gameObject; if (GameObject == null) { return; } Script = GameObject.GetComponent <MortSpawnerScript>(); if (Script == null) { return; } Script.KillScript(); }
private void AddScript(WorldBase _world, Vector3i _blockPos, BlockEntityData _ebcd) { if (_world.IsRemote()) { return; } if (_ebcd == null) { _ebcd = _world.ChunkClusters[0].GetBlockEntity(_blockPos); } if (_ebcd == null || _ebcd.transform == null) { return; } GameObject = _ebcd.transform.gameObject; if (GameObject == null) { return; } Script = GameObject.GetComponent <MortSpawnerScript>() ?? GameObject.AddComponent <MortSpawnerScript>(); Script.Initialize(_world, _blockPos); }
private void AddScript(WorldBase _world, Vector3i _blockPos, BlockEntityData _ebcd) { if (_world.IsRemote()) { return; } if (GameManager.Instance.IsEditMode()) { //Log.Out("BlockMortSpawner::AddScript - Cancelled due to Edit mode enabled."); return; } if (_ebcd == null) { _ebcd = _world.ChunkClusters[0].GetBlockEntity(_blockPos); } if (_ebcd == null || _ebcd.transform == null) { return; } GameObject = _ebcd.transform.gameObject; if (GameObject == null) { return; } Script = GameObject.GetComponent <MortSpawnerScript>() ?? GameObject.AddComponent <MortSpawnerScript>(); Script.Initialize(_world, _blockPos); }
public static bool IsBlockPoweredUp(Vector3i _blockPos, int _clrIdx) { WorldBase world = GameManager.Instance.World; if (world.IsRemote()) { //Use HasActivePower power instead since directly powering blocks doesnt work on servers. return(BlockHydroponicFarmPower.HasActivePower(world, _clrIdx, _blockPos)); } TileEntityPowered tileEntityPowered = (TileEntityPowered)GameManager.Instance.World.GetTileEntity(_clrIdx, _blockPos); if (tileEntityPowered != null) { if (tileEntityPowered.IsPowered) { DebugMsg("Block Power Is On"); return(true); } } if (BlockHydroponicFarmPower.IsSpRemotePowerAllowed(_blockPos)) { DebugMsg("No direct power found, checking for remote power"); return(BlockHydroponicFarmPower.HasActivePower(world, _clrIdx, _blockPos)); } DebugMsg("Block Power Is Off"); return(false); }
public void OnBlockAdded(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue) { if (!autostart) { return; } if (dt > 0) { if (_blockValue.type == this.Block.blockID && !_world.IsRemote()) { _world.GetWBT().AddScheduledBlockUpdate(0, _blockPos, Block.blockID, dt); } } }