🚚 Rename project
This commit is contained in:
		@@ -1,7 +1,7 @@
 | 
			
		||||
using CodingLand.Scripts.Logic;
 | 
			
		||||
using AceField.Scripts.Logic;
 | 
			
		||||
using Godot;
 | 
			
		||||
 | 
			
		||||
namespace CodingLand.Scripts;
 | 
			
		||||
namespace AceField.Scripts;
 | 
			
		||||
 | 
			
		||||
public partial class Launcher : Node
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -1,44 +1,36 @@
 | 
			
		||||
using Godot;
 | 
			
		||||
 | 
			
		||||
namespace CodingLand.Scripts.Logic;
 | 
			
		||||
namespace AceField.Scripts.Logic;
 | 
			
		||||
 | 
			
		||||
public partial class PlayerInput : MultiplayerSynchronizer
 | 
			
		||||
{
 | 
			
		||||
    [Export] public bool IsDashing;
 | 
			
		||||
	[Export] public bool IsDashing;
 | 
			
		||||
 | 
			
		||||
    [Export] public Vector2 BuildingAt;
 | 
			
		||||
	[Export] public Vector2 MovementDirection;
 | 
			
		||||
 | 
			
		||||
    [Export] public Vector2 MovementDirection;
 | 
			
		||||
	private bool IsCurrentPlayer => GetMultiplayerAuthority() == Multiplayer.GetUniqueId();
 | 
			
		||||
 | 
			
		||||
    private bool IsCurrentPlayer => GetMultiplayerAuthority() == Multiplayer.GetUniqueId();
 | 
			
		||||
	public override void _Ready()
 | 
			
		||||
	{
 | 
			
		||||
		if (IsCurrentPlayer) return;
 | 
			
		||||
		SetProcess(false);
 | 
			
		||||
		SetPhysicsProcess(false);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    public override void _Ready()
 | 
			
		||||
    {
 | 
			
		||||
        if (IsCurrentPlayer) return;
 | 
			
		||||
        SetProcess(false);
 | 
			
		||||
        SetPhysicsProcess(false);
 | 
			
		||||
    }
 | 
			
		||||
	[Rpc(CallLocal = true)]
 | 
			
		||||
	private void Dash()
 | 
			
		||||
		=> IsDashing = true;
 | 
			
		||||
 | 
			
		||||
    [Rpc(CallLocal = true)]
 | 
			
		||||
    private void Dash()
 | 
			
		||||
        => IsDashing = true;
 | 
			
		||||
	public override void _Process(double delta)
 | 
			
		||||
	{
 | 
			
		||||
		MovementDirection = Input.GetVector("move_left", "move_right", "move_up", "move_down");
 | 
			
		||||
 | 
			
		||||
    [Rpc(CallLocal = true)]
 | 
			
		||||
    private void Build(Vector2 pos)
 | 
			
		||||
        => BuildingAt = pos;
 | 
			
		||||
		if (Input.IsActionJustPressed("move_dash"))
 | 
			
		||||
			Rpc(nameof(Dash));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    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));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public override void _Input(InputEvent evt)
 | 
			
		||||
    {
 | 
			
		||||
        if (!IsCurrentPlayer) return;
 | 
			
		||||
        if (evt is InputEventMouseButton { Pressed: true })
 | 
			
		||||
            Rpc(nameof(Build), GetViewport().GetMousePosition());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
	public override void _Input(InputEvent evt)
 | 
			
		||||
	{
 | 
			
		||||
		if (!IsCurrentPlayer) return;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,6 @@
 | 
			
		||||
using Godot;
 | 
			
		||||
using Vector2 = Godot.Vector2;
 | 
			
		||||
 | 
			
		||||
namespace CodingLand.Scripts.Logic;
 | 
			
		||||
namespace AceField.Scripts.Logic;
 | 
			
		||||
 | 
			
		||||
public partial class World : Node2D
 | 
			
		||||
{
 | 
			
		||||
@@ -47,7 +46,7 @@ public partial class World : Node2D
 | 
			
		||||
 | 
			
		||||
    private void AddPlayer(int id)
 | 
			
		||||
    {
 | 
			
		||||
        var player = PlayerScene.Instantiate<Player>();
 | 
			
		||||
        var player = PlayerScene.Instantiate<AceField.Scripts.Player>();
 | 
			
		||||
        player.SetPlayerId(id);
 | 
			
		||||
        var position = Vector2.FromAngle(GD.Randf() * 2 * Mathf.Pi);
 | 
			
		||||
        player.Position = new Vector2(position.X * 5f * GD.Randf(), position.Y * 5f * GD.Randf());
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
using CodingLand.Scripts.Logic;
 | 
			
		||||
using AceField.Scripts.Logic;
 | 
			
		||||
using Godot;
 | 
			
		||||
 | 
			
		||||
namespace CodingLand.Scripts;
 | 
			
		||||
namespace AceField.Scripts;
 | 
			
		||||
 | 
			
		||||
public partial class Player : CharacterBody2D
 | 
			
		||||
{
 | 
			
		||||
@@ -37,27 +37,14 @@ public partial class Player : CharacterBody2D
 | 
			
		||||
		PlayerInput.SetMultiplayerAuthority(id);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private TilesManager _tilesMgr;
 | 
			
		||||
 | 
			
		||||
	public override void _Ready()
 | 
			
		||||
	{
 | 
			
		||||
		if (PlayerId == Multiplayer.GetUniqueId())
 | 
			
		||||
			PlayerCamera.Enabled = true;
 | 
			
		||||
		_tilesMgr = GetNode<TilesManager>("../Tiles");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public override void _Process(double delta)
 | 
			
		||||
	{
 | 
			
		||||
		var vec = GetGlobalMousePosition();
 | 
			
		||||
		if (PlayerInput.BuildingAt == Vector2.Zero) return;
 | 
			
		||||
		var distance = Position.DistanceTo(vec);
 | 
			
		||||
		if (distance <= Reach * _tilesMgr.TileSize)
 | 
			
		||||
		{
 | 
			
		||||
			// Able to build
 | 
			
		||||
			Rpc(nameof(AddTile), vec);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		PlayerInput.BuildingAt = Vector2.Zero;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public override void _PhysicsProcess(double delta)
 | 
			
		||||
@@ -88,16 +75,4 @@ public partial class Player : CharacterBody2D
 | 
			
		||||
		Position += Velocity * (float)delta;
 | 
			
		||||
		MoveAndSlide();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	[Rpc(mode: MultiplayerApi.RpcMode.AnyPeer, CallLocal = true)]
 | 
			
		||||
	public void AddTile(Vector2 pos)
 | 
			
		||||
	{
 | 
			
		||||
		if (_tilesMgr.GetTileByPosition<Node2D>(pos) != null) return;
 | 
			
		||||
		
 | 
			
		||||
		var tileVec = new Vector2(_tilesMgr.TileSize, _tilesMgr.TileSize);
 | 
			
		||||
		var blueprint = GD.Load<PackedScene>("res://Scenes/Tiles/Brick.tscn");
 | 
			
		||||
		var instance = blueprint.Instantiate<Node2D>();
 | 
			
		||||
		instance.Position = pos.Snapped(tileVec);
 | 
			
		||||
		_tilesMgr.AddChild(instance);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,35 +0,0 @@
 | 
			
		||||
using Godot;
 | 
			
		||||
 | 
			
		||||
namespace CodingLand.Scripts;
 | 
			
		||||
 | 
			
		||||
public partial class TilesManager : Node2D
 | 
			
		||||
{
 | 
			
		||||
    [Export] public float TileSize = 51.2f;
 | 
			
		||||
 | 
			
		||||
    [Rpc(CallLocal = true)]
 | 
			
		||||
    public void AddTile(Vector2 pos)
 | 
			
		||||
    {
 | 
			
		||||
        if (GetTileByPosition<Node2D>(pos) == null)
 | 
			
		||||
        {
 | 
			
		||||
            var tileVec = new Vector2(TileSize, TileSize);
 | 
			
		||||
            // TODO Replace the brick to player selection
 | 
			
		||||
            var blueprint = GD.Load<PackedScene>("res://Scenes/Tiles/Brick.tscn");
 | 
			
		||||
            var instance = blueprint.Instantiate<Node2D>();
 | 
			
		||||
            instance.Position = pos.Snapped(tileVec);
 | 
			
		||||
            AddChild(instance);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public T GetTileByPosition<T>(Vector2 position) where T : Node2D
 | 
			
		||||
    {
 | 
			
		||||
        foreach (var item in GetChildren())
 | 
			
		||||
        {
 | 
			
		||||
            if (item is T tile && tile.Position == position)
 | 
			
		||||
            {
 | 
			
		||||
                return tile;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
using Godot;
 | 
			
		||||
 | 
			
		||||
namespace CodingLand.Scripts.UI;
 | 
			
		||||
namespace AceField.Scripts.UI;
 | 
			
		||||
 | 
			
		||||
public partial class StartScreen : Control
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user