Initial commit
This commit is contained in:
35
Abilities/ProjectileBase.cs
Normal file
35
Abilities/ProjectileBase.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Godot;
|
||||
|
||||
public partial class ProjectileBase : Area2D
|
||||
{
|
||||
[Export] public float Speed { get; set; }
|
||||
|
||||
protected CharacterBase? Character;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
if (Character is null)
|
||||
{
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
|
||||
void OnBodyEntered(Node body)
|
||||
{
|
||||
if (body == Character)
|
||||
{
|
||||
// Ignore self
|
||||
return;
|
||||
}
|
||||
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
public void Spawn(CharacterBase character)
|
||||
{
|
||||
Character = character;
|
||||
Position = character.GlobalPosition;
|
||||
Rotation = character.FacingRotation;
|
||||
TopLevel = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user