This commit is contained in:
Marek Le
2026-05-09 23:37:26 +02:00
parent 6d28b04c12
commit 2d4002bd3f
263 changed files with 5250 additions and 4597 deletions

View File

@@ -0,0 +1,36 @@
extends StaticBody3D
@export var building_id: StringName = &""
@onready var mesh: MeshInstance3D = $Mesh
@onready var collision: CollisionShape3D = $Collision
func _enter_tree() -> void:
set_multiplayer_authority(1)
func _ready() -> void:
add_to_group("buildings")
apply_building(building_id)
func apply_building(id: StringName) -> void:
building_id = id
var data: Building = _load_building(id)
if data == null:
return
var box: BoxMesh = mesh.mesh as BoxMesh
if box:
box.size = data.size
var shape: BoxShape3D = collision.shape as BoxShape3D
if shape:
shape.size = data.size
collision.position = Vector3(0.0, data.size.y * 0.5, 0.0)
mesh.position = Vector3(0.0, data.size.y * 0.5, 0.0)
var mat: StandardMaterial3D = StandardMaterial3D.new()
mat.albedo_color = data.color
mesh.material_override = mat
static func _load_building(id: StringName) -> Building:
var path := "res://resources/buildings/%s.tres" % str(id)
if ResourceLoader.exists(path):
return load(path) as Building
return null

View File

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

View File

@@ -0,0 +1,22 @@
[gd_scene load_steps=4 format=3 uid="uid://b0building001"]
[ext_resource type="Script" path="res://scenes/entities/building/building.gd" id="1"]
[sub_resource type="BoxShape3D" id="BoxShape3D_1"]
size = Vector3(1, 1, 1)
[sub_resource type="BoxMesh" id="BoxMesh_1"]
size = Vector3(1, 1, 1)
[node name="Building" type="StaticBody3D"]
collision_layer = 16
collision_mask = 0
script = ExtResource("1")
[node name="Collision" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
shape = SubResource("BoxShape3D_1")
[node name="Mesh" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
mesh = SubResource("BoxMesh_1")