mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Disable debugdraw in release
This commit is contained in:
parent
7c2d01a52e
commit
34a0e8e380
8 changed files with 70 additions and 68 deletions
|
|
@ -33,12 +33,12 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
public bool Enabled { get; private set; } = false;
|
||||
|
||||
//public float SpriteRotation { get; private set; } = 0f;
|
||||
|
||||
|
||||
[Signal]
|
||||
public delegate void OnDestroyEventHandler();
|
||||
|
||||
[Signal]
|
||||
public delegate void InitializedEventHandler();
|
||||
public delegate void InitializedEventHandler();
|
||||
|
||||
private AudioStreamPlayer3D _grazeSound;
|
||||
private GpuParticles3D _grazeParticles;
|
||||
|
|
@ -70,7 +70,7 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
rotation
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_grazeSound = GetNodeOrNull<AudioStreamPlayer3D>("GrazeSound");
|
||||
|
|
@ -84,7 +84,7 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
public void Initialize(BulletInfo bulletInfo)
|
||||
{
|
||||
_bulletInfo = bulletInfo;
|
||||
|
||||
|
||||
_elapsedTime = 0f;
|
||||
|
||||
this.Speed = bulletInfo.Speed;
|
||||
|
|
@ -99,12 +99,12 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
|
||||
if (_collisionShape.Shape is SphereShape3D sphere && bulletInfo.OriginalBulletResource.BulletSize > 0)
|
||||
{
|
||||
sphere.Radius = bulletInfo.OriginalBulletResource.BulletSize;
|
||||
sphere.Radius = bulletInfo.OriginalBulletResource.BulletSize;
|
||||
}
|
||||
|
||||
IsGrazed = false;
|
||||
IsFrozen = false;
|
||||
|
||||
|
||||
// Need to clone them here
|
||||
// _modifiers = _bulletInfo.TimeModifiers.Select(x => x.MakeClone()).ToList();
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
|
||||
// Ugly hack to make instances unique
|
||||
_modifiers = _bulletInfo.TimeModifiers.Select(x => x.Wrap()).ToList();
|
||||
|
||||
|
||||
EmitSignalInitialized();
|
||||
}
|
||||
|
||||
|
|
@ -134,11 +134,11 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
direction.X * cos - direction.Y * sin,
|
||||
direction.X * sin + direction.Y * cos
|
||||
);
|
||||
|
||||
|
||||
//float zRotation = Mathf.Atan2(rotatedDir.Y, rotatedDir.X)/* - Mathf.Pi / 2f*/;
|
||||
|
||||
|
||||
float zRotation = Mathf.Atan2(-rotatedDir.Y, rotatedDir.X) + Mathf.Pi;
|
||||
|
||||
|
||||
return MakeRotationVectorRad(zRotation);
|
||||
}
|
||||
|
||||
|
|
@ -190,7 +190,6 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
|
||||
private void ApplyTimeModifiers(double delta)
|
||||
{
|
||||
|
||||
foreach (var modifier in _modifiers)
|
||||
{
|
||||
if (_elapsedTime >= modifier.TimeModifier.TimeInSeconds)
|
||||
|
|
@ -205,9 +204,8 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
{
|
||||
modifier.Elapsed += delta;
|
||||
}
|
||||
|
||||
|
||||
modifier.TimeModifier.Update(this, delta, modifier.Elapsed);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -216,7 +214,7 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
{
|
||||
float radians = Mathf.DegToRad(degrees);
|
||||
_direction = _direction.Rotated(radians).Normalized(); // Rotate direction
|
||||
|
||||
|
||||
if (!BulletInfo.Attributes.HasFlag(BulletFlags.Rotateable)) return;
|
||||
SetSpriteRotationToDirection();
|
||||
//SetRotation(Rotation + radians);
|
||||
|
|
@ -227,9 +225,9 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
if (!BulletInfo.Attributes.HasFlag(BulletFlags.Rotateable)) return;
|
||||
|
||||
var currentRotation = _sprite.GetRotationDegrees().Z;
|
||||
|
||||
|
||||
_sprite.RotateZ(Mathf.DegToRad(currentRotation + degrees));
|
||||
|
||||
|
||||
// SpriteRotation = Mathf.DegToRad(Mathf.RadToDeg(SpriteRotation) + degrees);
|
||||
|
||||
//SetRotationDegrees(RotationDegrees + degrees);
|
||||
|
|
@ -240,28 +238,28 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
if (!BulletInfo.Attributes.HasFlag(BulletFlags.Rotateable)) return;
|
||||
|
||||
var currentRotation = _sprite.GetRotation().Z;
|
||||
|
||||
|
||||
var axis = Basis.FromEuler(_defaultRotation).Z;
|
||||
_sprite?.Rotate(axis, currentRotation + radians);
|
||||
|
||||
|
||||
//_sprite.SetRotation(new Vector3());
|
||||
//Rotate(axis, radians);
|
||||
//_sprite?.Rotate(Vector3.Forward, radians);
|
||||
//_sprite?.RotateZ(radians);
|
||||
//SetRotation(Rotation + radians);
|
||||
|
||||
}
|
||||
|
||||
public void FacePlayer()
|
||||
{
|
||||
if (GameController.Instance.PlayerPosition.HasValue)
|
||||
{
|
||||
_direction = (GameController.Instance.PlayerPosition.Value.ToVector2() - this.GlobalPosition.ToVector2()).Normalized();
|
||||
_direction = (GameController.Instance.PlayerPosition.Value.ToVector2() - this.GlobalPosition.ToVector2())
|
||||
.Normalized();
|
||||
RotateBullet(0); // quick hack to rotate lasers
|
||||
//LookAt(player.GlobalPosition);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void SetDirection(Vector2 direction)
|
||||
{
|
||||
|
|
@ -270,11 +268,9 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
_direction = normalized;
|
||||
|
||||
if (!BulletInfo.Attributes.HasFlag(BulletFlags.Rotateable)) return;
|
||||
|
||||
|
||||
SetSpriteRotationToDirection();
|
||||
//SetRotation(Mathf.Atan2(normalized.Y, normalized.X) + Mathf.Pi / 2);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
|
|
@ -290,7 +286,10 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
|
||||
if (GameController.Instance is not null && GameController.Instance.DebugDraw)
|
||||
{
|
||||
DebugDraw3D.DrawSphere(this.GlobalPosition, this._bulletInfo.OriginalBulletResource.BulletSize, Colors.DarkRed);
|
||||
#if !DISABLE_DD3D
|
||||
DebugDraw3D.DrawSphere(this.GlobalPosition, this._bulletInfo.OriginalBulletResource.BulletSize,
|
||||
Colors.DarkRed);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -308,7 +307,7 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
}
|
||||
|
||||
var newPos2D = ((float)(Speed * delta) * _direction);
|
||||
|
||||
|
||||
this.Position += new Vector3(newPos2D.X, 0, newPos2D.Y);
|
||||
}
|
||||
|
||||
|
|
@ -335,7 +334,7 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
private readonly StringName SolidGroup = "Solid";
|
||||
private readonly StringName PermeableGroup = "Permeable";
|
||||
private readonly StringName DestroyableGroup = "Destroyable";
|
||||
|
||||
|
||||
private void _on_body_entered(Node3D body)
|
||||
{
|
||||
if (body.IsInGroup(DestroyableGroup) && body is IDestructible destructible &&
|
||||
|
|
@ -347,7 +346,7 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
RequestCollisionDestruction();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (body.IsInGroup(SolidGroup) && !body.IsInGroup(PermeableGroup))
|
||||
{
|
||||
//Debug.WriteLine("Collision");
|
||||
|
|
@ -407,7 +406,7 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
var particleData =
|
||||
_bulletInfo?.OriginalBulletResource.DestructionParticlesBullet.MakeBullet(
|
||||
this.GlobalPosition.ToVector2());
|
||||
|
||||
|
||||
var particle = PoolingManager.Instance.SpawnBullet<Bullet3D>(particleData.OriginalBulletResource);
|
||||
particle.GlobalPosition = this.GlobalPosition;
|
||||
particle.Initialize(particleData);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue