file refactor
This commit is contained in:
parent
da5a3e874b
commit
bffb012a26
175 changed files with 1086 additions and 1107 deletions
41
scripts/particles/FallFloor.cs
Normal file
41
scripts/particles/FallFloor.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
1
scripts/particles/FallFloor.cs.uid
Normal file
1
scripts/particles/FallFloor.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://blpu7t8tf6277
|
||||
33
scripts/particles/FallParticle.cs
Normal file
33
scripts/particles/FallParticle.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
1
scripts/particles/FallParticle.cs.uid
Normal file
1
scripts/particles/FallParticle.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dt5uj25u0g6y3
|
||||
22
scripts/particles/StandardParticles.cs
Normal file
22
scripts/particles/StandardParticles.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
1
scripts/particles/StandardParticles.cs.uid
Normal file
1
scripts/particles/StandardParticles.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dxcd70o6aa7pr
|
||||
Loading…
Add table
Add a link
Reference in a new issue