Wednesday, 20 August 2025 02:02:40
This commit is contained in:
@@ -1,11 +1,19 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public partial class Tchotchke : StaticBody2D
|
||||
{
|
||||
public bool _hovered = false, _held = false;
|
||||
public List<Effect> _effects = new();
|
||||
public List<Action> _actions = new();
|
||||
public Node _target;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
MouseEntered += OnMouseEntered;
|
||||
MouseExited += OnMouseExited;
|
||||
}
|
||||
|
||||
public override void _Process(double DELTA_)
|
||||
{
|
||||
@@ -47,6 +55,18 @@ public partial class Tchotchke : StaticBody2D
|
||||
_held = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void FireActions(Trigger.On TRIGGER, Node TARGET = null)
|
||||
{
|
||||
List<Action> triggeredActions = _actions.Where(e => e._triggers.IndexOf(TRIGGER) > -1).ToList();
|
||||
for (int i = 0; i < triggeredActions.Count; i++)
|
||||
{
|
||||
triggeredActions[i].Target(TARGET);
|
||||
triggeredActions[i].Fire();
|
||||
}
|
||||
List<Action> expiredActions = _actions.Where(e => e._triggers.IndexOf(TRIGGER) > -1).ToList();
|
||||
_actions.Except(expiredActions);
|
||||
}
|
||||
|
||||
public void Hold()
|
||||
{
|
||||
@@ -56,8 +76,6 @@ public partial class Tchotchke : StaticBody2D
|
||||
}
|
||||
_held = true;
|
||||
}
|
||||
|
||||
// Processes
|
||||
|
||||
// PRIVATE METHODS
|
||||
private void OnMouseEntered()
|
||||
@@ -65,20 +83,10 @@ public partial class Tchotchke : StaticBody2D
|
||||
_hovered = true;
|
||||
}
|
||||
|
||||
private void OnMouseExited()
|
||||
{
|
||||
_hovered = false;
|
||||
}
|
||||
private void OnMouseExited()
|
||||
{
|
||||
_hovered = false;
|
||||
}
|
||||
|
||||
private void OnBodyEntered(Node NODE)
|
||||
{
|
||||
if (NODE is Worker)
|
||||
{
|
||||
for (int i = 0; i < _effects.Count; i++)
|
||||
{
|
||||
GD.Print(1001);
|
||||
_effects[i].TriggerEffect((Worker)NODE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user