Object parenting; Ship module prototype; Use 64 bit
This commit is contained in:
parent
3f97e18615
commit
8335714acc
30 changed files with 436 additions and 62 deletions
|
|
@ -1,9 +1,7 @@
|
||||||
<Project Sdk="Godot.NET.Sdk/4.6.0-rc.2">
|
<Project Sdk="Godot.NET.Sdk/4.6.0-rc">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<TargetFramework
|
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net9.0</TargetFramework>
|
||||||
Condition=" '$(GodotTargetPlatform)' == 'android' "
|
|
||||||
>net9.0</TargetFramework>
|
|
||||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||||
<RootNamespace>ImperfectSpace</RootNamespace>
|
<RootNamespace>ImperfectSpace</RootNamespace>
|
||||||
<SuppressImplicitGitSourceLink>true</SuppressImplicitGitSourceLink>
|
<SuppressImplicitGitSourceLink>true</SuppressImplicitGitSourceLink>
|
||||||
|
|
|
||||||
11
Imperfect Space.csproj.old
Normal file
11
Imperfect Space.csproj.old
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<Project Sdk="Godot.NET.Sdk/4.6.0-rc.2">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<TargetFramework
|
||||||
|
Condition=" '$(GodotTargetPlatform)' == 'android' "
|
||||||
|
>net9.0</TargetFramework>
|
||||||
|
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||||
|
<RootNamespace>ImperfectSpace</RootNamespace>
|
||||||
|
<SuppressImplicitGitSourceLink>true</SuppressImplicitGitSourceLink>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
9
Imperfect Space.csproj.old.1
Normal file
9
Imperfect Space.csproj.old.1
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
<Project Sdk="Godot.NET.Sdk/4.6.0-rc.1">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net9.0</TargetFramework>
|
||||||
|
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||||
|
<RootNamespace>ImperfectSpace</RootNamespace>
|
||||||
|
<SuppressImplicitGitSourceLink>true</SuppressImplicitGitSourceLink>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
46
prefabs/modules/test_module_bridge.tscn
Normal file
46
prefabs/modules/test_module_bridge.tscn
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
[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"]
|
||||||
53
prefabs/modules/test_module_combined.tscn
Normal file
53
prefabs/modules/test_module_combined.tscn
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
[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"]
|
||||||
29
prefabs/modules/test_module_engine.tscn
Normal file
29
prefabs/modules/test_module_engine.tscn
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
[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)
|
||||||
9
prefabs/vessel.tscn
Normal file
9
prefabs/vessel.tscn
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[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")
|
||||||
|
|
@ -12,7 +12,7 @@ config_version=5
|
||||||
|
|
||||||
config/name="Imperfect Space"
|
config/name="Imperfect Space"
|
||||||
run/main_scene="uid://bnmh1mebldx4l"
|
run/main_scene="uid://bnmh1mebldx4l"
|
||||||
config/features=PackedStringArray("4.6", "C#", "Forward Plus")
|
config/features=PackedStringArray("4.6", "C#", "Double Precision", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
[dotnet]
|
[dotnet]
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,11 @@
|
||||||
[ext_resource type="Script" uid="uid://cy8nuarxbnd" path="res://scripts/GravityZone.cs" id="1_yqjtg"]
|
[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://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://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"]
|
[ext_resource type="Script" uid="uid://betypbypf6bf2" path="res://scripts/GameMenuController.cs" id="5_iywne"]
|
||||||
|
|
||||||
[sub_resource type="PlaneMesh" id="PlaneMesh_8cj0n"]
|
[sub_resource type="BoxMesh" id="BoxMesh_p57ef"]
|
||||||
|
size = Vector3(2, 0.1, 2)
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_8cj0n"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_8cj0n"]
|
||||||
size = Vector3(10, 0.5, 10)
|
size = Vector3(10, 0.5, 10)
|
||||||
|
|
@ -20,31 +22,12 @@ size = Vector3(10, 5, 10)
|
||||||
|
|
||||||
[node name="Game" type="Node3D" unique_id=1201210338]
|
[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]
|
[node name="Plane" type="StaticBody3D" parent="." unique_id=1260154250]
|
||||||
transform = Transform3D(1, 0, 0, 0, 0.70710677, 0.70710677, 0, -0.70710677, 0.70710677, 0, 0, 0)
|
transform = Transform3D(1, 0, 0, 0, 0.99999994, 0, 0, 0, 0.99999994, 20, 0, 0)
|
||||||
|
|
||||||
[node name="PlaneMesh" type="MeshInstance3D" parent="Plane" unique_id=107049489]
|
[node name="PlaneMesh" type="MeshInstance3D" parent="Plane" unique_id=107049489]
|
||||||
transform = Transform3D(5, 0, 0, 0, 1, 0, 0, 0, 5, 0, 0, 0)
|
transform = Transform3D(5, 0, 0, 0, 1, 0, 0, 0, 5, 0, 0, 0)
|
||||||
mesh = SubResource("PlaneMesh_8cj0n")
|
mesh = SubResource("BoxMesh_p57ef")
|
||||||
|
|
||||||
[node name="PlaneCollider" type="CollisionShape3D" parent="Plane" unique_id=970373853]
|
[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)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.2, 0)
|
||||||
|
|
@ -59,7 +42,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.5, 0)
|
||||||
shape = SubResource("BoxShape3D_uwrxv")
|
shape = SubResource("BoxShape3D_uwrxv")
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody3D" parent="." unique_id=612572257 node_paths=PackedStringArray("GameMenu")]
|
[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, 5.1320534, 0.7854848)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8.823173, 0.7854848)
|
||||||
script = ExtResource("1_uwrxv")
|
script = ExtResource("1_uwrxv")
|
||||||
GameMenu = NodePath("../GameMenu")
|
GameMenu = NodePath("../GameMenu")
|
||||||
|
|
||||||
|
|
@ -78,8 +61,11 @@ script = ExtResource("3_lnu2h")
|
||||||
|
|
||||||
[node name="OmniLight" type="OmniLight3D" parent="." unique_id=1887866205]
|
[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)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6497431, -4.41529)
|
||||||
omni_range = 95.383
|
omni_range = 500.0
|
||||||
omni_attenuation = 0.254
|
omni_attenuation = 0.1
|
||||||
|
|
||||||
|
[node name="GameManager" type="Node" parent="." unique_id=267630256]
|
||||||
|
script = ExtResource("4_p57ef")
|
||||||
|
|
||||||
[node name="GeneralControlManager" type="Node" parent="." unique_id=1751385863 node_paths=PackedStringArray("GameMenu")]
|
[node name="GeneralControlManager" type="Node" parent="." unique_id=1751385863 node_paths=PackedStringArray("GameMenu")]
|
||||||
script = ExtResource("4_lbhrr")
|
script = ExtResource("4_lbhrr")
|
||||||
|
|
@ -115,8 +101,6 @@ offset_bottom = 63.0
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Main Menu"
|
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_entered" from="Plane/GravityZone" to="Plane/GravityZone" method="OnBodyEntered"]
|
||||||
[connection signal="body_exited" from="Plane/GravityZone" to="Plane/GravityZone" method="OnBodyExited"]
|
[connection signal="body_exited" from="Plane/GravityZone" to="Plane/GravityZone" method="OnBodyExited"]
|
||||||
[connection signal="pressed" from="GameMenu/VBoxContainer/MainMenuButton" to="GameMenu" method="OnMainMenu"]
|
[connection signal="pressed" from="GameMenu/VBoxContainer/MainMenuButton" to="GameMenu" method="OnMainMenu"]
|
||||||
|
|
|
||||||
12
scripts/GameManager.cs
Normal file
12
scripts/GameManager.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
public partial class GameManager : Node
|
||||||
|
{
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
PackedScene shipPrefab = ResourceLoader.Load<PackedScene>("res://prefabs/vessel.tscn");
|
||||||
|
Node3D shipInstance = shipPrefab.Instantiate<Node3D>();
|
||||||
|
|
||||||
|
GetTree().CurrentScene.CallDeferred("add_child", shipInstance);
|
||||||
|
}
|
||||||
|
}
|
||||||
1
scripts/GameManager.cs.uid
Normal file
1
scripts/GameManager.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bwgjvm21oi3d6
|
||||||
4
scripts/GameObject.cs
Normal file
4
scripts/GameObject.cs
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
public abstract class GameObject
|
||||||
|
{
|
||||||
|
public abstract void Simulate(double delta);
|
||||||
|
}
|
||||||
1
scripts/GameObject.cs.uid
Normal file
1
scripts/GameObject.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dknsws58ej0bp
|
||||||
14
scripts/GameObjects/Vessel.cs
Normal file
14
scripts/GameObjects/Vessel.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
public class Vessel : GameObject
|
||||||
|
{
|
||||||
|
public List<VesselModule> Modules = [];
|
||||||
|
|
||||||
|
public override void Simulate(double delta)
|
||||||
|
{
|
||||||
|
Modules.ForEach(module =>
|
||||||
|
{
|
||||||
|
module.Simulate(delta);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
1
scripts/GameObjects/Vessel.cs.uid
Normal file
1
scripts/GameObjects/Vessel.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://b8lwtj6w6u5d1
|
||||||
|
|
@ -2,21 +2,85 @@ using Godot;
|
||||||
|
|
||||||
public partial class GravityReceiver : Node3D
|
public partial class GravityReceiver : Node3D
|
||||||
{
|
{
|
||||||
|
public int CheckInterval = 100;
|
||||||
public bool InGravityZone = false;
|
public bool InGravityZone = false;
|
||||||
public float GravityStrength = 0f;
|
public GravityZone Zone { get; private set; }
|
||||||
public Vector3 GravityDirection = Vector3.Down;
|
public Node3D Parent { get; private set; }
|
||||||
|
|
||||||
public void EnterGravityZone(float gravityStrength, Vector3 gravityDirection)
|
private int checkCounter = 0;
|
||||||
|
private Node3D owner;
|
||||||
|
private Node3D root;
|
||||||
|
private GravityZone oldZone;
|
||||||
|
private Node3D oldParent;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
InGravityZone = true;
|
owner = GetParent<Node3D>();
|
||||||
GravityStrength = gravityStrength;
|
root = GetTree().Root.GetNode<Node3D>("Game");
|
||||||
GravityDirection = gravityDirection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ExitGravityZone()
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ExitGravityZone(GravityZone gravityZone)
|
||||||
|
{
|
||||||
|
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;
|
InGravityZone = false;
|
||||||
GravityStrength = 0f;
|
Zone = null;
|
||||||
GravityDirection = Vector3.Down;
|
Parent = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public double GetGravityStrength()
|
||||||
|
{
|
||||||
|
return Zone.Gravity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 GetGravityDirection()
|
||||||
|
{
|
||||||
|
return Zone.GlobalTransform.Basis.Y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,22 @@ using Godot;
|
||||||
|
|
||||||
public partial class GravityZone : Area3D
|
public partial class GravityZone : Area3D
|
||||||
{
|
{
|
||||||
|
public Node3D Parent;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
Parent = GetParent<Node3D>();
|
||||||
|
}
|
||||||
|
|
||||||
public void OnBodyEntered(Node3D body)
|
public void OnBodyEntered(Node3D body)
|
||||||
{
|
{
|
||||||
GravityReceiver receiver = body.GetNodeOrNull<GravityReceiver>("GravityReceiver");
|
GravityReceiver receiver = body.GetNodeOrNull<GravityReceiver>("GravityReceiver");
|
||||||
receiver?.EnterGravityZone(Gravity, GlobalTransform.Basis.Y);
|
receiver?.EnterGravityZone(this, Parent.GetParent<Node3D>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnBodyExited(Node3D body)
|
public void OnBodyExited(Node3D body)
|
||||||
{
|
{
|
||||||
GravityReceiver receiver = body.GetNodeOrNull<GravityReceiver>("GravityReceiver");
|
GravityReceiver receiver = body.GetNodeOrNull<GravityReceiver>("GravityReceiver");
|
||||||
receiver?.ExitGravityZone();
|
receiver?.ExitGravityZone(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
26
scripts/Modules/BridgeModule.cs
Normal file
26
scripts/Modules/BridgeModule.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
1
scripts/Modules/BridgeModule.cs.uid
Normal file
1
scripts/Modules/BridgeModule.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dqft6vnajtjhg
|
||||||
9
scripts/Modules/CombinedModule.cs
Normal file
9
scripts/Modules/CombinedModule.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
public class CombinedModule : VesselModule
|
||||||
|
{
|
||||||
|
public double BaseWatts { get; private set; }
|
||||||
|
|
||||||
|
public override double GetWatts()
|
||||||
|
{
|
||||||
|
return BaseWatts;
|
||||||
|
}
|
||||||
|
}
|
||||||
1
scripts/Modules/CombinedModule.cs.uid
Normal file
1
scripts/Modules/CombinedModule.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bq0qr0g8gokhb
|
||||||
9
scripts/Modules/EngineModule.cs
Normal file
9
scripts/Modules/EngineModule.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
public class EngineModule : VesselModule
|
||||||
|
{
|
||||||
|
public double BaseThrust { get; private set; }
|
||||||
|
|
||||||
|
public override double GetThrust()
|
||||||
|
{
|
||||||
|
return BaseThrust;
|
||||||
|
}
|
||||||
|
}
|
||||||
1
scripts/Modules/EngineModule.cs.uid
Normal file
1
scripts/Modules/EngineModule.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://crmpdo2d6oqke
|
||||||
|
|
@ -10,7 +10,7 @@ public partial class Player : CharacterBody3D
|
||||||
|
|
||||||
private Vector3 gravityVelocity = Vector3.Zero;
|
private Vector3 gravityVelocity = Vector3.Zero;
|
||||||
private Vector3 movementVelocity = Vector3.Zero;
|
private Vector3 movementVelocity = Vector3.Zero;
|
||||||
private float cameraPitch = 0f;
|
private double cameraPitch = 0f;
|
||||||
private Camera3D camera;
|
private Camera3D camera;
|
||||||
private GravityReceiver gravityReceiver;
|
private GravityReceiver gravityReceiver;
|
||||||
|
|
||||||
|
|
@ -60,10 +60,10 @@ public partial class Player : CharacterBody3D
|
||||||
|
|
||||||
if (@event is InputEventMouseMotion motion)
|
if (@event is InputEventMouseMotion motion)
|
||||||
{
|
{
|
||||||
float yawDelta = -motion.Relative.X * MouseSensitivity;
|
double yawDelta = -motion.Relative.X * MouseSensitivity;
|
||||||
float yawDeltaRad = Mathf.DegToRad(yawDelta);
|
double yawDeltaRad = Mathf.DegToRad(yawDelta);
|
||||||
float pitchDelta = -motion.Relative.Y * MouseSensitivity;
|
double pitchDelta = -motion.Relative.Y * MouseSensitivity;
|
||||||
float pitchDeltaRad = Mathf.DegToRad(pitchDelta);
|
double pitchDeltaRad = Mathf.DegToRad(pitchDelta);
|
||||||
|
|
||||||
RotateObjectLocal(Vector3.Up, yawDeltaRad);
|
RotateObjectLocal(Vector3.Up, yawDeltaRad);
|
||||||
|
|
||||||
|
|
@ -82,7 +82,7 @@ public partial class Player : CharacterBody3D
|
||||||
|
|
||||||
public bool IsInGravity()
|
public bool IsInGravity()
|
||||||
{
|
{
|
||||||
return gravityReceiver.InGravityZone && gravityReceiver.GravityStrength > 0f;
|
return gravityReceiver.InGravityZone && gravityReceiver.GetGravityStrength() > 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsOnGravityFloor()
|
public bool IsOnGravityFloor()
|
||||||
|
|
@ -92,7 +92,7 @@ public partial class Player : CharacterBody3D
|
||||||
KinematicCollision3D collision = GetSlideCollision(i);
|
KinematicCollision3D collision = GetSlideCollision(i);
|
||||||
Vector3 collisionNormal = collision.GetNormal();
|
Vector3 collisionNormal = collision.GetNormal();
|
||||||
|
|
||||||
float alignment = collisionNormal.Dot(gravityReceiver.GravityDirection);
|
double alignment = collisionNormal.Dot(gravityReceiver.GetGravityDirection());
|
||||||
|
|
||||||
if (alignment > 0.7f)
|
if (alignment > 0.7f)
|
||||||
{
|
{
|
||||||
|
|
@ -107,35 +107,35 @@ public partial class Player : CharacterBody3D
|
||||||
{
|
{
|
||||||
if (!IsOnGravityFloor())
|
if (!IsOnGravityFloor())
|
||||||
{
|
{
|
||||||
newGravityVelocity -= gravityReceiver.GravityDirection * gravityReceiver.GravityStrength * (float)delta;
|
newGravityVelocity -= gravityReceiver.GetGravityDirection() * gravityReceiver.GetGravityStrength() * (float)delta;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newGravityVelocity = -gravityReceiver.GravityDirection;
|
newGravityVelocity = -gravityReceiver.GetGravityDirection();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 currentUp = GlobalTransform.Basis.Y;
|
Vector3 currentUp = GlobalTransform.Basis.Y;
|
||||||
Vector3 targetUp = gravityReceiver.GravityDirection;
|
Vector3 targetUp = gravityReceiver.GetGravityDirection();
|
||||||
|
|
||||||
Vector3 axis = currentUp.Cross(targetUp);
|
Vector3 axis = currentUp.Cross(targetUp);
|
||||||
if (axis.Length() < 0.00001f)
|
if (axis.Length() < 0.00001f)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float angle = currentUp.AngleTo(targetUp);
|
double angle = currentUp.AngleTo(targetUp);
|
||||||
|
|
||||||
Rotate(axis.Normalized(), angle * (float)delta * 10f);
|
GlobalRotate(axis.Normalized(), angle * delta * 10f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProcessCamera(double delta)
|
private void ProcessCamera(double delta)
|
||||||
{
|
{
|
||||||
if (cameraPitch > 0.01f)
|
if (cameraPitch > 0.01f)
|
||||||
{
|
{
|
||||||
cameraPitch -= 90f * (float)delta;
|
cameraPitch -= 90f * delta;
|
||||||
}
|
}
|
||||||
else if (cameraPitch < -0.001f)
|
else if (cameraPitch < -0.001f)
|
||||||
{
|
{
|
||||||
cameraPitch += 90f * (float)delta;
|
cameraPitch += 90f * delta;
|
||||||
}
|
}
|
||||||
if (Mathf.Abs(cameraPitch) < 1f)
|
if (Mathf.Abs(cameraPitch) < 1f)
|
||||||
{
|
{
|
||||||
|
|
@ -149,7 +149,7 @@ public partial class Player : CharacterBody3D
|
||||||
float inputX = Input.GetAxis("move_left", "move_right");
|
float inputX = Input.GetAxis("move_left", "move_right");
|
||||||
float inputZ = Input.GetAxis("move_forward", "move_back");
|
float inputZ = Input.GetAxis("move_forward", "move_back");
|
||||||
|
|
||||||
Vector3 direction = Transform.Basis.X * inputX + Transform.Basis.Z * inputZ;
|
Vector3 direction = GlobalTransform.Basis.X * inputX + GlobalTransform.Basis.Z * inputZ;
|
||||||
|
|
||||||
if (direction != Vector3.Zero)
|
if (direction != Vector3.Zero)
|
||||||
{
|
{
|
||||||
|
|
@ -166,7 +166,7 @@ public partial class Player : CharacterBody3D
|
||||||
|
|
||||||
if (Input.IsActionJustPressed("jump") && IsOnGravityFloor())
|
if (Input.IsActionJustPressed("jump") && IsOnGravityFloor())
|
||||||
{
|
{
|
||||||
newGravityVelocity = gravityReceiver.GravityDirection * JumpForce;
|
newGravityVelocity = gravityReceiver.GetGravityDirection() * JumpForce;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -191,9 +191,9 @@ public partial class Player : CharacterBody3D
|
||||||
newMovementVelocity.Z = 0f;
|
newMovementVelocity.Z = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float inputRotateZ = Input.GetAxis("rotate_left", "rotate_right");
|
double inputRotateZ = Input.GetAxis("rotate_left", "rotate_right");
|
||||||
|
|
||||||
float rotateAmountZ = Mathf.DegToRad(inputRotateZ);
|
double rotateAmountZ = Mathf.DegToRad(inputRotateZ);
|
||||||
|
|
||||||
RotateObjectLocal(Vector3.Forward, rotateAmountZ);
|
RotateObjectLocal(Vector3.Forward, rotateAmountZ);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
29
scripts/VesselModule.cs
Normal file
29
scripts/VesselModule.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
1
scripts/VesselModule.cs.uid
Normal file
1
scripts/VesselModule.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://4boxx2qksadv
|
||||||
11
scripts/VesselModuleNode.cs
Normal file
11
scripts/VesselModuleNode.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
public partial class VesselModuleNode : StaticBody3D
|
||||||
|
{
|
||||||
|
public VesselModule ModuleData { get; private set; }
|
||||||
|
|
||||||
|
public Node3D GetAnchor(string name)
|
||||||
|
{
|
||||||
|
return GetNode<Node3D>(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
1
scripts/VesselModuleNode.cs.uid
Normal file
1
scripts/VesselModuleNode.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://d4naw4kwsaxgi
|
||||||
41
scripts/VesselNode.cs
Normal file
41
scripts/VesselNode.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
public partial class VesselNode : RigidBody3D
|
||||||
|
{
|
||||||
|
public Vessel VesselData = new();
|
||||||
|
public List<VesselModuleNode> 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<PackedScene>($"res://prefabs/modules/{moduleName}.tscn");
|
||||||
|
VesselModuleNode moduleInstance = modulePrefab.Instantiate<VesselModuleNode>();
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
1
scripts/VesselNode.cs.uid
Normal file
1
scripts/VesselNode.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dvd8i36joinsc
|
||||||
Loading…
Add table
Add a link
Reference in a new issue