diff --git a/Imperfect Space.csproj b/Imperfect Space.csproj index 72ff5a0..d7ef75c 100644 --- a/Imperfect Space.csproj +++ b/Imperfect Space.csproj @@ -1,7 +1,9 @@ - + net8.0 - net9.0 + net9.0 true ImperfectSpace true diff --git a/Imperfect Space.csproj.old b/Imperfect Space.csproj.old deleted file mode 100644 index d7ef75c..0000000 --- a/Imperfect Space.csproj.old +++ /dev/null @@ -1,11 +0,0 @@ - - - net8.0 - net9.0 - true - ImperfectSpace - true - - diff --git a/Imperfect Space.csproj.old.1 b/Imperfect Space.csproj.old.1 deleted file mode 100644 index 787950a..0000000 --- a/Imperfect Space.csproj.old.1 +++ /dev/null @@ -1,9 +0,0 @@ - - - net8.0 - net9.0 - true - ImperfectSpace - true - - diff --git a/prefabs/modules/test_module_bridge.tscn b/prefabs/modules/test_module_bridge.tscn deleted file mode 100644 index ddc9a67..0000000 --- a/prefabs/modules/test_module_bridge.tscn +++ /dev/null @@ -1,46 +0,0 @@ -[gd_scene format=3 uid="uid://btspomjpmaeix"] - -[ext_resource type="Script" uid="uid://cy8nuarxbnd" path="res://scripts/GravityZone.cs" id="1_cp5qc"] -[ext_resource type="Script" uid="uid://d4naw4kwsaxgi" path="res://scripts/VesselModuleNode.cs" id="1_hmual"] - -[sub_resource type="CylinderMesh" id="CylinderMesh_cp5qc"] -top_radius = 5.0 -bottom_radius = 5.0 -height = 0.3 - -[sub_resource type="CylinderShape3D" id="CylinderShape3D_8km7m"] -height = 0.3 -radius = 5.0 - -[sub_resource type="CylinderShape3D" id="CylinderShape3D_ok5mh"] -height = 3.0 -radius = 5.0 - -[node name="TestModuleBridge" type="StaticBody3D" unique_id=734366198] -script = ExtResource("1_hmual") - -[node name="Mesh1" type="MeshInstance3D" parent="." unique_id=1213452774] -mesh = SubResource("CylinderMesh_cp5qc") - -[node name="Collider1" type="CollisionShape3D" parent="." unique_id=379931522] -shape = SubResource("CylinderShape3D_8km7m") - -[node name="GravityZone" type="Area3D" parent="." unique_id=431050752] -gravity_space_override = 2 -script = ExtResource("1_cp5qc") - -[node name="CollisionShape3D" type="CollisionShape3D" parent="GravityZone" unique_id=1904473317] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0) -shape = SubResource("CylinderShape3D_ok5mh") - -[node name="TestModuleBridge_AnchorBack" type="Node3D" parent="." unique_id=1526898268] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5) - -[node name="TestModuleBridge_AnchorLeft" type="Node3D" parent="." unique_id=1699158457] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5, 0, 0) - -[node name="TestModuleBridge_AnchorRight" type="Node3D" parent="." unique_id=742563404] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5, 0, 0) - -[connection signal="body_entered" from="GravityZone" to="GravityZone" method="OnBodyEntered"] -[connection signal="body_exited" from="GravityZone" to="GravityZone" method="OnBodyExited"] diff --git a/prefabs/modules/test_module_combined.tscn b/prefabs/modules/test_module_combined.tscn deleted file mode 100644 index efb45c6..0000000 --- a/prefabs/modules/test_module_combined.tscn +++ /dev/null @@ -1,53 +0,0 @@ -[gd_scene format=3 uid="uid://xpja3is7guc1"] - -[ext_resource type="Script" uid="uid://cy8nuarxbnd" path="res://scripts/GravityZone.cs" id="1_02ngc"] -[ext_resource type="Script" uid="uid://d4naw4kwsaxgi" path="res://scripts/VesselModuleNode.cs" id="1_xo7v4"] - -[sub_resource type="BoxMesh" id="BoxMesh_on55t"] -size = Vector3(1, 0.3, 1) - -[sub_resource type="BoxShape3D" id="BoxShape3D_l471i"] -size = Vector3(1, 0.3, 1) - -[sub_resource type="BoxMesh" id="BoxMesh_fyq5x"] -size = Vector3(3, 0.3, 5) - -[sub_resource type="BoxShape3D" id="BoxShape3D_fyol8"] -size = Vector3(3, 0.3, 5) - -[sub_resource type="BoxShape3D" id="BoxShape3D_fyq5x"] -size = Vector3(3, 3, 6) - -[node name="TestModuleCombined" type="StaticBody3D" unique_id=1980918964] -script = ExtResource("1_xo7v4") - -[node name="Mesh1" type="MeshInstance3D" parent="." unique_id=1213452774] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 2) -mesh = SubResource("BoxMesh_on55t") - -[node name="Collider1" type="CollisionShape3D" parent="." unique_id=379931522] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 2) -shape = SubResource("BoxShape3D_l471i") - -[node name="Mesh2" type="MeshInstance3D" parent="." unique_id=731042680] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1) -mesh = SubResource("BoxMesh_fyq5x") - -[node name="Collider2" type="CollisionShape3D" parent="." unique_id=1953709166] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1) -shape = SubResource("BoxShape3D_fyol8") - -[node name="GravityZone" type="Area3D" parent="." unique_id=431050752] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1) -gravity_space_override = 2 -script = ExtResource("1_02ngc") - -[node name="CollisionShape3D" type="CollisionShape3D" parent="GravityZone" unique_id=1904473317] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0.5) -shape = SubResource("BoxShape3D_fyq5x") - -[node name="TestModuleCombined_AnchorFront" type="Node3D" parent="." unique_id=1191422945] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 2.5) - -[connection signal="body_entered" from="GravityZone" to="GravityZone" method="OnBodyEntered"] -[connection signal="body_exited" from="GravityZone" to="GravityZone" method="OnBodyExited"] diff --git a/prefabs/modules/test_module_engine.tscn b/prefabs/modules/test_module_engine.tscn deleted file mode 100644 index f073c57..0000000 --- a/prefabs/modules/test_module_engine.tscn +++ /dev/null @@ -1,29 +0,0 @@ -[gd_scene format=3 uid="uid://dbi3g3j5txjwh"] - -[ext_resource type="Script" uid="uid://d4naw4kwsaxgi" path="res://scripts/VesselModuleNode.cs" id="1_op0d6"] - -[sub_resource type="CylinderMesh" id="CylinderMesh_d1o6a"] -top_radius = 1.0 -bottom_radius = 1.0 -height = 5.0 - -[sub_resource type="CylinderShape3D" id="CylinderShape3D_g1n3o"] -height = 5.0 -radius = 1.0 - -[node name="TestModuleEngine" type="StaticBody3D" unique_id=734366198] -script = ExtResource("1_op0d6") - -[node name="Mesh1" type="MeshInstance3D" parent="." unique_id=1213452774] -transform = Transform3D(3.749399456654644e-33, -6.123233995736766e-17, -1, 1, 6.123233995736766e-17, 0, 6.123233995736766e-17, -1, 6.123233995736766e-17, 0, 0, 0) -mesh = SubResource("CylinderMesh_d1o6a") - -[node name="Collider1" type="CollisionShape3D" parent="." unique_id=379931522] -transform = Transform3D(3.749399456654644e-33, -6.123233995736766e-17, -1, 1, 6.123233995736766e-17, 0, 6.123233995736766e-17, -1, 6.123233995736766e-17, 0, 0, 0) -shape = SubResource("CylinderShape3D_g1n3o") - -[node name="TestModuleEngine_AnchorLeft" type="Node3D" parent="." unique_id=1526898268] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0) - -[node name="TestModuleEngine_AnchorRight" type="Node3D" parent="." unique_id=1761527145] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 0, 0) diff --git a/prefabs/vessel.tscn b/prefabs/vessel.tscn deleted file mode 100644 index 0cbf4bc..0000000 --- a/prefabs/vessel.tscn +++ /dev/null @@ -1,9 +0,0 @@ -[gd_scene format=3 uid="uid://bhb866m25nc8k"] - -[ext_resource type="Script" uid="uid://dvd8i36joinsc" path="res://scripts/VesselNode.cs" id="1_d8j6t"] - -[node name="Vessel" type="RigidBody3D" unique_id=817832939] -mass = 1000.0 -gravity_scale = 0.0 -linear_damp_mode = 1 -script = ExtResource("1_d8j6t") diff --git a/project.godot b/project.godot index 0a822f5..19b0a67 100644 --- a/project.godot +++ b/project.godot @@ -12,7 +12,7 @@ config_version=5 config/name="Imperfect Space" run/main_scene="uid://bnmh1mebldx4l" -config/features=PackedStringArray("4.6", "C#", "Double Precision", "Forward Plus") +config/features=PackedStringArray("4.6", "C#", "Forward Plus") config/icon="res://icon.svg" [dotnet] diff --git a/scenes/game.tscn b/scenes/game.tscn index dfd79da..b47df55 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -4,11 +4,9 @@ [ext_resource type="Script" uid="uid://cy8nuarxbnd" path="res://scripts/GravityZone.cs" id="1_yqjtg"] [ext_resource type="Script" uid="uid://bwpdtkgmwjs7g" path="res://scripts/GravityReceiver.cs" id="3_lnu2h"] [ext_resource type="Script" uid="uid://n557xfrv0i6x" path="res://scripts/GeneralControlManager.cs" id="4_lbhrr"] -[ext_resource type="Script" uid="uid://bwgjvm21oi3d6" path="res://scripts/GameManager.cs" id="4_p57ef"] [ext_resource type="Script" uid="uid://betypbypf6bf2" path="res://scripts/GameMenuController.cs" id="5_iywne"] -[sub_resource type="BoxMesh" id="BoxMesh_p57ef"] -size = Vector3(2, 0.1, 2) +[sub_resource type="PlaneMesh" id="PlaneMesh_8cj0n"] [sub_resource type="BoxShape3D" id="BoxShape3D_8cj0n"] size = Vector3(10, 0.5, 10) @@ -22,12 +20,31 @@ size = Vector3(10, 5, 10) [node name="Game" type="Node3D" unique_id=1201210338] +[node name="Plane2" type="StaticBody3D" parent="." unique_id=289682669] +transform = Transform3D(1, 0, 0, 0, 0.99999994, 0, 0, 0, 0.99999994, -20.320108, 0, 0) + +[node name="PlaneMesh" type="MeshInstance3D" parent="Plane2" unique_id=1859317875] +transform = Transform3D(5, 0, 0, 0, 1, 0, 0, 0, 5, 0, 0, 0) +mesh = SubResource("PlaneMesh_8cj0n") + +[node name="PlaneCollider" type="CollisionShape3D" parent="Plane2" unique_id=907638578] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.2, 0) +shape = SubResource("BoxShape3D_8cj0n") + +[node name="GravityZone" type="Area3D" parent="Plane2" unique_id=600317513] +gravity_space_override = 2 +script = ExtResource("1_yqjtg") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Plane2/GravityZone" unique_id=991265750] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.5, 0) +shape = SubResource("BoxShape3D_uwrxv") + [node name="Plane" type="StaticBody3D" parent="." unique_id=1260154250] -transform = Transform3D(1, 0, 0, 0, 0.99999994, 0, 0, 0, 0.99999994, 20, 0, 0) +transform = Transform3D(1, 0, 0, 0, 0.70710677, 0.70710677, 0, -0.70710677, 0.70710677, 0, 0, 0) [node name="PlaneMesh" type="MeshInstance3D" parent="Plane" unique_id=107049489] transform = Transform3D(5, 0, 0, 0, 1, 0, 0, 0, 5, 0, 0, 0) -mesh = SubResource("BoxMesh_p57ef") +mesh = SubResource("PlaneMesh_8cj0n") [node name="PlaneCollider" type="CollisionShape3D" parent="Plane" unique_id=970373853] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.2, 0) @@ -42,7 +59,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.5, 0) shape = SubResource("BoxShape3D_uwrxv") [node name="Player" type="CharacterBody3D" parent="." unique_id=612572257 node_paths=PackedStringArray("GameMenu")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8.823173, 0.7854848) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5.1320534, 0.7854848) script = ExtResource("1_uwrxv") GameMenu = NodePath("../GameMenu") @@ -61,11 +78,8 @@ script = ExtResource("3_lnu2h") [node name="OmniLight" type="OmniLight3D" parent="." unique_id=1887866205] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6497431, -4.41529) -omni_range = 500.0 -omni_attenuation = 0.1 - -[node name="GameManager" type="Node" parent="." unique_id=267630256] -script = ExtResource("4_p57ef") +omni_range = 95.383 +omni_attenuation = 0.254 [node name="GeneralControlManager" type="Node" parent="." unique_id=1751385863 node_paths=PackedStringArray("GameMenu")] script = ExtResource("4_lbhrr") @@ -101,6 +115,8 @@ offset_bottom = 63.0 layout_mode = 2 text = "Main Menu" +[connection signal="body_entered" from="Plane2/GravityZone" to="Plane2/GravityZone" method="OnBodyEntered"] +[connection signal="body_exited" from="Plane2/GravityZone" to="Plane2/GravityZone" method="OnBodyExited"] [connection signal="body_entered" from="Plane/GravityZone" to="Plane/GravityZone" method="OnBodyEntered"] [connection signal="body_exited" from="Plane/GravityZone" to="Plane/GravityZone" method="OnBodyExited"] [connection signal="pressed" from="GameMenu/VBoxContainer/MainMenuButton" to="GameMenu" method="OnMainMenu"] diff --git a/scripts/GameManager.cs b/scripts/GameManager.cs deleted file mode 100644 index 11dbc06..0000000 --- a/scripts/GameManager.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Godot; - -public partial class GameManager : Node -{ - public override void _Ready() - { - PackedScene shipPrefab = ResourceLoader.Load("res://prefabs/vessel.tscn"); - Node3D shipInstance = shipPrefab.Instantiate(); - - GetTree().CurrentScene.CallDeferred("add_child", shipInstance); - } -} diff --git a/scripts/GameManager.cs.uid b/scripts/GameManager.cs.uid deleted file mode 100644 index c34245f..0000000 --- a/scripts/GameManager.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bwgjvm21oi3d6 diff --git a/scripts/GameObject.cs b/scripts/GameObject.cs deleted file mode 100644 index f45e1e7..0000000 --- a/scripts/GameObject.cs +++ /dev/null @@ -1,4 +0,0 @@ -public abstract class GameObject -{ - public abstract void Simulate(double delta); -} diff --git a/scripts/GameObject.cs.uid b/scripts/GameObject.cs.uid deleted file mode 100644 index ddd43d9..0000000 --- a/scripts/GameObject.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://dknsws58ej0bp diff --git a/scripts/GameObjects/Vessel.cs b/scripts/GameObjects/Vessel.cs deleted file mode 100644 index e0b761a..0000000 --- a/scripts/GameObjects/Vessel.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Collections.Generic; - -public class Vessel : GameObject -{ - public List Modules = []; - - public override void Simulate(double delta) - { - Modules.ForEach(module => - { - module.Simulate(delta); - }); - } -} diff --git a/scripts/GameObjects/Vessel.cs.uid b/scripts/GameObjects/Vessel.cs.uid deleted file mode 100644 index c866aa3..0000000 --- a/scripts/GameObjects/Vessel.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://b8lwtj6w6u5d1 diff --git a/scripts/GravityReceiver.cs b/scripts/GravityReceiver.cs index e7f3583..94eab20 100644 --- a/scripts/GravityReceiver.cs +++ b/scripts/GravityReceiver.cs @@ -2,85 +2,21 @@ using Godot; public partial class GravityReceiver : Node3D { - public int CheckInterval = 100; public bool InGravityZone = false; - public GravityZone Zone { get; private set; } - public Node3D Parent { get; private set; } + public float GravityStrength = 0f; + public Vector3 GravityDirection = Vector3.Down; - private int checkCounter = 0; - private Node3D owner; - private Node3D root; - private GravityZone oldZone; - private Node3D oldParent; - - public override void _Ready() + public void EnterGravityZone(float gravityStrength, Vector3 gravityDirection) { - owner = GetParent(); - root = GetTree().Root.GetNode("Game"); - } - - public override void _PhysicsProcess(double delta) - { - checkCounter++; - if (checkCounter >= CheckInterval) - { - checkCounter = 0; - if (InGravityZone && owner.GetParent() != Parent) - { - owner.Reparent(Parent, true); - } - if (!InGravityZone && owner.GetParent() != root) - { - owner.Reparent(root, true); - } - } - } - - public void EnterGravityZone(GravityZone gravityZone, Node3D newParent) - { - if (Zone != null) - { - oldZone = Zone; - oldParent = Parent; - } - InGravityZone = true; - Zone = gravityZone; - Parent = newParent; + GravityStrength = gravityStrength; + GravityDirection = gravityDirection; } - public void ExitGravityZone(GravityZone gravityZone) + public void ExitGravityZone() { - if (gravityZone == Zone) - { - if (oldZone != null && oldZone.GetOverlappingBodies().Contains(owner)) - { - GravityZone tempZone = Zone; - Node3D tempParent = Parent; - - InGravityZone = true; - Zone = oldZone; - Parent = oldParent; - - oldZone = tempZone; - oldParent = tempParent; - } - else - { - InGravityZone = false; - Zone = null; - Parent = null; - } - } - } - - public double GetGravityStrength() - { - return Zone.Gravity; - } - - public Vector3 GetGravityDirection() - { - return Zone.GlobalTransform.Basis.Y; + InGravityZone = false; + GravityStrength = 0f; + GravityDirection = Vector3.Down; } } diff --git a/scripts/GravityZone.cs b/scripts/GravityZone.cs index 98e353b..37d5d7d 100644 --- a/scripts/GravityZone.cs +++ b/scripts/GravityZone.cs @@ -2,22 +2,15 @@ using Godot; public partial class GravityZone : Area3D { - public Node3D Parent; - - public override void _Ready() - { - Parent = GetParent(); - } - public void OnBodyEntered(Node3D body) { GravityReceiver receiver = body.GetNodeOrNull("GravityReceiver"); - receiver?.EnterGravityZone(this, Parent.GetParent()); + receiver?.EnterGravityZone(Gravity, GlobalTransform.Basis.Y); } public void OnBodyExited(Node3D body) { GravityReceiver receiver = body.GetNodeOrNull("GravityReceiver"); - receiver?.ExitGravityZone(this); + receiver?.ExitGravityZone(); } } diff --git a/scripts/Modules/BridgeModule.cs b/scripts/Modules/BridgeModule.cs deleted file mode 100644 index 0c59d84..0000000 --- a/scripts/Modules/BridgeModule.cs +++ /dev/null @@ -1,26 +0,0 @@ -public class BridgeModule : VesselModule -{ - public double BaseFlops { get; private set; } - public double WattHoursCapacity { get; private set; } - public double WattHoursActual { get; private set; } - - public BridgeModule() - { - WattHoursActual = WattHoursCapacity; - } - - public override double GetFlops() - { - return BaseFlops; - } - - public override double GetWattHoursCapacity() - { - return WattHoursCapacity; - } - - public override double GetWattHoursActual() - { - return WattHoursActual; - } -} diff --git a/scripts/Modules/BridgeModule.cs.uid b/scripts/Modules/BridgeModule.cs.uid deleted file mode 100644 index 4632e07..0000000 --- a/scripts/Modules/BridgeModule.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://dqft6vnajtjhg diff --git a/scripts/Modules/CombinedModule.cs b/scripts/Modules/CombinedModule.cs deleted file mode 100644 index e1b537f..0000000 --- a/scripts/Modules/CombinedModule.cs +++ /dev/null @@ -1,9 +0,0 @@ -public class CombinedModule : VesselModule -{ - public double BaseWatts { get; private set; } - - public override double GetWatts() - { - return BaseWatts; - } -} diff --git a/scripts/Modules/CombinedModule.cs.uid b/scripts/Modules/CombinedModule.cs.uid deleted file mode 100644 index 0e9e652..0000000 --- a/scripts/Modules/CombinedModule.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bq0qr0g8gokhb diff --git a/scripts/Modules/EngineModule.cs b/scripts/Modules/EngineModule.cs deleted file mode 100644 index d5351bb..0000000 --- a/scripts/Modules/EngineModule.cs +++ /dev/null @@ -1,9 +0,0 @@ -public class EngineModule : VesselModule -{ - public double BaseThrust { get; private set; } - - public override double GetThrust() - { - return BaseThrust; - } -} diff --git a/scripts/Modules/EngineModule.cs.uid b/scripts/Modules/EngineModule.cs.uid deleted file mode 100644 index 564eaf6..0000000 --- a/scripts/Modules/EngineModule.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://crmpdo2d6oqke diff --git a/scripts/Player.cs b/scripts/Player.cs index ae7a6c8..b00bd12 100644 --- a/scripts/Player.cs +++ b/scripts/Player.cs @@ -10,7 +10,7 @@ public partial class Player : CharacterBody3D private Vector3 gravityVelocity = Vector3.Zero; private Vector3 movementVelocity = Vector3.Zero; - private double cameraPitch = 0f; + private float cameraPitch = 0f; private Camera3D camera; private GravityReceiver gravityReceiver; @@ -60,10 +60,10 @@ public partial class Player : CharacterBody3D if (@event is InputEventMouseMotion motion) { - double yawDelta = -motion.Relative.X * MouseSensitivity; - double yawDeltaRad = Mathf.DegToRad(yawDelta); - double pitchDelta = -motion.Relative.Y * MouseSensitivity; - double pitchDeltaRad = Mathf.DegToRad(pitchDelta); + float yawDelta = -motion.Relative.X * MouseSensitivity; + float yawDeltaRad = Mathf.DegToRad(yawDelta); + float pitchDelta = -motion.Relative.Y * MouseSensitivity; + float pitchDeltaRad = Mathf.DegToRad(pitchDelta); RotateObjectLocal(Vector3.Up, yawDeltaRad); @@ -82,7 +82,7 @@ public partial class Player : CharacterBody3D public bool IsInGravity() { - return gravityReceiver.InGravityZone && gravityReceiver.GetGravityStrength() > 0f; + return gravityReceiver.InGravityZone && gravityReceiver.GravityStrength > 0f; } public bool IsOnGravityFloor() @@ -92,7 +92,7 @@ public partial class Player : CharacterBody3D KinematicCollision3D collision = GetSlideCollision(i); Vector3 collisionNormal = collision.GetNormal(); - double alignment = collisionNormal.Dot(gravityReceiver.GetGravityDirection()); + float alignment = collisionNormal.Dot(gravityReceiver.GravityDirection); if (alignment > 0.7f) { @@ -107,35 +107,35 @@ public partial class Player : CharacterBody3D { if (!IsOnGravityFloor()) { - newGravityVelocity -= gravityReceiver.GetGravityDirection() * gravityReceiver.GetGravityStrength() * (float)delta; + newGravityVelocity -= gravityReceiver.GravityDirection * gravityReceiver.GravityStrength * (float)delta; } else { - newGravityVelocity = -gravityReceiver.GetGravityDirection(); + newGravityVelocity = -gravityReceiver.GravityDirection; } Vector3 currentUp = GlobalTransform.Basis.Y; - Vector3 targetUp = gravityReceiver.GetGravityDirection(); + Vector3 targetUp = gravityReceiver.GravityDirection; Vector3 axis = currentUp.Cross(targetUp); if (axis.Length() < 0.00001f) { return; } - double angle = currentUp.AngleTo(targetUp); + float angle = currentUp.AngleTo(targetUp); - GlobalRotate(axis.Normalized(), angle * delta * 10f); + Rotate(axis.Normalized(), angle * (float)delta * 10f); } private void ProcessCamera(double delta) { if (cameraPitch > 0.01f) { - cameraPitch -= 90f * delta; + cameraPitch -= 90f * (float)delta; } else if (cameraPitch < -0.001f) { - cameraPitch += 90f * delta; + cameraPitch += 90f * (float)delta; } if (Mathf.Abs(cameraPitch) < 1f) { @@ -149,7 +149,7 @@ public partial class Player : CharacterBody3D float inputX = Input.GetAxis("move_left", "move_right"); float inputZ = Input.GetAxis("move_forward", "move_back"); - Vector3 direction = GlobalTransform.Basis.X * inputX + GlobalTransform.Basis.Z * inputZ; + Vector3 direction = Transform.Basis.X * inputX + Transform.Basis.Z * inputZ; if (direction != Vector3.Zero) { @@ -166,7 +166,7 @@ public partial class Player : CharacterBody3D if (Input.IsActionJustPressed("jump") && IsOnGravityFloor()) { - newGravityVelocity = gravityReceiver.GetGravityDirection() * JumpForce; + newGravityVelocity = gravityReceiver.GravityDirection * JumpForce; } } @@ -191,9 +191,9 @@ public partial class Player : CharacterBody3D newMovementVelocity.Z = 0f; } - double inputRotateZ = Input.GetAxis("rotate_left", "rotate_right"); + float inputRotateZ = Input.GetAxis("rotate_left", "rotate_right"); - double rotateAmountZ = Mathf.DegToRad(inputRotateZ); + float rotateAmountZ = Mathf.DegToRad(inputRotateZ); RotateObjectLocal(Vector3.Forward, rotateAmountZ); } diff --git a/scripts/VesselModule.cs b/scripts/VesselModule.cs deleted file mode 100644 index d0935bb..0000000 --- a/scripts/VesselModule.cs +++ /dev/null @@ -1,29 +0,0 @@ -public abstract class VesselModule -{ - public virtual void Simulate(double delta) { } - - public virtual double GetFlops() - { - return 0; - } - - public virtual double GetWattHoursCapacity() - { - return 0; - } - - public virtual double GetWattHoursActual() - { - return 0; - } - - public virtual double GetWatts() - { - return 0; - } - - public virtual double GetThrust() - { - return 0; - } -} diff --git a/scripts/VesselModule.cs.uid b/scripts/VesselModule.cs.uid deleted file mode 100644 index 01a3f91..0000000 --- a/scripts/VesselModule.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://4boxx2qksadv diff --git a/scripts/VesselModuleNode.cs b/scripts/VesselModuleNode.cs deleted file mode 100644 index a7201c3..0000000 --- a/scripts/VesselModuleNode.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Godot; - -public partial class VesselModuleNode : StaticBody3D -{ - public VesselModule ModuleData { get; private set; } - - public Node3D GetAnchor(string name) - { - return GetNode(name); - } -} diff --git a/scripts/VesselModuleNode.cs.uid b/scripts/VesselModuleNode.cs.uid deleted file mode 100644 index c5ebef0..0000000 --- a/scripts/VesselModuleNode.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://d4naw4kwsaxgi diff --git a/scripts/VesselNode.cs b/scripts/VesselNode.cs deleted file mode 100644 index fba0bdd..0000000 --- a/scripts/VesselNode.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Collections.Generic; -using Godot; - -public partial class VesselNode : RigidBody3D -{ - public Vessel VesselData = new(); - public List Modules = []; - - public override void _Ready() - { - VesselModuleNode moduleBridge = InstantiateModule("test_module_bridge"); - VesselModuleNode moduleCombined = InstantiateModule("test_module_combined"); - VesselModuleNode moduleEngine1 = InstantiateModule("test_module_engine"); - VesselModuleNode moduleEngine2 = InstantiateModule("test_module_engine"); - - CallDeferred(nameof(AttachModule), moduleBridge, moduleCombined, "TestModuleBridge_AnchorBack", "TestModuleCombined_AnchorFront"); - CallDeferred(nameof(AttachModule), moduleBridge, moduleEngine1, "TestModuleBridge_AnchorLeft", "TestModuleEngine_AnchorRight"); - CallDeferred(nameof(AttachModule), moduleBridge, moduleEngine2, "TestModuleBridge_AnchorRight", "TestModuleEngine_AnchorLeft"); - } - - private VesselModuleNode InstantiateModule(string moduleName) - { - PackedScene modulePrefab = ResourceLoader.Load($"res://prefabs/modules/{moduleName}.tscn"); - VesselModuleNode moduleInstance = modulePrefab.Instantiate(); - - CallDeferred("add_child", moduleInstance); - - VesselData.Modules.Add(moduleInstance.ModuleData); - Modules.Add(moduleInstance); - - return moduleInstance; - } - - private void AttachModule(VesselModuleNode attachToModule, VesselModuleNode newModule, string existingAnchorName, string newAnchorName) - { - Node3D existingAnchor = attachToModule.GetAnchor(existingAnchorName); - Node3D newAnchor = newModule.GetAnchor(newAnchorName); - - newModule.GlobalTransform = existingAnchor.GlobalTransform * newAnchor.Transform.AffineInverse(); - } -} diff --git a/scripts/VesselNode.cs.uid b/scripts/VesselNode.cs.uid deleted file mode 100644 index 4847563..0000000 --- a/scripts/VesselNode.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://dvd8i36joinsc