private void OnDestroy() { InputsManager.Get().UnregisterReceiver(this); }
private bool ShouldCancel() { return(!InputsManager.Get().IsActionActive(TriggerAction.TYPE.Expand)); }
protected virtual void OnDestroy() { InputsManager.Get().UnregisterReceiver(this); }
public override void OnShow() { base.OnShow(); this.InitializeButtons(); InputsManager.Get().RegisterReceiver(this); }
private void UpdateActions() { foreach (HUDItemInHand.Action action in this.m_Actions) { action.rect_trans.anchoredPosition = action.disbled_pos; } if (!Player.Get().GetCurrentItem()) { return; } this.m_ActionsTemp.Clear(); Player.Get().GetInputActions(ref this.m_ActionsTemp); if (this.m_ActionsTemp.Count > this.m_Actions.Count) { DebugUtils.Assert("HUDItemInHand - Not enough action slots!", true, DebugUtils.AssertType.Info); } bool flag = GreenHellGame.IsPadControllerActive(); int num = 0; while (num < this.m_ActionsTemp.Count && num < this.m_Actions.Count) { InputActionData inputActionData = InputsManager.Get().GetInputActionData((InputsManager.InputAction) this.m_ActionsTemp[num]); string text; if (!this.m_CachedTexts.TryGetValue(this.m_ActionsTemp[num], out text)) { text = this.GetText(inputActionData); this.m_CachedTexts[this.m_ActionsTemp[num]] = text; } if (!text.Empty()) { HUDItemInHand.Action action2 = this.m_Actions[num]; action2.rect_trans.anchoredPosition = action2.position; action2.text.text = text; if (flag) { action2.pad_icon.sprite = inputActionData.m_PadIcon; action2.key_frame.gameObject.SetActive(false); action2.key_text.gameObject.SetActive(false); action2.key_text_long.gameObject.SetActive(false); action2.mouse_icon_lmb.gameObject.SetActive(false); action2.mouse_icon_rmb.gameObject.SetActive(false); action2.mouse_icon_mmb.gameObject.SetActive(false); } else { string keyText = this.GetKeyText(inputActionData); if (inputActionData.m_KeyCode == KeyCode.Mouse0) { action2.key_frame.gameObject.SetActive(false); action2.key_text.gameObject.SetActive(false); action2.key_text_long.gameObject.SetActive(false); action2.mouse_icon_lmb.gameObject.SetActive(true); action2.mouse_icon_rmb.gameObject.SetActive(false); action2.mouse_icon_mmb.gameObject.SetActive(false); } else if (inputActionData.m_KeyCode == KeyCode.Mouse1) { action2.key_frame.gameObject.SetActive(false); action2.key_text.gameObject.SetActive(false); action2.key_text_long.gameObject.SetActive(false); action2.mouse_icon_lmb.gameObject.SetActive(false); action2.mouse_icon_rmb.gameObject.SetActive(true); action2.mouse_icon_mmb.gameObject.SetActive(false); } else if (inputActionData.m_KeyCode == KeyCode.Mouse2) { action2.key_frame.gameObject.SetActive(false); action2.key_text.gameObject.SetActive(false); action2.key_text_long.gameObject.SetActive(false); action2.mouse_icon_lmb.gameObject.SetActive(false); action2.mouse_icon_rmb.gameObject.SetActive(false); action2.mouse_icon_mmb.gameObject.SetActive(true); } else if (action2.key_text.text.Length <= 1) { action2.key_frame.gameObject.SetActive(true); action2.key_text.gameObject.SetActive(true); action2.key_text_long.gameObject.SetActive(false); action2.mouse_icon_lmb.gameObject.SetActive(false); action2.mouse_icon_rmb.gameObject.SetActive(false); action2.mouse_icon_mmb.gameObject.SetActive(false); action2.key_text.text = keyText; } else { action2.key_frame.gameObject.SetActive(false); action2.key_text.gameObject.SetActive(false); action2.key_text_long.gameObject.SetActive(true); action2.mouse_icon_lmb.gameObject.SetActive(false); action2.mouse_icon_rmb.gameObject.SetActive(false); action2.mouse_icon_mmb.gameObject.SetActive(false); action2.key_text_long.text = keyText; } } } num++; } }
private void SetupPadText() { string text = this.m_ActiveHint.m_LocalizedPadText; foreach (Image image in this.m_PadIcons) { image.gameObject.SetActive(false); } TextGenerationSettings generationSettings = this.m_Text.GetGenerationSettings(this.m_Text.rectTransform.rect.size); generationSettings.scaleFactor = 1f; float num = 20f; float preferredWidth = this.m_TextGen.GetPreferredWidth(" ", generationSettings); int num2 = (int)(num / preferredWidth); string text2 = ""; for (int i = 0; i < num2; i++) { text2 += " "; } float preferredWidth2 = this.m_TextGen.GetPreferredWidth(text2, generationSettings); int j = 0; int num3 = 0; int num4 = 0; j = text.IndexOf("[", j); if (j < 0) { this.m_Text.text = text; return; } string text3 = text; int num5 = 0; while (j >= 0) { num3 = text3.IndexOf("]", j); if (num4 == 0) { text = text3.Substring(num4, j - num4); } else { text += text3.Substring(num4 + 1, j - num4 - 1); } text += text2; string value = text3.Substring(j + 1, num3 - j - 1); InputsManager.InputAction input_action = InputsManager.InputAction.None; Enum.TryParse <InputsManager.InputAction>(value, true, out input_action); InputActionData actionDataByInputAction = InputsManager.Get().GetActionDataByInputAction(input_action, ControllerType.Pad); if (actionDataByInputAction != null) { this.m_PadIcons[num5].sprite = actionDataByInputAction.m_PadIcon; this.m_PadIcons[num5].gameObject.SetActive(true); } num4 = num3; j = text3.IndexOf("[", num4); num5++; } text += text3.Substring(num3 + 1, text3.Length - num3 - 1); this.m_Text.text = text; float preferredWidth3 = this.m_TextGen.GetPreferredWidth(text, generationSettings); Vector3 localPosition = this.m_Text.rectTransform.localPosition; localPosition.x -= preferredWidth3 * 0.5f; j = 0; text3 = text; num5 = 0; j = text.IndexOf(text2, j); while (j >= 0) { text = text3.Substring(0, j); float preferredWidth4 = this.m_TextGen.GetPreferredWidth(text, generationSettings); Vector3 localPosition2 = localPosition; localPosition2.x += preferredWidth4 + preferredWidth + preferredWidth2 * 0.5f; this.m_PadIcons[num5].rectTransform.localPosition = localPosition2; num4 = j + num2; j = text3.IndexOf(text2, num4); num5++; } }
private void UpdateActions() { Trigger trigger = this.GetTrigger(); if (!trigger || !trigger.CanExecuteActions() || this.IsExpanded()) { for (int i = 0; i < this.m_Actions.Length; i++) { this.m_KeyFrames[i].gameObject.SetActive(false); this.m_Keys[i].gameObject.SetActive(false); this.m_Actions[i].gameObject.SetActive(false); if (this.m_MouseRMBIcon[i]) { this.m_MouseRMBIcon[i].gameObject.SetActive(false); } } return; } this.m_TriggerActions.Clear(); if (!this.IsExpanded()) { if (Inventory3DManager.Get().gameObject.activeSelf) { Item item = (!trigger.IsItem()) ? null : ((Item)trigger); if (item && item.m_OnCraftingTable) { this.m_TriggerActions.Add(TriggerAction.TYPE.Remove); } else { this.m_TriggerActions.Add(TriggerAction.TYPE.InventoryExpand); } } else { trigger.GetActions(this.m_TriggerActions); } } Vector3 position = Vector3.zero; int num = 0; while (num < this.m_TriggerActions.Count && num < 2) { this.m_KeyFrames[num].gameObject.SetActive(true); this.m_Keys[num].gameObject.SetActive(true); this.m_Actions[num].gameObject.SetActive(true); if (this.m_MouseRMBIcon[num]) { this.m_MouseRMBIcon[num].gameObject.SetActive(false); } this.m_Keys[num].text = string.Empty; this.m_Actions[num].text = string.Empty; TriggerAction.TYPE action = this.m_TriggerActions[num]; InputActionData inputActionData = InputsManager.Get().GetInputActionData(action); if (inputActionData != null) { if (inputActionData.m_KeyCode == KeyCode.Mouse1) { if (this.m_MouseRMBIcon[num]) { this.m_MouseRMBIcon[num].gameObject.SetActive(true); this.m_KeyFrames[num].gameObject.SetActive(false); } this.m_Keys[num].gameObject.SetActive(false); } else { Text text = this.m_Keys[num]; text.text += inputActionData.m_KeyCode.ToString(); } if (inputActionData.m_Hold > 0f) { Text text2 = this.m_Actions[num]; text2.text = text2.text + GreenHellGame.Instance.GetLocalization().Get("HUD_Trigger_Hold") + " "; } Text text3 = this.m_Actions[num]; text3.text += GreenHellGame.Instance.GetLocalization().Get(TriggerAction.GetText(action)); } else { this.m_Actions[num].text = GreenHellGame.Instance.GetLocalization().Get(TriggerAction.GetText(action)); } if (num == 0) { TextGenerationSettings generationSettings = this.m_Actions[num].GetGenerationSettings(this.m_Actions[num].rectTransform.rect.size); float width = ((RectTransform)HUDManager.Get().m_CanvasGameObject.transform).rect.width; float x = ((RectTransform)HUDManager.Get().m_CanvasGameObject.transform).localScale.x; generationSettings.scaleFactor = x; float preferredWidth = this.m_TextGen.GetPreferredWidth(this.m_Actions[num].text, generationSettings); position = this.m_KeyFrames[num].rectTransform.position; position.x += this.m_KeyFrames[num].rectTransform.rect.width * 0.5f * x; position.x += preferredWidth + width * x * 0.01f; position.x += this.m_KeyFrames[num].rectTransform.rect.width * x; } else if (num == 1 && this.m_KeyFrameParents[num] != null) { this.m_KeyFrameParents[num].position = position; } num++; } for (int j = this.m_TriggerActions.Count; j < this.m_Actions.Length; j++) { this.m_KeyFrames[j].gameObject.SetActive(false); this.m_Keys[j].gameObject.SetActive(false); this.m_Actions[j].gameObject.SetActive(false); if (this.m_MouseRMBIcon[j] != null) { this.m_MouseRMBIcon[j].gameObject.SetActive(false); } } }
public override void OnInputAction(InputActionData action_data) { base.OnInputAction(action_data); if (LoadingScreen.Get().m_Active) { return; } if (InventoryBackpack.Get().IsMaxOverload()) { return; } if (action_data.m_Action == InputsManager.InputAction.Jump && HUDMovie.Get().GetMovieType() == MovieType.None) { bool flag = FreeHandsLadderController.Get().IsActive(); if ((this.m_CollisionFlags & CollisionFlags.Below) > CollisionFlags.None || flag) { bool flag2 = InputsManager.Get().IsActionActive(InputsManager.InputAction.DodgeLeft); bool flag3 = InputsManager.Get().IsActionActive(InputsManager.InputAction.DodgeRight); bool flag4 = InputsManager.Get().IsActionActive(InputsManager.InputAction.DodgeForward); bool flag5 = InputsManager.Get().IsActionActive(InputsManager.InputAction.DodgeBackward); if (!flag && flag2 && !flag4) { this.Dodge(Direction.Left); return; } if (!flag && flag3 && !flag4) { this.Dodge(Direction.Right); return; } if (!flag && flag5) { this.Dodge(Direction.Backward); return; } this.Jump(); return; } } else if (action_data.m_Action == InputsManager.InputAction.Duck && GreenHellGame.Instance.m_Settings.m_ToggleCrouch) { if (this.CanCrouch()) { this.m_Inputs.m_Duck = !this.m_Inputs.m_Duck; this.m_Inputs.m_Sprint = false; return; } } else if (action_data.m_Action == InputsManager.InputAction.Duck && !GreenHellGame.Instance.m_Settings.m_ToggleCrouch) { if (this.CanCrouch()) { this.m_Inputs.m_Duck = true; this.m_Inputs.m_Sprint = false; return; } } else { if (action_data.m_Action == InputsManager.InputAction.DuckStop && !GreenHellGame.Instance.m_Settings.m_ToggleCrouch) { this.m_Inputs.m_Duck = false; return; } if (action_data.m_Action == InputsManager.InputAction.Sprint && (GreenHellGame.Instance.m_Settings.m_ToggleRunOption == GameSettings.ToggleRunOption.Yes || GreenHellGame.Instance.m_Settings.m_ToggleRunOption == GameSettings.ToggleRunOption.Always)) { this.m_Inputs.m_Sprint = !this.m_Inputs.m_Sprint; this.m_Inputs.m_Duck = false; } } }
private void UpdateInputs() { if (!Player.Get().GetMovesBlocked()) { this.m_Inputs.m_Vertical = InputsManager.Get().GetActionValue(InputsManager.InputAction.Forward) - InputsManager.Get().GetActionValue(InputsManager.InputAction.Backward); this.m_Inputs.m_Vertical = Mathf.Sign(this.m_Inputs.m_Vertical) * (this.m_Inputs.m_Vertical * this.m_Inputs.m_Vertical); this.m_Inputs.m_Horizontal = InputsManager.Get().GetActionValue(InputsManager.InputAction.Right) - InputsManager.Get().GetActionValue(InputsManager.InputAction.Left); this.m_Inputs.m_Horizontal = Mathf.Sign(this.m_Inputs.m_Horizontal) * (this.m_Inputs.m_Horizontal * this.m_Inputs.m_Horizontal); this.m_Inputs.m_Jump = InputsManager.Get().IsActionActive(InputsManager.InputAction.Jump); if (GreenHellGame.IsPadControllerActive() && HUDWheel.Get().m_Active) { this.m_Inputs.m_Duck = false; } if (GreenHellGame.Instance.m_Settings.m_ToggleRunOption == GameSettings.ToggleRunOption.No) { this.m_Inputs.m_Sprint = InputsManager.Get().IsActionActive(InputsManager.InputAction.Sprint); } } else if (!MainLevel.Instance.IsPause()) { this.m_Inputs.m_Jump = false; this.m_Inputs.m_Sprint = false; } if (!this.m_Player.GetRotationBlocked()) { Vector2 lookInput = InputHelpers.GetLookInput(this.m_LookSensitivityX, this.m_LookSensitivityY, this.m_PadSensitivity); this.m_Inputs.m_MouseX = lookInput.x; this.m_Inputs.m_MouseY = lookInput.y; } }
public void UpdatePadCursor(float speed_mul = 1f) { if (!GreenHellGame.IsPadControllerActive()) { return; } Vector2 vector = new Vector2(InputsManager.Get().GetActionValue(InputsManager.InputAction.LookRight) - InputsManager.Get().GetActionValue(InputsManager.InputAction.LookLeft), InputsManager.Get().GetActionValue(InputsManager.InputAction.LookUp) - InputsManager.Get().GetActionValue(InputsManager.InputAction.LookDown)); vector.x = CJTools.Math.GetProportionalClamp(this.m_ControllerCursorDeadZone, 1f, System.Math.Abs(vector.x), 0f, 1f) * (float)System.Math.Sign(vector.x); vector.y = CJTools.Math.GetProportionalClamp(this.m_ControllerCursorDeadZone, 1f, System.Math.Abs(vector.y), 0f, 1f) * (float)System.Math.Sign(vector.y); if (vector == Vector2.zero) { return; } float magnitude = vector.magnitude; if (magnitude > 1f) { vector /= magnitude; } float num = (float)Screen.height / 1080f; float num2 = this.m_ControllerCursorSpeedCurve.Evaluate(vector.magnitude); vector *= num2 * this.m_ControllerCursorSpeed * num * Time.deltaTime * speed_mul; this.m_LocalCursorPos += vector; this.m_LocalCursorPos.x = Mathf.Clamp(this.m_LocalCursorPos.x, 0f, (float)Screen.width); this.m_LocalCursorPos.y = Mathf.Clamp(this.m_LocalCursorPos.y, 0f, (float)Screen.height); this.SetCursorPos(this.m_LocalCursorPos); }
private void Update() { // Don't toggle the runtime inspector while typing something to chat if (toggleKey.Length > 0 && (!InputsManager.Get() || !InputsManager.Get().m_TextInputActive)) { // Check if configurable key is held // First, make sure that all modifier keys are held bool modifierKeysHeld = true; for (int i = 0; i < toggleKey.Length - 1; i++) { if (!Input.GetKey(toggleKey[i])) { modifierKeysHeld = false; toggleKeyTriggered = false; break; } } if (modifierKeysHeld) { if (!toggleKeyTriggered && Input.GetKeyDown(toggleKey[toggleKey.Length - 1])) { toggleKeyTriggered = true; toggleKeyHeldTime = 0f; } else if (toggleKeyTriggered && Input.GetKey(toggleKey[toggleKey.Length - 1])) { toggleKeyHeldTime += Time.unscaledDeltaTime; if (toggleKeyHeldTime >= 0.5f) { toggleKeyTriggered = false; // Toggle inspector's visibility inspector.Show = !inspector.Show; SetCursorVisibility(inspector.Show); } } else { toggleKeyTriggered = false; } } } // Allow rotating the camera while RMB is held if (inspector.Show && Player.Get()) { if (!rmbHeld && Input.GetMouseButtonDown(1)) { rmbHeld = true; Player.Get().UnblockRotation(); } else if (rmbHeld && Input.GetMouseButtonUp(1)) { rmbHeld = false; Player.Get().BlockRotation(); } } inspector.Update(); }
public override void ControllerUpdate() { base.ControllerUpdate(); bool flag = (GreenHellGame.IsPCControllerActive() && InputsManager.Get().IsActionActive(InputsManager.InputAction.RMB)) || (GreenHellGame.IsPadControllerActive() && InputsManager.Get().IsActionActive(InputsManager.InputAction.ZoomMap)); if (flag != this.m_Animator.GetBool(this.m_ZoomHash)) { this.m_Animator.SetBool(this.m_ZoomHash, flag); } if (this.m_CursorVisible && WatchController.Get().IsActive()) { CursorManager.Get().ShowCursor(false, false); this.m_CursorVisible = false; return; } if (!this.m_CursorVisible && !WatchController.Get().IsActive() && GreenHellGame.IsPCControllerActive()) { CursorManager.Get().ShowCursor(true, true); this.m_CursorVisible = true; } }
private bool ShouldCancel() { return(!GreenHellGame.IsPadControllerActive() && !InputsManager.Get().IsActionActive(TriggerAction.TYPE.Expand)); }
private bool ShouldExecute() { return(!GreenHellGame.IsPadControllerActive() && (Input.GetMouseButtonDown(0) || !InputsManager.Get().IsActionActive(TriggerAction.TYPE.Expand))); }
private void Update() { // If the configurable hotkey is pressed while hovering an item in inventory, move the item to crafting table Inventory3DManager inventory = Inventory3DManager.Get(); CraftingManager craftingTable = CraftingManager.Get(); if (inventory && craftingTable && !HUDItem.Get().m_Active&& // Make sure RMB menu isn't open for any item right now TriggerController.Get().GetBestTrigger() && // Make sure there is a highlighted item !InputsManager.Get().m_TextInputActive&& // Make sure chat isn't active GetButtonDown(hotkey)) // Make sure hotkey is pressed { bool forceOpenedInventory = false; if (!inventory.IsActive() && openInventoryIfNotOpen) { // Force open inventory Item triggerItem = TriggerController.Get().GetBestTrigger().GetComponent <Item>(); if (triggerItem) { inventory.Activate(); if (inventory.IsActive()) { forceOpenedInventory = true; inventory.m_FocusedItem = triggerItem; if (!triggerItem.GetWasTriggered()) { triggerItem.SetWasTriggered(true); } } } } if (inventory.IsActive() && // Make sure inventory is currently open inventory.m_FocusedItem && !inventory.m_FocusedItem.m_OnCraftingTable && // Make sure the highlighted item isn't already on crafting table !inventory.m_CarriedItem && inventory.CanSetCarriedItem(true) && // Make sure we aren't drag & dropping any items at the moment TriggerController.Get().GetBestTrigger().gameObject == inventory.m_FocusedItem.gameObject) // Make sure the highlighted item is the item that the cursor is on { craftingTable.Activate(); inventory.StartCarryItem(inventory.m_FocusedItem, false); craftingTable.AddItem(inventory.m_CarriedItem, true); if (inventory.m_StackItems != null) { for (int i = 0; i < inventory.m_StackItems.Count; i++) { craftingTable.AddItem(inventory.m_StackItems[i], true); } } inventory.SetCarriedItem(null, true); if (dropItemToTableClip) { inventory.GetComponent <AudioSource>().PlayOneShot(dropItemToTableClip); } } else if (forceOpenedInventory) { inventory.Deactivate(); } } }
public override void OnInputAction(InputsManager.InputAction action) { base.OnInputAction(action); if (LoadingScreen.Get().m_Active) { return; } if (InventoryBackpack.Get().IsCriticalOverload()) { return; } if (action == InputsManager.InputAction.Jump && HUDMovie.Get().GetMovieType() == MovieType.None && (this.m_CollisionFlags & CollisionFlags.Below) != CollisionFlags.None) { if (InputsManager.Get().IsActionActive(InputsManager.InputAction.DodgeLeft) && !InputsManager.Get().IsActionActive(InputsManager.InputAction.DodgeForward)) { this.Dodge(Direction.Left); } else if (InputsManager.Get().IsActionActive(InputsManager.InputAction.DodgeRight) && !InputsManager.Get().IsActionActive(InputsManager.InputAction.DodgeForward)) { this.Dodge(Direction.Right); } else if (InputsManager.Get().IsActionActive(InputsManager.InputAction.DodgeBackward)) { this.Dodge(Direction.Backward); } else { this.Jump(); } } }
private void UpdateState() { switch (this.m_State) { case ItemController.State.None: this.SetAnimatorParameters(); return; case ItemController.State.Swing: case ItemController.State.Throw: break; case ItemController.State.FinishSwing: this.SetState(ItemController.State.None); return; case ItemController.State.Aim: if (this.m_Item.m_Info.IsStone()) { if (GreenHellGame.IsPCControllerActive() && !InputsManager.Get().IsActionActive(InputsManager.InputAction.ThrowStone) && Player.Get().CanThrowStone()) { this.SetState(ItemController.State.Throw); return; } } else if (!InputsManager.Get().IsActionActive(InputsManager.InputAction.ItemAim) || TriggerController.Get().IsGrabInProgress() || Inventory3DManager.Get().gameObject.activeSelf) { this.SetState(ItemController.State.None); return; } break; case ItemController.State.StoneAim: if (GreenHellGame.IsPCControllerActive() && this.m_Animator.GetCurrentAnimatorStateInfo(this.m_SpineLayerIndex).shortNameHash == this.m_ObjectAimHash && !this.m_Animator.IsInTransition(this.m_SpineLayerIndex) && !InputsManager.Get().IsActionActive(InputsManager.InputAction.ThrowStone)) { Camera mainCamera = CameraManager.Get().m_MainCamera; Player.Get().m_StopAimCameraMtx.SetColumn(0, mainCamera.transform.right); Player.Get().m_StopAimCameraMtx.SetColumn(1, mainCamera.transform.up); Player.Get().m_StopAimCameraMtx.SetColumn(2, mainCamera.transform.forward); Player.Get().m_StopAimCameraMtx.SetColumn(3, mainCamera.transform.position); this.SetState(ItemController.State.Throw); } break; default: return; } }
private void UpdateSelection() { HUDWheel.HUDWheelSlot selectedSlot = this.m_SelectedSlot; if (GreenHellGame.IsPCControllerActive()) { float num = (float)Screen.width; Vector3 from = Input.mousePosition - base.transform.position; if (from.magnitude / (num * 0.5f) < 0.08f) { this.m_SelectedSlot = HUDWheel.HUDWheelSlot.None; for (int i = 0; i < 6; i++) { this.m_Selections[i].enabled = false; this.m_Icons[i].enabled = true; this.m_IconsHL[i].enabled = false; } this.UpdateText(); return; } from.Normalize(); float num2 = Vector3.Angle(from, Vector3.up); if (Input.mousePosition.x < base.transform.position.x) { num2 = 360f - num2; } this.m_SelectedSlot = (HUDWheel.HUDWheelSlot)(num2 / 360f * 6f); } else { float axis = InputsManager.Get().GetAxis("RightStickX"); float axis2 = InputsManager.Get().GetAxis("RightStickY"); Vector2 zero = Vector2.zero; zero.x = axis; zero.y = axis2; if (zero.magnitude <= 0.1f) { this.m_DeadZoneDuration += Time.deltaTime; if (this.m_DeadZoneDuration >= 0.15f) { this.m_SelectedSlot = HUDWheel.HUDWheelSlot.None; for (int j = 0; j < 6; j++) { this.m_Selections[j].enabled = false; this.m_Icons[j].enabled = true; this.m_IconsHL[j].enabled = false; } } this.UpdateText(); return; } this.m_DeadZoneDuration = 0f; float num3 = Vector3.Angle(zero, Vector3.up); if (axis > 0f) { num3 = 360f - num3; } this.m_SelectedSlot = (HUDWheel.HUDWheelSlot)(num3 / 360f * 6f); } for (int k = 0; k < 6; k++) { this.m_Selections[k].enabled = (k == (int)this.m_SelectedSlot && this.IsSlotActive((HUDWheel.HUDWheelSlot)k)); this.m_Icons[k].enabled = (k != (int)this.m_SelectedSlot || !this.IsSlotActive((HUDWheel.HUDWheelSlot)k)); this.m_IconsHL[k].enabled = (k == (int)this.m_SelectedSlot && this.IsSlotActive((HUDWheel.HUDWheelSlot)k)); } if (HUDWheel.HUDWheelSlot.Inspect == this.m_SelectedSlot && !Player.Get().CanStartBodyInspection()) { this.m_SelectedSlot = HUDWheel.HUDWheelSlot.None; this.m_Selections[5].enabled = false; } if (HUDWheel.HUDWheelSlot.Sleep == this.m_SelectedSlot && !Player.Get().CanSleep()) { this.m_SelectedSlot = HUDWheel.HUDWheelSlot.None; this.m_Selections[2].enabled = false; } this.UpdateText(); if (this.m_SelectedSlot != HUDWheel.HUDWheelSlot.None && selectedSlot != this.m_SelectedSlot && this.m_Selections[(int)this.m_SelectedSlot].enabled) { if (this.m_AudioSource.isPlaying) { this.m_AudioSource.Stop(); } this.m_AudioSource.Play(); } }
public override void OnAnimEvent(AnimEventID id) { base.OnAnimEvent(id); if (id == AnimEventID.SpearAimEnd) { if (this.m_SpearState == WeaponSpearController.State.Aim) { this.SetState(WeaponSpearController.State.AimIdle); } else if (this.m_SpearState == WeaponSpearController.State.ThrowAim) { this.SetState(WeaponSpearController.State.ThrowAimIdle); } } else if (id == AnimEventID.SpearAttackEnd) { if (this.m_SpearState == WeaponSpearController.State.AttackDown) { if (this.m_AttackDownCombo) { this.m_AttackDownCombo = false; this.m_Animator.Play(this.m_AttackDownHash, 1, 0f); this.SetState(WeaponSpearController.State.AttackDown); } else { this.SetState(WeaponSpearController.State.Idle); } } else if (this.m_SpearState == WeaponSpearController.State.AttackNonHit) { if (InputsManager.Get().IsActionActive(InputsManager.InputAction.SpearThrow)) { this.SetState(WeaponSpearController.State.AimIdle); } else { this.SetState(WeaponSpearController.State.Idle); } } else if (this.m_SpearState == WeaponSpearController.State.Attack) { this.SetState(WeaponSpearController.State.AttackNonHit); } } else if (id == AnimEventID.SpearUnAimEnd) { this.SetState(WeaponSpearController.State.Idle); } else if (id == AnimEventID.SpearShot && this.m_SpearState == WeaponSpearController.State.Throw) { this.Shot(); } else if (id == AnimEventID.SpearShotEnd) { this.SetState(WeaponSpearController.State.None); } else if (id == AnimEventID.DamageStart) { this.m_CanHitWater = true; } else if (id == AnimEventID.DamageEnd) { this.m_CanHitWater = false; } else if (id == AnimEventID.SpearEnterPresentationEnd) { this.SetState(WeaponSpearController.State.PresentationIdle); } }
private void Update() { // Don't toggle the menu while typing something to chat if (toggleKey.Length > 0 && !InputsManager.Get().m_TextInputActive) { // Check if configurable key is held // First, make sure that all modifier keys are held bool modifierKeysHeld = true; for (int i = 0; i < toggleKey.Length - 1; i++) { if (!Input.GetKey(toggleKey[i])) { modifierKeysHeld = false; toggleKeyTriggered = false; break; } } if (modifierKeysHeld) { if (!toggleKeyTriggered && Input.GetKeyDown(toggleKey[toggleKey.Length - 1])) { toggleKeyTriggered = true; toggleKeyHeldTime = 0f; } else if (toggleKeyTriggered && Input.GetKey(toggleKey[toggleKey.Length - 1])) { toggleKeyHeldTime += Time.unscaledDeltaTime; if (toggleKeyHeldTime >= 0.5f) { toggleKeyTriggered = false; ToggleUI(); } } else { toggleKeyTriggered = false; } } } // Allow rotating the camera while RMB is held if (uiVisible) { if (!rmbHeld && Input.GetMouseButtonDown(1)) { rmbHeld = true; Player.Get().UnblockRotation(); } else if (rmbHeld && Input.GetMouseButtonUp(1)) { rmbHeld = false; Player.Get().BlockRotation(); } } // Allow closing the menu with ESC key if (uiVisible && !InputsManager.Get().m_TextInputActive&& Input.GetKeyDown(KeyCode.Escape)) { SetUIVisible(false); } }
public string Get(string key) { string text = string.Empty; if (!this.m_LocalizedTexts.TryGetValue(key, out text)) { text = key + " = !!!MISSING TEXT!!!"; return(text); } if (text.Length == 0) { return(text); } int i = 0; int num = 0; int num2 = 0; i = text.IndexOf("[", i); string text2 = text; bool flag = false; while (i >= 0) { flag = true; num = text2.IndexOf("]", i); if (num2 == 0) { text = text2.Substring(num2, i - num2 + 1); } else { text += text2.Substring(num2 + 1, i - num2); } string text3 = text2.Substring(i + 1, num - i - 1); bool flag2 = true; InputsManager.InputAction key2 = InputsManager.InputAction.SkipCutscene; TriggerAction.TYPE key3 = TriggerAction.TYPE.Take; bool flag3 = false; bool flag4 = false; try { key2 = (InputsManager.InputAction)Enum.Parse(typeof(InputsManager.InputAction), text3); flag3 = true; } catch (ArgumentException) { flag2 = false; } if (!flag2) { try { key3 = (TriggerAction.TYPE)Enum.Parse(typeof(TriggerAction.TYPE), text3); flag4 = true; } catch (ArgumentException) { flag2 = false; } } if (flag2) { string str = string.Empty; if (flag3) { KeyCode keyCode = InputsManager.Get().GetActionsByInputAction()[(int)key2].m_KeyCode; str = KeyCodeToString.GetString(keyCode); } else if (flag4) { KeyCode keyCode2 = InputsManager.Get().GetActionsByTriggerAction()[(int)key3].m_KeyCode; str = KeyCodeToString.GetString(keyCode2); } text = text + str + "]"; } else { text = text + text3 + "]"; } num2 = num; i = text2.IndexOf("[", num2); } if (flag) { text += text2.Substring(num + 1, text2.Length - num - 1); } return(text); }
public string Get(string key, bool replace = true) { string text = string.Empty; if (!this.m_LocalizedTexts.TryGetValue(key, out text)) { text = key + " = !!!MISSING TEXT!!!"; return(text); } if (text.Length == 0) { return(text); } if (replace) { int i = 0; int num = 0; int num2 = 0; i = text.IndexOf("[", i); string text2 = text; bool flag = false; while (i >= 0) { flag = true; num = text2.IndexOf("]", i); if (num2 == 0) { text = text2.Substring(num2, i - num2 + 1); } else { text += text2.Substring(num2 + 1, i - num2); } string text3 = text2.Substring(i + 1, num - i - 1); bool flag2 = true; InputsManager.InputAction input_action = InputsManager.InputAction.SkipCutscene; TriggerAction.TYPE trigger_action = TriggerAction.TYPE.Take; bool flag3 = false; bool flag4 = false; if (Enum.TryParse <InputsManager.InputAction>(text3, true, out input_action)) { flag3 = true; } else { flag2 = false; } if (!flag2) { if (Enum.TryParse <TriggerAction.TYPE>(text3, true, out trigger_action)) { flag4 = true; } else { flag2 = false; } } if (flag2) { string str = string.Empty; if (flag3) { InputActionData actionDataByInputAction = InputsManager.Get().GetActionDataByInputAction(input_action, ControllerType._Count); if (actionDataByInputAction == null) { actionDataByInputAction = InputsManager.Get().GetActionDataByInputAction(input_action, (GreenHellGame.Instance.m_Settings.m_ControllerType == ControllerType.Pad) ? ControllerType.PC : ControllerType.Pad); } KeyCode keyCode = (actionDataByInputAction != null) ? actionDataByInputAction.m_KeyCode : KeyCode.None; str = ((keyCode != KeyCode.None) ? KeyCodeToString.GetString(keyCode) : text3); } else if (flag4) { InputActionData actionDataByTriggerAction = InputsManager.Get().GetActionDataByTriggerAction(trigger_action, ControllerType._Count); str = KeyCodeToString.GetString((actionDataByTriggerAction != null) ? actionDataByTriggerAction.m_KeyCode : KeyCode.None); } text = text + str + "]"; } else { text = text + text3 + "]"; } num2 = num; i = text2.IndexOf("[", num2); } if (flag) { text += text2.Substring(num + 1, text2.Length - num - 1); } } return(text); }
public override void OnHide() { base.OnHide(); InputsManager.Get().UnregisterReceiver(this); }
public static Vector2 GetLookInput(float mouse_mul_x = 1f, float mouse_mul_y = 1f, float pad_multiplier = 150f) { Vector2 vector = new Vector2(InputsManager.Get().GetActionValue(InputsManager.InputAction.LookRight) - InputsManager.Get().GetActionValue(InputsManager.InputAction.LookLeft), InputsManager.Get().GetActionValue(InputsManager.InputAction.LookUp) - InputsManager.Get().GetActionValue(InputsManager.InputAction.LookDown)); if (GreenHellGame.Instance.m_Settings.m_InvertMouseY) { vector.y *= -1f; } if (GreenHellGame.Instance.m_Settings.m_ControllerType != ControllerType.PC) { float magnitude = vector.magnitude; if (magnitude > 1f) { vector /= magnitude; } vector *= Mathf.Pow(vector.magnitude, 2f); vector *= Time.deltaTime * pad_multiplier; } else { vector.x *= mouse_mul_x; vector.y *= mouse_mul_y; } return(vector); }
private bool ShouldExecute() { return(Input.GetMouseButtonDown(0) || !InputsManager.Get().IsActionActive(TriggerAction.TYPE.Expand)); }
public static KeyCode KeyFromPad(this InputHelpers.PadButton pad_button) { return(pad_button.KeyFromPad(GreenHellGame.IsPadControllerActive() ? InputsManager.Get().m_PadControllerType : InputsManager.PadControllerType.None)); }
public void LoadSettings() { string text = GameSettings.s_SettingsFileName; if (!GreenHellGame.Instance.FileExistsInRemoteStorage(text)) { text = GameSettings.s_SettingsOldFileName; } if (GreenHellGame.Instance.IsGamescom()) { text = "GAMESCOM_SETTINGS.sav"; } if (GreenHellGame.Instance.FileExistsInRemoteStorage(text)) { BinaryFormatter binaryFormatter = new BinaryFormatter(); int fileSize = GreenHellGame.Instance.m_RemoteStorage.GetFileSize(text); byte[] array = new byte[fileSize]; int num = GreenHellGame.Instance.m_RemoteStorage.FileRead(text, array, fileSize); if (num != fileSize) { if (num == 0) { Debug.LogError("Local file " + text + " is missing!!! Skipping reading data."); } else { Debug.LogError("Local file " + text + " size mismatch!!! Skipping reading data."); } GreenHellGame.Instance.m_RemoteStorage.FileForget(text); } else { MemoryStream memoryStream = new MemoryStream(array); GameVersion gameVersion = new GameVersion((GameVersion)binaryFormatter.Deserialize(memoryStream)); this.m_Language = (Language)binaryFormatter.Deserialize(memoryStream); this.m_Volume = (float)binaryFormatter.Deserialize(memoryStream); if (gameVersion < GreenHellGame.s_GameVersionEarlyAccessUpdate2) { this.m_Volume = General.DecibelToLinear(this.m_Volume); } this.m_SoftShadows = (bool)binaryFormatter.Deserialize(memoryStream); this.m_ShadowsBlur = (GameSettings.OptionLevel)binaryFormatter.Deserialize(memoryStream); if (gameVersion > GreenHellGame.s_GameVersionEarlyAcces) { this.m_InvertMouseY = (bool)binaryFormatter.Deserialize(memoryStream); this.m_XSensitivity = (float)binaryFormatter.Deserialize(memoryStream); this.m_YSensitivity = (float)binaryFormatter.Deserialize(memoryStream); this.m_DialogsVolume = (float)binaryFormatter.Deserialize(memoryStream); this.m_MusicVolume = (float)binaryFormatter.Deserialize(memoryStream); this.m_EnviroVolume = (float)binaryFormatter.Deserialize(memoryStream); this.m_GeneralVolume = (float)binaryFormatter.Deserialize(memoryStream); } if (gameVersion >= GreenHellGame.s_GameVersionEarlyAccessUpdate3) { InputsManager.Get().LoadSettings(binaryFormatter, memoryStream, gameVersion); } if (gameVersion >= GreenHellGame.s_GameVersionEarlyAccessUpdate7 && gameVersion < GreenHellGame.s_GameVersionEarlyAccessUpdate13) { binaryFormatter.Deserialize(memoryStream); binaryFormatter.Deserialize(memoryStream); } if (gameVersion >= GreenHellGame.s_GameVersionEarlyAccessUpdate13) { try { this.m_Subtitles = (SubtitlesSetting)binaryFormatter.Deserialize(memoryStream); this.m_Crosshair = (bool)binaryFormatter.Deserialize(memoryStream); this.m_Hints = (bool)binaryFormatter.Deserialize(memoryStream); this.m_Resolution = (string)binaryFormatter.Deserialize(memoryStream); this.m_Fullscreen = (string)binaryFormatter.Deserialize(memoryStream); this.m_VSync = (bool)binaryFormatter.Deserialize(memoryStream); this.m_ShadowDistance = (float)binaryFormatter.Deserialize(memoryStream); this.m_AntiAliasing = (bool)binaryFormatter.Deserialize(memoryStream); this.m_FOVChange = (float)binaryFormatter.Deserialize(memoryStream); this.m_ObjectDrawDistance = (float)binaryFormatter.Deserialize(memoryStream); this.m_TextureQuality = (string)binaryFormatter.Deserialize(memoryStream); this.m_LastPlatformLanguage = (Language)binaryFormatter.Deserialize(memoryStream); this.m_BrightnessMul = (float)binaryFormatter.Deserialize(memoryStream); this.m_NeverPlayed = (bool)binaryFormatter.Deserialize(memoryStream); this.m_LookRotationSpeed = (float)binaryFormatter.Deserialize(memoryStream); } catch { } } if (gameVersion >= GreenHellGame.s_GameVersionMasterHotfix3) { try { this.m_GameVisibilityInternal = (P2PGameVisibility)binaryFormatter.Deserialize(memoryStream); } catch { } try { this.m_ControllerType = (ControllerType)binaryFormatter.Deserialize(memoryStream); } catch { } } if (gameVersion >= GreenHellGame.s_GameVersionMasterController1_2) { try { this.m_ToggleRunOption = (GameSettings.ToggleRunOption)binaryFormatter.Deserialize(memoryStream); this.m_ToggleWatch = (bool)binaryFormatter.Deserialize(memoryStream); this.m_ToggleCrouch = (bool)binaryFormatter.Deserialize(memoryStream); } catch { } } memoryStream.Close(); } } this.SetLanguage(); this.ApplySettings(false); }
private void ApplyDefaultOptions() { InputsManager.Get().ApplyDefaultOptions(); this.InitializeButtons(); }
protected virtual void Start() { InputsManager.Get().RegisterReceiver(this); }
private void Start() { base.gameObject.SetActive(false); InputsManager.Get().RegisterReceiver(this); }