Wednesday, 10 September 2025 01:31:36
This commit is contained in:
@@ -1,28 +1,26 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
public partial class Worker : CharacterBody2D
|
||||
{
|
||||
[Signal]
|
||||
public delegate void SetHoveredEventHandler(Worker THIS);
|
||||
|
||||
public bool _dead = false, _hovered = false, _held = false, _selected = false;
|
||||
public int _size, _health, _healthMax;
|
||||
public float _distanceTraveled, _stamina, _staminaMax;
|
||||
public Stat _aptitude = new(), _agility = new(), _ardor = new(), _accumen = new(), _awareness = new(), _appeal = new();
|
||||
public float _rotationalForce = 0;
|
||||
public Vector2 _chainPosition = new Vector2(-1, -1);
|
||||
public Vector2 _chainPosition = new Vector2(-1, -1), _deskPosition;
|
||||
public List<Vector2> _moves = new();
|
||||
public Sprite2D _image;
|
||||
public ProgressBar _healthBar;
|
||||
public Manager _manager;
|
||||
public Node _actions;
|
||||
public Node _conditions;
|
||||
public List<Trait> _traits = new();
|
||||
public override void _Ready()
|
||||
{
|
||||
_actions = GetNode("Actions");
|
||||
_conditions = GetNode("Conditions");
|
||||
_size = (int)(((CircleShape2D)GetNode<CollisionShape2D>("Bounds").Shape).Radius);
|
||||
|
||||
_aptitude._default = 5;
|
||||
@@ -41,7 +39,7 @@ public partial class Worker : CharacterBody2D
|
||||
|
||||
_image = GetNode<Sprite2D>("Sprite2D");
|
||||
|
||||
_actions.AddChild(new BasicAttack(this));
|
||||
_traits.Add(new BasicAttack(this));
|
||||
|
||||
// _healthBar = GetNode<ProgressBar>("HealthBar");
|
||||
// _healthBar.MaxValue = _healthMax;
|
||||
@@ -86,28 +84,23 @@ public partial class Worker : CharacterBody2D
|
||||
}
|
||||
}
|
||||
|
||||
public void FireActions(Trigger.On TRIGGER, Node TARGET = null)
|
||||
public void FireActions(Trigger.On TRIGGER, Worker TARGET = null)
|
||||
{
|
||||
List<Node> children = _actions.GetChildren().ToList();
|
||||
for (int i = 0; i < children.Count; i++)
|
||||
for (int i = 0; i < _traits.Count; i++)
|
||||
{
|
||||
if (children[i] is Action)
|
||||
if (_traits[i]._triggers.Contains(TRIGGER))
|
||||
{
|
||||
Action action = (Action)children[i];
|
||||
if (action._triggers.Contains(TRIGGER))
|
||||
{
|
||||
action.Target(TARGET);
|
||||
action.Fire();
|
||||
}
|
||||
_traits[i].Target(TARGET);
|
||||
_traits[i].Fire();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasCondition(string CONDITION)
|
||||
{
|
||||
List<string> conditionNames = _conditions.GetChildren().Select(c => c.GetType().ToString()).ToList();
|
||||
return conditionNames.Contains(CONDITION);
|
||||
}
|
||||
// public bool HasCondition(string CONDITION)
|
||||
// {
|
||||
// List<string> conditionNames = _conditions.GetChildren().Select(c => c.GetType().ToString()).ToList();
|
||||
// return conditionNames.Contains(CONDITION);
|
||||
// }
|
||||
|
||||
public void Hold()
|
||||
{
|
||||
@@ -132,11 +125,13 @@ public partial class Worker : CharacterBody2D
|
||||
private void OnMouseEntered()
|
||||
{
|
||||
_hovered = true;
|
||||
EmitSignal(SignalName.SetHovered, this);
|
||||
}
|
||||
|
||||
private void OnMouseExited()
|
||||
{
|
||||
_hovered = false;
|
||||
EmitSignal(SignalName.SetHovered, this);
|
||||
}
|
||||
|
||||
// private void OnBodyEntered(Node NODE)
|
||||
|
||||
Reference in New Issue
Block a user