From 1342ca26109f89b6458d2bfbbee65020a1026039 Mon Sep 17 00:00:00 2001 From: "olof.pettersson" Date: Fri, 14 Nov 2025 10:58:45 +0100 Subject: [PATCH] New visible celestial bodies --- scenes/UI/map_icon.gd | 20 +---- scenes/celestial_bodies/asteroid.gd | 19 ----- scenes/celestial_bodies/asteroid.gd.uid | 1 - scenes/celestial_bodies/asteroid.tscn | 8 -- scenes/celestial_bodies/celestial_body.gd | 13 +++ scenes/celestial_bodies/celestial_body.gd.uid | 1 + scenes/celestial_bodies/celestial_body.tscn | 27 ++++++ .../materials/sun_mat.gdshader | 52 ++++++++++++ .../materials/sun_mat.gdshader.uid | 1 + .../celestial_bodies/materials/sun_mat.tres | 27 ++++++ scenes/celestial_bodies/moon.gd | 17 ---- scenes/celestial_bodies/moon.gd.uid | 1 - scenes/celestial_bodies/moon.tscn | 8 -- scenes/celestial_bodies/planet.gd | 15 ---- scenes/celestial_bodies/planet.gd.uid | 1 - scenes/celestial_bodies/planet.tscn | 10 --- scenes/celestial_bodies/star.gd | 14 ---- scenes/celestial_bodies/star.gd.uid | 1 - scenes/celestial_bodies/star.tscn | 15 ---- scenes/celestial_bodies/station.gd | 17 ---- scenes/celestial_bodies/station.gd.uid | 1 - scenes/celestial_bodies/station.tscn | 8 -- scenes/modules/test_module.tscn | 82 ------------------- scenes/ship/computer/UI/sensor_panel.gd | 4 +- scenes/tests/3d/character_pawn_3d.tscn | 1 + scripts/star_system.gd | 2 +- scripts/star_system_generator.gd | 14 +++- 27 files changed, 138 insertions(+), 242 deletions(-) delete mode 100644 scenes/celestial_bodies/asteroid.gd delete mode 100644 scenes/celestial_bodies/asteroid.gd.uid delete mode 100644 scenes/celestial_bodies/asteroid.tscn create mode 100644 scenes/celestial_bodies/celestial_body.gd create mode 100644 scenes/celestial_bodies/celestial_body.gd.uid create mode 100644 scenes/celestial_bodies/celestial_body.tscn create mode 100644 scenes/celestial_bodies/materials/sun_mat.gdshader create mode 100644 scenes/celestial_bodies/materials/sun_mat.gdshader.uid create mode 100644 scenes/celestial_bodies/materials/sun_mat.tres delete mode 100644 scenes/celestial_bodies/moon.gd delete mode 100644 scenes/celestial_bodies/moon.gd.uid delete mode 100644 scenes/celestial_bodies/moon.tscn delete mode 100644 scenes/celestial_bodies/planet.gd delete mode 100644 scenes/celestial_bodies/planet.gd.uid delete mode 100644 scenes/celestial_bodies/planet.tscn delete mode 100644 scenes/celestial_bodies/star.gd delete mode 100644 scenes/celestial_bodies/star.gd.uid delete mode 100644 scenes/celestial_bodies/star.tscn delete mode 100644 scenes/celestial_bodies/station.gd delete mode 100644 scenes/celestial_bodies/station.gd.uid delete mode 100644 scenes/celestial_bodies/station.tscn delete mode 100644 scenes/modules/test_module.tscn diff --git a/scenes/UI/map_icon.gd b/scenes/UI/map_icon.gd index 6474cda..df8dc34 100644 --- a/scenes/UI/map_icon.gd +++ b/scenes/UI/map_icon.gd @@ -31,14 +31,7 @@ func initialize(body: OrbitalBody3D): body_reference = body name_label.text = body.name - if body is Star: - dot_color = Color.GOLD - elif body is Planet: - dot_color = Color.DODGER_BLUE - elif body is Moon: - dot_color = Color.PURPLE - else: - dot_color = Color.CYAN + dot_color = Color.CYAN self.tooltip_text = _generate_tooltip_text() @@ -98,7 +91,7 @@ func _on_mouse_exited(): func _generate_tooltip_text() -> String: var info = [body_reference.name] - if body_reference is Planet: + if body_reference is CelestialBody: var planet_system = body_reference.get_parent() as Barycenter var period_seconds = OrbitalMechanics.get_orbital_time_in_seconds(planet_system, GameManager.get_system_data().star) @@ -106,18 +99,11 @@ func _generate_tooltip_text() -> String: var moon_count = 0 for child in planet_system.get_internal_attractors(): - if child is Moon: + if child is CelestialBody: moon_count += 1 if moon_count > 0: info.append("Moons: %d" % moon_count) - - if body_reference is Moon: - var planet_system = body_reference.get_parent() as Barycenter - var period_seconds = OrbitalMechanics.get_orbital_time_in_seconds(body_reference as Moon, planet_system) - - info.append("Orbital Period: %s" % _format_seconds_to_mmss(period_seconds)) - if body_reference is Module: info.append("Class: Player Vessel") info.append("Mass: %.0f kg" % body_reference.mass) diff --git a/scenes/celestial_bodies/asteroid.gd b/scenes/celestial_bodies/asteroid.gd deleted file mode 100644 index cd1a592..0000000 --- a/scenes/celestial_bodies/asteroid.gd +++ /dev/null @@ -1,19 +0,0 @@ -class_name Asteroid -extends OrbitalBody3D - -# The orbital radius for this asteroid. -var orbital_radius: float - -func get_class_name() -> String: - return "Asteroid" - -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - # An Asteroid has negligible mass for physics calculations. - #mass = 0.001 - #radius = 5.0 - - # You can set a default texture here. - # texture = preload("res://assets/asteroid_texture.png") - - super._ready() diff --git a/scenes/celestial_bodies/asteroid.gd.uid b/scenes/celestial_bodies/asteroid.gd.uid deleted file mode 100644 index fe54404..0000000 --- a/scenes/celestial_bodies/asteroid.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://c816xae77cbmq diff --git a/scenes/celestial_bodies/asteroid.tscn b/scenes/celestial_bodies/asteroid.tscn deleted file mode 100644 index 4cfe793..0000000 --- a/scenes/celestial_bodies/asteroid.tscn +++ /dev/null @@ -1,8 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://bawsujtlpmh5r"] - -[ext_resource type="Script" uid="uid://0isnsk356que" path="res://scripts/orbital_body_2d.gd" id="1_4q05e"] - -[node name="Asteroid" type="Node2D"] -script = ExtResource("1_4q05e") -base_mass = 50000.0 -metadata/_custom_type_script = "uid://0isnsk356que" diff --git a/scenes/celestial_bodies/celestial_body.gd b/scenes/celestial_bodies/celestial_body.gd new file mode 100644 index 0000000..8218a61 --- /dev/null +++ b/scenes/celestial_bodies/celestial_body.gd @@ -0,0 +1,13 @@ +class_name CelestialBody extends OrbitalBody3D + +@export var radius: float = 100.0 + +func set_radius(value: float): + radius = value + + if $Surface.mesh is SphereMesh: + $Surface.mesh.radius = radius + $Surface.mesh.height = radius * 2.0 + + if $CollisionShape3D.shape is SphereShape3D: + $CollisionShape3D.shape.radius = radius diff --git a/scenes/celestial_bodies/celestial_body.gd.uid b/scenes/celestial_bodies/celestial_body.gd.uid new file mode 100644 index 0000000..0b3efa7 --- /dev/null +++ b/scenes/celestial_bodies/celestial_body.gd.uid @@ -0,0 +1 @@ +uid://dok35h0q4pseh diff --git a/scenes/celestial_bodies/celestial_body.tscn b/scenes/celestial_bodies/celestial_body.tscn new file mode 100644 index 0000000..a54ab53 --- /dev/null +++ b/scenes/celestial_bodies/celestial_body.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=5 format=3 uid="uid://dv18eg4xrlefe"] + +[ext_resource type="Script" uid="uid://dok35h0q4pseh" path="res://scenes/celestial_bodies/celestial_body.gd" id="1_uxu4s"] +[ext_resource type="Material" uid="uid://de0xnmjf12ted" path="res://scenes/celestial_bodies/materials/sun_mat.tres" id="2_vi0nt"] + +[sub_resource type="SphereMesh" id="SphereMesh_vi0nt"] +resource_local_to_scene = true +material = ExtResource("2_vi0nt") +radius = 2000.0 +height = 4000.0 + +[sub_resource type="SphereShape3D" id="SphereShape3D_uxu4s"] + +[node name="CelestialBody" type="RigidBody3D"] +script = ExtResource("1_uxu4s") +metadata/_custom_type_script = "uid://dok35h0q4pseh" + +[node name="Surface" type="MeshInstance3D" parent="."] +mesh = SubResource("SphereMesh_vi0nt") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +shape = SubResource("SphereShape3D_uxu4s") + +[node name="OmniLight3D" type="OmniLight3D" parent="."] +light_color = Color(0.958646, 0.7997282, 0.55087835, 1) +omni_range = 200000.0 +omni_attenuation = 2.0 diff --git a/scenes/celestial_bodies/materials/sun_mat.gdshader b/scenes/celestial_bodies/materials/sun_mat.gdshader new file mode 100644 index 0000000..3550606 --- /dev/null +++ b/scenes/celestial_bodies/materials/sun_mat.gdshader @@ -0,0 +1,52 @@ +// https://godotshaders.com/shader/3d-sun-shader/ +shader_type spatial; +render_mode specular_schlick_ggx; + +uniform float Glow_Power : hint_range(0,10) = 3; +uniform float Lightness_Difference : hint_range(0,10) = 3; +uniform vec4 Sun_Color: source_color; + +uniform sampler2D voronoi_noise; +uniform sampler2D emission_noise; +varying vec3 vertex_pos; +uniform float waveSpeed : hint_range(0,1) = 0.1; +uniform float fresnel : hint_range(0,2) = 1.0; + +uniform float scale : hint_range(0,2) = 0.01; +uniform float blendSharpness : hint_range(0,2) = 0.0; + +// TRIPLANAR FUNCTION +vec4 triplanar_texture(vec3 position, vec3 normal, vec2 offset, sampler2D noise) { + vec4 colX = texture(noise, position.xy * scale + offset); + vec4 colY = texture(noise, position.xz * scale + offset); + vec4 colZ = texture(noise, position.zy * scale + offset); + + vec3 blendWeight = abs(normal); + blendWeight = vec3(pow(blendWeight.x, blendSharpness), pow(blendWeight.y, blendSharpness), pow(blendWeight.z, blendSharpness)); + blendWeight /= (blendWeight.x + blendWeight.y + blendWeight.z); + + return colX * blendWeight.x + colY * blendWeight.y + colZ * blendWeight.z; +} + +void vertex() { + vertex_pos = VERTEX; +} + +void fragment() { + // Fresnel + float fresnel_out = pow(fresnel - clamp(dot(NORMAL, VIEW), 0.0, fresnel), fresnel); + + vec2 waveOffsetA = vec2(TIME * waveSpeed, TIME * waveSpeed * 0.8); + vec2 waveOffsetB = vec2(TIME * waveSpeed * - 0.8, TIME * waveSpeed * -0.3); + vec2 result_offset = waveOffsetA + waveOffsetB; + + vec3 cloud_tex = triplanar_texture(vertex_pos, NORMAL, result_offset, voronoi_noise).rgb; + vec3 cloud_tex_with_light = cloud_tex * vec3(Lightness_Difference); + vec3 cloud_tex_with_light_with_color = cloud_tex_with_light * Sun_Color.rgb; + vec3 cloud_tex_with_light_with_color_with_glow = vec3(Glow_Power) * cloud_tex_with_light_with_color; + + vec3 noise_tex = triplanar_texture(vertex_pos, NORMAL, result_offset, emission_noise).rgb; + vec3 result = cloud_tex_with_light_with_color_with_glow * noise_tex; + + EMISSION = vec3(fresnel_out) * result; +} \ No newline at end of file diff --git a/scenes/celestial_bodies/materials/sun_mat.gdshader.uid b/scenes/celestial_bodies/materials/sun_mat.gdshader.uid new file mode 100644 index 0000000..1dd8fac --- /dev/null +++ b/scenes/celestial_bodies/materials/sun_mat.gdshader.uid @@ -0,0 +1 @@ +uid://0cjdd62t25g1 diff --git a/scenes/celestial_bodies/materials/sun_mat.tres b/scenes/celestial_bodies/materials/sun_mat.tres new file mode 100644 index 0000000..707d35e --- /dev/null +++ b/scenes/celestial_bodies/materials/sun_mat.tres @@ -0,0 +1,27 @@ +[gd_resource type="ShaderMaterial" load_steps=6 format=3 uid="uid://de0xnmjf12ted"] + +[ext_resource type="Shader" uid="uid://0cjdd62t25g1" path="res://scenes/celestial_bodies/materials/sun_mat.gdshader" id="1_f1bp4"] + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_f1bp4"] + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_1eyo5"] +noise = SubResource("FastNoiseLite_f1bp4") + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_6484p"] + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_oxjal"] +noise = SubResource("FastNoiseLite_6484p") +in_3d_space = true + +[resource] +render_priority = 0 +shader = ExtResource("1_f1bp4") +shader_parameter/Glow_Power = 10.0 +shader_parameter/Lightness_Difference = 4.26400020254 +shader_parameter/Sun_Color = Color(0.90528274, 0.8164857, 0.6356678, 1) +shader_parameter/voronoi_noise = SubResource("NoiseTexture2D_oxjal") +shader_parameter/emission_noise = SubResource("NoiseTexture2D_1eyo5") +shader_parameter/waveSpeed = 0.1 +shader_parameter/fresnel = 1.0 +shader_parameter/scale = 0.01 +shader_parameter/blendSharpness = 0.0 diff --git a/scenes/celestial_bodies/moon.gd b/scenes/celestial_bodies/moon.gd deleted file mode 100644 index 8859053..0000000 --- a/scenes/celestial_bodies/moon.gd +++ /dev/null @@ -1,17 +0,0 @@ -class_name Moon -extends OrbitalBody3D - -# The orbital radius for this moon. -var orbital_radius: float - -func get_class_name() -> String: - return "Moon" - -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - # A Moon has a smaller mass than a planet. - - # You can set a default texture here. - # texture = preload("res://assets/moon_texture.png") - - super._ready() diff --git a/scenes/celestial_bodies/moon.gd.uid b/scenes/celestial_bodies/moon.gd.uid deleted file mode 100644 index 7d986ea..0000000 --- a/scenes/celestial_bodies/moon.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://b1xsx7er22nxn diff --git a/scenes/celestial_bodies/moon.tscn b/scenes/celestial_bodies/moon.tscn deleted file mode 100644 index 422e1ad..0000000 --- a/scenes/celestial_bodies/moon.tscn +++ /dev/null @@ -1,8 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://74ppvxcw8an4"] - -[ext_resource type="Script" uid="uid://b1xsx7er22nxn" path="res://scenes/celestial_bodies/moon.gd" id="1_530pw"] - -[node name="Moon" type="Node2D"] -script = ExtResource("1_530pw") -base_mass = 1e+06 -metadata/_custom_type_script = "uid://0isnsk356que" diff --git a/scenes/celestial_bodies/planet.gd b/scenes/celestial_bodies/planet.gd deleted file mode 100644 index 7e9d8da..0000000 --- a/scenes/celestial_bodies/planet.gd +++ /dev/null @@ -1,15 +0,0 @@ -class_name Planet -extends OrbitalBody3D - -# The orbital radius for this planet. -var orbital_radius: float - -func get_class_name() -> String: - return "Planet" - -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - # You can set a default texture here. - # texture = preload("res://assets/planet_texture.png") - - super._ready() diff --git a/scenes/celestial_bodies/planet.gd.uid b/scenes/celestial_bodies/planet.gd.uid deleted file mode 100644 index b6322e5..0000000 --- a/scenes/celestial_bodies/planet.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://5f6ipgu65urb diff --git a/scenes/celestial_bodies/planet.tscn b/scenes/celestial_bodies/planet.tscn deleted file mode 100644 index 79f0fa6..0000000 --- a/scenes/celestial_bodies/planet.tscn +++ /dev/null @@ -1,10 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://clt4qlsjcfgln"] - -[ext_resource type="Script" uid="uid://5f6ipgu65urb" path="res://scenes/celestial_bodies/planet.gd" id="1_cktii"] - -[node name="Planet" type="Node2D"] -script = ExtResource("1_cktii") -base_mass = 2.5e+07 -metadata/_custom_type_script = "uid://0isnsk356que" - -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] diff --git a/scenes/celestial_bodies/star.gd b/scenes/celestial_bodies/star.gd deleted file mode 100644 index b41aa4a..0000000 --- a/scenes/celestial_bodies/star.gd +++ /dev/null @@ -1,14 +0,0 @@ -class_name Star -extends OrbitalBody3D - -func get_class_name() -> String: - return "Star" - -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - # A Star has no primary and a very large mass. - - # You can set a default texture here, or assign it in the Inspector. - # texture = preload("res://assets/star_texture.png") - - super._ready() diff --git a/scenes/celestial_bodies/star.gd.uid b/scenes/celestial_bodies/star.gd.uid deleted file mode 100644 index f90bdf4..0000000 --- a/scenes/celestial_bodies/star.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://um2sfghmii42 diff --git a/scenes/celestial_bodies/star.tscn b/scenes/celestial_bodies/star.tscn deleted file mode 100644 index 1de007b..0000000 --- a/scenes/celestial_bodies/star.tscn +++ /dev/null @@ -1,15 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://5uqp4amjj7ww"] - -[ext_resource type="Script" uid="uid://um2sfghmii42" path="res://scenes/celestial_bodies/star.gd" id="1_mcqwg"] - -[sub_resource type="CircleShape2D" id="CircleShape2D_508pf"] -radius = 200.0 - -[node name="Star" type="Node2D"] -script = ExtResource("1_mcqwg") -base_mass = 5e+08 -metadata/_custom_type_script = "uid://0isnsk356que" - -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -shape = SubResource("CircleShape2D_508pf") -debug_color = Color(0.863865, 0.471779, 0.162305, 1) diff --git a/scenes/celestial_bodies/station.gd b/scenes/celestial_bodies/station.gd deleted file mode 100644 index 50ef197..0000000 --- a/scenes/celestial_bodies/station.gd +++ /dev/null @@ -1,17 +0,0 @@ -class_name Station -extends OrbitalBody3D - -# The orbital radius for this station. -var orbital_radius: float - -func get_class_name() -> String: - return "Station" - -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - # A Station has negligible mass for physics calculations. - - # You can set a default texture here. - # texture = preload("res://assets/station_texture.png") - - super._ready() diff --git a/scenes/celestial_bodies/station.gd.uid b/scenes/celestial_bodies/station.gd.uid deleted file mode 100644 index c39eb24..0000000 --- a/scenes/celestial_bodies/station.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://ulw61oxppwdu diff --git a/scenes/celestial_bodies/station.tscn b/scenes/celestial_bodies/station.tscn deleted file mode 100644 index 16f85c2..0000000 --- a/scenes/celestial_bodies/station.tscn +++ /dev/null @@ -1,8 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://dm3s33o4xhqfv"] - -[ext_resource type="Script" uid="uid://ulw61oxppwdu" path="res://scenes/celestial_bodies/station.gd" id="1_rod8h"] - -[node name="Station" type="Node2D"] -script = ExtResource("1_rod8h") -base_mass = 5000.0 -metadata/_custom_type_script = "uid://0isnsk356que" diff --git a/scenes/modules/test_module.tscn b/scenes/modules/test_module.tscn deleted file mode 100644 index a5f0679..0000000 --- a/scenes/modules/test_module.tscn +++ /dev/null @@ -1,82 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://c77wxeb7gpplw"] - -[ext_resource type="Script" uid="uid://6co67nfy8ngb" path="res://scenes/ship/builder/module.gd" id="1_mtskc"] -[ext_resource type="PackedScene" uid="uid://bho8x10x4oab7" path="res://scenes/ship/builder/pieces/hullplate.tscn" id="2_aovrk"] -[ext_resource type="PackedScene" uid="uid://d3hitk62fice4" path="res://scenes/ship/builder/pieces/bulkhead.tscn" id="4_dwgsg"] - -[node name="Module" type="Node2D"] -position = Vector2(-50, 50) -script = ExtResource("1_mtskc") -metadata/_custom_type_script = "uid://0isnsk356que" - -[node name="StructuralContainer" type="Node2D" parent="."] - -[node name="Hullplate" parent="StructuralContainer" instance=ExtResource("2_aovrk")] - -[node name="@StaticBody2D@31031" parent="StructuralContainer" instance=ExtResource("2_aovrk")] -position = Vector2(0, 100) - -[node name="@StaticBody2D@31033" parent="StructuralContainer" instance=ExtResource("2_aovrk")] -position = Vector2(100, 100) - -[node name="@StaticBody2D@31035" parent="StructuralContainer" instance=ExtResource("2_aovrk")] -position = Vector2(100, 0) - -[node name="@StaticBody2D@31037" parent="StructuralContainer" instance=ExtResource("2_aovrk")] -position = Vector2(100, -100) - -[node name="@StaticBody2D@31039" parent="StructuralContainer" instance=ExtResource("2_aovrk")] -position = Vector2(100, -200) - -[node name="@StaticBody2D@31041" parent="StructuralContainer" instance=ExtResource("2_aovrk")] -position = Vector2(0, -200) - -[node name="@StaticBody2D@31043" parent="StructuralContainer" instance=ExtResource("2_aovrk")] -position = Vector2(0, -100) - -[node name="Bulkhead" parent="StructuralContainer" instance=ExtResource("4_dwgsg")] -position = Vector2(-50, 100) - -[node name="@StaticBody2D@31046" parent="StructuralContainer" instance=ExtResource("4_dwgsg")] -position = Vector2(-50, 0) - -[node name="@StaticBody2D@31048" parent="StructuralContainer" instance=ExtResource("4_dwgsg")] -position = Vector2(-50, -100) - -[node name="@StaticBody2D@31050" parent="StructuralContainer" instance=ExtResource("4_dwgsg")] -position = Vector2(-50, -200) - -[node name="@StaticBody2D@31052" parent="StructuralContainer" instance=ExtResource("4_dwgsg")] -position = Vector2(150, -200) - -[node name="@StaticBody2D@31054" parent="StructuralContainer" instance=ExtResource("4_dwgsg")] -position = Vector2(150, -100) - -[node name="@StaticBody2D@31056" parent="StructuralContainer" instance=ExtResource("4_dwgsg")] -position = Vector2(150, 0) - -[node name="@StaticBody2D@31058" parent="StructuralContainer" instance=ExtResource("4_dwgsg")] -position = Vector2(150, 100) - -[node name="@StaticBody2D@31060" parent="StructuralContainer" instance=ExtResource("4_dwgsg")] -position = Vector2(0, 150) -rotation = 1.5708 - -[node name="@StaticBody2D@31062" parent="StructuralContainer" instance=ExtResource("4_dwgsg")] -position = Vector2(100, 150) -rotation = 1.5708 - -[node name="@StaticBody2D@31064" parent="StructuralContainer" instance=ExtResource("4_dwgsg")] -position = Vector2(0, -250) -rotation = 1.5708 - -[node name="@StaticBody2D@31066" parent="StructuralContainer" instance=ExtResource("4_dwgsg")] -position = Vector2(100, -250) -rotation = 1.5708 - -[node name="HullVolumeContainer" type="Node2D" parent="."] - -[node name="AtmosphereVisualizer" type="Node2D" parent="."] - -[node name="Camera2D" type="Camera2D" parent="."] -position = Vector2(50, -50) diff --git a/scenes/ship/computer/UI/sensor_panel.gd b/scenes/ship/computer/UI/sensor_panel.gd index 88adfbb..3f680d9 100644 --- a/scenes/ship/computer/UI/sensor_panel.gd +++ b/scenes/ship/computer/UI/sensor_panel.gd @@ -76,12 +76,12 @@ func _draw() -> void: draw_projected_orbits(star_orbiters) for body in icon_map: - if body is Asteroid: continue + #if body is Asteroid: continue var icon = icon_map[body] if not icon.visible: continue var path_points = [] - if body is Planet: + if body is CelestialBody: var planet_system = body.get_parent() as Barycenter draw_projected_orbits(planet_system.get_internal_attractors()) else: continue diff --git a/scenes/tests/3d/character_pawn_3d.tscn b/scenes/tests/3d/character_pawn_3d.tscn index f585560..a001b9c 100644 --- a/scenes/tests/3d/character_pawn_3d.tscn +++ b/scenes/tests/3d/character_pawn_3d.tscn @@ -44,6 +44,7 @@ top_level = true spring_length = 3.0 [node name="Camera3D" type="Camera3D" parent="CameraPivot/SpringArm"] +far = 200000.0 [node name="GripDetector" type="Area3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1) diff --git a/scripts/star_system.gd b/scripts/star_system.gd index 0498943..7f10329 100644 --- a/scripts/star_system.gd +++ b/scripts/star_system.gd @@ -36,7 +36,7 @@ func get_planetary_systems() -> Array[Barycenter]: func get_orbital_bodies() -> Array[OrbitalBody3D]: var bodies: Array[OrbitalBody3D] = [] for child in get_children(): - if child is Star or child is Barycenter: + if child is CelestialBody or child is Barycenter: continue if child is OrbitalBody3D: bodies.append(child) diff --git a/scripts/star_system_generator.gd b/scripts/star_system_generator.gd index 8cc4353..aef9062 100644 --- a/scripts/star_system_generator.gd +++ b/scripts/star_system_generator.gd @@ -11,12 +11,16 @@ const MAX_PLANETS = 8 const MAX_MOONS_PER_PLANET = 5 const ORBIT_SAFETY_FACTOR = 5 -func generate(star_system: StarSystem) -> SystemData: +var CelestialBodyScene: PackedScene = preload("res://scenes/celestial_bodies/celestial_body.tscn") + +func generate(star_system: StarSystem) -> SystemData: var system_data = SystemData.new() - var star = Star.new() + var star: CelestialBody = CelestialBodyScene.instantiate() + system_data.star = star star.name = "Star" + star.set_radius(2000.0) star.base_mass = STAR_MASS star_system.add_child(star) @@ -28,7 +32,8 @@ func generate(star_system: StarSystem) -> SystemData: planet_barycenter.name = "PlanetSystem_%d" % (i + 1) star_system.add_child(planet_barycenter) - var planet = Planet.new() + var planet: CelestialBody = CelestialBodyScene.instantiate() + planet.set_radius(randf_range(50.0, 200.0)) system_data.planets.append(planet) planet.name = "Planet_%d" % (i + 1) planet.base_mass = randf_range(PLANET_MASS * 0.2, PLANET_MASS * 5.0) @@ -63,7 +68,8 @@ func _generate_moons(planet: OrbitalBody3D, planet_barycenter: Barycenter, syste var current_orbit_radius = 200.0 for i in range(num_moons): - var moon = Moon.new() + var moon = CelestialBodyScene.instantiate() + moon.set_radius(10.0) system_data.moons.append(moon) planet_barycenter.add_child(moon) planet_barycenter.recalculate_total_mass()