mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Selective bullet rotation
This commit is contained in:
parent
538f4f215f
commit
5624d0178c
8 changed files with 52 additions and 10 deletions
|
|
@ -117,16 +117,19 @@ public partial class Bullet : Area2D
|
|||
//SetRotationDegrees(RotationDegrees + degrees);
|
||||
float radians = Mathf.DegToRad(degrees);
|
||||
_direction = _direction.Rotated(radians).Normalized(); // Rotate direction
|
||||
if (!BulletInfo.RotateSprite) return;
|
||||
SetRotation(Rotation + radians);
|
||||
}
|
||||
|
||||
public virtual void RotateSpriteDegrees(float degrees)
|
||||
{
|
||||
if (!BulletInfo.RotateSprite) return;
|
||||
SetRotationDegrees(RotationDegrees + degrees);
|
||||
}
|
||||
|
||||
public virtual void RotateSprite(float radians)
|
||||
{
|
||||
if (!BulletInfo.RotateSprite) return;
|
||||
SetRotation(Rotation + radians);
|
||||
}
|
||||
|
||||
|
|
@ -156,6 +159,7 @@ public partial class Bullet : Area2D
|
|||
|
||||
_direction = normalized;
|
||||
|
||||
if (!BulletInfo.RotateSprite) return;
|
||||
SetRotation(Mathf.Atan2(normalized.Y, normalized.X) + Mathf.Pi / 2);
|
||||
|
||||
//Debug.WriteLine($"Bullet Shot at direction {direction.X} {direction.Y}");
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ public class BulletInfo
|
|||
public float RotationOffset { get; set; }
|
||||
//public double Time { get; set; }
|
||||
public float Spread { get; set; }
|
||||
public bool RotateSprite { get; set; } = false;
|
||||
public bool Controllabe { get; set; } = false;
|
||||
public PackedScene BulletScene { get; set; }
|
||||
public PackedScene DestructionParticlesScene { get; set; }
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ public partial class BulletResource : Resource
|
|||
[Export] public bool DestroyOnCollision = true;
|
||||
[Export] public BulletOwner Owner = BulletOwner.None;
|
||||
[Export] public DamageType DamageType = DamageType.Neutral;
|
||||
[Export] public bool RotateSprite = false;
|
||||
[Export] public bool Controllable = false;
|
||||
[Export] public bool Grazeable { get; set; } = true;
|
||||
[Export] public float GrazeValue { get; set; } = 0.2f;
|
||||
|
|
@ -45,6 +46,7 @@ public partial class BulletResource : Resource
|
|||
LifeTime = LifeTime,
|
||||
DestroyOnCollision = DestroyOnCollision,
|
||||
DestructionParticlesScene = DestructionParticlesScene,
|
||||
RotateSprite = RotateSprite,
|
||||
Controllabe = Controllable,
|
||||
TimeModifiers = TimeModifiers.Select(x => x).ToList(),
|
||||
Grazeable = Grazeable,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue