This commit is contained in:
Marco 2025-06-18 18:09:30 +02:00
commit 341f76d885
17 changed files with 156 additions and 55 deletions

View file

@ -47,7 +47,7 @@ public partial class KeyboardInputProvider : InputProvider
private void DelayedRegisterGameManager()
{
_mouseAImProvider = GetNodeOrNull<IMouseAimProvider>("MouseAimProvider");
_mouseAImProvider = this.GetParent().GetNodeOrNull<IMouseAimProvider>("MouseAimProvider");
if (_mouseAImProvider is null)
{
@ -57,10 +57,18 @@ public partial class KeyboardInputProvider : InputProvider
if (GameManager.Instance is null)
{
GD.Print("No GameManager found for keyboard inputprovider");
return;
}
else
{
GameManager.Instance.GameStateChange += InstanceOnGameStateChange;
}
GameManager.Instance.GameStateChange += InstanceOnGameStateChange;
if (GameController.Instance is not null)
{
GameController.Instance.GameStateChange += InstanceOnGameStateChange;
}
_enabled = true;
}

View file

@ -13,4 +13,5 @@ public partial class MouseAimProvider3D : Node3D, IMouseAimProvider
return mouseWorldPos - screenPosition;
}
}

View file

@ -53,10 +53,12 @@ public partial class IsoMovementModule : ModuleBase<PlayerState, CharacterBody3D
if (rightStickInput.Length() > 0.1f) // If the right stick is moved
{
PlayerStorage.FacingDirection = rightStickInput;
PlayerStorage.AimingDirection = rightStickInput;
}
else if (movementInput != Vector2.Zero) // Fall back to movement direction
{
PlayerStorage.FacingDirection = movementInput;
PlayerStorage.AimingDirection = rightStickInput;
}
// }

View file

@ -52,8 +52,10 @@ public partial class PlayerWeaponModule3D : ModuleBase<PlayerState, CharacterBod
return;
}
if (!InputProvider.GetShootPressed()) return;
WeaponProvider.Shoot(Storage.AimingDirection);
if (InputProvider.GetShootPressed())
{
WeaponProvider.Shoot(Storage.AimingDirection);
}
}
private void HandleWeaponSwitch()

View file

@ -221,9 +221,12 @@ public partial class PlayerWeaponProvider3D : Node
if (maybeExistingWeapon is not null) return maybeExistingWeapon;
var weapon = WeaponTemplate.Instantiate<Weapon3D>();
this.AddChild(weapon);
_parent.AddChild(weapon);
weapon.GlobalPosition = _parent.GlobalPosition;
//this.CreateSibling<Weapon>(WeaponTemplate);
weapon.WeaponData = startingItem.WeaponData;
weapon.WeaponData = startingItem.WeaponData3D;
weapon.Sprite.Texture = startingItem.InventorySprite;

View file

@ -124,10 +124,10 @@ public partial class PoolingManager : Node
private IBullet InstantiateBullet(BulletResource bulletData)
{
var bullet = bulletData.BulletScene.Instantiate<Bullet>();
var bullet = bulletData.BulletScene.Instantiate<Node>();
this.AddChild(bullet);
//this.CreateChild<Bullet>(bulletData.BulletScene);
return bullet;
return bullet as IBullet;
}
}

View file

@ -17,6 +17,7 @@ public partial class LootItem : Resource
[Export] public int Price { get; set; }
[Export] public ItemEffectResource ItemEffect { get; private set; }
[Export] public WeaponResource WeaponData { get; set; }
[Export] public WeaponResource WeaponData3D { get; set; }
[Export] public int Amount;
[Export] public int Max;
[Export] public bool PickupIfMaxed;

View file

@ -36,17 +36,17 @@ public partial class Bullet3D : Area3D, IBullet
[Signal]
public delegate void OnDestroyEventHandler();
private AudioStreamPlayer2D _grazeSound;
private GpuParticles2D _grazeParticles;
private AudioStreamPlayer3D _grazeSound;
private GpuParticles3D _grazeParticles;
private CollisionShape2D _collisionShape2D;
private CollisionShape3D _collisionShape;
public override void _Ready()
{
_grazeSound = GetNodeOrNull<AudioStreamPlayer2D>("AudioStreamPlayer2D");
_grazeParticles = GetNodeOrNull<GpuParticles2D>("GrazeParticles");
_grazeSound = GetNodeOrNull<AudioStreamPlayer3D>("AudioStreamPlayer");
_grazeParticles = GetNodeOrNull<GpuParticles3D>("GrazeParticles");
_collisionShape2D = GetNode<CollisionShape2D>("CollisionShape2D");
_collisionShape = GetNode<CollisionShape3D>("CollisionShape");
}
public void Initialize(BulletInfo bulletInfo, GameManager gameManager)
@ -77,12 +77,12 @@ public partial class Bullet3D : Area3D, IBullet
{
Enabled = true;
Show();
if (this._collisionShape2D is null)
if (this._collisionShape is null)
{
_collisionShape2D = GetNode<CollisionShape2D>("CollisionShape2D");
_collisionShape = GetNode<CollisionShape3D>("CollisionShape");
}
_collisionShape2D.SetDeferred(CollisionShape2D.PropertyName.Disabled, false);
_collisionShape.SetDeferred(CollisionShape3D.PropertyName.Disabled, false);
}
/// <summary>
@ -96,12 +96,12 @@ public partial class Bullet3D : Area3D, IBullet
Hide();
}
if (this._collisionShape2D is null)
if (this._collisionShape is null)
{
_collisionShape2D = GetNode<CollisionShape2D>("CollisionShape2D");
_collisionShape = GetNode<CollisionShape3D>("CollisionShape2D");
}
_collisionShape2D.SetDeferred(CollisionShape2D.PropertyName.Disabled, true);
_collisionShape.SetDeferred(CollisionShape2D.PropertyName.Disabled, true);
}
public void Graze()
@ -209,7 +209,9 @@ public partial class Bullet3D : Area3D, IBullet
ControlBullet(delta);
}
//this.Position += ((float)(Speed * delta) * _direction);
var newPos2D = ((float)(Speed * delta) * _direction);
this.Position += new Vector3(newPos2D.X, 0, newPos2D.Y);
}
private void ControlBullet(double delta)
@ -232,7 +234,7 @@ public partial class Bullet3D : Area3D, IBullet
Destroy();
}
private void _on_body_entered(Node2D body)
private void _on_body_entered(Node3D body)
{
if (body.IsInGroup("Solid"))
{
@ -247,7 +249,7 @@ public partial class Bullet3D : Area3D, IBullet
// }
}
private void _on_area_entered(Area2D area)
private void _on_area_entered(Area3D area)
{
if (area.IsInGroup("Solid"))
{

View file

@ -5,7 +5,7 @@ using Godot;
namespace Cirno.Scripts.Weapons;
public partial class Weapon3D : Node
public partial class Weapon3D : Node3D
{
[Export]
public WeaponResource WeaponData { get; set; }
@ -103,18 +103,18 @@ public partial class Weapon3D : Node
}
// Check for battery if it's used
if (UsesBattery)
{
if (GameManager.Instance.Player.Shield.CurrentResource >= WeaponData.AmmoPerShot)
{
GameManager.Instance.Player.Shield.CurrentResource -= WeaponData.AmmoPerShot;
}
else
{
EmitSignalEmpty();
return;
}
}
// if (UsesBattery)
// {
// if (GameManager.Instance.Player.Shield.CurrentResource >= WeaponData.AmmoPerShot)
// {
// GameManager.Instance.Player.Shield.CurrentResource -= WeaponData.AmmoPerShot;
// }
// else
// {
// EmitSignalEmpty();
// return;
// }
// }
// Out of ammo?
if (LoadedAmmo < WeaponData.AmmoPerShot)