Particles system
This commit is contained in:
parent
30266b36cf
commit
0e5dee50f7
46 changed files with 643 additions and 200 deletions
|
|
@ -18,8 +18,10 @@ public partial class PoolContainer : Node2D
|
|||
public Node2D Projectiles { get; private set; }
|
||||
[Export]
|
||||
public Node2D Structures { get; private set; }
|
||||
[Export]
|
||||
public Node2D Particles { get; private set; }
|
||||
|
||||
public static PoolContainer Instance {get; private set;}
|
||||
public static PoolContainer Instance { get; private set; }
|
||||
|
||||
public Dictionary<Vector2, IEntity>[] EntityField = { new(), new(), new() };
|
||||
public override void _Ready()
|
||||
|
|
@ -27,31 +29,38 @@ public partial class PoolContainer : Node2D
|
|||
Instance = this;
|
||||
}
|
||||
public bool TryGetEntity(Vector2 key, out IEntity result, int layer = 1)
|
||||
{
|
||||
if (EntityField[layer].ContainsKey(key))
|
||||
{
|
||||
result = EntityField[layer][key];
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
return EntityField[layer].ContainsKey(key)
|
||||
{
|
||||
if (EntityField[layer].ContainsKey(key))
|
||||
{
|
||||
result = EntityField[layer][key];
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
return EntityField[layer].ContainsKey(key)
|
||||
&& EntityField[layer][key] != null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetEntity<T>(Vector2 key, out T result, int layer = 1) where T : class
|
||||
{
|
||||
if (EntityField[layer].ContainsKey(key))
|
||||
{
|
||||
result = EntityField[layer][key] as T;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
return EntityField[layer].ContainsKey(key)
|
||||
{
|
||||
result = EntityField[layer][key] as T;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
return EntityField[layer].ContainsKey(key)
|
||||
&& EntityField[layer][key] != null
|
||||
&& result != null;
|
||||
}
|
||||
|
||||
public void SpawnParticles(PackedScene particles, Vector2 position)
|
||||
{
|
||||
var emitter = particles.Instantiate<StandardParticles>();
|
||||
Instance.Particles.AddChild(emitter);
|
||||
emitter.GlobalPosition = position;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue