file refactor

This commit is contained in:
Rendo 2025-07-11 22:35:36 +05:00
commit bffb012a26
175 changed files with 1086 additions and 1107 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

47
scripts/zombies/EatBox.cs Normal file
View file

@ -0,0 +1,47 @@
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;
private RuntimePlantData plant;
public bool isEating = false;
public void Bite()
{
if (GetParent<RuntimeZombieData>().AbleToEat)
{
plant?.TakeDamage((int)_damage.GetValue(), GetParent());
}
}
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,53 @@
using Godot;
namespace Newlon.Components.Zombies;
public partial class RuntimeZombieData : Entity
{
[Export]
private Armor _armor;
[Export]
private AudioStream garlicSound;
[Export]
private AudioStream freezeSound;
public bool AbleToEat = true;
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();
}
}
#region Death sequence
public override void KillByDamage()
{
AbleToEat = false;
}
#endregion
}

View file

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

View file

@ -0,0 +1,46 @@
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>();
_speed = (FloatModifiers)_speed.Duplicate();
_speed.ChangePercentage((float)GD.RandRange(-0.05,0.05));
}
public override void _PhysicsProcess(double delta)
{
_zombie.Position -= _zombie.Transform.X
* (float)delta
* Utility.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("hobo_zombie_can_destroy");
_eatBox._damage.SetMult(3.0f);
}
}

View file

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