tile-types #15
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=9 format=2]
|
[gd_scene load_steps=11 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://nodes/grid.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://nodes/grid.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://nodes/grid_cursor.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://nodes/grid_cursor.tscn" type="PackedScene" id=2]
|
||||||
|
@ -7,6 +7,8 @@
|
||||||
[ext_resource path="res://nodes/interaction_modes/interaction_mode.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://nodes/interaction_modes/interaction_mode.tscn" type="PackedScene" id=5]
|
||||||
[ext_resource path="res://nodes/ui/build_mode_ui.tscn" type="PackedScene" id=6]
|
[ext_resource path="res://nodes/ui/build_mode_ui.tscn" type="PackedScene" id=6]
|
||||||
[ext_resource path="res://nodes/interaction_modes/build_mode.tscn" type="PackedScene" id=7]
|
[ext_resource path="res://nodes/interaction_modes/build_mode.tscn" type="PackedScene" id=7]
|
||||||
|
[ext_resource path="res://nodes/interaction_modes/selection_mode.tscn" type="PackedScene" id=8]
|
||||||
|
[ext_resource path="res://nodes/ui/selection_mode_ui.tscn" type="PackedScene" id=9]
|
||||||
|
|
||||||
[sub_resource type="Curve" id=1]
|
[sub_resource type="Curve" id=1]
|
||||||
_data = [ Vector2( 0, 0 ), 0.0, 5.0, 0, 0, Vector2( 0.5, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), -4.0, 0.0, 0, 0 ]
|
_data = [ Vector2( 0, 0 ), 0.0, 5.0, 0, 0, Vector2( 0.5, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), -4.0, 0.0, 0, 0 ]
|
||||||
|
@ -25,19 +27,27 @@ _pulseShape = SubResource( 1 )
|
||||||
|
|
||||||
[node name="Interaction Mode" parent="." instance=ExtResource( 5 )]
|
[node name="Interaction Mode" parent="." instance=ExtResource( 5 )]
|
||||||
_buildModePath = NodePath("../Build Mode")
|
_buildModePath = NodePath("../Build Mode")
|
||||||
|
_selectionModePath = NodePath("../Selection Mode")
|
||||||
|
|
||||||
[node name="Build Mode" parent="." instance=ExtResource( 7 )]
|
[node name="Build Mode" parent="." instance=ExtResource( 7 )]
|
||||||
_key = 66
|
_key = 66
|
||||||
|
|
||||||
|
[node name="Selection Mode" parent="." instance=ExtResource( 8 )]
|
||||||
|
|
||||||
[node name="UI" type="Control" parent="."]
|
[node name="UI" type="Control" parent="."]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
|
mouse_filter = 2
|
||||||
|
|
||||||
[node name="Debug" parent="UI" instance=ExtResource( 3 )]
|
[node name="Debug" parent="UI" instance=ExtResource( 3 )]
|
||||||
|
|
||||||
[node name="Build Mode" parent="UI" instance=ExtResource( 6 )]
|
[node name="Build Mode" parent="UI" instance=ExtResource( 6 )]
|
||||||
|
visible = false
|
||||||
_buildModePath = NodePath("../../Build Mode")
|
_buildModePath = NodePath("../../Build Mode")
|
||||||
|
|
||||||
|
[node name="Selection Mode" parent="UI" instance=ExtResource( 9 )]
|
||||||
|
_selectionModePath = NodePath("../../Selection Mode")
|
||||||
|
|
||||||
[connection signal="OnPauseChanged" from="Clock" to="UI/Debug" method="_on_Clock_OnPauseChanged"]
|
[connection signal="OnPauseChanged" from="Clock" to="UI/Debug" method="_on_Clock_OnPauseChanged"]
|
||||||
[connection signal="OnTick" from="Clock" to="Grid" method="_on_Clock_OnTick"]
|
[connection signal="OnTick" from="Clock" to="Grid" method="_on_Clock_OnTick"]
|
||||||
[connection signal="OnTick" from="Clock" to="UI/Debug" method="_on_Clock_OnTick"]
|
[connection signal="OnTick" from="Clock" to="UI/Debug" method="_on_Clock_OnTick"]
|
||||||
|
@ -45,4 +55,7 @@ _buildModePath = NodePath("../../Build Mode")
|
||||||
[connection signal="OnInteractionModeChanged" from="Interaction Mode" to="UI/Debug" method="_on_Interaction_Mode_OnInteractionModeChanged"]
|
[connection signal="OnInteractionModeChanged" from="Interaction Mode" to="UI/Debug" method="_on_Interaction_Mode_OnInteractionModeChanged"]
|
||||||
[connection signal="OnModeEntered" from="Build Mode" to="Interaction Mode" method="_on_Build_Mode_OnModeEntered"]
|
[connection signal="OnModeEntered" from="Build Mode" to="Interaction Mode" method="_on_Build_Mode_OnModeEntered"]
|
||||||
[connection signal="OnModeExited" from="Build Mode" to="Interaction Mode" method="_on_Build_Mode_OnModeExited"]
|
[connection signal="OnModeExited" from="Build Mode" to="Interaction Mode" method="_on_Build_Mode_OnModeExited"]
|
||||||
|
[connection signal="OnModeEntered" from="Selection Mode" to="Interaction Mode" method="_on_Selection_Mode_OnModeEntered"]
|
||||||
|
[connection signal="OnModeExited" from="Selection Mode" to="Interaction Mode" method="_on_Selection_Mode_OnModeExited"]
|
||||||
[connection signal="OnExit" from="UI/Build Mode" to="Interaction Mode" method="Reset"]
|
[connection signal="OnExit" from="UI/Build Mode" to="Interaction Mode" method="Reset"]
|
||||||
|
[connection signal="EnableBuildMode" from="UI/Selection Mode" to="Build Mode" method="Enable"]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[gd_scene load_steps=2 format=2]
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://scripts/interaction_modes/InteractionMode.cs" type="Script" id=1]
|
[ext_resource path="res://scripts/interaction_modes/InteractionModes.cs" type="Script" id=1]
|
||||||
|
|
||||||
[node name="Interaction Mode" type="Node"]
|
[node name="Interaction Mode" type="Node"]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://scripts/interaction_modes/SelectionMode.cs" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="Selection Mode" type="Node"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
_key = 16777217
|
|
@ -3,43 +3,24 @@
|
||||||
[ext_resource path="res://scripts/ui/BuildModeUI.cs" type="Script" id=1]
|
[ext_resource path="res://scripts/ui/BuildModeUI.cs" type="Script" id=1]
|
||||||
|
|
||||||
[node name="Build Mode" type="Control"]
|
[node name="Build Mode" type="Control"]
|
||||||
anchor_right = 1.0
|
anchor_top = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
|
margin_top = -600.0
|
||||||
|
margin_bottom = -600.0
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="ColorRect" type="ColorRect" parent="."]
|
[node name="Exit" type="Button" parent="."]
|
||||||
anchor_top = 1.0
|
|
||||||
anchor_right = 1.0
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
margin_top = -40.0
|
|
||||||
grow_horizontal = 0
|
|
||||||
grow_vertical = 0
|
|
||||||
|
|
||||||
[node name="Exit" type="Button" parent="ColorRect"]
|
|
||||||
margin_left = 2.0
|
margin_left = 2.0
|
||||||
margin_top = 2.0
|
margin_top = 562.0
|
||||||
margin_right = 38.0
|
margin_right = 38.0
|
||||||
margin_bottom = 38.0
|
margin_bottom = 598.0
|
||||||
|
text = "Exit"
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="ColorRect/Exit"]
|
[node name="Developed" type="Button" parent="."]
|
||||||
anchor_right = 1.0
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
text = "exit"
|
|
||||||
align = 1
|
|
||||||
valign = 1
|
|
||||||
|
|
||||||
[node name="Exit2" type="Button" parent="ColorRect"]
|
|
||||||
margin_left = 54.0
|
margin_left = 54.0
|
||||||
margin_top = 2.0
|
margin_top = 562.0
|
||||||
margin_right = 90.0
|
margin_right = 90.0
|
||||||
margin_bottom = 38.0
|
margin_bottom = 598.0
|
||||||
|
text = "Developed"
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="ColorRect/Exit2"]
|
[connection signal="pressed" from="Exit" to="." method="_on_Exit_pressed"]
|
||||||
anchor_right = 1.0
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
text = "developed"
|
|
||||||
align = 1
|
|
||||||
valign = 1
|
|
||||||
autowrap = true
|
|
||||||
|
|
||||||
[connection signal="pressed" from="ColorRect/Exit" to="." method="_on_Exit_pressed"]
|
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
[ext_resource path="res://scripts/ui/DebugUI.cs" type="Script" id=1]
|
[ext_resource path="res://scripts/ui/DebugUI.cs" type="Script" id=1]
|
||||||
|
|
||||||
[node name="Debug UI" type="Control"]
|
[node name="Debug UI" type="Control"]
|
||||||
|
anchor_left = 1.0
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
mouse_filter = 2
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
TicksLabelPath = NodePath("Ticks")
|
TicksLabelPath = NodePath("Ticks")
|
||||||
PauseLabelPath = NodePath("Paused")
|
PauseLabelPath = NodePath("Paused")
|
||||||
|
@ -19,7 +20,7 @@ margin_right = -14.0
|
||||||
margin_bottom = 29.0
|
margin_bottom = 29.0
|
||||||
grow_horizontal = 0
|
grow_horizontal = 0
|
||||||
grow_vertical = 0
|
grow_vertical = 0
|
||||||
text = "mode: SELECT"
|
text = "mode: Selection"
|
||||||
align = 2
|
align = 2
|
||||||
|
|
||||||
[node name="Ticks" type="Label" parent="."]
|
[node name="Ticks" type="Label" parent="."]
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://scripts/ui/SelectionModeUI.cs" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="Selection Mode UI" type="Control"]
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
margin_top = -600.0
|
||||||
|
margin_bottom = -600.0
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Build Mode" type="Button" parent="."]
|
||||||
|
margin_left = 2.0
|
||||||
|
margin_top = 562.0
|
||||||
|
margin_right = 38.0
|
||||||
|
margin_bottom = 598.0
|
||||||
|
text = "Build Mode"
|
||||||
|
|
||||||
|
[connection signal="pressed" from="Build Mode" to="." method="_on_Build_Mode_pressed"]
|
|
@ -38,25 +38,25 @@ public class GridCursor : Sprite
|
||||||
this.Visible = _grid.IsInBounds(x, y);
|
this.Visible = _grid.IsInBounds(x, y);
|
||||||
var position = new Vector2(x + .5f, y + .5f) * _grid.CellSize;
|
var position = new Vector2(x + .5f, y + .5f) * _grid.CellSize;
|
||||||
this.Position = position;
|
this.Position = position;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (@event is InputEventMouseButton mouseButtonEvent)
|
|
||||||
|
if (@event is InputEventMouseButton mouseButtonEvent)
|
||||||
{
|
{
|
||||||
switch ((ButtonList)mouseButtonEvent.ButtonIndex)
|
var button = (ButtonList)mouseButtonEvent.ButtonIndex;
|
||||||
|
if (button != ButtonList.Left)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!mouseButtonEvent.Pressed)
|
||||||
{
|
{
|
||||||
case ButtonList.Left:
|
_material.SetShaderParam(T, 0f);
|
||||||
if (mouseButtonEvent.Pressed)
|
return;
|
||||||
{
|
|
||||||
var pos = mouseButtonEvent.Position;
|
|
||||||
_grid.GetGridPos(pos, out var x, out var y);
|
|
||||||
_grid.SetTileValue(x, y, 1.0f);
|
|
||||||
_material.SetShaderParam(T, 1f);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_material.SetShaderParam(T, 0f);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var pos = mouseButtonEvent.Position;
|
||||||
|
_grid.GetGridPos(pos, out var x, out var y);
|
||||||
|
_grid.SetTileValue(x, y, 1.0f);
|
||||||
|
_material.SetShaderParam(T, 1f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,17 +74,8 @@ public class GridCursor : Sprite
|
||||||
_material.SetShaderParam(T, a);
|
_material.SetShaderParam(T, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void _on_Interaction_Mode_OnInteractionModeChanged(InteractionMode.Mode oldMode, InteractionMode.Mode newMode)
|
public void _on_Interaction_Mode_OnInteractionModeChanged(Mode oldMode, Mode newMode)
|
||||||
{
|
{
|
||||||
switch (newMode)
|
_pulsing = newMode is BuildMode;
|
||||||
{
|
|
||||||
case InteractionMode.Mode.SELECT:
|
|
||||||
_pulsing = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case InteractionMode.Mode.BUILD:
|
|
||||||
_pulsing = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,66 +1,9 @@
|
||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public class BuildMode : Node
|
public class BuildMode : Mode
|
||||||
{
|
{
|
||||||
[Signal]
|
|
||||||
delegate void OnModeEntered();
|
|
||||||
[Signal]
|
|
||||||
delegate void OnModeExited();
|
|
||||||
|
|
||||||
[Export]
|
|
||||||
private KeyList _key;
|
|
||||||
|
|
||||||
public bool Active
|
|
||||||
{
|
|
||||||
get => _active;
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
if (value == _active)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_active = value;
|
|
||||||
|
|
||||||
var signal = _active
|
|
||||||
? nameof(OnModeEntered)
|
|
||||||
: nameof(OnModeExited);
|
|
||||||
EmitSignal(signal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private bool _active;
|
|
||||||
|
|
||||||
private const int NO_TILE_TYPE_SELECTED = -1;
|
private const int NO_TILE_TYPE_SELECTED = -1;
|
||||||
|
|
||||||
public int SelectedTileType { get; set; } = NO_TILE_TYPE_SELECTED;
|
public int SelectedTileType { get; set; } = NO_TILE_TYPE_SELECTED;
|
||||||
|
|
||||||
public override void _Ready()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void _Input(InputEvent @event)
|
|
||||||
{
|
|
||||||
base._Input(@event);
|
|
||||||
|
|
||||||
if (!(@event is InputEventKey keyEvent))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!keyEvent.Pressed)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var key = (KeyList)keyEvent.Scancode;
|
|
||||||
|
|
||||||
// TODO: this should be developed into a UI stack
|
|
||||||
if (key == KeyList.Escape)
|
|
||||||
{
|
|
||||||
Active = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key == _key)
|
|
||||||
{
|
|
||||||
Active = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
using Godot;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
public class InteractionMode : Node
|
|
||||||
{
|
|
||||||
[Export]
|
|
||||||
private NodePath _buildModePath;
|
|
||||||
private BuildMode _buildMode;
|
|
||||||
|
|
||||||
[Signal]
|
|
||||||
delegate void OnInteractionModeChanged(Mode oldMode, Mode newMode);
|
|
||||||
|
|
||||||
public enum Mode
|
|
||||||
{
|
|
||||||
SELECT = 0,
|
|
||||||
BUILD = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
public Mode Current { get; private set; }
|
|
||||||
|
|
||||||
public void _on_Build_Mode_OnModeEntered()
|
|
||||||
{
|
|
||||||
ChangeMode(Mode.BUILD);
|
|
||||||
}
|
|
||||||
public void _on_Build_Mode_OnModeExited()
|
|
||||||
{
|
|
||||||
ChangeMode(Mode.SELECT);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ChangeMode(Mode mode)
|
|
||||||
{
|
|
||||||
if (Current == mode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var old = Current;
|
|
||||||
Current = mode;
|
|
||||||
|
|
||||||
EmitSignal(nameof(OnInteractionModeChanged), old, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void _Ready()
|
|
||||||
{
|
|
||||||
base._Ready();
|
|
||||||
|
|
||||||
_buildMode = GetNode<BuildMode>(_buildModePath);
|
|
||||||
|
|
||||||
Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Reset()
|
|
||||||
{
|
|
||||||
Current = Mode.SELECT;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public class InteractionModes : Node
|
||||||
|
{
|
||||||
|
[Export]
|
||||||
|
private NodePath _buildModePath;
|
||||||
|
private BuildMode _buildMode;
|
||||||
|
[Export]
|
||||||
|
private NodePath _selectionModePath;
|
||||||
|
private SelectionMode _selectionMode;
|
||||||
|
|
||||||
|
[Signal]
|
||||||
|
delegate void OnInteractionModeChanged(Mode oldMode, Mode newMode);
|
||||||
|
|
||||||
|
private Mode _current = null;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
base._Ready();
|
||||||
|
|
||||||
|
_selectionMode = GetNode<SelectionMode>(_selectionModePath);
|
||||||
|
_buildMode = GetNode<BuildMode>(_buildModePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _Process(float delta)
|
||||||
|
{
|
||||||
|
base._Process(delta);
|
||||||
|
|
||||||
|
if (_current == null)
|
||||||
|
{
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void _on_Build_Mode_OnModeEntered()
|
||||||
|
{
|
||||||
|
_selectionMode.Disable();
|
||||||
|
ChangeMode(_selectionMode, _buildMode);
|
||||||
|
}
|
||||||
|
public void _on_Build_Mode_OnModeExited()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void _on_Selection_Mode_OnModeEntered()
|
||||||
|
{
|
||||||
|
_buildMode.Disable();
|
||||||
|
ChangeMode(_buildMode, _selectionMode);
|
||||||
|
}
|
||||||
|
public void _on_Selection_Mode_OnModeExited()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangeMode(Mode oldMode, Mode newMode)
|
||||||
|
{
|
||||||
|
if (oldMode == newMode)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_current != null && oldMode != _current)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
_current = newMode;
|
||||||
|
EmitSignal(nameof(OnInteractionModeChanged), oldMode, newMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
_buildMode.Disable();
|
||||||
|
_selectionMode.Enable();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public abstract class Mode : Node
|
||||||
|
{
|
||||||
|
[Signal]
|
||||||
|
delegate void OnModeEntered();
|
||||||
|
[Signal]
|
||||||
|
delegate void OnModeExited();
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
private KeyList _key;
|
||||||
|
|
||||||
|
public bool Active
|
||||||
|
{
|
||||||
|
get => _active;
|
||||||
|
private set
|
||||||
|
{
|
||||||
|
if (value == _active)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_active = value;
|
||||||
|
|
||||||
|
var signal = _active
|
||||||
|
? nameof(OnModeEntered)
|
||||||
|
: nameof(OnModeExited);
|
||||||
|
EmitSignal(signal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private bool _active;
|
||||||
|
|
||||||
|
public override void _Input(InputEvent @event)
|
||||||
|
{
|
||||||
|
base._Input(@event);
|
||||||
|
|
||||||
|
if (!(@event is InputEventKey keyEvent))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!keyEvent.Pressed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var key = (KeyList)keyEvent.Scancode;
|
||||||
|
|
||||||
|
if (key == _key)
|
||||||
|
{
|
||||||
|
Active = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Enable()
|
||||||
|
{
|
||||||
|
Active = true;
|
||||||
|
}
|
||||||
|
public void Disable()
|
||||||
|
{
|
||||||
|
Active = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return GetType().ToString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public class SelectionMode : Mode
|
||||||
|
{
|
||||||
|
}
|
|
@ -28,8 +28,10 @@ public class DebugUI : Control
|
||||||
public void _on_Clock_OnTick(int ticks) =>
|
public void _on_Clock_OnTick(int ticks) =>
|
||||||
SetLabelText(_ticksLabel, "ticks", ticks);
|
SetLabelText(_ticksLabel, "ticks", ticks);
|
||||||
|
|
||||||
public void _on_Interaction_Mode_OnInteractionModeChanged(InteractionMode.Mode oldMode, InteractionMode.Mode newMode) =>
|
public void _on_Interaction_Mode_OnInteractionModeChanged(Mode oldMode, Mode newMode)
|
||||||
|
{
|
||||||
SetLabelText(_interactionModeLabel, "mode", newMode);
|
SetLabelText(_interactionModeLabel, "mode", newMode);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private void SetLabelText(Label label, string key, object value)
|
private void SetLabelText(Label label, string key, object value)
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public class SelectionModeUI : Control
|
||||||
|
{
|
||||||
|
[Signal]
|
||||||
|
delegate void EnableBuildMode();
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
private NodePath _selectionModePath;
|
||||||
|
public SelectionMode _selectionMode;
|
||||||
|
|
||||||
|
public void _on_Build_Mode_pressed() => EmitSignal(nameof(EnableBuildMode));
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
_selectionMode = GetNode<SelectionMode>(_selectionModePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _Process(float delta)
|
||||||
|
{
|
||||||
|
base._Process(delta);
|
||||||
|
|
||||||
|
Visible = _selectionMode.Active;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue