Friday, 22 August 2025 01:17:08

This commit is contained in:
2025-08-22 01:17:10 -04:00
parent 2eb95b18fd
commit 4fe431a8e0
18 changed files with 172 additions and 56 deletions

View File

@@ -1,38 +1,47 @@
using Godot;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Linq;
public partial class Worker : RigidBody2D
{
public bool _dead = false, _hovered = false, _held = false, _placed = false, _selected = false, _primed = false, _moving = false;
public int _health, _healthMax, _aptitude, _agility, _ardor, _accumen, _awareness, _appeal, _id;
public bool _dead = false, _hovered = false, _held = false, _placed = false, _selected = false, _primed = false, _moving = false, _staminaCanDrain = true;
public int _health, _healthMax;
public float _stamina, _staminaMax;
public Stat _aptitude = new(), _agility = new(), _ardor = new(), _accumen = new(), _awareness = new(), _appeal = new();
public float _rotationalForce = 0;
public Vector2 _force = Vector2.Zero;
public Node _collisionTarget;
public Sprite2D _image;
public ProgressBar _healthBar;
public Manager _manager;
public List<Action> _Actions = new();
public List<Action> _actions = new();
public List<Condition> _conditions = new();
public override void _Ready()
{
_health = 10;
_aptitude = 5;
_agility = 5;
_ardor = 5;
_accumen = 5;
_awareness = 5;
_appeal = 5;
_aptitude._default = 5;
_agility._default = 5;
_ardor._default = 5;
_accumen._default = 5;
_awareness._default = 5;
_appeal._default = 5;
_aptitude._effective = _aptitude._default;
_agility._effective = _agility._default;
_ardor._effective = _ardor._default;
_accumen._effective = _accumen._default;
_awareness._effective = _awareness._default;
_appeal._effective = _appeal._default;
_healthMax = _health;
_image = GetNode<Sprite2D>("Sprite2D");
_Actions.Add(new BasicAttack(this));
_actions.Add(new BasicAttack(this));
_healthBar = GetNode<ProgressBar>("HealthBar");
_healthBar.MaxValue = _healthMax;
_healthBar.Value = _health;
// _healthBar = GetNode<ProgressBar>("HealthBar");
// _healthBar.MaxValue = _healthMax;
// _healthBar.Value = _health;
}
public override void _Process(double DELTA_)
@@ -62,7 +71,7 @@ public partial class Worker : RigidBody2D
{
_selected = false;
_force = (GlobalPosition - mousePosition) * 100;
_rotationalForce = 5f;
_stamina = _agility._effective;
_primed = true;
}
}
@@ -79,9 +88,12 @@ public partial class Worker : RigidBody2D
{
// Vector2 towardCenter = (Globals.Instance._screenCenter - GlobalPosition).Normalized();
// ApplyCentralForce(towardCenter * 100);
_image.Rotate(_rotationalForce);
_rotationalForce -= 0.5f / 60;
if (_rotationalForce <= 0f)
_image.Rotate(_stamina);
if (_staminaCanDrain)
{
_stamina -= 0.25f / 60;
}
if (_stamina <= 0f)
{
Stop();
}
@@ -121,7 +133,6 @@ public partial class Worker : RigidBody2D
}
}
public void Drop()
{
if (_held)
@@ -132,6 +143,24 @@ public partial class Worker : RigidBody2D
}
}
public void FireActions(Trigger.On TRIGGER, Node TARGET = null)
{
List<Action> triggeredActions = _actions.Where(e => e._triggers.Contains(TRIGGER)).ToList();
for (int i = 0; i < triggeredActions.Count; i++)
{
triggeredActions[i].Target(TARGET);
triggeredActions[i].Fire();
}
List<Action> expiredActions = _actions.Where(e => e._triggers.Contains(TRIGGER)).ToList();
_actions.Except(expiredActions);
}
public bool HasCondition(string CONDITION)
{
List<string> conditionNames = _conditions.Select(c => c.GetType().ToString()).ToList();
return conditionNames.Contains(CONDITION);
}
public void Hold()
{
if (_held)
@@ -157,20 +186,18 @@ public partial class Worker : RigidBody2D
GravityScale = 0.0f;
Sleeping = true;
_moving = false;
_rotationalForce = 0f;
_stamina = 0f;
FireActions(Trigger.On.Stop, _manager);
}
public void FireActions(Trigger.On TRIGGER, Node TARGET = null)
public void ResetStats()
{
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);
_aptitude._effective = _aptitude._default;
_agility._effective = _agility._default;
_ardor._effective = _ardor._default;
_accumen._effective = _accumen._default;
_awareness._effective = _awareness._default;
_appeal._effective = _appeal._default;
}
// PRIVATE METHODS