Skip to content

Commit a8afa6d

Browse files
committed
Add basic grenade icon for testing.
Add inputnames for making input keys more esay Edit GunBase to use UsableBase AnimPlayer exposed to public MainMenu temporarly moving you to Inventory Instead of Settings (soon be back) Remove GunUse in InvModule Changing player to use InputNames Adding Slow, Run speed for player add InputHandle for server (commands and stuff) Add basic ItemSlot, inventory Scene
1 parent b689904 commit a8afa6d

24 files changed

+437
-78
lines changed

assets/game-icons/grenade.png

35.8 KB
Loading

assets/game-icons/licenses.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
grenade.png
2+
https://game-icons.net/1x1/lorc/grenade.html#download
3+
https://lorcblog.blogspot.com/
4+
https://creativecommons.org/licenses/by/3.0/
5+
6+
---

assets/game-icons/readme.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
All icons downloaded from https://game-icons.net/
2+
3+
See licenses.txt for individual icon assets.
4+
5+
FileName
6+
Link to download page
7+
Who made it (Link if can)
8+
License Link

csharp/Client/GameSettings.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ public partial class GameSettings : Resource
66
{
77
[Export]
88
public VideoSettings Video { get; set; } = new();
9+
10+
[Export]
11+
public ControlSettings Control { get; set; } = new();
912
}
1013

1114
public partial class VideoSettings : Resource
@@ -37,6 +40,13 @@ public partial class VideoSettings : Resource
3740
public ScreenSizeEnum ScreenSize = ScreenSizeEnum._1280x720;
3841
}
3942

