initial commit

This commit is contained in:
saarsena@gmail.com 2026-04-22 10:19:57 -04:00
commit c2bb3893a9
1038 changed files with 75846 additions and 0 deletions

View file

@ -0,0 +1,48 @@
extends Node3D
## Door entity. Place at a cell center in TrenchBroom (normal 64 grid).
## The door's local -Z is "forward" (the direction the player approaches from).
## At runtime the mesh/collision shift forward to the cell boundary so the door
## sits flush against the wall the player is facing.
## If true the door swings toward its local +Z (outward). If false it swings
## toward -Z (inward).
@export var opens_outward := true
@onready var hinge_pivot: Node3D = $HingePivot
@onready var door_collision: CollisionShape3D = $DoorBody/DoorCollision
@onready var interact_area: Area3D = $InteractArea
var _is_open := false
var _tween: Tween
const SWING_DURATION := 0.5
## How far forward (local -Z) to shift everything so the door sits on the cell boundary.
const BOUNDARY_OFFSET := 0.0
func _ready() -> void:
add_to_group("facing_interactable")
# Shift children to the cell boundary along the door's forward axis.
var offset := -transform.basis.z.normalized() * BOUNDARY_OFFSET
for child: Node3D in [hinge_pivot, $DoorBody, interact_area]:
child.global_position += offset
func try_interact(player: CharacterBody3D) -> bool:
if not interact_area.overlaps_body(player):
return false
if _tween and _tween.is_running():
return true
_is_open = !_is_open
_tween = create_tween()
var swing := -PI / 2.0 if opens_outward else PI / 2.0
var target_angle := swing if _is_open else 0.0
_tween.tween_property(hinge_pivot, "rotation:y", target_angle, SWING_DURATION)
if _is_open:
door_collision.disabled = true
else:
_tween.tween_callback(func(): door_collision.disabled = false)
return true

View file

@ -0,0 +1 @@
uid://bvlqja7ffq8me

View file

@ -0,0 +1,48 @@
[gd_scene format=3 uid="uid://dxwcrc6ktiyx5"]
[ext_resource type="Script" uid="uid://bvlqja7ffq8me" path="res://elements/entities/door/door.gd" id="1_script"]
[ext_resource type="Material" uid="uid://u4la7a0y4ti1" path="res://textures/tb/door/door/7a.tres" id="2_fbfc2"]
[ext_resource type="Shader" uid="uid://cdkesoyod4tga" path="res://shaders/door.gdshader" id="2_shader"]
[ext_resource type="Texture2D" uid="uid://d1ltfx6s4kou4" path="res://textures/tb/door/door/7a.png" id="3_texture"]
[sub_resource type="BoxMesh" id="BoxMesh_door"]
material = ExtResource("2_fbfc2")
size = Vector3(2, 2.6, 0.125)
[sub_resource type="ShaderMaterial" id="ShaderMaterial_door"]
render_priority = 0
shader = ExtResource("2_shader")
shader_parameter/door_texture = ExtResource("3_texture")
shader_parameter/uv_scale = Vector3(3, 2, 3)
[sub_resource type="BoxShape3D" id="BoxShape3D_m5tju"]
size = Vector3(2, 2.5, 0.125)
[sub_resource type="BoxShape3D" id="BoxShape3D_interact"]
size = Vector3(2001.897, 2.546997, 3)
[node name="Door" type="Node3D" unique_id=1729595504]
script = ExtResource("1_script")
[node name="HingePivot" type="Node3D" parent="." unique_id=29731943]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 1.12, 0)
[node name="DoorMesh" type="MeshInstance3D" parent="HingePivot" unique_id=839410192]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0)
mesh = SubResource("BoxMesh_door")
surface_material_override/0 = SubResource("ShaderMaterial_door")
[node name="DoorBody" type="StaticBody3D" parent="." unique_id=376301710]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.12, 0)
collision_mask = 0
[node name="DoorCollision" type="CollisionShape3D" parent="DoorBody" unique_id=1652482101]
shape = SubResource("BoxShape3D_m5tju")
[node name="InteractArea" type="Area3D" parent="." unique_id=1749724580]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.12, 0)
collision_layer = 0
monitorable = false
[node name="InteractShape" type="CollisionShape3D" parent="InteractArea" unique_id=329907396]
shape = SubResource("BoxShape3D_interact")