filesystem rework

This commit is contained in:
Rendo 2025-07-19 20:13:34 +05:00
commit 2905db3dce
174 changed files with 93 additions and 353 deletions

View file

@ -0,0 +1,11 @@
using Godot;
namespace Newlon.Components.Zombies;
public partial class AudioDamage : AudioStreamPlayer2D
{
public void OnDamaged(int amount, Node origin)
{
Play();
}
}

View file

@ -0,0 +1 @@
uid://bsg4utgc0u0vo

View file

@ -0,0 +1,50 @@
using Godot;
using Newlon.Components.Plants;
namespace Newlon.Components.Zombies;
public partial class EatBox : Area2D
{
// Rewrite this class completely when field system will be introduced.
[Export] public FloatModifiers _damage;
[Export]
private AudioStream biteSound = ResourceLoader.Load<AudioStream>("uid://dyid55nhflwyn");
private RuntimePlantData plant;
public bool isEating = false;
public void Bite()
{
if (GetParent<RuntimeZombieData>().AbleToEat)
{
plant?.TakeDamage((int)_damage.GetValue(), GetParent());
AudioSequencer.Play("bite", biteSound);
}
}
public void OnAreaEntered(Area2D area)
{
var parent = area.GetParent();
if (parent != null && parent is RuntimePlantData plantData)
{
plant = plantData;
isEating = true;
}
}
public void OnAreaExited(Area2D area)
{
var parent = area.GetParent();
if (parent == plant)
{
plant = null;
isEating = false;
}
}
}

View file

@ -0,0 +1 @@
uid://dqyony6jxt2p0

View file

@ -0,0 +1,78 @@
using Godot;
namespace Newlon.Components.Zombies;
public partial class RuntimeZombieData : Entity
{
[Export]
private Armor _armor;
[Signal] public delegate void HasBeenKilledEventHandler(RuntimeZombieData who);
[Signal] public delegate void HPChangedMixedEventHandler(float delta);
public bool AbleToEat = true;
public override void _Ready()
{
base._Ready();
OnHPChanged += HPChangedMixedInvokerSource;
LocalTimescale -= (float)GD.Randf() / 100.0f;
}
public override void Heal(float amount, Node origin)
{
if (_armor != null)
{
HP += _armor.Heal(amount);
}
else
HP += amount;
EmitSignal(SignalName.OnHPChanged, amount, origin);
if (HP > MaxHP)
{
HP = MaxHP;
}
}
public override void TakeDamage(float amount, Node origin)
{
if (_armor != null)
{
HP -= _armor.RecieveDamage(amount);
}
else
HP -= amount;
EmitSignal(SignalName.OnHPChanged, -amount, origin);
EmitSignal(SignalName.OnDamaged);
if (HP <= 0)
{
KillByDamage();
}
}
public void HPChangedMixedInvokerSource(float delta, Node source)
{
EmitSignal(SignalName.HPChangedMixed, delta);
}
public void HPChangedMixedInvoker(float delta)
{
EmitSignal(SignalName.HPChangedMixed, -delta);
}
public float GetMaxHPMixed()
{
if (_armor != null)
return MaxHP + _armor.MaxHP;
return MaxHP;
}
#region Death sequence
private bool _killed = false;
public override void KillByDamage()
{
if (_killed) return;
_killed = true;
AbleToEat = false;
EmitSignal(SignalName.HasBeenKilled,this);
}
#endregion
}

View file

@ -0,0 +1 @@
uid://dildme6epx8l4

View file

@ -0,0 +1,24 @@
using Godot;
using Newlon.Components.Zombies;
public partial class ZombieKillHandler : Node
{
[Export] private AnimationTree _tree;
[Export] private CollisionShape2D _collider;
private void OnKilled(RuntimeZombieData who)
{
var tween = CreateTween();
tween.TweenInterval(4.0);
tween.TweenCallback(Callable.From(() =>
{
((AnimationNodeStateMachinePlayback)_tree.Get("parameters/Tree/playback")).Travel("Death");
_collider.Disabled = true;
}));
tween.TweenInterval(3.0);
tween.TweenProperty(who, "modulate",new Color(1, 1, 1, 0),1.0);
tween.TweenCallback(Callable.From(() =>
{
who.Kill();
}));
}
}

View file

@ -0,0 +1 @@
uid://dk32ln8c2574d

View file

@ -0,0 +1,44 @@
using Godot;
namespace Newlon.Components.Zombies;
public partial class ZombieMover : Node
{
[Export]
private FloatModifiers _speed;
[Export]
private float _speedControlMult;
private Node2D _zombie;
public override void _Ready()
{
_zombie = GetParent<Node2D>();
}
public override void _PhysicsProcess(double delta)
{
_zombie.Position -= _zombie.Transform.X
* (float)delta
* FieldParams.TileWidth
* GetParent<RuntimeZombieData>().LocalTimescale
* _speed.GetValue()
* _speedControlMult;
}
public void SetSpeedFlat(float speed)
{
_speed.SetFlat(speed);
}
public void SetSpeedPercentage(float speed)
{
_speed.SetPercentage(speed);
}
public void SetSpeedMult(float speed)
{
_speed.SetMult(speed);
}
public void AddMult(float amount)
{
_speed.ChangeMult(amount);
}
}

View file

@ -0,0 +1 @@
uid://7hdj2k14lfe4

View file

@ -0,0 +1,17 @@
using Godot;
namespace Newlon.Components.Zombies.Behaviours;
public partial class HoboBehaviour : Node
{
[Export] private EatBox _eatBox;
[Export] private AnimationTree _animationTree;
public bool isEating => _eatBox.isEating;
public bool canDestroyed = false;
public void Trashed()
{
canDestroyed = true;
((AnimationNodeStateMachinePlayback)_animationTree.Get("parameters/Tree/playback")).Travel("Destroy");
GetParent<Entity>().LocalTimescale *= 3;
}
}

View file

@ -0,0 +1 @@
uid://c5v2og85t7s6j