diff --git a/game.tscn b/game.tscn index 2e09d1f3..19f89cbe 100644 --- a/game.tscn +++ b/game.tscn @@ -151,6 +151,9 @@ script = ExtResource("7_6citj") hyperspace_controller = NodePath("../HyperspaceController") free_when_destroyed = false +[node name="MinimapIcon" parent="Player" index="3"] +transform = Transform3D(1, -1.21652e-31, 0, -1.21652e-31, 1, 0, 0, 0, 1, 0, 0, 0) + [node name="AudioListener3D" type="AudioListener3D" parent="Player"] transform = Transform3D(1, -1.21652e-31, 0, -1.21652e-31, 1, 0, 0, 0, 1, 0, 0, 0) current = true diff --git a/gui/minimap_target_override_mat.tres b/gui/minimap_target_override_mat.tres new file mode 100644 index 00000000..0d99e818 --- /dev/null +++ b/gui/minimap_target_override_mat.tres @@ -0,0 +1,5 @@ +[gd_resource type="StandardMaterial3D" format=3 uid="uid://cyhh74uif4hp0"] + +[resource] +shading_mode = 0 +albedo_color = Color(1, 1, 0, 1) diff --git a/ships/corvette01/corvette01.tscn b/ships/corvette01/corvette01.tscn index 8d0730aa..ec93c074 100644 --- a/ships/corvette01/corvette01.tscn +++ b/ships/corvette01/corvette01.tscn @@ -1,11 +1,10 @@ -[gd_scene load_steps=13 format=3 uid="uid://cqxv07b8bwiev"] +[gd_scene load_steps=12 format=3 uid="uid://cqxv07b8bwiev"] [ext_resource type="Script" path="res://ships/ship.gd" id="1_wioy5"] [ext_resource type="ArrayMesh" uid="uid://40a23nnu1j37" path="res://ships/corvette01/corvette01_mesh.tres" id="1_yacfo"] [ext_resource type="Resource" uid="uid://dc468i445pkgd" path="res://ships/corvette01/corvette01.tres" id="2_20tol"] [ext_resource type="PackedScene" uid="uid://b7tckdwyjwpso" path="res://weapons/blaster/blaster_bolt.tscn" id="2_gae27"] [ext_resource type="PackedScene" uid="uid://cdyo800b83x5i" path="res://effects/explosions/explosion002.tscn" id="2_xcc1t"] -[ext_resource type="Material" uid="uid://dskoto6nul131" path="res://gui/target_overlay_mat.tres" id="4_it73y"] [ext_resource type="AudioStream" uid="uid://5iqc5o8p02l5" path="res://ships/audio/THRUSTER LOW.wav" id="4_xrdjv"] [ext_resource type="PackedScene" uid="uid://dbc2usdmy5wf3" path="res://effects/engine_glow/engine_glow.tscn" id="8_kgu6n"] @@ -23,7 +22,7 @@ shading_mode = 0 material = SubResource("StandardMaterial3D_t5loa") orientation = 1 -[node name="Corvette" type="RigidBody3D" node_paths=PackedStringArray("thruster_audio", "mesh_instance", "weapon_hardpoints", "engine_glow") groups=["ships"]] +[node name="Corvette" type="RigidBody3D" node_paths=PackedStringArray("thruster_audio", "mesh_instance", "minimap_mesh_instance", "weapon_hardpoints", "engine_glow") groups=["ships"]] transform = Transform3D(1, -3.48787e-16, 3.48787e-16, 3.48787e-16, 1, -3.48787e-16, -3.48787e-16, 3.48787e-16, 1, 0, 0, 0) collision_mask = 2 axis_lock_linear_y = true @@ -34,8 +33,8 @@ ship_def = ExtResource("2_20tol") bullet = ExtResource("2_gae27") explosion = ExtResource("2_xcc1t") thruster_audio = NodePath("AudioStreamPlayer3D") -target_overlay_material = ExtResource("4_it73y") mesh_instance = NodePath("MeshInstance3D") +minimap_mesh_instance = NodePath("MinimapIcon") weapon_hardpoints = [NodePath("BlasterHardpoint")] engine_glow = [NodePath("EngineGlowLeft"), NodePath("EngineGlowRight")] engine_glow_tween_duration_sec = 0.3 diff --git a/ships/frigate03/frigate03.tscn b/ships/frigate03/frigate03.tscn index 917450d4..5f2f7598 100644 --- a/ships/frigate03/frigate03.tscn +++ b/ships/frigate03/frigate03.tscn @@ -1,10 +1,9 @@ -[gd_scene load_steps=15 format=3 uid="uid://bxggrqus7bst5"] +[gd_scene load_steps=14 format=3 uid="uid://bxggrqus7bst5"] [ext_resource type="Script" path="res://ships/ship.gd" id="1_wioy5"] [ext_resource type="PackedScene" uid="uid://b7tckdwyjwpso" path="res://weapons/blaster/blaster_bolt.tscn" id="2_gae27"] [ext_resource type="Resource" uid="uid://dmd83o4ylhb0l" path="res://ships/frigate03/frigate03.tres" id="2_lg5km"] [ext_resource type="PackedScene" uid="uid://cdyo800b83x5i" path="res://effects/explosions/explosion002.tscn" id="2_xcc1t"] -[ext_resource type="Material" uid="uid://dskoto6nul131" path="res://gui/target_overlay_mat.tres" id="4_it73y"] [ext_resource type="AudioStream" uid="uid://5iqc5o8p02l5" path="res://ships/audio/THRUSTER LOW.wav" id="4_xrdjv"] [ext_resource type="ArrayMesh" uid="uid://c2y60nf8m25ka" path="res://ships/frigate03/frigate03_mesh.tres" id="6_g7bx0"] [ext_resource type="PackedScene" uid="uid://dbc2usdmy5wf3" path="res://effects/engine_glow/engine_glow.tscn" id="8_ibdmx"] @@ -32,7 +31,7 @@ material = SubResource("ShaderMaterial_rurkt") size = Vector2(1, 2) orientation = 1 -[node name="Frigate" type="RigidBody3D" node_paths=PackedStringArray("thruster_audio", "mesh_instance", "weapon_hardpoints", "engine_glow") groups=["ships"]] +[node name="Frigate" type="RigidBody3D" node_paths=PackedStringArray("thruster_audio", "mesh_instance", "minimap_mesh_instance", "weapon_hardpoints", "engine_glow") groups=["ships"]] transform = Transform3D(1, -3.48787e-16, 3.48787e-16, 3.48787e-16, 1, -3.48787e-16, -3.48787e-16, 3.48787e-16, 1, 0, 0, 0) collision_mask = 2 axis_lock_linear_y = true @@ -43,8 +42,8 @@ ship_def = ExtResource("2_lg5km") bullet = ExtResource("2_gae27") explosion = ExtResource("2_xcc1t") thruster_audio = NodePath("AudioStreamPlayer3D") -target_overlay_material = ExtResource("4_it73y") mesh_instance = NodePath("MeshInstance3D") +minimap_mesh_instance = NodePath("MinimapIcon") weapon_hardpoints = [NodePath("BlasterHardpoint")] engine_glow = [NodePath("EngineGlow")] engine_glow_tween_duration_sec = 0.6 diff --git a/ships/ship.gd b/ships/ship.gd index b896a875..8a2b67c9 100644 --- a/ships/ship.gd +++ b/ships/ship.gd @@ -19,12 +19,18 @@ class_name Ship ## This audio stream should be a looping sound. Rather than restarting from the beginning each time the thruster is used, the audio stream is paused and resumed, and evenutally loops. @export var thruster_audio: AudioStreamPlayer3D -## A material to overlay on this ship's mesh when it is targeted by the player. -@export var target_overlay_material: BaseMaterial3D - ## This ship's mesh. @export var mesh_instance: MeshInstance3D +## A material to overlay on this ship's mesh when it is targeted by the player. +@export var target_overlay_material: BaseMaterial3D = preload ("res://gui/target_overlay_mat.tres") + +## This ship's minimap icon. +@export var minimap_mesh_instance: MeshInstance3D + +## A material to override this ship's minimap icon when it is targeted by the player. +@export var minimap_target_override_material: BaseMaterial3D = preload ("res://gui/minimap_target_override_mat.tres") + ## Whether the ship node should be removed from the scene tree and freed when it is destroyed. ## ## If false, the ship will instead be made invisible and stop participating in physics and collision calculations. This is mostly useful for the player's ship, which is often expected to exist (even if invisible) by other nodes. @@ -235,7 +241,12 @@ func set_target(targeted_ship: Ship) -> void: ## Invoked when the player's target changes to or from this ship, to apply or remove the corresponding visual indicator. func set_targeted_by_player(targeted: bool) -> void: - self.mesh_instance.material_overlay = self.target_overlay_material if targeted else null + if targeted: + self.mesh_instance.material_overlay = self.target_overlay_material + self.minimap_mesh_instance.material_override = self.minimap_target_override_material + else: + self.mesh_instance.material_overlay = null + self.minimap_mesh_instance.material_override = null func _on_ship_destroyed(ship: Ship) -> void: assert(ship == self.target, "Should only receive ship destruction notification from current target")