53 lines
1.2 KiB
C#
53 lines
1.2 KiB
C#
using Godot;
|
|
|
|
namespace AceField.Scripts.Logic;
|
|
|
|
public partial class PlayerInput : MultiplayerSynchronizer
|
|
{
|
|
[Export] public bool IsDashing;
|
|
[Export] public bool IsBuilding;
|
|
[Export] public bool IsShooting;
|
|
[Export] public bool IsReloading;
|
|
|
|
[Export] public Vector2 MovementDirection;
|
|
|
|
private bool IsCurrentPlayer => GetMultiplayerAuthority() == Multiplayer.GetUniqueId();
|
|
|
|
public override void _Ready()
|
|
{
|
|
if (IsCurrentPlayer) return;
|
|
SetProcess(false);
|
|
SetPhysicsProcess(false);
|
|
}
|
|
|
|
[Rpc(CallLocal = true)]
|
|
private void Dash()
|
|
=> IsDashing = true;
|
|
|
|
[Rpc(CallLocal = true)]
|
|
private void Shoot()
|
|
=> IsShooting = true;
|
|
|
|
[Rpc(CallLocal = true)]
|
|
private void Reload()
|
|
=> IsReloading = true;
|
|
|
|
[Rpc(CallLocal = true)]
|
|
private void Build()
|
|
=> IsBuilding = true;
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
MovementDirection = Input.GetVector("move_left", "move_right", "move_up", "move_down");
|
|
|
|
if (Input.IsActionJustPressed("move_dash"))
|
|
Rpc(nameof(Dash));
|
|
if (Input.IsActionPressed("weapon_shoot"))
|
|
Rpc(nameof(Shoot));
|
|
if (Input.IsActionJustPressed("weapon_reload"))
|
|
Rpc(nameof(Reload));
|
|
if (Input.IsActionJustPressed("skill_place_tile"))
|
|
Rpc(nameof(Build));
|
|
}
|
|
}
|