✨ Block placing
This commit is contained in:
@ -6,22 +6,26 @@ public partial class PlayerInput : MultiplayerSynchronizer
|
||||
{
|
||||
[Export] public bool IsDashing;
|
||||
|
||||
[Export] public Vector2 BuildingAt;
|
||||
|
||||
[Export] public Vector2 MovementDirection;
|
||||
|
||||
private bool IsCurrentPlayer => GetMultiplayerAuthority() == Multiplayer.GetUniqueId();
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
if (GetMultiplayerAuthority() != Multiplayer.GetUniqueId())
|
||||
{
|
||||
SetProcess(false);
|
||||
SetPhysicsProcess(false);
|
||||
}
|
||||
if (IsCurrentPlayer) return;
|
||||
SetProcess(false);
|
||||
SetPhysicsProcess(false);
|
||||
}
|
||||
|
||||
[Rpc(CallLocal = true)]
|
||||
private void Dash()
|
||||
{
|
||||
IsDashing = true;
|
||||
}
|
||||
=> IsDashing = true;
|
||||
|
||||
[Rpc(CallLocal = true)]
|
||||
private void Build(Vector2 pos)
|
||||
=> BuildingAt = pos;
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
@ -30,4 +34,11 @@ public partial class PlayerInput : MultiplayerSynchronizer
|
||||
if (Input.IsActionJustPressed("move_dash"))
|
||||
Rpc(nameof(Dash));
|
||||
}
|
||||
|
||||
public override void _Input(InputEvent evt)
|
||||
{
|
||||
if (!IsCurrentPlayer) return;
|
||||
if (evt is InputEventMouseButton { Pressed: true })
|
||||
Rpc(nameof(Build), GetViewport().GetMousePosition());
|
||||
}
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
using System.Numerics;
|
||||
using Godot;
|
||||
using Vector2 = Godot.Vector2;
|
||||
|
||||
|
Reference in New Issue
Block a user