basic capture functionality
This commit is contained in:
parent
246f3c0840
commit
c141e6a169
20 changed files with 430 additions and 14 deletions
28
scripts/core/CaptureController.cs
Normal file
28
scripts/core/CaptureController.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using Godot;
|
||||
|
||||
public partial class CaptureController : Node
|
||||
{
|
||||
[Export] public NodePath CaptureUIPath { get; set; }
|
||||
|
||||
private GameRoot _root = null!;
|
||||
private CaptureUI? _ui;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_ui = GetNodeOrNull<CaptureUI>(CaptureUIPath);
|
||||
if (_ui == null)
|
||||
{
|
||||
GD.PrintErr("CaptureController: CaptureUIPath not set.");
|
||||
return;
|
||||
}
|
||||
|
||||
GameRoot.Instance.CaptureRequested += OnRequestCapture;
|
||||
}
|
||||
|
||||
private void OnRequestCapture(Creature creature)
|
||||
{
|
||||
if (_ui == null) return;
|
||||
if (!IsInstanceValid(creature)) return;
|
||||
_ui.StartCapture(creature);
|
||||
}
|
||||
}
|
||||
1
scripts/core/CaptureController.cs.uid
Normal file
1
scripts/core/CaptureController.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bl7xagtutg20w
|
||||
14
scripts/core/GameRoot.cs
Normal file
14
scripts/core/GameRoot.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
using Godot;
|
||||
|
||||
public partial class GameRoot : Node
|
||||
{
|
||||
public static GameRoot Instance { get; private set; } = null!;
|
||||
public event System.Action<Creature>? CaptureRequested;
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public void RequestCapture(Creature creature) => CaptureRequested?.Invoke(creature);
|
||||
}
|
||||
1
scripts/core/GameRoot.cs.uid
Normal file
1
scripts/core/GameRoot.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://boip0mbmeqmhk
|
||||
|
|
@ -9,6 +9,8 @@ public class SaveState
|
|||
// Respawnables: pickupId -> unixTimeSeconds when it becomes available again
|
||||
public Dictionary<string, long> PickupRespawnAt { get; set; } = new();
|
||||
|
||||
public HashSet<string> CapturedCreatures { get; set; } = new();
|
||||
|
||||
//public Vector2I? LastPlayerChunk { get; set; } // optional debug, requires "using Godot;"
|
||||
//public int[]? LastPlayerChunk { get; set; } // [x,y] same debug as above, does not require Godot
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue