17 Commits
Author SHA1 Message Date
admin a66c39e9f8 Adding simple dialog system 2026-02-13 11:41:39 -06:00
pillboxstyx 2d27e4254e Merge pull request 'Starting to add a sprint, will figure out how to hook in the run animation next' (#7) from pillboxstyx/addingSprint into main
Deploy Promiscuity Auth API / deploy (push) Successful in 46s
Deploy Promiscuity Character API / deploy (push) Successful in 44s
Deploy Promiscuity Locations API / deploy (push) Successful in 45s
k8s smoke test / test (push) Successful in 7s
Reviewed-on: #7
2026-02-13 02:50:06 -06:00
pillboxstyx b3287ccf6f Starting to add a sprint, will figure out how to hook in the run animation next 2026-02-13 02:48:07 -06:00
admin d1fade919c Adding beginning of world block generation
Deploy Promiscuity Auth API / deploy (push) Successful in 46s
Deploy Promiscuity Character API / deploy (push) Successful in 57s
Deploy Promiscuity Locations API / deploy (push) Successful in 58s
k8s smoke test / test (push) Successful in 7s
2026-01-27 21:01:29 -06:00
admin b2eb85fdf1 Hooking up animations, and tweaking car behavior 2026-01-27 20:53:53 -06:00
admin d8138fbe69 sync assets and microservice updates 2026-01-27 20:41:28 -06:00
admin e54dd191f1 Merge branch 'car' 2026-01-27 20:37:17 -06:00
admin db632e2522 Merge pull request 'character-coords' (#5) from character-coords into main
Deploy Promiscuity Auth API / deploy (push) Successful in 45s
Deploy Promiscuity Character API / deploy (push) Successful in 1m25s
Deploy Promiscuity Locations API / deploy (push) Successful in 1m0s
k8s smoke test / test (push) Successful in 7s
Reviewed-on: #5
2026-01-27 20:23:25 -06:00
deifiedexile 52e1dfe99f Add player test character with baked animations
Deploy Promiscuity Auth API / deploy (push) Successful in 58s
Deploy Promiscuity Character API / deploy (push) Successful in 47s
Deploy Promiscuity Locations API / deploy (push) Successful in 44s
k8s smoke test / test (push) Successful in 8s
2026-01-27 17:43:05 -06:00
Zeeshaun 3a99c2154c Location Service now ensures that the 0,0 location exists 2026-01-23 14:24:08 -06:00
Zeeshaun 241312b0be Adding character coords 2026-01-23 14:24:08 -06:00
admin aef117bcf9 enhancing car behavior 2026-01-21 18:16:04 -06:00
admin 582b2c43cb Adding basic car 2026-01-21 17:59:14 -06:00
admin 900951b1a7 Location fixes
Deploy Promiscuity Auth API / deploy (push) Successful in 43s
Deploy Promiscuity Character API / deploy (push) Successful in 42s
Deploy Promiscuity Locations API / deploy (push) Successful in 56s
k8s smoke test / test (push) Successful in 6s
2026-01-21 17:43:39 -06:00
admin fc647890a6 Adding coordinate to Location model
Deploy Promiscuity Auth API / deploy (push) Successful in 43s
Deploy Promiscuity Character API / deploy (push) Successful in 42s
Deploy Promiscuity Locations API / deploy (push) Successful in 56s
k8s smoke test / test (push) Successful in 5s
2026-01-20 17:29:34 -06:00
admin 86fa27c78d Adding coordinate to Location model
Deploy Promiscuity Auth API / deploy (push) Successful in 44s
Deploy Promiscuity Character API / deploy (push) Successful in 42s
Deploy Promiscuity Locations API / deploy (push) Failing after 12s
k8s smoke test / test (push) Successful in 5s
2026-01-20 17:25:41 -06:00
admin 268eca39c0 Adding coordinate to Location model 2026-01-20 17:25:35 -06:00
45 changed files with 1765 additions and 773 deletions
+7
View File
@@ -12,3 +12,10 @@
- `test1/test1` - Super User - `test1/test1` - Super User
- `test3/test3` - User - `test3/test3` - User
## Controls
- Move: WASD
- Jump: Space
- Interact (enter/exit car): E
- Flashlight: F
- Phone: Tab
- Pause menu: Esc
Binary file not shown.
@@ -0,0 +1,42 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://bnqaqbgynoyys"
path="res://.godot/imported/TestCharAnimated.glb-ecf7bb997b01494120b0dfccb4e1f064.scn"
[deps]
source_file="res://assets/models/TestCharAnimated.glb"
dest_files=["res://.godot/imported/TestCharAnimated.glb-ecf7bb997b01494120b0dfccb4e1f064.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/root_script=null
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_name_suffixes=true
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
materials/extract=0
materials/extract_format=0
materials/extract_path=""
_subresources={}
gltf/naming_version=2
gltf/embedded_image_handling=1
Binary file not shown.
+42
View File
@@ -0,0 +1,42 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://cpuebxqhtv72i"
path="res://.godot/imported/humanFemale.glb-45dfb97e0f5fa98244d8cb6255565c65.scn"
[deps]
source_file="res://assets/models/humanFemale.glb"
dest_files=["res://.godot/imported/humanFemale.glb-45dfb97e0f5fa98244d8cb6255565c65.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/root_script=null
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_name_suffixes=true
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
materials/extract=0
materials/extract_format=0
materials/extract_path=""
_subresources={}
gltf/naming_version=2
gltf/embedded_image_handling=1
+7
View File
@@ -25,6 +25,8 @@ MenuMusic="*res://scenes/UI/menu_music.tscn"
MenuSfx="*res://scenes/UI/menu_sfx.tscn" 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"
DialogSystem="*res://scenes/UI/dialog_system.gd"
[dotnet] [dotnet]
@@ -74,3 +76,8 @@ player_phone={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194306,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194306,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
] ]
} }
interact={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null)
]
}
+13 -4
View File
@@ -5,6 +5,7 @@ extends Node3D
@export var camera_path: NodePath @export var camera_path: NodePath
@export var look_origin_path: NodePath = NodePath("Body/HeadPivot") @export var look_origin_path: NodePath = NodePath("Body/HeadPivot")
@export var look_reference_path: NodePath = NodePath("Body") @export var look_reference_path: NodePath = NodePath("Body")
@export var look_target_path: NodePath = NodePath("")
@export var lock_vertical: bool = true @export var lock_vertical: bool = true
@export var vertical_unlock_height: float = 0.6 @export var vertical_unlock_height: float = 0.6
@export var vertical_lock_smooth_speed: float = 6.0 @export var vertical_lock_smooth_speed: float = 6.0
@@ -29,6 +30,7 @@ var _head_base_rot: Vector3
var _vertical_lock_factor: float = 1.0 var _vertical_lock_factor: float = 1.0
var _vertical_hold_timer: float = 0.0 var _vertical_hold_timer: float = 0.0
var _look_reference: Node3D var _look_reference: Node3D
var _look_target: Node3D
func _ready() -> void: func _ready() -> void:
@@ -41,6 +43,7 @@ func _ready() -> void:
_camera = _resolve_camera() _camera = _resolve_camera()
_look_origin = get_node_or_null(look_origin_path) as Node3D _look_origin = get_node_or_null(look_origin_path) as Node3D
_look_reference = get_node_or_null(look_reference_path) as Node3D _look_reference = get_node_or_null(look_reference_path) as Node3D
_look_target = get_node_or_null(look_target_path) as Node3D
_head = get_node_or_null(head_path) as Node3D _head = get_node_or_null(head_path) as Node3D
if _head: if _head:
_head_base_rot = _head.rotation _head_base_rot = _head.rotation
@@ -55,14 +58,20 @@ func _process(_delta: float) -> void:
func _update_pupils() -> void: func _update_pupils() -> void:
if _camera == null or not _camera.is_inside_tree(): if _look_target == null and look_target_path != NodePath(""):
_camera = _resolve_camera() _look_target = get_node_or_null(look_target_path) as Node3D
if _camera == null: if _look_target == null:
var viewport_cam := get_viewport().get_camera_3d()
if viewport_cam != null and viewport_cam != _camera:
_camera = viewport_cam
elif _camera == null or not _camera.is_inside_tree():
_camera = _resolve_camera()
if _look_target == null and _camera == null:
return return
var origin := _look_origin var origin := _look_origin
if origin == null: if origin == null:
origin = self origin = self
var target := _camera.global_position var target := _look_target.global_position if _look_target != null else _camera.global_position
var dir_world := target - origin.global_position var dir_world := target - origin.global_position
if dir_world.length_squared() <= 0.0001: if dir_world.length_squared() <= 0.0001:
return return
+21 -1
View File
@@ -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)
@@ -54,10 +55,18 @@ material = SubResource("StandardMaterial3D_accent")
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")
[node name="Body" type="StaticBody3D" parent="."] [node name="Body" type="RigidBody3D" parent="."]
mass = 1.5
axis_lock_angular_x = true
axis_lock_angular_z = true
angular_damp = 8.0
linear_damp = 0.5
[node name="CollisionShape3D" type="CollisionShape3D" parent="Body"] [node name="CollisionShape3D" type="CollisionShape3D" parent="Body"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.55, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.55, 0)
@@ -109,3 +118,14 @@ 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
+12
View File
@@ -2,12 +2,24 @@ 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
@export var show_spawn_dialog := true
@export_multiline var spawn_dialog_text := "Welcome to Promiscuity.\n\nPress E to close this message."
@export var spawn_dialog_auto_close_seconds := 4.0
var end_light_angle = start_light_angle + 360.0 var end_light_angle = start_light_angle + 360.0
var start_radians = start_light_angle * PI / 180 var start_radians = start_light_angle * PI / 180
var time := 0.0 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
+203 -29
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=17 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,6 +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" 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
@@ -19,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)
@@ -42,6 +59,7 @@ script = ExtResource("1_a4mo8")
[node name="RepoBot" parent="." instance=ExtResource("4_repo")] [node name="RepoBot" parent="." instance=ExtResource("4_repo")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.9426608, 0, -4.4451966) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.9426608, 0, -4.4451966)
look_target_path = NodePath("../Player")
[node name="Thing" type="RigidBody3D" parent="."] [node name="Thing" type="RigidBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -3.7986288) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -3.7986288)
@@ -59,20 +77,173 @@ 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")
phone_path = NodePath("../PhoneUI") phone_path = NodePath("../PhoneUI")
[node name="TestCharAnimated" parent="Player" instance=ExtResource("5_fi66n")]
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"]
bones/0/position = Vector3(0.002616825, -0.0012634661, -0.98995954)
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/rotation = Quaternion(-0.03163086, 0.011397719, 0.022761386, 0.9991754)
bones/2/position = Vector3(-2.2989244e-10, 0.117319785, 2.9730852e-08)
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/rotation = Quaternion(0.06755522, 0.0021543663, 0.013774819, 0.99761814)
bones/4/position = Vector3(2.508626e-07, 0.15027755, 0.008779066)
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/rotation = Quaternion(-0.06595736, 0.011938445, -0.0014933152, 0.9977499)
bones/6/position = Vector3(1.5477327e-06, 0.18474667, 0.06636399)
bones/7/position = Vector3(0.061058242, 0.09106279, 0.0075706206)
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/rotation = Quaternion(0.543452, 0.18399428, 0.20302251, 0.79346573)
bones/9/position = Vector3(1.5054144e-07, 0.2740467, 2.2048344e-08)
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/rotation = Quaternion(0.04830448, -0.2848921, 0.026799988, 0.9569665)
bones/11/position = Vector3(-0.030029751, 0.037888147, 0.021671427)
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/rotation = Quaternion(-0.14269812, 0.08661232, -0.24053419, 0.9561793)
bones/13/position = Vector3(-9.313215e-09, 0.043821093, 1.7813335e-08)
bones/13/rotation = Quaternion(-0.121022485, -0.07554186, 0.024044419, 0.98947906)
bones/14/position = Vector3(-4.847594e-08, 0.034590863, -5.3379924e-08)
bones/15/position = Vector3(-0.02822038, 0.12266627, 0.0023182186)
bones/15/rotation = Quaternion(0.06621808, 0.00073213095, 0.008435749, 0.99776924)
bones/16/position = Vector3(-8.136956e-09, 0.03891963, -1.4837047e-08)
bones/16/rotation = Quaternion(0.1509963, 7.805282e-07, -0.015479834, 0.98841316)
bones/17/position = Vector3(7.499967e-09, 0.034151517, -5.4443618e-08)
bones/17/rotation = Quaternion(0.070082076, 7.71772e-07, -0.007181638, 0.99751544)
bones/18/position = Vector3(2.700483e-09, 0.030779874, 4.9589467e-08)
bones/19/position = Vector3(-1.2452401e-07, 0.12775533, -8.01722e-08)
bones/19/rotation = Quaternion(0.13653132, -0.0038339633, -0.022952663, 0.9903624)
bones/20/position = Vector3(2.5990463e-09, 0.036139663, 1.713758e-10)
bones/20/rotation = Quaternion(0.15125485, 1.1823237e-06, -0.015500045, 0.9883733)
bones/21/position = Vector3(2.9034163e-07, 0.034597658, -3.6051716e-08)
bones/21/rotation = Quaternion(0.1599333, 1.4124467e-06, -0.016389191, 0.98699176)
bones/22/position = Vector3(-3.0519334e-07, 0.03680197, -9.1170705e-08)
bones/23/position = Vector3(0.022166358, 0.12147022, -9.993157e-05)
bones/23/rotation = Quaternion(0.18325116, -0.004651328, -0.031451236, 0.9825519)
bones/24/position = Vector3(4.5585904e-09, 0.036011815, -8.07135e-09)
bones/24/rotation = Quaternion(0.18138836, 1.5675009e-06, -0.018595627, 0.9832358)
bones/25/position = Vector3(-9.647604e-09, 0.033073086, -1.46341534e-08)
bones/25/rotation = Quaternion(0.1552087, 2.2643005e-06, -0.015905593, 0.9877537)
bones/26/position = Vector3(-2.434721e-07, 0.03660111, 2.471306e-07)
bones/27/position = Vector3(0.04725836, 0.109081924, 0.0022613404)
bones/27/rotation = Quaternion(0.23387046, -0.0035344863, -0.048872076, 0.97103226)
bones/28/position = Vector3(4.3135207e-09, 0.041366525, 3.569472e-08)
bones/28/rotation = Quaternion(0.15124865, 1.4340599e-05, -0.015863812, 0.98836845)
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/30/position = Vector3(-2.4944999e-08, 0.029238665, 6.2325825e-08)
bones/31/position = Vector3(-0.06105696, 0.09106397, 0.007570758)
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/rotation = Quaternion(0.46436408, -0.26298717, -0.23268588, 0.8130566)
bones/33/position = Vector3(-2.350565e-08, 0.27404687, 1.5161348e-08)
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/rotation = Quaternion(0.059025347, 0.17513894, -0.005969527, 0.9827547)
bones/35/position = Vector3(0.030029776, 0.03788806, 0.021671649)
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/rotation = Quaternion(-0.14410053, -0.076146945, 0.2772088, 0.9468854)
bones/37/position = Vector3(5.58785e-09, 0.04382136, 3.566345e-08)
bones/37/rotation = Quaternion(-0.1552004, 0.07467698, -0.026057797, 0.9847117)
bones/38/position = Vector3(8.2187e-08, 0.034590647, -2.4929412e-07)
bones/39/position = Vector3(0.028220426, 0.1226661, 0.0023184721)
bones/39/rotation = Quaternion(0.059513006, -0.0009918809, -0.010980465, 0.99816674)
bones/40/position = Vector3(-1.1795999e-08, 0.038919587, -4.9162594e-09)
bones/40/rotation = Quaternion(0.15128906, 2.1640317e-06, 0.012328284, 0.98841274)
bones/41/position = Vector3(-1.4053852e-07, 0.034151636, -1.1118345e-08)
bones/41/rotation = Quaternion(0.07021882, 5.966413e-07, 0.0057199914, 0.9975152)
bones/42/position = Vector3(-7.1266735e-09, 0.030779934, 3.7720538e-10)
bones/43/position = Vector3(1.69263e-07, 0.12775521, 2.5128352e-07)
bones/43/rotation = Quaternion(0.13051407, 0.003691554, 0.018921439, 0.99125904)
bones/44/position = Vector3(4.8907918e-09, 0.036139727, -8.499214e-09)
bones/44/rotation = Quaternion(0.15154669, 1.6962191e-06, 0.012345144, 0.988373)
bones/45/position = Vector3(-2.8403383e-07, 0.03459763, -4.4995545e-09)
bones/45/rotation = Quaternion(0.16023898, 1.233635e-06, 0.013053549, 0.98699194)
bones/46/position = Vector3(2.8485744e-07, 0.03680191, -9.493007e-09)
bones/47/position = Vector3(-0.022166327, 0.12146996, -9.982591e-05)
bones/47/rotation = Quaternion(0.1774532, 0.0045050457, 0.02645378, 0.98376334)
bones/48/position = Vector3(4.6136024e-09, 0.036011953, 3.056637e-08)
bones/48/rotation = Quaternion(0.18173504, 1.8501213e-06, 0.014812392, 0.98323596)
bones/49/position = Vector3(-3.407626e-08, 0.033073153, 1.8664657e-08)
bones/49/rotation = Quaternion(0.15551038, 3.26233e-07, 0.012668259, 0.98775303)
bones/50/position = Vector3(2.3113911e-07, 0.03660121, -1.1142021e-08)
bones/51/position = Vector3(-0.047258336, 0.109081805, 0.0022614468)
bones/51/rotation = Quaternion(0.22849467, 0.003407588, 0.042977322, 0.97259015)
bones/52/position = Vector3(-1.5261804e-08, 0.041366428, -1.9607107e-09)
bones/52/rotation = Quaternion(0.1515478, 7.4422354e-07, 0.01235583, 0.98837274)
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/54/position = Vector3(4.750415e-09, 0.029238641, -1.2388978e-09)
bones/55/position = Vector3(0.09123873, -0.06657194, -0.0005540352)
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/rotation = Quaternion(-0.1325433, -0.014470397, 0.03215335, 0.9905499)
bones/57/position = Vector3(5.707578e-09, 0.42099008, -1.5425995e-08)
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/rotation = Quaternion(0.2693438, -0.032380052, -0.014592491, 0.96238893)
bones/59/position = Vector3(2.4854705e-08, 0.09999996, -3.1755625e-09)
bones/60/position = Vector3(-0.091250315, -0.066556, -0.0005535231)
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/rotation = Quaternion(-0.07409451, 0.08402694, -0.024555309, 0.9934016)
bones/62/position = Vector3(-7.3885964e-10, 0.42099023, -5.226429e-09)
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/rotation = Quaternion(0.2890854, 0.031904142, 0.014081784, 0.9566679)
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)
shape = SubResource("SphereShape3D_mx8sn") shape = SubResource("SphereShape3D_mx8sn")
[node name="Camera3D" type="Camera3D" parent="Player"] [node name="Camera3D" type="Camera3D" parent="Player"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.31670225, 0) transform = Transform3D(0.9989785, -4.651856e-10, -0.045188628, 0.006969331, 0.9880354, 0.15407, 0.044647958, -0.15422754, 0.9870261, 0.22036135, 1.8988357, 0.64972365)
current = true current = true
fov = 49.0
[node name="SpotLight3D" type="SpotLight3D" parent="Player"] [node name="SpotLight3D" type="SpotLight3D" parent="Player"]
[node name="Car" parent="." instance=ExtResource("5_car")]
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)
@@ -80,6 +251,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0)
shape = SubResource("BoxShape3D_2q6dc") shape = SubResource("BoxShape3D_2q6dc")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Ground"] [node name="MeshInstance3D" type="MeshInstance3D" parent="Ground"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00053596497, 0.0075991154, -0.0019865036)
mesh = SubResource("BoxMesh_w7c3h") mesh = SubResource("BoxMesh_w7c3h")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] [node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
@@ -99,33 +271,6 @@ process_mode = 3
visible = false visible = false
script = ExtResource("3_tc7dm") script = ExtResource("3_tc7dm")
[node name="PhoneUI" type="CanvasLayer" parent="."]
layer = 5
visible = false
[node name="Control" type="Control" parent="PhoneUI"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="PhoneFrame" type="ColorRect" parent="PhoneUI/Control"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -180.0
offset_top = -320.0
offset_right = 180.0
offset_bottom = 320.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.08, 0.08, 0.1, 1)
[node name="Control" type="Control" parent="Menu"] [node name="Control" type="Control" parent="Menu"]
layout_mode = 3 layout_mode = 3
anchors_preset = 15 anchors_preset = 15
@@ -162,9 +307,38 @@ text = "Main Menu"
layout_mode = 2 layout_mode = 2
text = "Quit" text = "Quit"
[node name="PhoneUI" type="CanvasLayer" parent="."]
layer = 5
visible = false
[node name="Control" type="Control" parent="PhoneUI"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="PhoneFrame" type="ColorRect" parent="PhoneUI/Control"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -180.0
offset_top = -320.0
offset_right = 180.0
offset_bottom = 320.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.08, 0.08, 0.1, 1)
[node name="WorldEnvironment" type="WorldEnvironment" parent="."] [node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_a4mo8") environment = SubResource("Environment_a4mo8")
[connection signal="pressed" from="Menu/Control/VBoxContainer/ContinueButton" to="Menu" method="_on_continue_button_pressed"] [connection signal="pressed" from="Menu/Control/VBoxContainer/ContinueButton" to="Menu" method="_on_continue_button_pressed"]
[connection signal="pressed" from="Menu/Control/VBoxContainer/MainMenuButton" to="Menu" method="_on_main_menu_button_pressed"] [connection signal="pressed" from="Menu/Control/VBoxContainer/MainMenuButton" to="Menu" method="_on_main_menu_button_pressed"]
[connection signal="pressed" from="Menu/Control/VBoxContainer/QuitButton" to="Menu" method="_on_quit_button_pressed"] [connection signal="pressed" from="Menu/Control/VBoxContainer/QuitButton" to="Menu" method="_on_quit_button_pressed"]
[editable path="Player/TestCharAnimated"]
+15
View File
@@ -0,0 +1,15 @@
extends Node3D
@export var tile_size := 4.0
@export var block_height := 1.0
@onready var _block: MeshInstance3D = $TerrainBlock
@onready var _camera: Camera3D = $Camera3D
func _ready() -> void:
var coord := SelectedCharacter.get_coord()
var block_pos := Vector3(coord.x * tile_size, block_height * 0.5, coord.y * tile_size)
_block.position = block_pos
_block.scale = Vector3(tile_size, block_height, tile_size)
if _camera:
_camera.look_at(block_pos, Vector3.UP)
+1
View File
@@ -0,0 +1 @@
uid://1fico5npv6dy
+23
View File
@@ -0,0 +1,23 @@
[gd_scene load_steps=4 format=3 uid="uid://b7p7k1i4t0m2l"]
[ext_resource type="Script" path="res://scenes/Levels/location_level.gd" id="1_6y4q1"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_yu2x4"]
albedo_color = Color(0.2, 0.6, 0.2, 1)
[sub_resource type="BoxMesh" id="BoxMesh_t2a5k"]
material = SubResource("StandardMaterial3D_yu2x4")
[node name="LocationLevel" type="Node3D"]
script = ExtResource("1_6y4q1")
[node name="TerrainBlock" type="MeshInstance3D" parent="."]
mesh = SubResource("BoxMesh_t2a5k")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.819152, 0.573576, 0, -0.573576, 0.819152, 0, 6, 0)
shadow_enabled = true
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.92388, 0.382683, 0, -0.382683, 0.92388, 0, 6, 10)
current = true
+3
View File
@@ -17,10 +17,12 @@ func _input(event):
func pause_game(): func pause_game():
get_tree().paused = true get_tree().paused = true
visible = true visible = true
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
func resume_game(): func resume_game():
get_tree().paused = false get_tree().paused = false
visible = false visible = false
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _on_quit_button_pressed(): func _on_quit_button_pressed():
get_tree().quit() get_tree().quit()
@@ -30,6 +32,7 @@ func _on_continue_button_pressed():
func _on_main_menu_button_pressed(): func _on_main_menu_button_pressed():
resume_game() resume_game()
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
get_tree().change_scene_to_file(START_SCREEN_SCENE) get_tree().change_scene_to_file(START_SCREEN_SCENE)
func _register_focus_sounds() -> void: func _register_focus_sounds() -> void:
+15
View File
@@ -97,6 +97,21 @@ func _on_delete_button_pressed() -> void:
_character_list.remove_item(index) _character_list.remove_item(index)
_status_label.text = "Character deleted." _status_label.text = "Character deleted."
func _on_select_button_pressed() -> void:
var selected := _character_list.get_selected_items()
if selected.is_empty():
_status_label.text = "Select a character first."
return
var index := selected[0]
if index < 0 or index >= _characters.size():
_status_label.text = "Invalid selection."
return
var character: Dictionary = _characters[index]
SelectedCharacter.set_character(character)
get_tree().change_scene_to_file("res://scenes/Levels/location_level.tscn")
func _on_refresh_button_pressed() -> void: func _on_refresh_button_pressed() -> void:
_load_characters() _load_characters()
+8
View File
@@ -92,6 +92,13 @@ layout_mode = 2
size_flags_horizontal = 4 size_flags_horizontal = 4
theme_override_constants/separation = 10 theme_override_constants/separation = 10
[node name="SelectButton" type="Button" parent="MarginContainer/ContentCenter/ContentVBox/ActionHBox"]
layout_mode = 2
size_flags_horizontal = 4
theme = ExtResource("4_5b3b7")
text = "SELECT"
text_alignment = 1
[node name="RefreshButton" type="Button" parent="MarginContainer/ContentCenter/ContentVBox/ActionHBox"] [node name="RefreshButton" type="Button" parent="MarginContainer/ContentCenter/ContentVBox/ActionHBox"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 4 size_flags_horizontal = 4
@@ -124,6 +131,7 @@ text_alignment = 1
unique_name_in_owner = true unique_name_in_owner = true
[connection signal="pressed" from="MarginContainer/ContentCenter/ContentVBox/AddHBox/AddButton" to="." method="_on_add_button_pressed"] [connection signal="pressed" from="MarginContainer/ContentCenter/ContentVBox/AddHBox/AddButton" to="." method="_on_add_button_pressed"]
[connection signal="pressed" from="MarginContainer/ContentCenter/ContentVBox/ActionHBox/SelectButton" to="." method="_on_select_button_pressed"]
[connection signal="pressed" from="MarginContainer/ContentCenter/ContentVBox/ActionHBox/RefreshButton" to="." method="_on_refresh_button_pressed"] [connection signal="pressed" from="MarginContainer/ContentCenter/ContentVBox/ActionHBox/RefreshButton" to="." method="_on_refresh_button_pressed"]
[connection signal="pressed" from="MarginContainer/ContentCenter/ContentVBox/ActionHBox/DeleteButton" to="." method="_on_delete_button_pressed"] [connection signal="pressed" from="MarginContainer/ContentCenter/ContentVBox/ActionHBox/DeleteButton" to="." method="_on_delete_button_pressed"]
[connection signal="pressed" from="MarginContainer/ContentCenter/ContentVBox/ActionHBox/BackButton" to="." method="_on_back_button_pressed"] [connection signal="pressed" from="MarginContainer/ContentCenter/ContentVBox/ActionHBox/BackButton" to="." method="_on_back_button_pressed"]
+146
View File
@@ -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)
+1
View File
@@ -0,0 +1 @@
uid://be24usagr8kml
+16
View File
@@ -0,0 +1,16 @@
extends Node
var character: Dictionary = {}
func set_character(data: Dictionary) -> void:
character = data
func clear() -> void:
character = {}
func get_coord() -> Vector2:
var coord: Dictionary = character.get("coord", {})
return Vector2(
float(coord.get("x", 0)),
float(coord.get("y", 0))
)
+1
View File
@@ -0,0 +1 @@
uid://bbl0our5y4k7a
+105
View File
@@ -0,0 +1,105 @@
extends RigidBody3D
@export var drive_speed := 18.0
@export var drive_accel := 20.0
@export var brake_strength := 28.0
@export var turn_speed := 2.0
@export var turn_accel := 8.0
@export var lateral_damp := 10.0
@export var launch_impulse := 28.0
@export var launch_up_impulse := 6.0
@export var seat_path: NodePath
@export var exit_path: NodePath
@export var camera_path: NodePath
@export var interact_area_path: NodePath
@onready var seat: Node3D = get_node(seat_path) if seat_path != NodePath("") else null
@onready var exit_point: Node3D = get_node(exit_path) if exit_path != NodePath("") else null
@onready var car_camera: Camera3D = get_node(camera_path) if camera_path != NodePath("") else null
@onready var interact_area: Area3D = get_node(interact_area_path) if interact_area_path != NodePath("") else null
var _nearby_driver: Node = null
var _driver: Node = null
func _ready() -> void:
if interact_area:
interact_area.collision_layer = 2
interact_area.collision_mask = 1
interact_area.body_entered.connect(_on_interact_body_entered)
interact_area.body_exited.connect(_on_interact_body_exited)
if car_camera:
car_camera.current = false
contact_monitor = true
max_contacts_reported = 8
func _process(_delta: float) -> void:
if _driver == null and _nearby_driver != null and Input.is_action_just_pressed("interact"):
_enter_vehicle(_nearby_driver)
elif _driver != null and Input.is_action_just_pressed("interact"):
_exit_vehicle()
func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
if _driver == null:
return
var input2v := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
var forward := global_transform.basis.z
forward.y = 0.0
forward = forward.normalized()
var current_speed := linear_velocity.dot(forward)
var target_speed := input2v.y * drive_speed
var accel := drive_accel if abs(input2v.y) > 0.01 else brake_strength
var new_forward_speed := move_toward(current_speed, target_speed, accel * state.step)
var forward_vel := forward * new_forward_speed
var lateral_vel := linear_velocity - (forward * current_speed)
lateral_vel = lateral_vel.move_toward(Vector3.ZERO, lateral_damp * state.step)
linear_velocity = forward_vel + lateral_vel
var speed_factor: float = clamp(abs(new_forward_speed) / drive_speed, 0.0, 1.0)
var turn_input := input2v.x
if new_forward_speed < -0.1:
turn_input = -turn_input
var target_turn: float = turn_input * turn_speed * speed_factor
angular_velocity.y = move_toward(angular_velocity.y, target_turn, turn_accel * state.step)
if speed_factor > 0.2:
var hit_ids := {}
for i in state.get_contact_count():
var collider := state.get_contact_collider_object(i)
if collider is RigidBody3D and collider != self:
var collider_id := (collider as Node).get_instance_id()
if hit_ids.has(collider_id):
continue
hit_ids[collider_id] = true
var contact_pos := state.get_contact_collider_position(i)
var launch_dir := (contact_pos - global_position).normalized()
if launch_dir.length() <= 0.001:
var normal_world := (global_transform.basis * state.get_contact_local_normal(i)).normalized()
launch_dir = normal_world if normal_world.length() > 0.001 else forward.normalized()
var impulse := launch_dir * (launch_impulse * speed_factor) + Vector3.UP * launch_up_impulse
(collider as RigidBody3D).apply_central_impulse(impulse)
func _enter_vehicle(player: Node) -> void:
if seat == null:
return
_driver = player
player.call("enter_vehicle", self, seat, car_camera)
if car_camera:
car_camera.current = true
func _exit_vehicle() -> void:
if _driver == null:
return
_driver.call("exit_vehicle", exit_point, car_camera)
_driver = null
if car_camera:
car_camera.current = false
func _on_interact_body_entered(body: Node) -> void:
if body.has_method("enter_vehicle"):
_nearby_driver = body
func _on_interact_body_exited(body: Node) -> void:
if body == _nearby_driver:
_nearby_driver = null
+1
View File
@@ -0,0 +1 @@
uid://4qf5yinepytc
+43
View File
@@ -0,0 +1,43 @@
[gd_scene load_steps=6 format=3]
[ext_resource type="Script" path="res://scenes/Vehicles/car.gd" id="1_kbd20"]
[sub_resource type="BoxShape3D" id="BoxShape3D_7r1j6"]
size = Vector3(1.4, 0.9, 2.6)
[sub_resource type="BoxShape3D" id="BoxShape3D_jk0m1"]
size = Vector3(2.2, 2.0, 3.8)
[sub_resource type="BoxMesh" id="BoxMesh_4y8xk"]
size = Vector3(1.4, 0.9, 2.6)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_red"]
albedo_color = Color(0.85, 0.1, 0.1, 1)
[node name="Car" type="RigidBody3D"]
script = ExtResource("1_kbd20")
seat_path = NodePath("Seat")
exit_path = NodePath("Exit")
camera_path = NodePath("CarCamera")
interact_area_path = NodePath("InteractArea")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("BoxShape3D_7r1j6")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("BoxMesh_4y8xk")
surface_material_override/0 = SubResource("StandardMaterial3D_red")
[node name="InteractArea" type="Area3D" parent="."]
[node name="CollisionShape3D" type="CollisionShape3D" parent="InteractArea"]
shape = SubResource("BoxShape3D_jk0m1")
[node name="Seat" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0, 0.6, 0.0)
[node name="Exit" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.3, 0.0, 0.0)
[node name="CarCamera" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0, 2.0, 4.2)
+95 -2
View File
@@ -4,11 +4,11 @@ extends RigidBody3D
# 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 SPRINT_MOVE_SPEED :=13
const ACCELLERATION := 30.0 const ACCELLERATION := 30.0
const DECELLERATION := 40.0 const DECELLERATION := 40.0
const JUMP_SPEED := 4.0 const JUMP_SPEED := 4.0
const MAX_NUMBER_OF_JUMPS := 2 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
@@ -23,8 +23,23 @@ 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
var _in_vehicle := false
var _vehicle_collision_layer := 0
var _vehicle_collision_mask := 0
var _vehicle_original_parent: Node = null
var _light_was_on := false
var _jump_triggered := false
@onready var _flashlight: SpotLight3D = $SpotLight3D
@onready var _anim_player: AnimationPlayer = find_child("AnimationPlayer", true, false) as AnimationPlayer
@onready var _model_root: Node3D = find_child("TestCharAnimated", true, false) as Node3D
@export var camera_follow_speed := 10.0 @export var camera_follow_speed := 10.0
@export var anim_idle_name := "Idle"
@export var anim_walk_name := "Walk"
@export var anim_jump_name := "Jump"
@export var anim_run_name := "Run"
@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()
@@ -36,6 +51,7 @@ var audio_player = AudioStreamPlayer.new()
var phone_visible := false var phone_visible := false
func _ready() -> void: func _ready() -> void:
add_to_group("player")
axis_lock_angular_x = true axis_lock_angular_x = true
axis_lock_angular_z = true axis_lock_angular_z = true
angular_damp = 6.0 angular_damp = 6.0
@@ -60,8 +76,13 @@ func _ready() -> void:
_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_mask = collision_mask
func _integrate_forces(state): func _integrate_forces(state):
if _in_vehicle:
linear_velocity = Vector3.ZERO
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
@@ -99,8 +120,13 @@ func _integrate_forces(state):
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
# Sprinting
if Input.is_key_pressed(KEY_SHIFT):
target_v = dir * SPRINT_MOVE_SPEED
var ax := ACCELLERATION if dir != Vector3.ZERO else DECELLERATION var ax := ACCELLERATION if dir != Vector3.ZERO else DECELLERATION
linear_velocity.x = move_toward(linear_velocity.x, target_v.x, ax * state.step) linear_velocity.x = move_toward(linear_velocity.x, target_v.x, ax * state.step)
linear_velocity.z = move_toward(linear_velocity.z, target_v.z, ax * state.step) linear_velocity.z = move_toward(linear_velocity.z, target_v.z, ax * state.step)
@@ -117,6 +143,7 @@ func _integrate_forces(state):
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
audio_player.play() audio_player.play()
_jump_triggered = true
if cam: if cam:
var target_yaw := global_transform.basis.get_euler().y var target_yaw := global_transform.basis.get_euler().y
@@ -126,7 +153,12 @@ func _integrate_forces(state):
cam.global_position = cam.global_position.lerp(target_pos, camera_follow_speed * state.step) cam.global_position = cam.global_position.lerp(target_pos, camera_follow_speed * state.step)
cam.global_rotation = Vector3(_camera_pitch, _camera_yaw, 0.0) cam.global_rotation = Vector3(_camera_pitch, _camera_yaw, 0.0)
_update_animation(on_floor, state.linear_velocity)
_jump_triggered = false
func _input(event): func _input(event):
if _in_vehicle:
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:
@@ -146,9 +178,70 @@ func _input(event):
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"):
$SpotLight3D.visible = !$SpotLight3D.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)
func _update_animation(on_floor: bool, velocity: Vector3) -> void:
if _anim_player == null:
return
var horizontal_speed := Vector3(velocity.x, 0.0, velocity.z).length()
if _jump_triggered and _anim_player.has_animation(anim_jump_name):
if _anim_player.current_animation != anim_jump_name:
_anim_player.play(anim_jump_name)
return
if not on_floor and _anim_player.has_animation(anim_jump_name):
if _anim_player.current_animation != anim_jump_name:
_anim_player.play(anim_jump_name)
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 _anim_player.current_animation != anim_walk_name:
_anim_player.play(anim_walk_name)
return
if _anim_player.has_animation(anim_idle_name):
if _anim_player.current_animation != anim_idle_name:
_anim_player.play(anim_idle_name)
func enter_vehicle(_vehicle: Node, seat: Node3D, vehicle_camera: Camera3D) -> void:
_in_vehicle = true
freeze = true
sleeping = true
collision_layer = 0
collision_mask = 0
_vehicle_original_parent = get_parent()
_light_was_on = _flashlight.visible
_flashlight.visible = false
if _model_root:
_model_root.visible = false
if seat:
reparent(seat, true)
global_transform = seat.global_transform
if cam:
cam.current = false
if vehicle_camera:
vehicle_camera.current = true
func exit_vehicle(exit_point: Node3D, vehicle_camera: Camera3D) -> void:
_in_vehicle = false
freeze = false
sleeping = false
collision_layer = _vehicle_collision_layer
collision_mask = _vehicle_collision_mask
if _vehicle_original_parent:
reparent(_vehicle_original_parent, true)
_vehicle_original_parent = null
_flashlight.visible = _light_was_on
if _model_root:
_model_root.visible = true
if exit_point:
global_transform = exit_point.global_transform
if vehicle_camera:
vehicle_camera.current = false
if cam:
cam.current = true
@@ -32,6 +32,7 @@ public class CharactersController : ControllerBase
{ {
OwnerUserId = userId, OwnerUserId = userId,
Name = req.Name.Trim(), Name = req.Name.Trim(),
Coord = new Coord { X = 0, Y = 0 },
CreatedUtc = DateTime.UtcNow CreatedUtc = DateTime.UtcNow
}; };
+4
View File
@@ -18,6 +18,10 @@ Stored documents (MongoDB)
"id": "string (ObjectId)", "id": "string (ObjectId)",
"ownerUserId": "string", "ownerUserId": "string",
"name": "string", "name": "string",
"coord": {
"x": "number",
"y": "number"
},
"createdUtc": "string (ISO-8601 datetime)" "createdUtc": "string (ISO-8601 datetime)"
} }
``` ```
@@ -13,5 +13,7 @@ public class Character
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public Coord Coord { get; set; } = new();
public DateTime CreatedUtc { get; set; } = DateTime.UtcNow; public DateTime CreatedUtc { get; set; } = DateTime.UtcNow;
} }
@@ -0,0 +1,8 @@
namespace CharacterApi.Models;
public class Coord
{
public int X { get; set; }
public int Y { get; set; }
}
@@ -2,6 +2,7 @@ using LocationsApi.Models;
using LocationsApi.Services; using LocationsApi.Services;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using MongoDB.Driver;
namespace LocationsApi.Controllers; namespace LocationsApi.Controllers;
@@ -23,13 +24,29 @@ public class LocationsController : ControllerBase
if (string.IsNullOrWhiteSpace(req.Name)) if (string.IsNullOrWhiteSpace(req.Name))
return BadRequest("Name required"); return BadRequest("Name required");
if (req.Coord is null)
return BadRequest("Coord required");
var location = new Location var location = new Location
{ {
Name = req.Name.Trim(), Name = req.Name.Trim(),
Coord = req.Coord,
CreatedUtc = DateTime.UtcNow CreatedUtc = DateTime.UtcNow
}; };
await _locations.CreateAsync(location); try
{
await _locations.CreateAsync(location);
}
catch (MongoWriteException ex) when (ex.WriteError.Category == ServerErrorCategory.DuplicateKey)
{
return Conflict("Coord must be unique");
}
catch (MongoWriteException ex) when (ex.WriteError.Code == 121)
{
return BadRequest("Location document failed validation");
}
return Ok(location); return Ok(location);
} }
@@ -59,6 +76,9 @@ public class LocationsController : ControllerBase
if (string.IsNullOrWhiteSpace(req.Name)) if (string.IsNullOrWhiteSpace(req.Name))
return BadRequest("Name required"); return BadRequest("Name required");
if (req.Coord is not null)
return BadRequest("Coord cannot be updated");
var updated = await _locations.UpdateNameAsync(id, req.Name.Trim()); var updated = await _locations.UpdateNameAsync(id, req.Name.Trim());
if (!updated) if (!updated)
return NotFound(); return NotFound();
+10 -1
View File
@@ -7,7 +7,11 @@ Inbound JSON documents
- CreateLocationRequest (`POST /api/locations`) - CreateLocationRequest (`POST /api/locations`)
```json ```json
{ {
"name": "string" "name": "string",
"coord": {
"x": 0,
"y": 0
}
} }
``` ```
- UpdateLocationRequest (`PUT /api/locations/{id}`) - UpdateLocationRequest (`PUT /api/locations/{id}`)
@@ -16,6 +20,7 @@ Inbound JSON documents
"name": "string" "name": "string"
} }
``` ```
`coord` cannot be updated.
Stored documents (MongoDB) Stored documents (MongoDB)
- Location - Location
@@ -23,6 +28,10 @@ Stored documents (MongoDB)
{ {
"id": "string (ObjectId)", "id": "string (ObjectId)",
"name": "string", "name": "string",
"coord": {
"x": 0,
"y": 0
},
"createdUtc": "string (ISO-8601 datetime)" "createdUtc": "string (ISO-8601 datetime)"
} }
``` ```
@@ -0,0 +1,12 @@
using MongoDB.Bson.Serialization.Attributes;
namespace LocationsApi.Models;
public class Coord
{
[BsonElement("x")]
public int X { get; set; }
[BsonElement("y")]
public int Y { get; set; }
}
@@ -3,4 +3,6 @@ namespace LocationsApi.Models;
public class CreateLocationRequest public class CreateLocationRequest
{ {
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public required Coord Coord { get; set; }
} }
@@ -9,7 +9,12 @@ public class Location
[BsonRepresentation(BsonType.ObjectId)] [BsonRepresentation(BsonType.ObjectId)]
public string? Id { get; set; } public string? Id { get; set; }
[BsonElement("name")]
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
[BsonElement("coord")]
public required Coord Coord { get; set; }
[BsonElement("createdUtc")]
public DateTime CreatedUtc { get; set; } = DateTime.UtcNow; public DateTime CreatedUtc { get; set; } = DateTime.UtcNow;
} }
@@ -3,4 +3,6 @@ namespace LocationsApi.Models;
public class UpdateLocationRequest public class UpdateLocationRequest
{ {
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public Coord? Coord { get; set; }
} }
+1 -1
View File
@@ -4,7 +4,7 @@
See `DOCUMENTS.md` for request payloads and stored document shapes. See `DOCUMENTS.md` for request payloads and stored document shapes.
## Endpoints ## Endpoints
- `POST /api/locations` Create a location (SUPER only). - `POST /api/locations` Create a location with a unique coord pair (SUPER only).
- `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).
@@ -1,4 +1,5 @@
using LocationsApi.Models; using LocationsApi.Models;
using MongoDB.Bson;
using MongoDB.Driver; using MongoDB.Driver;
namespace LocationsApi.Services; namespace LocationsApi.Services;
@@ -13,8 +14,73 @@ public class LocationStore
var dbName = cfg["MongoDB:DatabaseName"] ?? "GameDb"; var dbName = cfg["MongoDB:DatabaseName"] ?? "GameDb";
var client = new MongoClient(cs); var client = new MongoClient(cs);
var db = client.GetDatabase(dbName); var db = client.GetDatabase(dbName);
_col = db.GetCollection<Location>("Locations"); var collectionName = "Locations";
EnsureLocationSchema(db, collectionName);
_col = db.GetCollection<Location>(collectionName);
var coordIndex = Builders<Location>.IndexKeys
.Ascending(l => l.Coord.X)
.Ascending(l => l.Coord.Y);
var coordIndexOptions = new CreateIndexOptions { Unique = true };
_col.Indexes.CreateOne(new CreateIndexModel<Location>(coordIndex, coordIndexOptions));
EnsureOriginLocation();
}
private static void EnsureLocationSchema(IMongoDatabase db, string collectionName)
{
var validator = new BsonDocument
{
{
"$jsonSchema", new BsonDocument
{
{ "bsonType", "object" },
{ "required", new BsonArray { "name", "coord", "createdUtc" } },
{
"properties", new BsonDocument
{
{ "name", new BsonDocument { { "bsonType", "string" } } },
{
"coord", new BsonDocument
{
{ "bsonType", "object" },
{ "required", new BsonArray { "x", "y" } },
{
"properties", new BsonDocument
{
{ "x", new BsonDocument { { "bsonType", "int" } } },
{ "y", new BsonDocument { { "bsonType", "int" } } }
}
}
}
},
{ "createdUtc", new BsonDocument { { "bsonType", "date" } } }
}
}
}
}
};
var collections = db.ListCollectionNames().ToList();
if (!collections.Contains(collectionName))
{
var createCommand = new BsonDocument
{
{ "create", collectionName },
{ "validator", validator },
{ "validationAction", "error" }
};
db.RunCommand<BsonDocument>(createCommand);
return;
}
var command = new BsonDocument
{
{ "collMod", collectionName },
{ "validator", validator },
{ "validationAction", "error" }
};
db.RunCommand<BsonDocument>(command);
} }
public Task CreateAsync(Location location) => _col.InsertOneAsync(location); public Task CreateAsync(Location location) => _col.InsertOneAsync(location);
@@ -36,4 +102,31 @@ public class LocationStore
var result = await _col.UpdateOneAsync(filter, update); var result = await _col.UpdateOneAsync(filter, update);
return result.ModifiedCount > 0; return result.ModifiedCount > 0;
} }
private void EnsureOriginLocation()
{
var filter = Builders<Location>.Filter.And(
Builders<Location>.Filter.Eq(l => l.Coord.X, 0),
Builders<Location>.Filter.Eq(l => l.Coord.Y, 0)
);
var existing = _col.Find(filter).FirstOrDefault();
if (existing is not null)
return;
var origin = new Location
{
Name = "Origin",
Coord = new Coord { X = 0, Y = 0 },
CreatedUtc = DateTime.UtcNow
};
try
{
_col.InsertOne(origin);
}
catch (MongoWriteException ex) when (ex.WriteError.Category == ServerErrorCategory.DuplicateKey)
{
// Another instance seeded it first.
}
}
} }