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,41 @@
using System;
using Godot;
using Godot.Collections;
public partial class FallFloor : Node2D
{
private static FallFloor Instance;
private Array<StaticBody2D> bodies = [];
public override void _Ready()
{
Instance = this;
foreach (StaticBody2D body in GetChildren())
{
bodies.Add(body);
}
}
public static StaticBody2D GetNearest(Vector2 point)
{
var selected = Instance.bodies[0];
foreach (StaticBody2D body in Instance.bodies)
{
if (Math.Abs(selected.GlobalPosition.Y - point.Y) > Math.Abs(body.GlobalPosition.Y - point.Y))
{
selected = body;
}
}
return selected;
}
public static Array<StaticBody2D> GetEverythingElse(StaticBody2D except)
{
Array<StaticBody2D> bodys = [];
foreach (StaticBody2D body in Instance.bodies)
{
if (except != body)
{
bodys.Add(body);
}
}
return bodys;
}
}

View file

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

View file

@ -0,0 +1,33 @@
using Godot;
using Newlon.Components.Level;
using Newlon.Components.Zombies;
public partial class FallParticle : RigidBody2D
{
[Export] private RuntimeZombieData data;
[Export] private float minAngle;
[Export] private float maxAngle;
[Export] private float minTorque;
[Export] private float maxTorque;
[Export] private float Impulse;
public void FallOff()
{
SetDeferred("freeze", false);
foreach (var floor in FallFloor.GetEverythingElse(FallFloor.GetNearest(data.GlobalPosition)))
{
AddCollisionExceptionWith(floor);
}
Callable.From(() =>
{
Reparent(PoolContainer.Instance.Zombies);
float rng_angle = Mathf.DegToRad((float)GD.RandRange(minAngle, maxAngle));
float rng_torque = Mathf.DegToRad((float)GD.RandRange(minTorque, maxTorque));
ApplyImpulse(new Vector2(Mathf.Sin(rng_angle) * Impulse, Mathf.Cos(rng_angle) * Impulse));
ApplyTorqueImpulse(rng_torque);
}).CallDeferred();
var tween = CreateTween();
tween.TweenInterval(4.0);
tween.TweenProperty(this, "modulate", new Color(Modulate.R, Modulate.G, Modulate.B, 0f), 1.0);
tween.TweenCallback(Callable.From(QueueFree));
}
}

View file

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

View file

@ -0,0 +1,22 @@
using Godot;
public partial class StandardParticles : Node2D
{
private int counter = 0;
private int counterMax = 0;
public override void _Ready()
{
foreach (GpuParticles2D emitter in GetChildren())
{
emitter.Emitting = true;
counterMax += 1;
emitter.Finished += MarkForDestruction;
}
}
public void MarkForDestruction()
{
if (Engine.IsEditorHint()) return;
if (++counter < counterMax) return;
QueueFree();
}
}

View file

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