Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a66c39e9f8 | ||
|
|
2d27e4254e | ||
|
|
b3287ccf6f |
@@ -26,6 +26,7 @@ MenuSfx="*res://scenes/UI/menu_sfx.tscn"
|
|||||||
AuthState="*res://scenes/UI/auth_state.gd"
|
AuthState="*res://scenes/UI/auth_state.gd"
|
||||||
CharacterService="*res://scenes/UI/character_service.gd"
|
CharacterService="*res://scenes/UI/character_service.gd"
|
||||||
SelectedCharacter="*res://scenes/UI/selected_character.gd"
|
SelectedCharacter="*res://scenes/UI/selected_character.gd"
|
||||||
|
DialogSystem="*res://scenes/UI/dialog_system.gd"
|
||||||
|
|
||||||
[dotnet]
|
[dotnet]
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
[gd_scene load_steps=14 format=3]
|
[gd_scene load_steps=14 format=3]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scenes/Characters/repo_bot.gd" id="1_repo_bot"]
|
[ext_resource type="Script" path="res://scenes/Characters/repo_bot.gd" id="1_repo_bot"]
|
||||||
|
[ext_resource type="Script" path="res://scenes/Interaction/dialog_trigger_area.gd" id="2_dialog"]
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_body"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_body"]
|
||||||
albedo_color = Color(0.78, 0.8, 0.82, 1)
|
albedo_color = Color(0.78, 0.8, 0.82, 1)
|
||||||
@@ -50,9 +51,12 @@ material = SubResource("StandardMaterial3D_body")
|
|||||||
size = Vector3(0.26, 0.3, 0.12)
|
size = Vector3(0.26, 0.3, 0.12)
|
||||||
material = SubResource("StandardMaterial3D_accent")
|
material = SubResource("StandardMaterial3D_accent")
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_body"]
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_body"]
|
||||||
radius = 0.3
|
radius = 0.3
|
||||||
height = 1.1
|
height = 1.1
|
||||||
|
|
||||||
|
[sub_resource type="SphereShape3D" id="SphereShape3D_interact"]
|
||||||
|
radius = 1.7
|
||||||
|
|
||||||
[node name="RepoBot" type="Node3D"]
|
[node name="RepoBot" type="Node3D"]
|
||||||
script = ExtResource("1_repo_bot")
|
script = ExtResource("1_repo_bot")
|
||||||
@@ -111,6 +115,17 @@ mesh = SubResource("CylinderMesh_limb")
|
|||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.12, 0.15, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.12, 0.15, 0)
|
||||||
mesh = SubResource("CylinderMesh_limb")
|
mesh = SubResource("CylinderMesh_limb")
|
||||||
|
|
||||||
[node name="Backpack" type="MeshInstance3D" parent="Body"]
|
[node name="Backpack" type="MeshInstance3D" parent="Body"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0.22)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0.22)
|
||||||
mesh = SubResource("BoxMesh_pack")
|
mesh = SubResource("BoxMesh_pack")
|
||||||
|
|
||||||
|
[node name="InteractArea" type="Area3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0)
|
||||||
|
script = ExtResource("2_dialog")
|
||||||
|
collision_layer = 2
|
||||||
|
collision_mask = 1
|
||||||
|
prompt_text = "Press E to talk"
|
||||||
|
dialog_text = "Repo Bot: Welcome to Promiscuity.\n\nPress E again to close this dialog."
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="InteractArea"]
|
||||||
|
shape = SubResource("SphereShape3D_interact")
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
extends Area3D
|
||||||
|
|
||||||
|
@export var target_group: StringName = &"player"
|
||||||
|
@export var prompt_text := "Press E to talk"
|
||||||
|
@export_multiline var dialog_text := ""
|
||||||
|
@export var auto_popup := false
|
||||||
|
@export_enum("Every Entry", "Once") var auto_popup_mode := 0
|
||||||
|
|
||||||
|
var _has_triggered := false
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
collision_layer = 2
|
||||||
|
collision_mask = 1
|
||||||
|
body_entered.connect(_on_body_entered)
|
||||||
|
body_exited.connect(_on_body_exited)
|
||||||
|
|
||||||
|
|
||||||
|
func _exit_tree() -> void:
|
||||||
|
if not auto_popup and DialogSystem:
|
||||||
|
DialogSystem.unregister_interactable(self)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_body_entered(body: Node) -> void:
|
||||||
|
if not (target_group == StringName() or body.is_in_group(target_group)):
|
||||||
|
return
|
||||||
|
if auto_popup:
|
||||||
|
if auto_popup_mode == 1 and _has_triggered:
|
||||||
|
return
|
||||||
|
_has_triggered = true
|
||||||
|
if DialogSystem and DialogSystem.has_method("show_text"):
|
||||||
|
DialogSystem.show_text(dialog_text)
|
||||||
|
return
|
||||||
|
if DialogSystem:
|
||||||
|
DialogSystem.register_interactable(self)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_body_exited(body: Node) -> void:
|
||||||
|
if auto_popup:
|
||||||
|
return
|
||||||
|
if target_group == StringName() or body.is_in_group(target_group):
|
||||||
|
DialogSystem.unregister_interactable(self)
|
||||||
|
|
||||||
|
|
||||||
|
func get_dialog_prompt() -> String:
|
||||||
|
return prompt_text
|
||||||
|
|
||||||
|
|
||||||
|
func get_dialog_text() -> String:
|
||||||
|
return dialog_text
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://bk53njt7i3kmv
|
||||||
@@ -1,13 +1,25 @@
|
|||||||
extends Node3D
|
extends Node3D
|
||||||
|
|
||||||
@export var day_length := 120.0 # seconds for full rotation
|
@export var day_length := 120.0 # seconds for full rotation
|
||||||
@export var start_light_angle := -90.0
|
@export var start_light_angle := -90.0
|
||||||
var end_light_angle = start_light_angle + 360.0
|
@export var show_spawn_dialog := true
|
||||||
var start_radians = start_light_angle * PI / 180
|
@export_multiline var spawn_dialog_text := "Welcome to Promiscuity.\n\nPress E to close this message."
|
||||||
var time := 0.0
|
@export var spawn_dialog_auto_close_seconds := 4.0
|
||||||
|
var end_light_angle = start_light_angle + 360.0
|
||||||
|
var start_radians = start_light_angle * PI / 180
|
||||||
|
var time := 0.0
|
||||||
|
|
||||||
@onready var sun := $DirectionalLight3D
|
@onready var sun := $DirectionalLight3D
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
if show_spawn_dialog and DialogSystem and DialogSystem.has_method("show_text"):
|
||||||
|
await get_tree().process_frame
|
||||||
|
DialogSystem.show_text(spawn_dialog_text)
|
||||||
|
if spawn_dialog_auto_close_seconds > 0.0:
|
||||||
|
await get_tree().create_timer(spawn_dialog_auto_close_seconds).timeout
|
||||||
|
if DialogSystem and DialogSystem.has_method("close_if_text"):
|
||||||
|
DialogSystem.close_if_text(spawn_dialog_text)
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
time = fmod((time + delta), day_length)
|
time = fmod((time + delta), day_length)
|
||||||
var t = time / day_length
|
var t = time / day_length
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=18 format=3 uid="uid://dchj6g2i8ebph"]
|
[gd_scene load_steps=23 format=3 uid="uid://dchj6g2i8ebph"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://brgmxhhhtakja" path="res://scenes/Levels/level.gd" id="1_a4mo8"]
|
[ext_resource type="Script" uid="uid://brgmxhhhtakja" path="res://scenes/Levels/level.gd" id="1_a4mo8"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bb6hj6l23043x" path="res://assets/models/human.blend" id="1_eg4yq"]
|
[ext_resource type="PackedScene" uid="uid://bb6hj6l23043x" path="res://assets/models/human.blend" id="1_eg4yq"]
|
||||||
@@ -6,8 +6,9 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://c5of6aaxop1hl" path="res://scenes/block.tscn" id="2_tc7dm"]
|
[ext_resource type="PackedScene" uid="uid://c5of6aaxop1hl" path="res://scenes/block.tscn" id="2_tc7dm"]
|
||||||
[ext_resource type="Script" uid="uid://b7fopt7sx74g8" path="res://scenes/Levels/menu.gd" id="3_tc7dm"]
|
[ext_resource type="Script" uid="uid://b7fopt7sx74g8" path="res://scenes/Levels/menu.gd" id="3_tc7dm"]
|
||||||
[ext_resource type="PackedScene" path="res://scenes/Characters/repo_bot.tscn" id="4_repo"]
|
[ext_resource type="PackedScene" path="res://scenes/Characters/repo_bot.tscn" id="4_repo"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bnqaqbgynoyys" path="res://assets/models/TestCharAnimated.glb" id="5_fi66n"]
|
|
||||||
[ext_resource type="PackedScene" path="res://scenes/Vehicles/car.tscn" id="5_car"]
|
[ext_resource type="PackedScene" path="res://scenes/Vehicles/car.tscn" id="5_car"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bnqaqbgynoyys" path="res://assets/models/TestCharAnimated.glb" id="5_fi66n"]
|
||||||
|
[ext_resource type="Script" uid="uid://bk53njt7i3kmv" path="res://scenes/Interaction/dialog_trigger_area.gd" id="6_dialog"]
|
||||||
|
|
||||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_2q6dc"]
|
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_2q6dc"]
|
||||||
bounce = 0.5
|
bounce = 0.5
|
||||||
@@ -21,6 +22,20 @@ bounce = 0.5
|
|||||||
|
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_mx8sn"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_mx8sn"]
|
||||||
|
|
||||||
|
[sub_resource type="SphereShape3D" id="SphereShape3D_dialog_zone"]
|
||||||
|
radius = 2.5
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_dialog_zone"]
|
||||||
|
transparency = 1
|
||||||
|
cull_mode = 2
|
||||||
|
shading_mode = 0
|
||||||
|
albedo_color = Color(0.2, 0.8, 0.35, 0.18)
|
||||||
|
|
||||||
|
[sub_resource type="SphereMesh" id="SphereMesh_dialog_zone"]
|
||||||
|
material = SubResource("StandardMaterial3D_dialog_zone")
|
||||||
|
radius = 2.5
|
||||||
|
height = 5.0
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_2q6dc"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_2q6dc"]
|
||||||
size = Vector3(1080, 2, 1080)
|
size = Vector3(1080, 2, 1080)
|
||||||
|
|
||||||
@@ -62,6 +77,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
|||||||
mesh = SubResource("SphereMesh_w7c3h")
|
mesh = SubResource("SphereMesh_w7c3h")
|
||||||
|
|
||||||
[node name="Player" type="RigidBody3D" parent="."]
|
[node name="Player" type="RigidBody3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.6563287, 0, 0)
|
||||||
physics_material_override = SubResource("PhysicsMaterial_w8frs")
|
physics_material_override = SubResource("PhysicsMaterial_w8frs")
|
||||||
script = ExtResource("1_muv8p")
|
script = ExtResource("1_muv8p")
|
||||||
camera_path = NodePath("Camera3D")
|
camera_path = NodePath("Camera3D")
|
||||||
@@ -71,27 +87,27 @@ phone_path = NodePath("../PhoneUI")
|
|||||||
transform = Transform3D(-0.9998549, 0, 0.01703362, 0, 1, 0, -0.01703362, 0, -0.9998549, 0, 0, 0)
|
transform = Transform3D(-0.9998549, 0, 0.01703362, 0, 1, 0, -0.01703362, 0, -0.9998549, 0, 0, 0)
|
||||||
|
|
||||||
[node name="Skeleton3D" parent="Player/TestCharAnimated/Armature" index="0"]
|
[node name="Skeleton3D" parent="Player/TestCharAnimated/Armature" index="0"]
|
||||||
bones/0/position = Vector3(0.0026170756, -0.0012418391, -0.98996276)
|
bones/0/position = Vector3(0.002616825, -0.0012634661, -0.98995954)
|
||||||
bones/0/rotation = Quaternion(-0.7278173, -0.05346041, 0.012412205, 0.6835714)
|
bones/0/rotation = Quaternion(-0.7278332, -0.05342924, 0.012382713, 0.6835575)
|
||||||
bones/1/position = Vector3(8.593209e-06, 0.09923458, -0.012273359)
|
bones/1/position = Vector3(8.593209e-06, 0.09923458, -0.012273359)
|
||||||
bones/1/rotation = Quaternion(-0.031655744, 0.011362745, 0.022744056, 0.9991754)
|
bones/1/rotation = Quaternion(-0.03163086, 0.011397719, 0.022761386, 0.9991754)
|
||||||
bones/2/position = Vector3(-2.2989244e-10, 0.117319785, 2.9730852e-08)
|
bones/2/position = Vector3(-2.2989244e-10, 0.117319785, 2.9730852e-08)
|
||||||
bones/2/rotation = Quaternion(0.010291794, 0.001169461, 0.013815534, 0.9998509)
|
bones/2/rotation = Quaternion(0.0102874795, 0.0011603195, 0.013812066, 0.99985105)
|
||||||
bones/3/position = Vector3(-2.3358266e-09, 0.13458829, -1.382244e-08)
|
bones/3/position = Vector3(-2.3358266e-09, 0.13458829, -1.382244e-08)
|
||||||
bones/3/rotation = Quaternion(0.067557335, 0.0021622085, 0.013776206, 0.99761796)
|
bones/3/rotation = Quaternion(0.06755522, 0.0021543663, 0.013774819, 0.99761814)
|
||||||
bones/4/position = Vector3(2.508626e-07, 0.15027755, 0.008779066)
|
bones/4/position = Vector3(2.508626e-07, 0.15027755, 0.008779066)
|
||||||
bones/4/rotation = Quaternion(0.051882792, -0.00090027065, 0.0039363643, 0.998645)
|
bones/4/rotation = Quaternion(0.051899955, -0.00089839776, 0.0039267424, 0.9986442)
|
||||||
bones/5/position = Vector3(2.152588e-08, 0.103218146, 0.03142428)
|
bones/5/position = Vector3(2.152588e-08, 0.103218146, 0.03142428)
|
||||||
bones/5/rotation = Quaternion(-0.06595954, 0.011917545, -0.0014885183, 0.99775004)
|
bones/5/rotation = Quaternion(-0.06595736, 0.011938445, -0.0014933152, 0.9977499)
|
||||||
bones/6/position = Vector3(1.5477327e-06, 0.18474667, 0.06636399)
|
bones/6/position = Vector3(1.5477327e-06, 0.18474667, 0.06636399)
|
||||||
bones/7/position = Vector3(0.061058242, 0.09106279, 0.0075706206)
|
bones/7/position = Vector3(0.061058242, 0.09106279, 0.0075706206)
|
||||||
bones/7/rotation = Quaternion(-0.5982132, -0.43452233, 0.50765175, -0.4422909)
|
bones/7/rotation = Quaternion(-0.598225, -0.43451372, 0.5076822, -0.44224826)
|
||||||
bones/8/position = Vector3(1.1842036e-08, 0.12922287, 5.2578955e-08)
|
bones/8/position = Vector3(1.1842036e-08, 0.12922287, 5.2578955e-08)
|
||||||
bones/8/rotation = Quaternion(0.5434686, 0.18407291, 0.20301422, 0.7934383)
|
bones/8/rotation = Quaternion(0.543452, 0.18399428, 0.20302251, 0.79346573)
|
||||||
bones/9/position = Vector3(1.5054144e-07, 0.2740467, 2.2048344e-08)
|
bones/9/position = Vector3(1.5054144e-07, 0.2740467, 2.2048344e-08)
|
||||||
bones/9/rotation = Quaternion(-5.192343e-09, -1.1239315e-06, 0.01273731, 0.99991894)
|
bones/9/rotation = Quaternion(-5.2907154e-09, -1.1239725e-06, 0.012734968, 0.999919)
|
||||||
bones/10/position = Vector3(1.9432857e-08, 0.27614468, 9.6609995e-08)
|
bones/10/position = Vector3(1.9432857e-08, 0.27614468, 9.6609995e-08)
|
||||||
bones/10/rotation = Quaternion(0.048323337, -0.28487536, 0.026756868, 0.9569718)
|
bones/10/rotation = Quaternion(0.04830448, -0.2848921, 0.026799988, 0.9569665)
|
||||||
bones/11/position = Vector3(-0.030029751, 0.037888147, 0.021671427)
|
bones/11/position = Vector3(-0.030029751, 0.037888147, 0.021671427)
|
||||||
bones/11/rotation = Quaternion(0.2098604, -0.059559863, 0.20750383, 0.9536002)
|
bones/11/rotation = Quaternion(0.2098604, -0.059559863, 0.20750383, 0.9536002)
|
||||||
bones/12/position = Vector3(-3.3527822e-08, 0.0474497, -1.48403245e-08)
|
bones/12/position = Vector3(-3.3527822e-08, 0.0474497, -1.48403245e-08)
|
||||||
@@ -128,13 +144,13 @@ bones/29/position = Vector3(1.195453e-08, 0.02594832, 1.5542597e-08)
|
|||||||
bones/29/rotation = Quaternion(0.14350323, 3.322942e-05, -0.014478063, 0.98954403)
|
bones/29/rotation = Quaternion(0.14350323, 3.322942e-05, -0.014478063, 0.98954403)
|
||||||
bones/30/position = Vector3(-2.4944999e-08, 0.029238665, 6.2325825e-08)
|
bones/30/position = Vector3(-2.4944999e-08, 0.029238665, 6.2325825e-08)
|
||||||
bones/31/position = Vector3(-0.06105696, 0.09106397, 0.007570758)
|
bones/31/position = Vector3(-0.06105696, 0.09106397, 0.007570758)
|
||||||
bones/31/rotation = Quaternion(0.60009927, -0.4346891, 0.52418536, 0.4197095)
|
bones/31/rotation = Quaternion(0.60012215, -0.43466684, 0.5242142, 0.41966385)
|
||||||
bones/32/position = Vector3(2.116817e-08, 0.12922288, 7.016769e-08)
|
bones/32/position = Vector3(2.116817e-08, 0.12922288, 7.016769e-08)
|
||||||
bones/32/rotation = Quaternion(0.46432823, -0.26300937, -0.23269261, 0.813068)
|
bones/32/rotation = Quaternion(0.46436408, -0.26298717, -0.23268588, 0.8130566)
|
||||||
bones/33/position = Vector3(-2.350565e-08, 0.27404687, 1.5161348e-08)
|
bones/33/position = Vector3(-2.350565e-08, 0.27404687, 1.5161348e-08)
|
||||||
bones/33/rotation = Quaternion(7.667138e-08, -5.0620065e-06, -0.058376648, 0.99829465)
|
bones/33/rotation = Quaternion(7.69042e-08, -5.0622584e-06, -0.058380682, 0.9982944)
|
||||||
bones/34/position = Vector3(1.3629875e-07, 0.27614468, -9.158248e-09)
|
bones/34/position = Vector3(1.3629875e-07, 0.27614468, -9.158248e-09)
|
||||||
bones/34/rotation = Quaternion(0.059040155, 0.17509013, -0.005968382, 0.9827626)
|
bones/34/rotation = Quaternion(0.059025347, 0.17513894, -0.005969527, 0.9827547)
|
||||||
bones/35/position = Vector3(0.030029776, 0.03788806, 0.021671649)
|
bones/35/position = Vector3(0.030029776, 0.03788806, 0.021671649)
|
||||||
bones/35/rotation = Quaternion(0.21378386, 0.065372065, -0.22564878, 0.94821185)
|
bones/35/rotation = Quaternion(0.21378386, 0.065372065, -0.22564878, 0.94821185)
|
||||||
bones/36/position = Vector3(-2.7939748e-09, 0.04744962, -1.7240383e-08)
|
bones/36/position = Vector3(-2.7939748e-09, 0.04744962, -1.7240383e-08)
|
||||||
@@ -171,23 +187,24 @@ bones/53/position = Vector3(1.4340932e-08, 0.025948457, 3.3946527e-08)
|
|||||||
bones/53/rotation = Quaternion(0.14377311, 5.8452275e-07, 0.011701506, 0.98954153)
|
bones/53/rotation = Quaternion(0.14377311, 5.8452275e-07, 0.011701506, 0.98954153)
|
||||||
bones/54/position = Vector3(4.750415e-09, 0.029238641, -1.2388978e-09)
|
bones/54/position = Vector3(4.750415e-09, 0.029238641, -1.2388978e-09)
|
||||||
bones/55/position = Vector3(0.09123873, -0.06657194, -0.0005540352)
|
bones/55/position = Vector3(0.09123873, -0.06657194, -0.0005540352)
|
||||||
bones/55/rotation = Quaternion(0.13601132, 0.07838244, 0.9844897, -0.07834015)
|
bones/55/rotation = Quaternion(0.136, 0.07837879, 0.98449296, -0.07832257)
|
||||||
bones/56/position = Vector3(-1.3288446e-09, 0.40599436, 1.0443015e-08)
|
bones/56/position = Vector3(-1.3288446e-09, 0.40599436, 1.0443015e-08)
|
||||||
bones/56/rotation = Quaternion(-0.13252214, -0.014519276, 0.03215593, 0.99055195)
|
bones/56/rotation = Quaternion(-0.1325433, -0.014470397, 0.03215335, 0.9905499)
|
||||||
bones/57/position = Vector3(5.707578e-09, 0.42099008, -1.5425995e-08)
|
bones/57/position = Vector3(5.707578e-09, 0.42099008, -1.5425995e-08)
|
||||||
bones/57/rotation = Quaternion(0.5344839, -0.021701135, -0.027458949, 0.8444537)
|
bones/57/rotation = Quaternion(0.5344709, -0.021695312, -0.027452054, 0.8444624)
|
||||||
bones/58/position = Vector3(-6.5650525e-09, 0.15721555, -2.6694579e-08)
|
bones/58/position = Vector3(-6.5650525e-09, 0.15721555, -2.6694579e-08)
|
||||||
bones/58/rotation = Quaternion(0.2693438, -0.032380052, -0.014592491, 0.96238893)
|
bones/58/rotation = Quaternion(0.2693438, -0.032380052, -0.014592491, 0.96238893)
|
||||||
bones/59/position = Vector3(2.4854705e-08, 0.09999996, -3.1755625e-09)
|
bones/59/position = Vector3(2.4854705e-08, 0.09999996, -3.1755625e-09)
|
||||||
bones/60/position = Vector3(-0.091250315, -0.066556, -0.0005535231)
|
bones/60/position = Vector3(-0.091250315, -0.066556, -0.0005535231)
|
||||||
bones/60/rotation = Quaternion(-0.09026457, -0.016758345, 0.9954146, -0.026857648)
|
bones/60/rotation = Quaternion(-0.09026675, -0.016730117, 0.9954149, -0.026855767)
|
||||||
bones/61/position = Vector3(1.3129254e-08, 0.40599442, 3.8557886e-09)
|
bones/61/position = Vector3(1.3129254e-08, 0.40599442, 3.8557886e-09)
|
||||||
bones/61/rotation = Quaternion(-0.07401098, 0.084030755, -0.024547135, 0.99340767)
|
bones/61/rotation = Quaternion(-0.07409451, 0.08402694, -0.024555309, 0.9934016)
|
||||||
bones/62/position = Vector3(-7.3885964e-10, 0.42099023, -5.226429e-09)
|
bones/62/position = Vector3(-7.3885964e-10, 0.42099023, -5.226429e-09)
|
||||||
bones/62/rotation = Quaternion(0.56540585, 0.011310213, -0.008501466, 0.8246915)
|
bones/62/rotation = Quaternion(0.5654398, 0.01134551, -0.008516049, 0.8246677)
|
||||||
bones/63/position = Vector3(7.93632e-09, 0.1572156, -2.6982683e-10)
|
bones/63/position = Vector3(7.93632e-09, 0.1572156, -2.6982683e-10)
|
||||||
bones/63/rotation = Quaternion(0.28907102, 0.031904068, 0.014082117, 0.9566723)
|
bones/63/rotation = Quaternion(0.2890854, 0.031904142, 0.014081784, 0.9566679)
|
||||||
bones/64/position = Vector3(7.567915e-10, 0.099999994, -3.2595668e-09)
|
bones/64/position = Vector3(7.567915e-10, 0.099999994, -3.2595668e-09)
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Player"]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="Player"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||||
shape = SubResource("SphereShape3D_mx8sn")
|
shape = SubResource("SphereShape3D_mx8sn")
|
||||||
@@ -201,6 +218,32 @@ fov = 49.0
|
|||||||
|
|
||||||
[node name="Car" parent="." instance=ExtResource("5_car")]
|
[node name="Car" parent="." instance=ExtResource("5_car")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 0, -3)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 0, -3)
|
||||||
|
|
||||||
|
[node name="DialogZone" type="Area3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.5, 0, -2.5)
|
||||||
|
script = ExtResource("6_dialog")
|
||||||
|
prompt_text = "Press E to inspect area"
|
||||||
|
dialog_text = "Dialog trigger area"
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="DialogZone"]
|
||||||
|
shape = SubResource("SphereShape3D_dialog_zone")
|
||||||
|
|
||||||
|
[node name="Visual" type="MeshInstance3D" parent="DialogZone"]
|
||||||
|
mesh = SubResource("SphereMesh_dialog_zone")
|
||||||
|
|
||||||
|
[node name="AutoDialogZone" type="Area3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4, 0, -6.5)
|
||||||
|
script = ExtResource("6_dialog")
|
||||||
|
dialog_text = "Auto dialog trigger"
|
||||||
|
auto_popup = true
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="AutoDialogZone"]
|
||||||
|
shape = SubResource("SphereShape3D_dialog_zone")
|
||||||
|
|
||||||
|
[node name="Visual" type="MeshInstance3D" parent="AutoDialogZone"]
|
||||||
|
transform = Transform3D(0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0)
|
||||||
|
mesh = SubResource("SphereMesh_dialog_zone")
|
||||||
|
|
||||||
[node name="Ground" type="StaticBody3D" parent="."]
|
[node name="Ground" type="StaticBody3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,146 @@
|
|||||||
|
extends CanvasLayer
|
||||||
|
|
||||||
|
var _interactables: Array[Node] = []
|
||||||
|
var _active_interactable: Node = null
|
||||||
|
var _dialog_visible := false
|
||||||
|
|
||||||
|
var _prompt_label: Label
|
||||||
|
var _dialog_panel: PanelContainer
|
||||||
|
var _dialog_label: RichTextLabel
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
layer = 50
|
||||||
|
process_mode = Node.PROCESS_MODE_ALWAYS
|
||||||
|
_setup_ui()
|
||||||
|
_set_dialog_visible(false)
|
||||||
|
_update_prompt_visibility()
|
||||||
|
|
||||||
|
|
||||||
|
func _process(_delta: float) -> void:
|
||||||
|
if Input.is_action_just_pressed("interact"):
|
||||||
|
if _dialog_visible:
|
||||||
|
_set_dialog_visible(false)
|
||||||
|
return
|
||||||
|
if _active_interactable != null:
|
||||||
|
_open_dialog_for(_active_interactable)
|
||||||
|
|
||||||
|
|
||||||
|
func register_interactable(interactable: Node) -> void:
|
||||||
|
if interactable == null:
|
||||||
|
return
|
||||||
|
if _interactables.has(interactable):
|
||||||
|
return
|
||||||
|
_interactables.append(interactable)
|
||||||
|
_refresh_active_interactable()
|
||||||
|
|
||||||
|
|
||||||
|
func unregister_interactable(interactable: Node) -> void:
|
||||||
|
if interactable == null:
|
||||||
|
return
|
||||||
|
_interactables.erase(interactable)
|
||||||
|
if _active_interactable == interactable and _dialog_visible:
|
||||||
|
_set_dialog_visible(false)
|
||||||
|
_refresh_active_interactable()
|
||||||
|
|
||||||
|
|
||||||
|
func _refresh_active_interactable() -> void:
|
||||||
|
while _interactables.size() > 0 and not is_instance_valid(_interactables[_interactables.size() - 1]):
|
||||||
|
_interactables.pop_back()
|
||||||
|
_active_interactable = _interactables[_interactables.size() - 1] if _interactables.size() > 0 else null
|
||||||
|
if _dialog_visible and _active_interactable != null:
|
||||||
|
_dialog_label.text = _get_dialog_text(_active_interactable)
|
||||||
|
_update_prompt_visibility()
|
||||||
|
|
||||||
|
|
||||||
|
func _open_dialog_for(interactable: Node) -> void:
|
||||||
|
if _dialog_label:
|
||||||
|
_dialog_label.text = _get_dialog_text(interactable)
|
||||||
|
_set_dialog_visible(true)
|
||||||
|
|
||||||
|
|
||||||
|
func show_text(text: String) -> void:
|
||||||
|
if _dialog_label:
|
||||||
|
_dialog_label.text = text
|
||||||
|
_set_dialog_visible(true)
|
||||||
|
|
||||||
|
|
||||||
|
func close_if_text(expected_text: String) -> void:
|
||||||
|
if not _dialog_visible:
|
||||||
|
return
|
||||||
|
if _dialog_label == null:
|
||||||
|
return
|
||||||
|
if _dialog_label.text != expected_text:
|
||||||
|
return
|
||||||
|
_set_dialog_visible(false)
|
||||||
|
|
||||||
|
|
||||||
|
func _set_dialog_visible(dialog_open: bool) -> void:
|
||||||
|
_dialog_visible = dialog_open
|
||||||
|
if _dialog_panel:
|
||||||
|
_dialog_panel.visible = _dialog_visible
|
||||||
|
_update_prompt_visibility()
|
||||||
|
|
||||||
|
|
||||||
|
func _update_prompt_visibility() -> void:
|
||||||
|
if _prompt_label == null:
|
||||||
|
return
|
||||||
|
var has_active := _active_interactable != null
|
||||||
|
_prompt_label.visible = has_active and not _dialog_visible
|
||||||
|
if _prompt_label.visible:
|
||||||
|
_prompt_label.text = _get_prompt_text(_active_interactable)
|
||||||
|
|
||||||
|
|
||||||
|
func _get_prompt_text(interactable: Node) -> String:
|
||||||
|
if interactable == null:
|
||||||
|
return ""
|
||||||
|
if interactable.has_method("get_dialog_prompt"):
|
||||||
|
return String(interactable.call("get_dialog_prompt"))
|
||||||
|
return "Press E to interact"
|
||||||
|
|
||||||
|
|
||||||
|
func _get_dialog_text(interactable: Node) -> String:
|
||||||
|
if interactable == null:
|
||||||
|
return ""
|
||||||
|
if interactable.has_method("get_dialog_text"):
|
||||||
|
return String(interactable.call("get_dialog_text"))
|
||||||
|
return "..."
|
||||||
|
|
||||||
|
|
||||||
|
func _setup_ui() -> void:
|
||||||
|
var root := Control.new()
|
||||||
|
root.name = "DialogRoot"
|
||||||
|
root.set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||||
|
root.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||||
|
add_child(root)
|
||||||
|
|
||||||
|
_prompt_label = Label.new()
|
||||||
|
_prompt_label.name = "PromptLabel"
|
||||||
|
_prompt_label.set_anchors_preset(Control.PRESET_CENTER_BOTTOM)
|
||||||
|
_prompt_label.offset_left = -140.0
|
||||||
|
_prompt_label.offset_top = -64.0
|
||||||
|
_prompt_label.offset_right = 140.0
|
||||||
|
_prompt_label.offset_bottom = -36.0
|
||||||
|
_prompt_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||||
|
_prompt_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||||
|
_prompt_label.text = "Press E to interact"
|
||||||
|
root.add_child(_prompt_label)
|
||||||
|
|
||||||
|
_dialog_panel = PanelContainer.new()
|
||||||
|
_dialog_panel.name = "DialogPanel"
|
||||||
|
_dialog_panel.visible = false
|
||||||
|
_dialog_panel.set_anchors_preset(Control.PRESET_CENTER_BOTTOM)
|
||||||
|
_dialog_panel.offset_left = -300.0
|
||||||
|
_dialog_panel.offset_top = -220.0
|
||||||
|
_dialog_panel.offset_right = 300.0
|
||||||
|
_dialog_panel.offset_bottom = -80.0
|
||||||
|
_dialog_panel.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||||
|
root.add_child(_dialog_panel)
|
||||||
|
|
||||||
|
_dialog_label = RichTextLabel.new()
|
||||||
|
_dialog_label.name = "DialogText"
|
||||||
|
_dialog_label.custom_minimum_size = Vector2(560.0, 120.0)
|
||||||
|
_dialog_label.fit_content = true
|
||||||
|
_dialog_label.scroll_active = false
|
||||||
|
_dialog_label.bbcode_enabled = true
|
||||||
|
_dialog_label.text = ""
|
||||||
|
_dialog_panel.add_child(_dialog_label)
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://be24usagr8kml
|
||||||
+131
-120
@@ -1,25 +1,25 @@
|
|||||||
extends RigidBody3D
|
extends RigidBody3D
|
||||||
# Initially I used a CharacterBody3D, however, I wanted the player to bounce off
|
# Initially I used a CharacterBody3D, however, I wanted the player to bounce off
|
||||||
# other objects in the environment and that would have required manual handling
|
# other objects in the environment and that would have required manual handling
|
||||||
# of collisions. So that's why we're using a RigidBody3D instead.
|
# of collisions. So that's why we're using a RigidBody3D instead.
|
||||||
|
|
||||||
const MOVE_SPEED := 8.0
|
const MOVE_SPEED := 8.0
|
||||||
const ACCELLERATION := 30.0
|
const SPRINT_MOVE_SPEED :=13
|
||||||
const DECELLERATION := 40.0
|
const ACCELLERATION := 30.0
|
||||||
const JUMP_SPEED := 4.0
|
const DECELLERATION := 40.0
|
||||||
const MAX_NUMBER_OF_JUMPS := 2
|
const JUMP_SPEED := 4.0
|
||||||
|
const MAX_NUMBER_OF_JUMPS := 2
|
||||||
const MIN_FOV := 10
|
const MIN_FOV := 10
|
||||||
const MAX_FOV := 180
|
const MAX_FOV := 180
|
||||||
const ZOOM_FACTOR := 1.1 # Zoom out when >1, in when < 1
|
const ZOOM_FACTOR := 1.1 # Zoom out when >1, in when < 1
|
||||||
var mouse_sensitivity := 0.005
|
var mouse_sensitivity := 0.005
|
||||||
var rotation_x := 0.0
|
var rotation_x := 0.0
|
||||||
var rotation_y := 0.0
|
var rotation_y := 0.0
|
||||||
var cameraMoveMode := false
|
var cameraMoveMode := false
|
||||||
var current_number_of_jumps := 0
|
var current_number_of_jumps := 0
|
||||||
var _pending_mouse_delta := Vector2.ZERO
|
var _pending_mouse_delta := Vector2.ZERO
|
||||||
var _last_move_forward := Vector3(0, 0, 1)
|
var _last_move_forward := Vector3(0, 0, 1)
|
||||||
var _last_move_right := Vector3(1, 0, 0)
|
var _last_move_right := Vector3(1, 0, 0)
|
||||||
var _camera_offset_local := Vector3.ZERO
|
var _camera_offset_local := Vector3.ZERO
|
||||||
var _camera_yaw := 0.0
|
var _camera_yaw := 0.0
|
||||||
var _camera_pitch := 0.0
|
var _camera_pitch := 0.0
|
||||||
@@ -37,40 +37,43 @@ var _jump_triggered := false
|
|||||||
@export var anim_idle_name := "Idle"
|
@export var anim_idle_name := "Idle"
|
||||||
@export var anim_walk_name := "Walk"
|
@export var anim_walk_name := "Walk"
|
||||||
@export var anim_jump_name := "Jump"
|
@export var anim_jump_name := "Jump"
|
||||||
|
@export var anim_run_name := "Run"
|
||||||
@export var anim_walk_speed_threshold := 0.25
|
@export var anim_walk_speed_threshold := 0.25
|
||||||
|
@export var anim_sprint_speed_threshold := 10.0
|
||||||
|
|
||||||
var jump_sound = preload("res://assets/audio/jump.ogg")
|
var jump_sound = preload("res://assets/audio/jump.ogg")
|
||||||
var audio_player = AudioStreamPlayer.new()
|
var audio_player = AudioStreamPlayer.new()
|
||||||
|
|
||||||
@export var camera_path: NodePath
|
@export var camera_path: NodePath
|
||||||
@onready var cam: Camera3D = get_node(camera_path) if camera_path != NodePath("") else null
|
@onready var cam: Camera3D = get_node(camera_path) if camera_path != NodePath("") else null
|
||||||
@export var phone_path: NodePath
|
@export var phone_path: NodePath
|
||||||
@onready var phone: CanvasLayer = get_node(phone_path) if phone_path != NodePath("") else null
|
@onready var phone: CanvasLayer = get_node(phone_path) if phone_path != NodePath("") else null
|
||||||
var phone_visible := false
|
var phone_visible := false
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
axis_lock_angular_x = true
|
add_to_group("player")
|
||||||
axis_lock_angular_z = true
|
axis_lock_angular_x = true
|
||||||
angular_damp = 6.0
|
axis_lock_angular_z = true
|
||||||
contact_monitor = true
|
angular_damp = 6.0
|
||||||
max_contacts_reported = 4
|
contact_monitor = true
|
||||||
add_child(audio_player)
|
max_contacts_reported = 4
|
||||||
audio_player.stream = jump_sound
|
add_child(audio_player)
|
||||||
audio_player.volume_db = -20
|
audio_player.stream = jump_sound
|
||||||
|
audio_player.volume_db = -20
|
||||||
if cam:
|
if cam:
|
||||||
_camera_offset_local = cam.transform.origin
|
_camera_offset_local = cam.transform.origin
|
||||||
_camera_pitch = cam.rotation.x
|
_camera_pitch = cam.rotation.x
|
||||||
_camera_yaw = global_transform.basis.get_euler().y
|
_camera_yaw = global_transform.basis.get_euler().y
|
||||||
cam.set_as_top_level(true)
|
cam.set_as_top_level(true)
|
||||||
cam.global_position = global_position + (Basis(Vector3.UP, _camera_yaw) * _camera_offset_local)
|
cam.global_position = global_position + (Basis(Vector3.UP, _camera_yaw) * _camera_offset_local)
|
||||||
cam.global_rotation = Vector3(_camera_pitch, _camera_yaw, 0.0)
|
cam.global_rotation = Vector3(_camera_pitch, _camera_yaw, 0.0)
|
||||||
var move_basis := cam.global_transform.basis if cam else global_transform.basis
|
var move_basis := cam.global_transform.basis if cam else global_transform.basis
|
||||||
var forward := move_basis.z
|
var forward := move_basis.z
|
||||||
var right := move_basis.x
|
var right := move_basis.x
|
||||||
forward.y = 0.0
|
forward.y = 0.0
|
||||||
right.y = 0.0
|
right.y = 0.0
|
||||||
if forward.length() > 0.0001:
|
if forward.length() > 0.0001:
|
||||||
_last_move_forward = forward.normalized()
|
_last_move_forward = forward.normalized()
|
||||||
if right.length() > 0.0001:
|
if right.length() > 0.0001:
|
||||||
_last_move_right = right.normalized()
|
_last_move_right = right.normalized()
|
||||||
_vehicle_collision_layer = collision_layer
|
_vehicle_collision_layer = collision_layer
|
||||||
@@ -81,56 +84,61 @@ func _integrate_forces(state):
|
|||||||
linear_velocity = Vector3.ZERO
|
linear_velocity = Vector3.ZERO
|
||||||
return
|
return
|
||||||
if cameraMoveMode and _pending_mouse_delta != Vector2.ZERO:
|
if cameraMoveMode and _pending_mouse_delta != Vector2.ZERO:
|
||||||
rotation_x -= _pending_mouse_delta.y * mouse_sensitivity
|
rotation_x -= _pending_mouse_delta.y * mouse_sensitivity
|
||||||
rotation_y -= _pending_mouse_delta.x * mouse_sensitivity
|
rotation_y -= _pending_mouse_delta.x * mouse_sensitivity
|
||||||
rotation_x = clamp(rotation_x, deg_to_rad(-90), deg_to_rad(90)) # Prevent flipping
|
rotation_x = clamp(rotation_x, deg_to_rad(-90), deg_to_rad(90)) # Prevent flipping
|
||||||
_camera_pitch = rotation_x
|
_camera_pitch = rotation_x
|
||||||
rotation.y = rotation_y
|
rotation.y = rotation_y
|
||||||
_pending_mouse_delta = Vector2.ZERO
|
_pending_mouse_delta = Vector2.ZERO
|
||||||
|
|
||||||
# Input as 2D vector
|
# Input as 2D vector
|
||||||
var input2v := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
var input2v := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
||||||
|
|
||||||
if Input.is_action_just_pressed("player_phone"):
|
if Input.is_action_just_pressed("player_phone"):
|
||||||
phone_visible = !phone_visible
|
phone_visible = !phone_visible
|
||||||
if phone:
|
if phone:
|
||||||
phone.visible = phone_visible
|
phone.visible = phone_visible
|
||||||
|
|
||||||
# Camera based movement
|
# Camera based movement
|
||||||
var forward := Vector3.FORWARD * -1.0
|
var forward := Vector3.FORWARD * -1.0
|
||||||
var right := Vector3.RIGHT
|
var right := Vector3.RIGHT
|
||||||
if cam:
|
if cam:
|
||||||
forward = cam.global_transform.basis.z
|
forward = cam.global_transform.basis.z
|
||||||
right = cam.global_transform.basis.x
|
right = cam.global_transform.basis.x
|
||||||
# Project onto ground plane so looking up/down doesn't kill movement.
|
# Project onto ground plane so looking up/down doesn't kill movement.
|
||||||
forward.y = 0.0
|
forward.y = 0.0
|
||||||
right.y = 0.0
|
right.y = 0.0
|
||||||
if forward.length() > 0.0001:
|
if forward.length() > 0.0001:
|
||||||
forward = forward.normalized()
|
forward = forward.normalized()
|
||||||
_last_move_forward = forward
|
_last_move_forward = forward
|
||||||
else:
|
else:
|
||||||
forward = _last_move_forward
|
forward = _last_move_forward
|
||||||
if right.length() > 0.0001:
|
if right.length() > 0.0001:
|
||||||
right = right.normalized()
|
right = right.normalized()
|
||||||
_last_move_right = right
|
_last_move_right = right
|
||||||
else:
|
else:
|
||||||
right = _last_move_right
|
right = _last_move_right
|
||||||
|
|
||||||
var dir := (right * input2v.x + forward * input2v.y).normalized()
|
var dir := (right * input2v.x + forward * input2v.y).normalized()
|
||||||
var target_v := dir * MOVE_SPEED
|
|
||||||
|
var target_v := dir * MOVE_SPEED
|
||||||
var ax := ACCELLERATION if dir != Vector3.ZERO else DECELLERATION
|
|
||||||
linear_velocity.x = move_toward(linear_velocity.x, target_v.x, ax * state.step)
|
# Sprinting
|
||||||
linear_velocity.z = move_toward(linear_velocity.z, target_v.z, ax * state.step)
|
if Input.is_key_pressed(KEY_SHIFT):
|
||||||
|
target_v = dir * SPRINT_MOVE_SPEED
|
||||||
# Jump Logic
|
|
||||||
var on_floor = false
|
var ax := ACCELLERATION if dir != Vector3.ZERO else DECELLERATION
|
||||||
for i in state.get_contact_count():
|
linear_velocity.x = move_toward(linear_velocity.x, target_v.x, ax * state.step)
|
||||||
var normal = state.get_contact_local_normal(i)
|
linear_velocity.z = move_toward(linear_velocity.z, target_v.z, ax * state.step)
|
||||||
if normal.y > 0.5:
|
|
||||||
on_floor = true
|
# Jump Logic
|
||||||
break
|
var on_floor = false
|
||||||
|
for i in state.get_contact_count():
|
||||||
|
var normal = state.get_contact_local_normal(i)
|
||||||
|
if normal.y > 0.5:
|
||||||
|
on_floor = true
|
||||||
|
break
|
||||||
|
|
||||||
if Input.is_action_just_pressed("ui_accept") and (on_floor or current_number_of_jumps == 1):
|
if Input.is_action_just_pressed("ui_accept") and (on_floor or current_number_of_jumps == 1):
|
||||||
current_number_of_jumps = (current_number_of_jumps + 1) % 2
|
current_number_of_jumps = (current_number_of_jumps + 1) % 2
|
||||||
linear_velocity.y = JUMP_SPEED
|
linear_velocity.y = JUMP_SPEED
|
||||||
@@ -147,31 +155,31 @@ func _integrate_forces(state):
|
|||||||
|
|
||||||
_update_animation(on_floor, state.linear_velocity)
|
_update_animation(on_floor, state.linear_velocity)
|
||||||
_jump_triggered = false
|
_jump_triggered = false
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
if _in_vehicle:
|
if _in_vehicle:
|
||||||
return
|
return
|
||||||
if event is InputEventMouseButton:
|
if event is InputEventMouseButton:
|
||||||
if event.button_index == MOUSE_BUTTON_MIDDLE:
|
if event.button_index == MOUSE_BUTTON_MIDDLE:
|
||||||
if event.pressed:
|
if event.pressed:
|
||||||
cameraMoveMode = true
|
cameraMoveMode = true
|
||||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||||
else:
|
else:
|
||||||
cameraMoveMode = false
|
cameraMoveMode = false
|
||||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||||
|
|
||||||
if event is InputEventMouseMotion and cameraMoveMode:
|
if event is InputEventMouseMotion and cameraMoveMode:
|
||||||
_pending_mouse_delta += event.relative
|
_pending_mouse_delta += event.relative
|
||||||
|
|
||||||
if event is InputEventMouseButton and event.pressed:
|
if event is InputEventMouseButton and event.pressed:
|
||||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||||
zoom_camera(1.0 / ZOOM_FACTOR) # Zoom in
|
zoom_camera(1.0 / ZOOM_FACTOR) # Zoom in
|
||||||
elif event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
elif event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||||
zoom_camera(ZOOM_FACTOR) # Zoom out
|
zoom_camera(ZOOM_FACTOR) # Zoom out
|
||||||
|
|
||||||
if event.is_action_pressed("player_light"):
|
if event.is_action_pressed("player_light"):
|
||||||
_flashlight.visible = !_flashlight.visible
|
_flashlight.visible = !_flashlight.visible
|
||||||
|
|
||||||
func zoom_camera(factor):
|
func zoom_camera(factor):
|
||||||
var new_fov = cam.fov * factor
|
var new_fov = cam.fov * factor
|
||||||
cam.fov = clamp(new_fov, MIN_FOV, MAX_FOV)
|
cam.fov = clamp(new_fov, MIN_FOV, MAX_FOV)
|
||||||
@@ -188,6 +196,10 @@ func _update_animation(on_floor: bool, velocity: Vector3) -> void:
|
|||||||
if _anim_player.current_animation != anim_jump_name:
|
if _anim_player.current_animation != anim_jump_name:
|
||||||
_anim_player.play(anim_jump_name)
|
_anim_player.play(anim_jump_name)
|
||||||
return
|
return
|
||||||
|
if on_floor and horizontal_speed > anim_sprint_speed_threshold and _anim_player.has_animation(anim_run_name):
|
||||||
|
if _anim_player.current_animation != anim_walk_name:
|
||||||
|
_anim_player.play(anim_walk_name)
|
||||||
|
return
|
||||||
if horizontal_speed > anim_walk_speed_threshold and _anim_player.has_animation(anim_walk_name):
|
if horizontal_speed > anim_walk_speed_threshold and _anim_player.has_animation(anim_walk_name):
|
||||||
if _anim_player.current_animation != anim_walk_name:
|
if _anim_player.current_animation != anim_walk_name:
|
||||||
_anim_player.play(anim_walk_name)
|
_anim_player.play(anim_walk_name)
|
||||||
@@ -233,4 +245,3 @@ func exit_vehicle(exit_point: Node3D, vehicle_camera: Camera3D) -> void:
|
|||||||
vehicle_camera.current = false
|
vehicle_camera.current = false
|
||||||
if cam:
|
if cam:
|
||||||
cam.current = true
|
cam.current = true
|
||||||
|
|
||||||
|
|||||||
@@ -8,16 +8,14 @@ namespace CharacterApi.Controllers;
|
|||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
public class CharactersController : ControllerBase
|
public class CharactersController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly CharacterStore _characters;
|
private readonly CharacterStore _characters;
|
||||||
private readonly LocationsClient _locations;
|
|
||||||
|
public CharactersController(CharacterStore characters)
|
||||||
public CharactersController(CharacterStore characters, LocationsClient locations)
|
{
|
||||||
{
|
_characters = characters;
|
||||||
_characters = characters;
|
}
|
||||||
_locations = locations;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = "USER,SUPER")]
|
[Authorize(Roles = "USER,SUPER")]
|
||||||
@@ -56,52 +54,17 @@ public class CharactersController : ControllerBase
|
|||||||
|
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[Authorize(Roles = "USER,SUPER")]
|
[Authorize(Roles = "USER,SUPER")]
|
||||||
public async Task<IActionResult> Delete(string id)
|
public async Task<IActionResult> Delete(string id)
|
||||||
{
|
{
|
||||||
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||||
if (string.IsNullOrWhiteSpace(userId))
|
if (string.IsNullOrWhiteSpace(userId))
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
|
|
||||||
var allowAnyOwner = User.IsInRole("SUPER");
|
var allowAnyOwner = User.IsInRole("SUPER");
|
||||||
var deleted = await _characters.DeleteForOwnerAsync(id, userId, allowAnyOwner);
|
var deleted = await _characters.DeleteForOwnerAsync(id, userId, allowAnyOwner);
|
||||||
if (!deleted)
|
if (!deleted)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
|
||||||
return Ok("Deleted");
|
return Ok("Deleted");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
[HttpPut("{id}/move")]
|
|
||||||
[Authorize(Roles = "USER,SUPER")]
|
|
||||||
public async Task<IActionResult> Move(string id, [FromBody] MoveCharacterRequest req, CancellationToken ct)
|
|
||||||
{
|
|
||||||
if (req?.Coord is null)
|
|
||||||
return BadRequest("Coord required");
|
|
||||||
|
|
||||||
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
|
||||||
if (string.IsNullOrWhiteSpace(userId))
|
|
||||||
return Unauthorized();
|
|
||||||
|
|
||||||
var allowAnyOwner = User.IsInRole("SUPER");
|
|
||||||
var existing = await _characters.GetForOwnerByIdAsync(id, userId, allowAnyOwner);
|
|
||||||
if (existing is null)
|
|
||||||
return NotFound();
|
|
||||||
|
|
||||||
var presence = await _locations.UpdatePresenceAsync(id, req.Coord, ct);
|
|
||||||
if (!presence.Ok)
|
|
||||||
{
|
|
||||||
var message = string.IsNullOrWhiteSpace(presence.Body)
|
|
||||||
? "Location presence update failed"
|
|
||||||
: presence.Body;
|
|
||||||
return StatusCode((int)presence.Status, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
var updated = await _characters.UpdateCoordAsync(id, userId, allowAnyOwner, req.Coord);
|
|
||||||
if (!updated)
|
|
||||||
{
|
|
||||||
await _locations.UpdatePresenceAsync(id, existing.Coord, ct);
|
|
||||||
return StatusCode(500, "Failed to update character coord");
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok("Moved");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,21 +4,12 @@ This service expects JSON request bodies for character creation and stores
|
|||||||
character documents in MongoDB.
|
character documents in MongoDB.
|
||||||
|
|
||||||
Inbound JSON documents
|
Inbound JSON documents
|
||||||
- CreateCharacterRequest (`POST /api/characters`)
|
- CreateCharacterRequest (`POST /api/characters`)
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"name": "string"
|
"name": "string"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
- MoveCharacterRequest (`PUT /api/characters/{id}/move`)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"coord": {
|
|
||||||
"x": 0,
|
|
||||||
"y": 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Stored documents (MongoDB)
|
Stored documents (MongoDB)
|
||||||
- Character
|
- Character
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
namespace CharacterApi.Models;
|
|
||||||
|
|
||||||
public class MoveCharacterRequest
|
|
||||||
{
|
|
||||||
public Coord? Coord { get; set; }
|
|
||||||
}
|
|
||||||
@@ -5,15 +5,10 @@ using Microsoft.OpenApi.Models;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
|
|
||||||
// DI
|
// DI
|
||||||
builder.Services.AddSingleton<CharacterStore>();
|
builder.Services.AddSingleton<CharacterStore>();
|
||||||
builder.Services.AddHttpClient<LocationsClient>(client =>
|
|
||||||
{
|
|
||||||
var baseUrl = builder.Configuration["LocationsApi:BaseUrl"] ?? "http://localhost:5002";
|
|
||||||
client.BaseAddress = new Uri(baseUrl);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Swagger + JWT auth in Swagger
|
// Swagger + JWT auth in Swagger
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
|||||||
@@ -7,4 +7,3 @@ See `DOCUMENTS.md` for request payloads and stored document shapes.
|
|||||||
- `POST /api/characters` Create a character.
|
- `POST /api/characters` Create a character.
|
||||||
- `GET /api/characters` List characters for the current user.
|
- `GET /api/characters` List characters for the current user.
|
||||||
- `DELETE /api/characters/{id}` Delete a character owned by the current user.
|
- `DELETE /api/characters/{id}` Delete a character owned by the current user.
|
||||||
- `PUT /api/characters/{id}/move` Move a character to a new coord.
|
|
||||||
|
|||||||
@@ -21,44 +21,14 @@ public class CharacterStore
|
|||||||
|
|
||||||
public Task CreateAsync(Character character) => _col.InsertOneAsync(character);
|
public Task CreateAsync(Character character) => _col.InsertOneAsync(character);
|
||||||
|
|
||||||
public Task<List<Character>> GetForOwnerAsync(string ownerUserId) =>
|
public Task<List<Character>> GetForOwnerAsync(string ownerUserId) =>
|
||||||
_col.Find(c => c.OwnerUserId == ownerUserId).ToListAsync();
|
_col.Find(c => c.OwnerUserId == ownerUserId).ToListAsync();
|
||||||
|
|
||||||
public async Task<Character?> GetForOwnerByIdAsync(string id, string ownerUserId, bool allowAnyOwner)
|
public async Task<bool> DeleteForOwnerAsync(string id, string ownerUserId, bool allowAnyOwner)
|
||||||
{
|
{
|
||||||
var filter = Builders<Character>.Filter.Eq(c => c.Id, id);
|
var filter = Builders<Character>.Filter.Eq(c => c.Id, id);
|
||||||
if (!allowAnyOwner)
|
if (!allowAnyOwner)
|
||||||
{
|
{
|
||||||
filter = Builders<Character>.Filter.And(
|
|
||||||
filter,
|
|
||||||
Builders<Character>.Filter.Eq(c => c.OwnerUserId, ownerUserId)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await _col.Find(filter).FirstOrDefaultAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<bool> UpdateCoordAsync(string id, string ownerUserId, bool allowAnyOwner, Coord coord)
|
|
||||||
{
|
|
||||||
var filter = Builders<Character>.Filter.Eq(c => c.Id, id);
|
|
||||||
if (!allowAnyOwner)
|
|
||||||
{
|
|
||||||
filter = Builders<Character>.Filter.And(
|
|
||||||
filter,
|
|
||||||
Builders<Character>.Filter.Eq(c => c.OwnerUserId, ownerUserId)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
var update = Builders<Character>.Update.Set(c => c.Coord, coord);
|
|
||||||
var result = await _col.UpdateOneAsync(filter, update);
|
|
||||||
return result.ModifiedCount > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<bool> DeleteForOwnerAsync(string id, string ownerUserId, bool allowAnyOwner)
|
|
||||||
{
|
|
||||||
var filter = Builders<Character>.Filter.Eq(c => c.Id, id);
|
|
||||||
if (!allowAnyOwner)
|
|
||||||
{
|
|
||||||
filter = Builders<Character>.Filter.And(
|
filter = Builders<Character>.Filter.And(
|
||||||
filter,
|
filter,
|
||||||
Builders<Character>.Filter.Eq(c => c.OwnerUserId, ownerUserId)
|
Builders<Character>.Filter.Eq(c => c.OwnerUserId, ownerUserId)
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
using CharacterApi.Models;
|
|
||||||
using System.Net;
|
|
||||||
using System.Net.Http.Json;
|
|
||||||
|
|
||||||
namespace CharacterApi.Services;
|
|
||||||
|
|
||||||
public class LocationsClient
|
|
||||||
{
|
|
||||||
private readonly HttpClient _http;
|
|
||||||
private readonly string _internalKey;
|
|
||||||
|
|
||||||
public LocationsClient(HttpClient http, IConfiguration cfg)
|
|
||||||
{
|
|
||||||
_http = http;
|
|
||||||
_internalKey = cfg["LocationsApi:InternalKey"] ?? string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<(bool Ok, HttpStatusCode Status, string? Body)> UpdatePresenceAsync(
|
|
||||||
string characterId,
|
|
||||||
Coord coord,
|
|
||||||
CancellationToken ct = default)
|
|
||||||
{
|
|
||||||
using var request = new HttpRequestMessage(HttpMethod.Post, "api/locations/presence")
|
|
||||||
{
|
|
||||||
Content = JsonContent.Create(new { characterId, coord })
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(_internalKey))
|
|
||||||
request.Headers.TryAddWithoutValidation("X-Internal-Key", _internalKey);
|
|
||||||
|
|
||||||
using var response = await _http.SendAsync(request, ct);
|
|
||||||
var body = await response.Content.ReadAsStringAsync(ct);
|
|
||||||
return (response.IsSuccessStatusCode, response.StatusCode, body);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"Kestrel": { "Endpoints": { "Http": { "Url": "http://0.0.0.0:5001" } } },
|
"Kestrel": { "Endpoints": { "Http": { "Url": "http://0.0.0.0:5001" } } },
|
||||||
"MongoDB": { "ConnectionString": "mongodb://192.168.86.50:27017", "DatabaseName": "promiscuity" },
|
"MongoDB": { "ConnectionString": "mongodb://192.168.86.50:27017", "DatabaseName": "promiscuity" },
|
||||||
"LocationsApi": { "BaseUrl": "http://localhost:5002", "InternalKey": "dev-internal-key" },
|
"Jwt": { "Key": "SuperUltraSecureJwtKeyWithAtLeast32Chars!!", "Issuer": "promiscuity", "Audience": "promiscuity-auth-api" },
|
||||||
"Jwt": { "Key": "SuperUltraSecureJwtKeyWithAtLeast32Chars!!", "Issuer": "promiscuity", "Audience": "promiscuity-auth-api" },
|
|
||||||
"Logging": { "LogLevel": { "Default": "Information" } }
|
"Logging": { "LogLevel": { "Default": "Information" } }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
{
|
{
|
||||||
"Kestrel": { "Endpoints": { "Http": { "Url": "http://0.0.0.0:5001" } } },
|
"Kestrel": { "Endpoints": { "Http": { "Url": "http://0.0.0.0:5001" } } },
|
||||||
"MongoDB": { "ConnectionString": "mongodb://192.168.86.50:27017", "DatabaseName": "promiscuity" },
|
"MongoDB": { "ConnectionString": "mongodb://192.168.86.50:27017", "DatabaseName": "promiscuity" },
|
||||||
"LocationsApi": { "BaseUrl": "http://localhost:5002", "InternalKey": "dev-internal-key" },
|
"Jwt": { "Key": "SuperUltraSecureJwtKeyWithAtLeast32Chars!!", "Issuer": "promiscuity", "Audience": "promiscuity-auth-api" },
|
||||||
"Jwt": { "Key": "SuperUltraSecureJwtKeyWithAtLeast32Chars!!", "Issuer": "promiscuity", "Audience": "promiscuity-auth-api" },
|
|
||||||
"Logging": { "LogLevel": { "Default": "Information" } },
|
"Logging": { "LogLevel": { "Default": "Information" } },
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,10 @@ namespace LocationsApi.Controllers;
|
|||||||
public class LocationsController : ControllerBase
|
public class LocationsController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly LocationStore _locations;
|
private readonly LocationStore _locations;
|
||||||
private readonly IConfiguration _cfg;
|
|
||||||
|
|
||||||
public LocationsController(LocationStore locations, IConfiguration cfg)
|
public LocationsController(LocationStore locations)
|
||||||
{
|
{
|
||||||
_locations = locations;
|
_locations = locations;
|
||||||
_cfg = cfg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
@@ -33,7 +31,6 @@ public class LocationsController : ControllerBase
|
|||||||
{
|
{
|
||||||
Name = req.Name.Trim(),
|
Name = req.Name.Trim(),
|
||||||
Coord = req.Coord,
|
Coord = req.Coord,
|
||||||
CharacterIds = new List<string>(),
|
|
||||||
CreatedUtc = DateTime.UtcNow
|
CreatedUtc = DateTime.UtcNow
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -88,28 +85,4 @@ public class LocationsController : ControllerBase
|
|||||||
|
|
||||||
return Ok("Updated");
|
return Ok("Updated");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("presence")]
|
|
||||||
[AllowAnonymous]
|
|
||||||
public async Task<IActionResult> UpdatePresence([FromBody] UpdateLocationPresenceRequest req)
|
|
||||||
{
|
|
||||||
var internalKey = _cfg["Internal:Key"];
|
|
||||||
if (!string.IsNullOrWhiteSpace(internalKey))
|
|
||||||
{
|
|
||||||
if (!Request.Headers.TryGetValue("X-Internal-Key", out var provided) || provided != internalKey)
|
|
||||||
return Unauthorized();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(req.CharacterId))
|
|
||||||
return BadRequest("CharacterId required");
|
|
||||||
|
|
||||||
if (req.Coord is null)
|
|
||||||
return BadRequest("Coord required");
|
|
||||||
|
|
||||||
var updated = await _locations.UpdatePresenceAsync(req.CharacterId.Trim(), req.Coord);
|
|
||||||
if (!updated)
|
|
||||||
return NotFound("Location not found");
|
|
||||||
|
|
||||||
return Ok("Updated");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,16 +21,6 @@ Inbound JSON documents
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
`coord` cannot be updated.
|
`coord` cannot be updated.
|
||||||
- UpdateLocationPresenceRequest (`POST /api/locations/presence`)
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"characterId": "string",
|
|
||||||
"coord": {
|
|
||||||
"x": 0,
|
|
||||||
"y": 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Stored documents (MongoDB)
|
Stored documents (MongoDB)
|
||||||
- Location
|
- Location
|
||||||
@@ -42,7 +32,6 @@ Stored documents (MongoDB)
|
|||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 0
|
"y": 0
|
||||||
},
|
},
|
||||||
"characterIds": ["string"],
|
|
||||||
"createdUtc": "string (ISO-8601 datetime)"
|
"createdUtc": "string (ISO-8601 datetime)"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -15,9 +15,6 @@ public class Location
|
|||||||
[BsonElement("coord")]
|
[BsonElement("coord")]
|
||||||
public required Coord Coord { get; set; }
|
public required Coord Coord { get; set; }
|
||||||
|
|
||||||
[BsonElement("characterIds")]
|
|
||||||
public List<string> CharacterIds { get; set; } = new();
|
|
||||||
|
|
||||||
[BsonElement("createdUtc")]
|
[BsonElement("createdUtc")]
|
||||||
public DateTime CreatedUtc { get; set; } = DateTime.UtcNow;
|
public DateTime CreatedUtc { get; set; } = DateTime.UtcNow;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
namespace LocationsApi.Models;
|
|
||||||
|
|
||||||
public class UpdateLocationPresenceRequest
|
|
||||||
{
|
|
||||||
public string CharacterId { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public Coord? Coord { get; set; }
|
|
||||||
}
|
|
||||||
@@ -8,4 +8,3 @@ See `DOCUMENTS.md` for request payloads and stored document shapes.
|
|||||||
- `GET /api/locations` List all locations (SUPER only).
|
- `GET /api/locations` List all locations (SUPER only).
|
||||||
- `DELETE /api/locations/{id}` Delete a location (SUPER only).
|
- `DELETE /api/locations/{id}` Delete a location (SUPER only).
|
||||||
- `PUT /api/locations/{id}` Update a location name (SUPER only).
|
- `PUT /api/locations/{id}` Update a location name (SUPER only).
|
||||||
- `POST /api/locations/presence` Update which characters are present at a coord (internal).
|
|
||||||
|
|||||||
@@ -34,13 +34,13 @@ public class LocationStore
|
|||||||
{
|
{
|
||||||
"$jsonSchema", new BsonDocument
|
"$jsonSchema", new BsonDocument
|
||||||
{
|
{
|
||||||
{ "bsonType", "object" },
|
{ "bsonType", "object" },
|
||||||
{ "required", new BsonArray { "name", "coord", "createdUtc" } },
|
{ "required", new BsonArray { "name", "coord", "createdUtc" } },
|
||||||
{
|
{
|
||||||
"properties", new BsonDocument
|
"properties", new BsonDocument
|
||||||
{
|
{
|
||||||
{ "name", new BsonDocument { { "bsonType", "string" } } },
|
{ "name", new BsonDocument { { "bsonType", "string" } } },
|
||||||
{
|
{
|
||||||
"coord", new BsonDocument
|
"coord", new BsonDocument
|
||||||
{
|
{
|
||||||
{ "bsonType", "object" },
|
{ "bsonType", "object" },
|
||||||
@@ -51,21 +51,14 @@ public class LocationStore
|
|||||||
{ "x", new BsonDocument { { "bsonType", "int" } } },
|
{ "x", new BsonDocument { { "bsonType", "int" } } },
|
||||||
{ "y", new BsonDocument { { "bsonType", "int" } } }
|
{ "y", new BsonDocument { { "bsonType", "int" } } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{ "createdUtc", new BsonDocument { { "bsonType", "date" } } }
|
||||||
"characterIds", new BsonDocument
|
}
|
||||||
{
|
}
|
||||||
{ "bsonType", "array" },
|
}
|
||||||
{ "items", new BsonDocument { { "bsonType", "string" } } }
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
{ "createdUtc", new BsonDocument { { "bsonType", "date" } } }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var collections = db.ListCollectionNames().ToList();
|
var collections = db.ListCollectionNames().ToList();
|
||||||
@@ -102,31 +95,13 @@ public class LocationStore
|
|||||||
return result.DeletedCount > 0;
|
return result.DeletedCount > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> UpdateNameAsync(string id, string name)
|
public async Task<bool> UpdateNameAsync(string id, string name)
|
||||||
{
|
{
|
||||||
var filter = Builders<Location>.Filter.Eq(l => l.Id, id);
|
var filter = Builders<Location>.Filter.Eq(l => l.Id, id);
|
||||||
var update = Builders<Location>.Update.Set(l => l.Name, name);
|
var update = Builders<Location>.Update.Set(l => l.Name, name);
|
||||||
var result = await _col.UpdateOneAsync(filter, update);
|
var result = await _col.UpdateOneAsync(filter, update);
|
||||||
return result.ModifiedCount > 0;
|
return result.ModifiedCount > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> UpdatePresenceAsync(string characterId, Coord coord)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(characterId))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var pullFilter = Builders<Location>.Filter.AnyEq(l => l.CharacterIds, characterId);
|
|
||||||
var pullUpdate = Builders<Location>.Update.Pull(l => l.CharacterIds, characterId);
|
|
||||||
await _col.UpdateManyAsync(pullFilter, pullUpdate);
|
|
||||||
|
|
||||||
var targetFilter = Builders<Location>.Filter.And(
|
|
||||||
Builders<Location>.Filter.Eq(l => l.Coord.X, coord.X),
|
|
||||||
Builders<Location>.Filter.Eq(l => l.Coord.Y, coord.Y)
|
|
||||||
);
|
|
||||||
var addUpdate = Builders<Location>.Update.AddToSet(l => l.CharacterIds, characterId);
|
|
||||||
var result = await _col.UpdateOneAsync(targetFilter, addUpdate);
|
|
||||||
return result.MatchedCount > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void EnsureOriginLocation()
|
private void EnsureOriginLocation()
|
||||||
{
|
{
|
||||||
@@ -138,13 +113,12 @@ public class LocationStore
|
|||||||
if (existing is not null)
|
if (existing is not null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var origin = new Location
|
var origin = new Location
|
||||||
{
|
{
|
||||||
Name = "Origin",
|
Name = "Origin",
|
||||||
Coord = new Coord { X = 0, Y = 0 },
|
Coord = new Coord { X = 0, Y = 0 },
|
||||||
CharacterIds = new List<string>(),
|
CreatedUtc = DateTime.UtcNow
|
||||||
CreatedUtc = DateTime.UtcNow
|
};
|
||||||
};
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"Kestrel": { "Endpoints": { "Http": { "Url": "http://0.0.0.0:5002" } } },
|
"Kestrel": { "Endpoints": { "Http": { "Url": "http://0.0.0.0:5002" } } },
|
||||||
"MongoDB": { "ConnectionString": "mongodb://192.168.86.50:27017", "DatabaseName": "promiscuity" },
|
"MongoDB": { "ConnectionString": "mongodb://192.168.86.50:27017", "DatabaseName": "promiscuity" },
|
||||||
"Internal": { "Key": "dev-internal-key" },
|
|
||||||
"Jwt": { "Key": "SuperUltraSecureJwtKeyWithAtLeast32Chars!!", "Issuer": "promiscuity", "Audience": "promiscuity-auth-api" },
|
"Jwt": { "Key": "SuperUltraSecureJwtKeyWithAtLeast32Chars!!", "Issuer": "promiscuity", "Audience": "promiscuity-auth-api" },
|
||||||
"Logging": { "LogLevel": { "Default": "Information" } }
|
"Logging": { "LogLevel": { "Default": "Information" } }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"Kestrel": { "Endpoints": { "Http": { "Url": "http://0.0.0.0:5002" } } },
|
"Kestrel": { "Endpoints": { "Http": { "Url": "http://0.0.0.0:5002" } } },
|
||||||
"MongoDB": { "ConnectionString": "mongodb://192.168.86.50:27017", "DatabaseName": "promiscuity" },
|
"MongoDB": { "ConnectionString": "mongodb://192.168.86.50:27017", "DatabaseName": "promiscuity" },
|
||||||
"Internal": { "Key": "dev-internal-key" },
|
|
||||||
"Jwt": { "Key": "SuperUltraSecureJwtKeyWithAtLeast32Chars!!", "Issuer": "promiscuity", "Audience": "promiscuity-auth-api" },
|
"Jwt": { "Key": "SuperUltraSecureJwtKeyWithAtLeast32Chars!!", "Issuer": "promiscuity", "Audience": "promiscuity-auth-api" },
|
||||||
"Logging": { "LogLevel": { "Default": "Information" } },
|
"Logging": { "LogLevel": { "Default": "Information" } },
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*"
|
||||||
|
|||||||
Reference in New Issue
Block a user