Add fishing shop and persistent upgrades
This commit is contained in:
parent
49e7faaf84
commit
6386c5e3e3
27 changed files with 1662 additions and 38 deletions
47
world/fishing_shop_interaction.gd
Normal file
47
world/fishing_shop_interaction.gd
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
class_name FishingShopInteraction
|
||||
extends Area3D
|
||||
|
||||
signal local_player_range_changed(in_range: bool)
|
||||
|
||||
var _local_player: Player
|
||||
var _local_player_in_range: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
body_entered.connect(_on_body_entered)
|
||||
body_exited.connect(_on_body_exited)
|
||||
|
||||
|
||||
func setup_local_player(player: Player) -> void:
|
||||
_local_player = player
|
||||
_refresh_overlaps()
|
||||
|
||||
|
||||
func is_local_player_in_range() -> bool:
|
||||
return _local_player_in_range
|
||||
|
||||
|
||||
func _refresh_overlaps() -> void:
|
||||
var is_overlapping: bool = (
|
||||
_local_player != null
|
||||
and is_instance_valid(_local_player)
|
||||
and _local_player in get_overlapping_bodies()
|
||||
)
|
||||
_set_local_player_in_range(is_overlapping)
|
||||
|
||||
|
||||
func _on_body_entered(body: Node3D) -> void:
|
||||
if body == _local_player:
|
||||
_set_local_player_in_range(true)
|
||||
|
||||
|
||||
func _on_body_exited(body: Node3D) -> void:
|
||||
if body == _local_player:
|
||||
_set_local_player_in_range(false)
|
||||
|
||||
|
||||
func _set_local_player_in_range(in_range: bool) -> void:
|
||||
if _local_player_in_range == in_range:
|
||||
return
|
||||
_local_player_in_range = in_range
|
||||
local_player_range_changed.emit(in_range)
|
||||
1
world/fishing_shop_interaction.gd.uid
Normal file
1
world/fishing_shop_interaction.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c06cr0abctued
|
||||
|
|
@ -1,8 +1,13 @@
|
|||
class_name TestWorld
|
||||
extends Node3D
|
||||
|
||||
const FishingShopInteractionType = preload(
|
||||
"res://world/fishing_shop_interaction.gd"
|
||||
)
|
||||
|
||||
@onready var _water_trigger: PlayerWaterTrigger = %PlayerWaterTrigger
|
||||
@onready var _safe_respawn_points: Node3D = %SafeRespawnPoints
|
||||
@onready var _fishing_shop: FishingShopInteractionType = %FishingShopInteraction
|
||||
|
||||
|
||||
func get_player_water_trigger() -> PlayerWaterTrigger:
|
||||
|
|
@ -16,3 +21,7 @@ func get_safe_respawn_points() -> Array[SafeRespawnPoint]:
|
|||
if point != null:
|
||||
points.append(point)
|
||||
return points
|
||||
|
||||
|
||||
func get_fishing_shop() -> FishingShopInteractionType:
|
||||
return _fishing_shop
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
[gd_scene load_steps=18 format=3]
|
||||
[gd_scene load_steps=25 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://world/fishable_water_region.gd" id="1_water_region"]
|
||||
[ext_resource type="Resource" path="res://fish/pools/test_water_pool.tres" id="2_fish_pool"]
|
||||
[ext_resource type="Script" path="res://world/test_world.gd" id="3_world"]
|
||||
[ext_resource type="Script" path="res://world/player_water_trigger.gd" id="4_water_trigger"]
|
||||
[ext_resource type="Script" path="res://world/safe_respawn_point.gd" id="5_safe_point"]
|
||||
[ext_resource type="Script" path="res://world/fishing_shop_interaction.gd" id="6_shop"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="GroundShape"]
|
||||
size = Vector3(30, 1, 30)
|
||||
|
|
@ -51,6 +52,24 @@ ambient_light_source = 3
|
|||
ambient_light_color = Color(0.65, 0.72, 0.8, 1)
|
||||
ambient_light_energy = 0.65
|
||||
|
||||
[sub_resource type="BoxMesh" id="ShopCounterMesh"]
|
||||
size = Vector3(3.4, 1.25, 1.5)
|
||||
|
||||
[sub_resource type="BoxMesh" id="ShopRoofMesh"]
|
||||
size = Vector3(4.2, 0.35, 2.2)
|
||||
|
||||
[sub_resource type="BoxMesh" id="ShopPostMesh"]
|
||||
size = Vector3(0.25, 2.8, 0.25)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="ShopPrimaryMaterial"]
|
||||
albedo_color = Color(0.18, 0.72, 0.68, 1)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="ShopAccentMaterial"]
|
||||
albedo_color = Color(1, 0.72, 0.22, 1)
|
||||
|
||||
[sub_resource type="SphereShape3D" id="ShopInteractionShape"]
|
||||
radius = 3.0
|
||||
|
||||
[node name="TestWorld" type="Node3D"]
|
||||
script = ExtResource("3_world")
|
||||
|
||||
|
|
@ -142,3 +161,44 @@ script = ExtResource("5_safe_point")
|
|||
[node name="DockEnd" type="Marker3D" parent="SafeRespawnPoints"]
|
||||
position = Vector3(0, 1.08, -17)
|
||||
script = ExtResource("5_safe_point")
|
||||
|
||||
[node name="FishingShop" type="Node3D" parent="."]
|
||||
position = Vector3(8, 0, 5)
|
||||
|
||||
[node name="Counter" type="MeshInstance3D" parent="FishingShop"]
|
||||
position = Vector3(0, 0.625, 0)
|
||||
mesh = SubResource("ShopCounterMesh")
|
||||
material_override = SubResource("ShopPrimaryMaterial")
|
||||
|
||||
[node name="Roof" type="MeshInstance3D" parent="FishingShop"]
|
||||
position = Vector3(0, 2.25, 0)
|
||||
mesh = SubResource("ShopRoofMesh")
|
||||
material_override = SubResource("ShopAccentMaterial")
|
||||
|
||||
[node name="WestPost" type="MeshInstance3D" parent="FishingShop"]
|
||||
position = Vector3(-1.55, 1.4, 0.55)
|
||||
mesh = SubResource("ShopPostMesh")
|
||||
material_override = SubResource("ShopPrimaryMaterial")
|
||||
|
||||
[node name="EastPost" type="MeshInstance3D" parent="FishingShop"]
|
||||
position = Vector3(1.55, 1.4, 0.55)
|
||||
mesh = SubResource("ShopPostMesh")
|
||||
material_override = SubResource("ShopPrimaryMaterial")
|
||||
|
||||
[node name="ShopName" type="Label3D" parent="FishingShop"]
|
||||
position = Vector3(0, 2.7, 0)
|
||||
text = "Fishing Shop"
|
||||
font_size = 36
|
||||
outline_size = 8
|
||||
billboard = 1
|
||||
no_depth_test = true
|
||||
|
||||
[node name="FishingShopInteraction" type="Area3D" parent="FishingShop"]
|
||||
unique_name_in_owner = true
|
||||
position = Vector3(0, 1, 0)
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
script = ExtResource("6_shop")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="FishingShop/FishingShopInteraction"]
|
||||
shape = SubResource("ShopInteractionShape")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue