58 lines
1.1 KiB
C#
58 lines
1.1 KiB
C#
using Godot;
|
|
using System;
|
|
|
|
public class InteractionModes : Node
|
|
{
|
|
[Export]
|
|
private NodePath _buildModePath;
|
|
private BuildMode _buildMode;
|
|
|
|
[Signal]
|
|
delegate void OnInteractionModeChanged(Mode oldMode, Mode newMode);
|
|
|
|
private Mode Mode
|
|
{
|
|
get => _current;
|
|
set
|
|
{
|
|
if (_current == value)
|
|
return;
|
|
|
|
if (value != null)
|
|
{
|
|
GD.Print($"set interaction mode: {value}");
|
|
}
|
|
else if (_current != null)
|
|
{
|
|
GD.Print($"clear interaction mode");
|
|
}
|
|
|
|
var old = _current;
|
|
_current = value;
|
|
EmitSignal(nameof(OnInteractionModeChanged), old, _current);
|
|
}
|
|
}
|
|
private Mode _current = null;
|
|
|
|
public override void _Ready()
|
|
{
|
|
base._Ready();
|
|
|
|
_buildMode = GetNode<BuildMode>(_buildModePath);
|
|
}
|
|
|
|
public void _on_Build_Mode_OnModeEntered()
|
|
{
|
|
Mode = _buildMode;
|
|
}
|
|
public void _on_Build_Mode_OnModeExited()
|
|
{
|
|
Mode = null;
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
_buildMode.Disable();
|
|
}
|
|
}
|