Files
GameJamDungeon/Zennysoft.Game.Ma/src/projectile/ProjectileSystem.cs
T
zenny f19cb7edda Rework projectiles and fix some demon wall attacks
Still working on Demon Wall boss fight overall
2026-03-09 22:05:53 -07:00

28 lines
859 B
C#

using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Godot;
using Zennysoft.Game.Ma;
[Meta(typeof(IAutoNode))]
public partial class ProjectileSystem : Node3D
{
public override void _Notification(int what) => this.Notify(what);
[Dependency] protected IMap _map => this.DependOn<IMap>();
[Export] public PackedScene ProjectileScene { get; set; }
[Export] private float _projectileForce { get; set; } = 7f;
public void Fire()
{
var instantiator = new Instantiator(GetTree());
var projectile = instantiator.LoadAndInstantiate<RigidBody3D>(ProjectileScene.ResourcePath);
_map.AddChild(projectile);
projectile.GlobalPosition = GlobalPosition;
projectile.GlobalBasis = GlobalBasis;
projectile.ResetPhysicsInterpolation();
projectile.ApplyCentralImpulse(projectile.GlobalBasis.Z * _projectileForce);
}
}