43+
public partial class ControlSettings : Resource
44+
{
45+
//var s = InputMap.ActionGetEvents("move_left")[0] as InputEventKey;
46+
47+
}
48+
49+
4050
public enum Scaling3DScaleEnum : byte
4151
{
4252
Performance,

csharp/Game/Consts.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using Godot;
2+
3+
namespace ExtractIntoVoid;
4+
5+
public static partial class Consts
6+
{
7+
public static float Gravity => ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle();
8+
}

csharp/Game/InputNames.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Godot;
2+
3+
namespace ExtractIntoVoid;
4+
5+
public static partial class InputNames
6+
{
7+
public static StringName MoveForward = "move_forward";
8+
public static StringName MoveBackward = "move_backward";
9+
public static StringName MoveLeft = "move_left";
10+
public static StringName MoveRight = "move_right";
11+
public static StringName Sprint = "move_sprint";
12+
public static StringName SlowWalk = "move_slowly";
13+
public static StringName Jump = "move_jump";
14+
public static StringName Crouch = "move_crouch";
15+
public static StringName Prone = "move_prone"; // Currently not implemented.
16+
public static StringName InventoryOpen = "inventory_open";
17+
public static StringName ItemUse = "item_use";
18+
public static StringName ItemCancel = "item_cancel";
19+
public static StringName WeaponReload = "weapon_reload";
20+
public static StringName ToolSlot0 = "slot0";
21+
public static StringName ToolSlot1 = "slot1";
22+
public static StringName ToolSlot2 = "slot2";
23+
public static StringName ToolSlot3 = "slot3";
24+
public static StringName ToolSlot4 = "slot4";
25+
public static StringName ToolSlot5 = "slot5";
26+
public static StringName ToolSlot6 = "slot6";
27+
public static StringName ToolSlot7 = "slot7";
28+
public static StringName ToolSlot8 = "slot8";
29+
public static StringName ToolSlot9 = "slot9";
30+
public static StringName MenuButton = "menu"; //Esc
31+
32+
// Add
33+
}

csharp/Items/GunBase.cs

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,48 @@
77

88
namespace ExtractIntoVoid.Items;
99

10-
public abstract partial class GunBase : InventoryItemBase
10+
public abstract partial class GunBase : UsableBase
1111
{
12-
Marker3D BulletSpawner;
13-
public Gun Gun => InventoryModule.Inventory.Hand.As<Gun>();
14-
12+
public Gun Gun => UsableItem.As<Gun>();
1513
public bool IsJammed { get; internal set; } = false;
14+
public Marker3D BulletSpawner { get; internal set; }
15+
1616
public override void _Ready()
1717
{
1818
BulletSpawner = GetNode<Marker3D>("BulletSpawner");
1919
}
2020

21-
public virtual void Shoot()
21+
public override void OnTick(double delta)
2222
{
2323
if (Gun.Magazine == null)
2424
return;
2525
if (IsJammed)
2626
return;
27-
if (Gun.Magazine.Ammunitions.Count > 0)
27+
if (Gun.Magazine.Ammunitions.Count == 0)
28+
return;
29+
30+
Ammo ammo = Gun.Magazine.Ammunitions.First();
31+
// Ammo doesnt have 3D representation of itself :(
32+
if (!ammo.HasValidAssetPath())
2833
{
29-
var ammo = Gun.Magazine.Ammunitions.First();
30-
// Ammo doesnt have 3D representation of itself :(
31-
if (!ammo.HasValidAssetPath())
32-
{
33-
PlayJammed();
34-
return;
35-
}
36-
var id = GD.Randi();
37-
var BulletSpawnTransform = BulletSpawner.GlobalTransform.LookingAt(BulletSpawner.Position);
38-
Rpc("ShootBullet", (int)id, ammo.Serialize(), BulletSpawnTransform);
39-
GetNode<AnimationPlayer>("AnimationPlayer").Play("Shoot");
40-
// UI update here
41-
Gun.Magazine.Ammunitions.Remove(ammo);
34+
PlayJammed();
35+
return;
4236
}
37+
Transform3D BulletSpawnTransform = BulletSpawner.GlobalTransform.LookingAt(BulletSpawner.Position);
38+
Rpc("ShootBullet", (int)GD.Randi(), ammo.Serialize(), BulletSpawnTransform);
39+
if (AnimPlayer != null)
40+
AnimPlayer.Play("Shoot");
41+
42+
#if CLIENT || GAME
43+
// UI update here
44+
#endif
45+
Gun.Magazine.Ammunitions.Remove(ammo);
46+
}
47+
48+
// Overriding cancel because we use that to "AIM"
49+
public override void UsingCancel()
50+
{
51+
// Todo Aim logic
4352
}
4453

4554
public virtual void PlayJammed()
@@ -74,9 +83,8 @@ private void ShootBullet(int id, byte[] ammo_bytes, Transform3D transform)
7483
GD.Print("Bullet Couldnt spawned because the scene is null");
7584
return;
7685
}
77-
78-
//
79-
var bullet = bulletScene.Instantiate<Bullet>();
86+
87+
Bullet bullet = bulletScene.Instantiate<Bullet>();
8088
bullet.Name = "Bullet_" + id.ToString();
8189
bullet.SetMP(id);
8290
bullet.SetAmmo(ammo);

csharp/Items/ThrowableBase.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,17 @@ namespace ExtractIntoVoid.Items;
66

77
public abstract partial class ThrowableBase : UsableBase
88
{
9-
public float Gravity = ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle();
109
public Throwable Throwable => UsableItem.As<Throwable>();
11-
12-
decimal FuseTime;
1310
public bool IsThrown { get; internal set; }
11+
private decimal FuseTime;
1412
public override void _Process(double delta)
1513
{
1614
if (!IsThrown)
1715
return;
1816
// Calculate to dont go to direction always, use the weight to be down a little i guess.
1917
Vector3 Pos = Position;
2018
Pos = Pos + -GlobalTransform.Basis.Z * 1;
21-
Pos.Y = Pos.Y - Gravity * (float)delta * 0.01f;
19+
Pos.Y = Pos.Y - Consts.Gravity * (float)delta * 0.1f;
2220
Position = Pos;
2321

2422
FuseTime -= (decimal)delta;

csharp/Items/UsableBase.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ namespace ExtractIntoVoid.Items;
66

77
public abstract partial class UsableBase : InventoryItemBase
88
{
9-
AnimationPlayer Animation;
109
public CoreUsable UsableItem => InventoryModule.Inventory.Hand.As<CoreUsable>();
10+
public AnimationPlayer AnimPlayer { get; protected set; }
1111
bool IsInUse = false;
1212
decimal UseTime = 0;
1313

1414
public UsableBase() : base()
1515
{
1616
if (HasNode("Animation"))
17-
Animation = GetNode<AnimationPlayer>("Animation");
18-
Animation = null;
17+
AnimPlayer = GetNode<AnimationPlayer>("Animation");
18+
AnimPlayer = null;
1919
}
2020

2121
public virtual void UsingStart()
@@ -33,17 +33,18 @@ public virtual void UsingCancel()
3333
IsInUse = false;
3434
UseTime = UsableItem.UseTime;
3535
}
36+
OnUsingCancelled();
3637
}
3738
public virtual void OnUsingStarted()
3839
{
39-
if (Animation != null)
40-
Animation.Play("Start");
40+
if (AnimPlayer != null)
41+
AnimPlayer.Play("Start");
4142
}
4243

4344
public virtual void OnUsingCancelled()
4445
{
45-
if (Animation != null)
46-
Animation.Play("RESET");
46+
if (AnimPlayer != null)
47+
AnimPlayer.Play("RESET");
4748
}
4849

4950
public virtual void OnUsingFinished()

csharp/Managers/ArgManager.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@ public static string GetArgParam(string search)
2525

2626
public static bool HasArgParam(string search)
2727
{
28-
var cmd_args = Godot.OS.GetCmdlineArgs().AsSpan();
29-
return cmd_args.Contains($"--{search}=");
28+
return Godot.OS.GetCmdlineArgs().AsSpan().Contains($"--{search}=");
3029
}
3130

3231
public static bool HasArg(string search)
3332
{
34-
var cmd_args = Godot.OS.GetCmdlineArgs().AsSpan();
35-
return cmd_args.Contains($"--{search}");
33+
return Godot.OS.GetCmdlineArgs().AsSpan().Contains($"--{search}");
3634
}
3735
}

0 commit comments

Comments
 (0)