mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 02:25:54 +00:00
Shooting
This commit is contained in:
parent
1229613def
commit
341f76d885
17 changed files with 156 additions and 55 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,4 +13,5 @@ public partial class MouseAimProvider3D : Node3D, IMouseAimProvider
|
|||
|
||||
return mouseWorldPos - screenPosition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
// }
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue