/** * This is the activation text that displays when the player looks at this block. */ public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing) { TileEntityBlockTransformer tileEntityBlockTransformer = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityBlockTransformer; if (tileEntityBlockTransformer == null) { return(string.Empty); } string arg = Localization.Get(Block.list[_blockValue.type].GetBlockName(), ""); PlayerActionsLocal playerInput = ((EntityPlayerLocal)_entityFocusing).playerInput; string keybindString = UIUtils.GetKeybindString(playerInput.Activate, playerInput.PermanentActions.Activate); if (!tileEntityBlockTransformer.bTouched) { return(string.Format(Localization.Get("lootTooltipNew", ""), keybindString, arg)); } if (tileEntityBlockTransformer.IsEmpty()) { return(string.Format(Localization.Get("lootTooltipEmpty", ""), keybindString, arg)); } return(string.Format(Localization.Get("lootTooltipTouched", ""), keybindString, arg)); }
// In addition to the transpiler above, we also want to see whether out inventory actions has the expected amount here. Hopefully this will only ever execute once. public static bool Prefix(PlayerMoveController __instance) { if (__instance.playerInput.InventoryActions.Count == 9) { SphereII_PlayerMoveController_Logger.Log("Player Action is 9. Adding Additional Slots"); PlayerActionsLocal temp = __instance.playerInput; temp.InventorySlot10 = temp.CreatePlayerAction("Inventory10"); temp.InventorySlot10.UserData = new PlayerActionsBase.ActionUserData("inpActInventorySlot9Name", null, PlayerActionsBase.GroupToolbelt, PlayerActionsBase.EAppliesToInputType.KbdMouseOnly, true); temp.InventorySlot11 = temp.CreatePlayerAction("Inventory11"); temp.InventorySlot11.UserData = new PlayerActionsBase.ActionUserData("inpActInventorySlot10Name", null, PlayerActionsBase.GroupToolbelt, PlayerActionsBase.EAppliesToInputType.KbdMouseOnly, true); temp.InventoryActions.Add(temp.InventorySlot10); temp.InventoryActions.Add(temp.InventorySlot11); temp.InventorySlot10.AddDefaultBinding(new InControl.Key[] { InControl.Key.Key0 }); } return(true); }
// 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 }
/** * This is the activation text that displays when the player looks at this block. * It will display whether the block is working, and if not, what conditions need to be fulfilled to make it work. */ public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing) { TileEntityBlockTransformer tileEntityBlockTransformer = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityBlockTransformer; if (tileEntityBlockTransformer == null) { return(string.Empty); } string lBlockName = Localization.Get(Block.list[_blockValue.type].GetBlockName(), ""); PlayerActionsLocal playerInput = ((EntityPlayerLocal)_entityFocusing).playerInput; string playerKey = playerInput.Activate.GetBindingXuiMarkupString(XUiUtils.EmptyBindingStyle.EmptyString, XUiUtils.DisplayStyle.Plain) + playerInput.PermanentActions.Activate.GetBindingXuiMarkupString(XUiUtils.EmptyBindingStyle.EmptyString, XUiUtils.DisplayStyle.Plain); string tooltip = ""; // If updates cannot happen we need to display this to the user and say why they can't happen yet. if (!tileEntityBlockTransformer.UpdateCanHappen((World)_world)) { // If no power, display this when looking at the block. if (!tileEntityBlockTransformer.IsPowered()) { tooltip = Localization.Get("transformerTooltipNoPower", ""); List <string> lPowerSources = new List <string>(); if (this.transformationPropertyParser.powerSources.Count > 0) { foreach (string powerSource in this.transformationPropertyParser.powerSources) { lPowerSources.Add(Localization.Get(powerSource)); } } string sources = StringHelpers.WriteListToString(lPowerSources); return(string.Format(tooltip, playerKey, lBlockName, sources)); } // If no heat, display this when looking at the block. else if (!tileEntityBlockTransformer.IsHeated()) { tooltip = Localization.Get("transformerTooltipNoHeat", ""); List <string> lHeatSources = new List <string>(); if (this.transformationPropertyParser.heatSources.Count > 0) { foreach (string heatSource in this.transformationPropertyParser.heatSources) { lHeatSources.Add(Localization.Get(heatSource)); } } string sources = StringHelpers.WriteListToString(lHeatSources); return(string.Format(tooltip, playerKey, lBlockName, sources)); } // Checks we have nearby blocks else if (!tileEntityBlockTransformer.HasNearbyBlocks()) { tooltip = Localization.Get("transformerTooltipNoBlocksNearby", ""); List <string> lNearbyBlocks = new List <string>(); if (this.transformationPropertyParser.nearbyBlockNames.Count > 0) { foreach (string blockName in this.transformationPropertyParser.nearbyBlockNames) { lNearbyBlocks.Add(Localization.Get(blockName)); } } if (this.transformationPropertyParser.nearbyBlockTags.Count > 0) { foreach (string blockTag in this.transformationPropertyParser.nearbyBlockTags) { lNearbyBlocks.Add(blockTag); } } string sources = StringHelpers.WriteListToString(lNearbyBlocks); string needed = this.transformationPropertyParser.nearbyBlockCount.ToString(); return(string.Format(tooltip, playerKey, lBlockName, needed, sources)); } // If all else fails, the block must be empty so needs items. else { tooltip = Localization.Get("transformerTooltipReady", ""); return(string.Format(tooltip, playerKey, lBlockName)); } } // Transforming here... tooltip = Localization.Get("transformerTooltipWorking", ""); return(string.Format(tooltip, playerKey, lBlockName)); }
public override void ExecuteAction(int _actionIdx, ItemInventoryData _data, bool _bReleased, PlayerActionsLocal _playerActions) { if (Actions[_actionIdx] == null) { return; } if (!_bReleased) { return; } EntityAlive ea = _data.holdingEntity; if (_actionIdx == 0) { _itemAction_TE_ObjectManipulator.ExecuteAction(_data.actionData[_actionIdx], _bReleased); } else if (_actionIdx == 1 && ea is EntityPlayerLocal) { _itemAction_TE_ObjectManipulator.ToggleActive(_data.actionData[_actionIdx]); } else { // I didn't see anywhere in the code where this was possible, but maybe in the future. A20?? Log.Out($"TE_ObjectManipulatorItem::ExecuteAction index: {_actionIdx} pressed."); } }