public void GetWorkstationBlockRenderers() { Vector3i workstationBlockPos = blockPos; workstationBlockPos.y += 1; Chunk workstationBlockChunk = (Chunk)GameManager.Instance.World.GetChunkFromWorldPos(workstationBlockPos); if (workstationBlockChunk != null) { BlockEntityData workstationBlockEntityData = workstationBlockChunk.GetBlockEntity(workstationBlockPos); if (workstationBlockEntityData != null) { workstationBlockRenderers = workstationBlockEntityData.transform.gameObject.GetComponentsInChildren <Renderer>(); foreach (Renderer rend in workstationBlockRenderers) { rend.material.EnableKeyword("_EMISSION"); rend.material.SetColor("_EmissionColor", new Color(0, 0, 0)); } } } }
private void CheckParticles(BlockEntityData _ebcd) { var particleAction = "None"; if (Properties.Values.ContainsKey(PropParticleAction)) { particleAction = Properties.Values[PropParticleAction]; } if (particleAction == "None") { return; } var setState = particleAction == "Start"; if (_ebcd == null || !_ebcd.bHasTransform) { return; } var componentsInChildren = _ebcd.transform.GetComponentsInChildren <Transform>(true); if (componentsInChildren == null) { return; } foreach (var transform in componentsInChildren) { if (transform.name != "particles") { continue; } transform.gameObject.SetActive(setState); break; } }
public override bool OnBlockActivated(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, EntityAlive _player) { BlockEntityData _ebcd = _world.ChunkClusters[_clrIdx].GetBlockEntity(_blockPos); if (!BlockCCTVScreen.Screen0(_blockValue.meta) && !BlockCCTVScreen.Screen1(_blockValue.meta) && !BlockCCTVScreen.Screen2(_blockValue.meta) && !BlockCCTVScreen.Screen3(_blockValue.meta)) { return(false); } else { screen0Mesh.enabled = false; screen1Mesh.enabled = false; screen2Mesh.enabled = false; screen3Mesh.enabled = false; _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 0)); _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 1)); _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 2)); _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 3)); _world.SetBlockRPC(_blockPos, _blockValue); ForceScreens(_blockPos, _blockValue, _ebcd); return(false); } }
// Display custom messages for turning on and off the music box, based on the block's name. public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing) { #region GetActivationText PlayerActionsLocal playerInput = ((EntityPlayerLocal)_entityFocusing).playerInput; string keybindString = playerInput.Activate.GetBindingXuiMarkupString(XUiUtils.EmptyBindingStyle.EmptyString, XUiUtils.DisplayStyle.Plain) + playerInput.PermanentActions.Activate.GetBindingXuiMarkupString(XUiUtils.EmptyBindingStyle.EmptyString, XUiUtils.DisplayStyle.Plain); //string keybindString = UIUtils.GetKeybindString(playerInput.Activate, playerInput.PermanentActions.Activate); Block block = Block.list[_blockValue.type]; string blockName = block.GetBlockName(); string strReturn = string.Format(Localization.Get("pickupPrompt"), Localization.Get(blockName)); BlockEntityData _ebcd = _world.GetChunkFromWorldPos(_blockPos).GetBlockEntity(_blockPos); if (_ebcd != null && _ebcd.transform) { MusicBoxScript myMusicBoxScript = _ebcd.transform.GetComponent <MusicBoxScript>(); if (myMusicBoxScript == null) { myMusicBoxScript = _ebcd.transform.gameObject.AddComponent <MusicBoxScript>(); myMusicBoxScript.enabled = false; } if (myMusicBoxScript) { if (myMusicBoxScript.enabled) { strReturn = string.Format(Localization.Get("musicbox_turnOff") + this.GetBlockName(), keybindString); } else { strReturn = string.Format(Localization.Get("musicbox_turnOn") + this.GetBlockName(), keybindString); } } } return(strReturn); #endregion }
public override void OnBlockEntityTransformBeforeActivated(WorldBase _world, Vector3i _blockPos, int _cIdx, BlockValue _blockValue, BlockEntityData _ebcd) { base.OnBlockEntityTransformBeforeActivated(_world, _blockPos, _cIdx, _blockValue, _ebcd); if (_blockValue.ischild) { return; } // Try to rehide the dummy boat mesh in case it got visible again HideBlockMeshes(_world, _blockPos, _cIdx, _ebcd); DestroyOrphanBlock(_cIdx, _blockPos); }
public override void OnBlockEntityTransformBeforeActivated(WorldBase _world, Vector3i _blockPos, int _cIdx, BlockValue _blockValue, BlockEntityData _ebcd) { LoadScript3(_ebcd, _blockPos, _blockValue); this.shape.OnBlockEntityTransformBeforeActivated(_world, _blockPos, _cIdx, _blockValue, _ebcd); }
public override void OnBlockEntityTransformBeforeActivated(WorldBase _world, Vector3i _blockPos, int _cIdx, BlockValue _blockValue, BlockEntityData _ebcd) { this.shape.OnBlockEntityTransformBeforeActivated(_world, _blockPos, _cIdx, _blockValue, _ebcd); DebugMsg("BlockMiner.OnBlockEntityTransformBeforeActivated"); try { if (_ebcd != null && _ebcd.bHasTransform) { GameObject gameObject = _ebcd.transform.gameObject; MinerControl healingPodControlScript = gameObject.GetComponent <MinerControl>(); if (healingPodControlScript == null) { healingPodControlScript = gameObject.AddComponent <MinerControl>(); } healingPodControlScript.enabled = true; healingPodControlScript.cIdx = _cIdx; healingPodControlScript.blockPos = _blockPos; healingPodControlScript.soundStart = soundStart; healingPodControlScript.soundRepeat = soundRepeat; healingPodControlScript.soundEnd = soundEnd; } else { DebugMsg("ERROR: _ebcd null (BlockMiner.OnBlockEntityTransformBeforeActivated)"); } } catch (Exception ex) { DebugMsg("Error Message: " + ex.ToString()); } }
public override void OnBlockEntityTransformAfterActivated(WorldBase _world, Vector3i _blockPos, int _cIdx, BlockValue _blockValue, BlockEntityData _ebcd) { var controller = GetStorageWindowController(); if (controller != null) { var tileEntity = _world.GetTileEntity(_cIdx, _blockPos); controller.SetTileEntity(tileEntity as TileEntitySecureLootContainer); controller.OnBlockEntityTransformAfterActivated(tileEntity.ToWorldPos().ToString()); } base.OnBlockEntityTransformAfterActivated(_world, _blockPos, _cIdx, _blockValue, _ebcd); }
// Play the music when its activated. We stop the sound broadcasting, in case they want to restart it again; otherwise we can get two sounds playing. public override bool OnBlockActivated(int _indexInBlockActivationCommands, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityAlive _player) { #region OnBlockActivated // If there's no transform, no sense on keeping going for this class. BlockEntityData _ebcd = _world.GetChunkFromWorldPos(_blockPos).GetBlockEntity(_blockPos); if (_ebcd == null || _ebcd.transform == null) { return(false); } MusicBoxScript myMusicBoxScript = _ebcd.transform.GetComponent <MusicBoxScript>(); if (myMusicBoxScript == null) { myMusicBoxScript = _ebcd.transform.gameObject.AddComponent <MusicBoxScript>(); } bool bRuntimeSwitch = myMusicBoxScript.enabled; // Turn off the music box before we do anything with it. myMusicBoxScript.enabled = false; if (_indexInBlockActivationCommands != 0) { if (_indexInBlockActivationCommands == 1) { base.OnBlockActivated(_world, _cIdx, _blockPos, _blockValue, _player); } if (_indexInBlockActivationCommands == 2) { TakeItemWithTimer(_cIdx, _blockPos, _blockValue, _player); } } else { bRuntimeSwitch = !bRuntimeSwitch; // Check if we have an animator and set it myMusicBoxScript.anim = _ebcd.transform.GetComponent <Animator>(); // Check if we have a video player as well. myMusicBoxScript.videoPlayer = _ebcd.transform.GetComponent <VideoPlayer>(); myMusicBoxScript.myBlockPos = _blockPos; // If the switch is on, then we want to look in the loot container to find a reference to any potential items, // which will over-ride the default audio clip / video clip. if (bRuntimeSwitch) { // We'll try to support getting sounds from multiple sound data nodes, based on all the items in the loot container. List <String> mySounds = new List <String>(); List <String> myVideos = new List <String>(); TileEntityLootContainer tileLootContainer = (TileEntityLootContainer)_world.GetTileEntity(_cIdx, _blockPos); if (tileLootContainer.items != null) { ItemStack[] array = tileLootContainer.items; for (int i = 0; i < array.Length; i++) { if (array[i].IsEmpty()) { continue; } // Check for a SoundDataNode for a potential sound clip. if (array[i].itemValue.ItemClass.Properties.Values.ContainsKey("SoundDataNode")) { String strSound = array[i].itemValue.ItemClass.Properties.Values["SoundDataNode"]; if (!mySounds.Contains(strSound)) { mySounds.Add(strSound); } } // Check for a video Source for a video clip. If we find it, load the asset and add it to the music box script. if (array[i].itemValue.ItemClass.Properties.Values.ContainsKey("VideoSource")) { // Check if the video source is an asset bundle, and if so, load it directly into the video clip on String strVideo = array[i].itemValue.ItemClass.Properties.Values["VideoSource"]; if (strVideo.IndexOf('#') == 0 && strVideo.IndexOf('?') > 0) { if (!myVideos.Contains(strVideo)) { myVideos.Add(strVideo); } } } } } // Initialize the data with our defaults. myMusicBoxScript.strAudioSource = this.strAudioSource; myMusicBoxScript.strSoundSource = this.strSoundSource; myMusicBoxScript.strVideoSource = this.strVideoSource; myMusicBoxScript.myEntity = _player; // List of Videos and Sound clips. myMusicBoxScript.VideoGroups = myVideos; myMusicBoxScript.SoundGroups = mySounds; myMusicBoxScript.myVideoClip = null; myMusicBoxScript.enabled = bRuntimeSwitch; } } return(false); #endregion }
public override void OnBlockEntityTransformBeforeActivated(WorldBase _world, Vector3i _blockPos, int _cIdx, BlockValue _blockValue, BlockEntityData _ebcd) { this.shape.OnBlockEntityTransformBeforeActivated(_world, _blockPos, _cIdx, _blockValue, _ebcd); DebugMsg("OnBlockEntityTransformBeforeActivated"); try { if (_ebcd != null && _ebcd.bHasTransform) { GameObject gameObject = _ebcd.transform.gameObject; if (LitObject() == null) { DebugMsg("LitObject is null!"); } GameObject litSignObject = _ebcd.transform.Find(LitObject()).gameObject; if (litSignObject == null) { DebugMsg("litSignObject is null"); } else { DebugMsg("Found litSignObject"); } NeonSignControl neonSignScript = gameObject.GetComponent <NeonSignControl>(); if (neonSignScript == null) { neonSignScript = gameObject.AddComponent <NeonSignControl>(); } neonSignScript.enabled = true; neonSignScript.cIdx = _cIdx; neonSignScript.blockPos = _blockPos; neonSignScript.litSignObject = litSignObject; neonSignScript.litSignObject.active = false; } else { DebugMsg("ERROR: _ebcd null (OnBlockEntityTransformBeforeActivated)"); } } catch (Exception ex) { DebugMsg("Error Message: " + ex.ToString()); } }
public override void OnBlockEntityTransformAfterActivated(WorldBase _world, Vector3i _blockPos, int _cIdx, BlockValue _blockValue, BlockEntityData _ebcd) { base.OnBlockEntityTransformAfterActivated(_world, _blockPos, _cIdx, _blockValue, _ebcd); SetTag(_ebcd.transform, _ebcd.transform, "T_Block"); //this is a really ugly way of doing it but there's no update tick on clients for dedi support if (Network.isClient) { Block block = Block.list.FirstOrDefault(d => d != null && d.GetBlockName() == "Windmill"); //.list[BlockID]; if (block == null) { Debug.Log("Can't find windmill block"); return; } var MinSpeed = 0f; var MaxSpeed = 0f; var WattPerMph = 0f; if (block.Properties.Values.ContainsKey("MinWindSpeed")) { MinSpeed = float.Parse(block.Properties.Values["MinWindSpeed"]); } if (block.Properties.Values.ContainsKey("MaxWindSpeed")) { MaxSpeed = float.Parse(block.Properties.Values["MaxWindSpeed"]); } if (block.Properties.Values.ContainsKey("WattPerMph")) { WattPerMph = float.Parse(block.Properties.Values["WattPerMph"]); } var animator = _ebcd.transform.gameObject.GetComponent <Animator>(); GameManager.Instance.StartCoroutine(CheckAnimation(animator, _cIdx, _blockPos, MinSpeed, MaxSpeed, WattPerMph)); } }
public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing) { BlockEntityData _ebcd = _world.ChunkClusters[_clrIdx].GetBlockEntity(_blockPos); //GameObjects screenOBJ_0 = _ebcd.transform.FindChild("TV/TVScreen1").gameObject; screenOBJ_1 = _ebcd.transform.FindChild("TV/TVScreen2").gameObject; screenOBJ_2 = _ebcd.transform.FindChild("TV/TVScreen3").gameObject; screenOBJ_3 = _ebcd.transform.FindChild("TV/TVScreen4").gameObject; //MeshRenderers screen0Mesh = screenOBJ_0.GetComponent <MeshRenderer>(); screen1Mesh = screenOBJ_1.GetComponent <MeshRenderer>(); screen2Mesh = screenOBJ_2.GetComponent <MeshRenderer>(); screen3Mesh = screenOBJ_3.GetComponent <MeshRenderer>(); ForceScreens(_blockPos, _blockValue, _ebcd); if (Input.GetKeyUp(KeyCode.Keypad1)) { screen0Mesh.enabled = true; screen1Mesh.enabled = false; screen2Mesh.enabled = false; screen3Mesh.enabled = false; _blockValue.meta = (byte)(_blockValue.meta | (1 << 0)); _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 1)); _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 2)); _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 3)); _world.SetBlockRPC(_blockPos, _blockValue); return(""); } if (Input.GetKeyUp(KeyCode.Keypad2)) { screen0Mesh.enabled = false; screen1Mesh.enabled = true; screen2Mesh.enabled = false; screen3Mesh.enabled = false; _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 0)); _blockValue.meta = (byte)(_blockValue.meta | (1 << 1)); _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 2)); _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 3)); _world.SetBlockRPC(_blockPos, _blockValue); return(""); } if (Input.GetKeyUp(KeyCode.Keypad3)) { screen0Mesh.enabled = false; screen1Mesh.enabled = false; screen2Mesh.enabled = true; screen3Mesh.enabled = false; _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 0)); _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 1)); _blockValue.meta = (byte)(_blockValue.meta | (1 << 2)); _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 3)); _world.SetBlockRPC(_blockPos, _blockValue); return(""); } if (Input.GetKeyUp(KeyCode.Keypad4)) { screen0Mesh.enabled = false; screen1Mesh.enabled = false; screen2Mesh.enabled = false; screen3Mesh.enabled = true; _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 0)); _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 1)); _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 2)); _blockValue.meta = (byte)(_blockValue.meta | (1 << 3)); _world.SetBlockRPC(_blockPos, _blockValue); return(""); } if (Input.GetKeyUp(KeyCode.Keypad8)) { DisplayChatAreaText("Turn the screen on by selecting a channel with numpad 1, 2, 3 or 4. You can pan the camera left and right using the arrow keys."); DisplayChatAreaText("Press E while looking at the screen to turn off the screen and all cams."); DisplayChatAreaText("Notes: In order to reduce frame rate loss only one camera is turned on at any time and all cameras are turned of when the screen is off."); DisplayChatAreaText("For this reason it's best to have only one screen turned on at a time."); return(""); } if (!BlockCCTVScreen.Screen0(_blockValue.meta) && !BlockCCTVScreen.Screen1(_blockValue.meta) && !BlockCCTVScreen.Screen2(_blockValue.meta) && !BlockCCTVScreen.Screen3(_blockValue.meta)) { return("To Turn On Select A Channel Using The NumPad."); } else { return(""); } }
public override void OnBlockEntityTransformBeforeActivated(WorldBase _world, Vector3i _blockPos, int _cIdx, BlockValue _blockValue, BlockEntityData _ebcd) { this.shape.OnBlockEntityTransformBeforeActivated(_world, _blockPos, _cIdx, _blockValue, _ebcd); DebugMsg("OnBlockEntityTransformBeforeActivated"); try { if (_ebcd != null && _ebcd.bHasTransform) { GameObject gameObject = _ebcd.transform.gameObject; HealingPodControl healingPodControlScript = gameObject.GetComponent <HealingPodControl>(); if (healingPodControlScript == null) { healingPodControlScript = gameObject.AddComponent <HealingPodControl>(); } healingPodControlScript.enabled = true; healingPodControlScript.cIdx = _cIdx; healingPodControlScript.blockPos = _blockPos; } else { DebugMsg("ERROR: _ebcd null (OnBlockEntityTransformBeforeActivated)"); } } catch (Exception ex) { DebugMsg("Error Message: " + ex.ToString()); } // Offset wire so that it's at the base of the Healing Pod TileEntityPowered tileEntityPowered = (TileEntityPowered)_world.GetTileEntity(_cIdx, _blockPos); if (tileEntityPowered != null) { tileEntityPowered.WireOffset = new Vector3(0, -0.5f, 0); } }
public override void OnBlockEntityTransformAfterActivated(WorldBase _world, Vector3i _blockPos, int _cIdx, BlockValue _blockValue, BlockEntityData _ebcd) { if (_ebcd == null) { return; } // Hide the sign, so its not visible. Without this, it errors out. _ebcd.bHasTransform = false; base.OnBlockEntityTransformAfterActivated(_world, _blockPos, _cIdx, _blockValue, _ebcd); // Re-show the transform. This won't have a visual effect, but fixes when you pick up the block, the outline of the block persists. _ebcd.bHasTransform = true; }
public bool FindSetAndOffsetAssignedBoat(int _cIdx, Vector3i _blockPos, BlockValue _blockValue, BlockEntityData _ebcd) { if (_ebcd == null) { DebugMsg("BlockDummyBoat FindSetAndOffsetAssignedBoat: BlockEntityData is NULL, aborting: _blockPos = " + _blockPos.ToString()); } EntityCustomBoat assignedBoat = null; if (_FindSetAndOffsetAssignedBoat(_cIdx, _blockPos, _blockValue, ref assignedBoat)) { DebugMsg("BlockDummyBoat FindSetAndOffsetAssignedBoat: Found Boat Dummy Block BlockEntityData: _blockPos = " + _blockPos.ToString()); assignedBoat.boatDummyBlockEntityData = _ebcd; // Adjust Boat and dummy block transform assignedBoat.bNeedBoatDummyBlockOffset = true; assignedBoat.AdjustBoatAndDummyBoatBlockPositions(); return(true); } return(false); }
public override void OnBlockEntityTransformBeforeActivated(WorldBase _world, Vector3i _blockPos, int _cIdx, BlockValue _blockValue, BlockEntityData _ebcd) { this.shape.OnBlockEntityTransformBeforeActivated(_world, _blockPos, _cIdx, _blockValue, _ebcd); DebugMsg("OnBlockEntityTransformBeforeActivated"); try { if (_ebcd != null && _ebcd.bHasTransform) { GameObject gameObject = _ebcd.transform.gameObject; PerpetualMotionGeneratorControl PMGControlScript = gameObject.GetComponent <PerpetualMotionGeneratorControl>(); if (PMGControlScript == null) { PMGControlScript = gameObject.AddComponent <PerpetualMotionGeneratorControl>(); } PMGControlScript.enabled = true; PMGControlScript.cIdx = _cIdx; PMGControlScript.blockPos = _blockPos; PMGControlScript.soundRepeat = soundRepeat; } else { DebugMsg("ERROR: _ebcd null (OnBlockEntityTransformBeforeActivated)"); } } catch (Exception ex) { DebugMsg("Error Message: " + ex.ToString()); } // Offset wire so that it's at the base of the Healing Pod TileEntityPowerSource tileEntityPowerSource = (TileEntityPowerSource)_world.GetTileEntity(_cIdx, _blockPos); if (tileEntityPowerSource != null) { tileEntityPowerSource.WireOffset = new Vector3(0.25f, 0.4f, 0); } }
public override void OnBlockEntityTransformBeforeActivated(WorldBase _world, Vector3i _blockPos, int _cIdx, BlockValue _blockValue, BlockEntityData _ebcd) { this.shape.OnBlockEntityTransformBeforeActivated(_world, _blockPos, _cIdx, _blockValue, _ebcd); DebugMsg("OnBlockEntityTransformBeforeActivated"); Debug.Log("power block initial _blockPos = " + _blockPos.ToString()); InitControlScript(_blockPos, _cIdx, _ebcd); /* * // Offset wire so that it's at the base of the Healing Pod * TileEntityPowered tileEntityPowered = (TileEntityPowered)_world.GetTileEntity(_cIdx, _blockPos); * if (tileEntityPowered != null) * { * tileEntityPowered.WireOffset = new Vector3(0, 0, 0); * }*/ }
public override void OnBlockEntityTransformAfterActivated(WorldBase _world, Vector3i _blockPos, int _cIdx, BlockValue _blockValue, BlockEntityData _ebcd) { base.OnBlockEntityTransformAfterActivated(_world, _blockPos, _cIdx, _blockValue, _ebcd); SetTag(_ebcd.transform, _ebcd.transform, "T_Block"); AddScript(_world, _blockPos, _ebcd); }
/*public override BlockValue OnBlockPlaced(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, Random _rnd) * { * //this.blockMaterial = MaterialBlock.water; * * DebugMsg("OnBlockPlaced rotation" + _blockValue.rotation.ToString()); * * return base.OnBlockPlaced(_world, _clrIdx, _blockPos, _blockValue, _rnd); * }*/ public override void OnBlockEntityTransformBeforeActivated(WorldBase _world, Vector3i _blockPos, int _cIdx, BlockValue _blockValue, BlockEntityData _ebcd) { //DebugMsg("OnBlockPlaced rotation = " + _blockValue.rotation.ToString()); base.OnBlockEntityTransformBeforeActivated(_world, _blockPos, _cIdx, _blockValue, _ebcd); }