private void Update() { if (TheGame.Get().IsPaused()) { return; } if (IsDead()) { return; } //Save position Data.position = GetPosition(); //Controls PlayerControls controls = PlayerControls.Get(player_id); //Stop sleep if (is_action || IsMoving() || sleep_target == null) { StopSleep(); } //Activate Selectable when near Vector3 move_dir = auto_move_target - transform.position; if (auto_move && !is_action && auto_move_select != null && move_dir.magnitude < auto_move_select.use_range) { auto_move = false; auto_move_select.Use(this, auto_move_target); auto_move_select = null; } //Finish construction when near clicked spot Buildable current_buildable = character_craft.GetCurrentBuildable(); if (auto_move && !is_action && character_craft.ClickedBuild() && current_buildable != null && move_dir.magnitude < current_buildable.build_distance) { auto_move = false; character_craft.StartCraftBuilding(auto_move_target); } //Stop move & drop when near clicked spot if (auto_move && !is_action && move_dir.magnitude < moving_threshold * 2f) { auto_move = false; character_inventory.DropItem(auto_move_drop_inventory, auto_move_drop); } //Stop attacking if target cant be attacked anymore (tool broke, or target died...) if (!character_combat.CanAttack(auto_move_attack)) { auto_move_attack = null; } //Ride animal if (is_riding) { if (riding_animal == null || riding_animal.IsDead()) { StopRide(); return; } transform.position = riding_animal.GetRideRoot(); transform.rotation = Quaternion.LookRotation(riding_animal.transform.forward, Vector3.up); } //Controls if (IsControlsEnabled() && !is_action) { //Check if panel is focused KeyControlsUI ui_controls = KeyControlsUI.Get(player_id); bool panel_focus = controls.gamepad_controls && ui_controls != null && ui_controls.IsPanelFocus(); if (!panel_focus) { //Press Action button if (controls.IsPressAction()) { if (character_craft.CanBuild()) { character_craft.StartCraftBuilding(); } else if (!panel_focus) { InteractWithNearest(); } } //Press attack if (Combat.can_attack && controls.IsPressAttack()) { AttackNearest(); } //Press jump if (character_jump != null && controls.IsPressJump()) { character_jump.Jump(); } } if (controls.IsPressUISelect()) { if (character_craft.CanBuild()) { character_craft.StartCraftBuilding(); } } } //Stop riding if (is_riding && (controls.IsPressJump() || controls.IsPressAction() || controls.IsPressUICancel())) { StopRide(); } }
public override bool CanDoAction(PlayerCharacter character, Selectable select) { AnimalRide ride = select.GetComponent <AnimalRide>(); return(ride != null && !ride.IsDead()); }