public void UpdateInputs() { inputHashes = new int[inputs.Length]; if (inputsDic == null) { inputsDic = new Dictionary <int, InputItem>(inputs.Length); } else { inputsDic.Clear(); } if (enabledInputs == null) { enabledInputs = new Dictionary <int, bool>(inputs.Length); } else { enabledInputs.Clear(); } for (int i = 0; i < inputs.Length; i++) { int hash = GoldPlayerController.InputNameToHash(inputs[i].ButtonName); inputHashes[i] = hash; inputsDic.Add(hash, inputs[i]); enabledInputs.Add(hash, false); } }
protected override void OnInitialize() { // If the camera head is null, complain. if (cameraHead == null) { Debug.LogError($"'{PlayerController.gameObject.name}' needs to have Camera Head assigned in the Camera settings!"); return; } if (IsCameraNull) { Debug.LogError($"'{PlayerController.gameObject.name}' needs to have a Target Camera assigned in the Camera Settings!"); return; } lookHash = GoldPlayerController.InputNameToHash(input_Look); zoomHash = GoldPlayerController.InputNameToHash(zoomInput); originalFieldOfView = CameraFieldOfView; zoomFieldOfView = originalFieldOfView; zoomTimer = zoomOutTime; // Lock the cursor, if it should. LockCursor(shouldLockCursor); // Set the original head rotation to the one on the camera head. originalHeadRotation = cameraHead.localRotation; // Initialize the FOV kick module. fieldOfViewKick.Initialize(PlayerController, PlayerInput); }
/// <summary> /// Initializes the audio behaviour. /// </summary> /// <param name="footstepsSource"></param> /// <param name="jumpSource"></param> /// <param name="landSource"></param> public void Initialize(GoldPlayerController playerController, IGoldInput input, AudioSource footstepsSource, AudioSource jumpSource, AudioSource landSource) { PlayerController = playerController; PlayerInput = input; FootstepsSource = footstepsSource; JumpSource = jumpSource; LandSource = landSource; }
internal void Reset() { // If the controller exists, default the camera head to the one provided on the controller. GoldPlayerController controller = GetComponent <GoldPlayerController>(); if (controller != null && cameraHead == null) { cameraHead = controller.Camera.CameraHead; } }
protected virtual void Awake() { #if OBSOLETE Debug.LogError(gameObject.name + " has GoldPlayerInteraction attached. It will be removed on build. Please remove this component if you don't intend to use it.", gameObject); #endif interactHash = GoldPlayerController.InputNameToHash(interactInput); // Apply the trigger interaction. SetTriggerInteraction(); }
/// <summary> /// Sets the player and finds all required components. /// </summary> private void SetPlayer(GoldPlayerController player) { #if !GOLD_PLAYER_DISABLE_INTERACTION // Only get the interaction if the previous set player isn't the new player. if (player != null && this.player != player) { playerInteraction = player.GetComponent <GoldPlayerInteraction>(); } #endif // Set the player. this.player = player; }
// Add all actions to the actions dictionary. public void UpdateActions() { if (actions == null) { return; } actionsDictionary = new Dictionary <int, InputAction>(); for (int i = 0; i < actions.Length; i++) { actionsDictionary.Add(GoldPlayerController.InputNameToHash(actions[i].actionName), actions[i].action); } }
private void GetStandardComponents() { // Gets the controller in the editor, usually when the script is added. // Avoids a GetComponent in Awake. if (controller == null) { controller = GetComponent <CharacterController>(); } if (playerController == null) { playerController = GetComponent <GoldPlayerController>(); } }
/// <summary> /// Initialize the module. /// </summary> /// <param name="player">The player controller itself.</param> /// <param name="input">Input, if available.</param> public void Initialize(GoldPlayerController player, IGoldInput input) { // If the module has already been initialized, stop here. if (HasBeenInitialized) { return; } playerController = player; if (input != null) { playerInput = input; } OnInitialize(); HasBeenInitialized = true; }
private void GetStandardComponents() { // Get the controller in the editor and cache it. if (controller == null) { controller = GetComponent <CharacterController>(); } if (playerController == null) { playerController = GetComponent <GoldPlayerController>(); } // Adapt to values if they are changed in play mode. if (Application.isPlaying) { ValidateParameters(); GetAnimatorHashes(); UpdateTargetLookAngle(); } }
private void Reset() { GoldPlayerController gp = GetComponent <GoldPlayerController>(); #if !GOLD_PLAYER_DISABLE_INTERACTION GoldPlayerInteraction gi = GetComponent <GoldPlayerInteraction>(); #endif // If the player controller exists, add the input action name from there, otherwise just make it generic. actions = new InputSystemItem[] { new InputSystemItem(gp != null ? gp.Camera.LookInput : "Look", null), new InputSystemItem(gp != null ? gp.Movement.MoveInput : "Move", null), new InputSystemItem(gp != null ? gp.Movement.JumpInput : "Jump", null), new InputSystemItem(gp != null ? gp.Movement.RunInput : "Run", null), new InputSystemItem(gp != null ? gp.Movement.CrouchInput : "Crouch", null), #if !GOLD_PLAYER_DISABLE_INTERACTION new InputSystemItem(gi != null ? gi.InteractInput : "Interact", null) #endif }; }
/// <summary> /// Gets a Vector2 input value. /// It's much more recommended to cache a hash using <see cref="GoldPlayerController.InputNameToHash"/> /// and call <see cref="GetAxisRaw(int)"/> instead. /// </summary> /// <param name="action"></param> /// <returns></returns> protected Vector2 GetVector2Input(string action) { return(GetVector2Input(GoldPlayerController.InputNameToHash(action))); }
/// <summary> /// Equivalent to Input's GetAxisRaw function. /// It's much more recommended to cache a hash using <see cref="GoldPlayerController.InputNameToHash"/> /// and call <see cref="GetAxisRaw(int)"/> instead. /// </summary> /// <param name="axisName">The axis name you want to get.</param> protected float GetAxisRaw(string axisName) { return(GetAxisRaw(GoldPlayerController.InputNameToHash(axisName))); }
/// <summary> /// Equivalent to Input's GetButtonUp/GetKeyUp function. /// It's much more recommended to cache a hash using <see cref="GoldPlayerController.InputNameToHash"/> /// and call <see cref="GetButtonUp(int)"/> instead. /// </summary> /// <param name="buttonName">The button name you want to get.</param> protected bool GetButtonUp(string buttonName) { return(GetButtonUp(GoldPlayerController.InputNameToHash(buttonName))); }
public void Initialize(GoldPlayerController player, IGoldInput input) { }