Premier commit

This commit is contained in:
2026-09-01 22:41:37 +02:00
commit 7cff988739
133 changed files with 6412 additions and 0 deletions
+87
View File
@@ -0,0 +1,87 @@
@tool
extends Node3D
class_name HexMap
const BASE_TILE_SET_SCENE = preload('res://objects/map/tiles/base_hex_tile_set.tscn') as PackedScene
@export_tool_button("Load Map", "Callable") var load_map_action = load_map
@export var radius = 10
@onready var tile_set : HexTileSet = BASE_TILE_SET_SCENE.instantiate()
var empty_hex_tiles_coords : Array[Vector2i] = []
var hex_tiles_by_pos : Dictionary[String, HexTile] = {}
var hex_tiles_by_id : Dictionary[String, Array] = {}
func load_map():
for c in get_children():
c.queue_free()
empty_hex_tiles_coords = []
hex_tiles_by_pos = {}
empty_hex_tiles_coords = get_all_hex_coords()
empty_hex_tiles_coords.shuffle()
var mandatory_tiles = tile_set.get_all_hex_tiles().filter(
func (tile : HexTile): return tile.mandatory_tile
)
for hex_tile in mandatory_tiles:
for i in range(hex_tile.mandatory_count):
if len(empty_hex_tiles_coords) != 0:
spawn_tile(
empty_hex_tiles_coords.pop_front(),
hex_tile
)
while len(empty_hex_tiles_coords) != 0:
var coord : Vector2i = empty_hex_tiles_coords.pop_front()
spawn_tile(
coord,
get_available_tiles_for_coord(coord).pick_random()
)
func spawn_tile(coord : Vector2i, hex_tile : HexTile):
var new_tile = hex_tile.duplicate()
hex_tiles_by_pos["%d:%d" % [coord.x, coord.y]] = new_tile
if not (new_tile.name in hex_tiles_by_id):
hex_tiles_by_id[new_tile.name] = []
hex_tiles_by_id[new_tile.name].append(new_tile)
new_tile.position = get_world_tile_coord(coord)
new_tile.rotation.y = (randi() % 6)/6. * 2. * PI
add_child(new_tile)
func get_available_tiles_for_coord(_coord : Vector2) -> Array[HexTile]:
return tile_set.get_all_hex_tiles().filter(
func (tile : HexTile): return not tile.mandatory_tile
)
func get_all_hex_coords() -> Array[Vector2i]:
var coords : Array[Vector2i] = []
for x in range(-radius, radius):
for y in range(-radius, radius):
if Vector2(x,y).length() < radius:
coords.append(Vector2i(x,y))
return coords
func get_world_tile_coord(coord: Vector2i) -> Vector3:
return Vector3(
coord.x * HexTile.BASE_TILE_SIZE + (HexTile.BASE_TILE_SIZE/2. if coord.y%2 == 0 else 0.),
0.,
coord.y * HexTile.BASE_TILE_SIZE * cos(PI/6),
)
func get_all_tiles_with_id(id : String) -> Array[HexTile]:
if id in hex_tiles_by_id:
return (hex_tiles_by_id[id] as Array[HexTile])
return ([] as Array[HexTile])
+1
View File
@@ -0,0 +1 @@
uid://da00pdn0rf7t5
Binary file not shown.
+75
View File
@@ -0,0 +1,75 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://c3tu8mi21rbj5"
path="res://.godot/imported/base.blend-1078cc3cc14bf2d0e109d3d1e8d426e3.scn"
[deps]
source_file="res://objects/map/tiles/base/base.blend"
dest_files=["res://.godot/imported/base.blend-1078cc3cc14bf2d0e109d3d1e8d426e3.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/root_script=null
mesh_library/use_node_names_as_mesh_names=false
array_mesh/deduplicate_surfaces=true
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={
"meshes": {
"base_Cylinder_003": {
"generate/lightmap_uv": 0,
"generate/lods": 0,
"generate/shadow_meshes": 0,
"lods/normal_merge_angle": 20.0,
"save_to_file/enabled": true,
"save_to_file/fallback_path": "res://objects/map/tiles/base/base.tres",
"save_to_file/path": "uid://dnhk02pm0g1j"
}
}
}
blender/nodes/visible=0
blender/nodes/active_collection_only=false
blender/nodes/punctual_lights=true
blender/nodes/cameras=true
blender/nodes/custom_properties=true
blender/nodes/modifiers=1
blender/meshes/vertex_colors=1
blender/meshes/uvs=true
blender/meshes/normals=true
blender/meshes/export_geometry_nodes_instances=false
blender/meshes/gpu_instances=false
blender/meshes/tangents=true
blender/meshes/skins=2
blender/meshes/export_bones_deforming_mesh_only=false
blender/materials/unpack_enabled=true
blender/materials/export_materials=1
blender/animation/limit_playback=true
blender/animation/always_sample=true
blender/animation/group_tracks=true
gltf/naming_version=2
gltf/texture_map_mode=1
Binary file not shown.
+33
View File
@@ -0,0 +1,33 @@
[gd_resource type="ArrayMesh" format=4 uid="uid://dnhk02pm0g1j"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_yhyhb"]
[sub_resource type="ArrayMesh" id="ArrayMesh_8mopr"]
_surfaces = [{
"aabb": AABB(-20, -2, -23.094011, 40, 2, 46.188023),
"format": 34896613377,
"index_count": 60,
"index_data": PackedByteArray("AAABAAIAAAADAAEABAACAAEAAwAEAAEABQAAAAIABQADAAAABQACAAYAAwAHAAQACAAFAAYAAwAFAAkACQAFAAgAAwAJAAcABwAKAAQABwAJAAoAAgAEAAsAAgALAAYACwAEAAoACAAGAAsACQALAAoACQAIAAsA"),
"primitive": 3,
"uv_scale": Vector4(0, 0, 0, 0),
"vertex_count": 12,
"vertex_data": PackedByteArray("/38AAAAAAAD//////z8AAP9///8AAAAA//8AAP8/AAD//////78AAAAAAAD/PwAAAAD///8/AAD//wAA/78AAAAAAAD/vwAA/38AAP//AAD/f/////8AAAAA////vwAA")
}]
blend_shape_mode = 0
[resource]
resource_name = "base_Cylinder_003"
_surfaces = [{
"aabb": AABB(-20, -2, -23.094011, 40, 2, 46.188023),
"attribute_data": PackedByteArray("//+kwKnq/3////9/qeqkwKnqpMBU1f9/qer/f1TVpMBU1aTA/7//f1TV/3//v6TA/7+kwKmq/3//v/9/qaqkwJm6e/D/n+/Bmbpz0WSFe/D/n///ZIVz0amqpMBUlf9/qar/f1SVpMBUlaTA/3//f1SV/3//f6TAZMVz0Zn6c9H/3+/B/9///2TFe/CZ+nvw"),
"format": 34896613399,
"index_count": 60,
"index_data": PackedByteArray("AAABAAIAAAADAAEABAAFAAYABAAHAAUACAAJAAoACAALAAkADAANAA4ADAAPAA0AEAARABIAEQAQABMAEwAQABQAEQATABUAFgAXABgAFgAZABcAGgAbABwAGgAdABsAHgAfACAAHwAeACEAIQAeACIAHwAhACMA"),
"material": SubResource("StandardMaterial3D_yhyhb"),
"primitive": 3,
"uv_scale": Vector4(2, 1.98, 0, 0),
"vertex_count": 36,
"vertex_data": PackedByteArray("/38AAAAAqer//////z+p6v9///8AAKnq//8AAP8/qer//wAA/z//v///////v/+///////8//7///wAA/7//v///AAD/v1SV/3//////VJX//////79Ulf9/AAD//1SV/38AAP//VJUAAP///79Ulf9//////1SVAAAAAP+/VJX//////7//v/9///8AAP+///////8//78AAP///7//v/9///////+/AAD///8//78AAAAA/7//vwAA////P/+/AAD///+//78AAAAA/z//vwAAAAD/P6nq/3///wAAqeoAAP///z+p6v9/AAAAAKnqAAAAAP8//z///wAA/z//P/9/AAAAAP8//38AAP///z8AAAAA/7//P///AAD/v/8//38AAP9/AAD/fwAA/38AAP9/AAD/fwAA/38AAP9/AAD/fwAA/38AAP9/AAD/fwAA/3////9/////f////3///////3////9/////f////3////9/////f/9/////f////3////9/////f////3////9/////f///AAD/fwAA/38AAP9/AAD/fwAA/38AAP9/")
}]
blend_shape_mode = 0
shadow_mesh = SubResource("ArrayMesh_8mopr")
+170
View File
@@ -0,0 +1,170 @@
[gd_scene format=3 uid="uid://ygpr1p4jwi4v"]
[ext_resource type="Script" uid="uid://ovrpkbwq0piy" path="res://objects/map/tiles/hex_tile_set.gd" id="1_sgwpe"]
[ext_resource type="Script" uid="uid://bcelqd50co3p3" path="res://objects/map/tiles/hex_tile.gd" id="2_0fw1f"]
[ext_resource type="ArrayMesh" uid="uid://dnhk02pm0g1j" path="res://objects/map/tiles/base/base.tres" id="3_6x72r"]
[ext_resource type="Script" uid="uid://boba1g0kd5n68" path="res://objects/map/tiles/hex_tile_types/hex_tile_house.gd" id="4_0fw1f"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_oixbx"]
albedo_color = Color(0.35686275, 0.6509804, 0.45882353, 1)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_sgwpe"]
albedo_color = Color(0.47058824, 0.8, 0.43529412, 1)
[sub_resource type="CylinderMesh" id="CylinderMesh_g4v7s"]
bottom_radius = 12.328
height = 21.673828
radial_segments = 10
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_yf5fn"]
albedo_color = Color(0.35686275, 0.6509804, 0.45882353, 1)
[sub_resource type="CylinderShape3D" id="CylinderShape3D_sgwpe"]
height = 24.650146
radius = 9.0859375
[sub_resource type="CylinderShape3D" id="CylinderShape3D_yf5fn"]
height = 24.650146
radius = 12.075195
[sub_resource type="PrismMesh" id="PrismMesh_sgwpe"]
size = Vector3(10, 10, 10)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_0fw1f"]
albedo_color = Color(0.8, 0.25882354, 0.36862746, 1)
[sub_resource type="CylinderMesh" id="CylinderMesh_yf5fn"]
height = 200.0
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_57qmd"]
transparency = 1
shading_mode = 0
albedo_color = Color(0.8, 0.256, 0.36480018, 0.42352942)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_6x72r"]
albedo_color = Color(0.81960785, 0.7058824, 0.7607843, 1)
[sub_resource type="CylinderShape3D" id="CylinderShape3D_6x72r"]
height = 24.650146
radius = 6.894
[sub_resource type="Gradient" id="Gradient_0fw1f"]
interpolation_mode = 1
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
[sub_resource type="GradientTexture2D" id="GradientTexture2D_g4v7s"]
gradient = SubResource("Gradient_0fw1f")
width = 300
height = 300
fill = 1
fill_from = Vector2(0.5, 0.5)
fill_to = Vector2(0.5, 1)
[node name="HexTileSet" type="Node3D" unique_id=549438538]
script = ExtResource("1_sgwpe")
[node name="Grass" type="StaticBody3D" parent="." unique_id=940672834]
script = ExtResource("2_0fw1f")
id = &"Grass"
metadata/_custom_type_script = "uid://bcelqd50co3p3"
[node name="Base" type="MeshInstance3D" parent="Grass" unique_id=76705257]
mesh = ExtResource("3_6x72r")
surface_material_override/0 = SubResource("StandardMaterial3D_oixbx")
[node name="Grass2" type="StaticBody3D" parent="." unique_id=1341297106]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 40, 0, 0)
script = ExtResource("2_0fw1f")
id = &"Grass2"
metadata/_custom_type_script = "uid://bcelqd50co3p3"
[node name="Base" type="MeshInstance3D" parent="Grass2" unique_id=2047809771]
mesh = ExtResource("3_6x72r")
surface_material_override/0 = SubResource("StandardMaterial3D_sgwpe")
[node name="Tree1" type="StaticBody3D" parent="." unique_id=779600102]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 80, 0, 0)
script = ExtResource("2_0fw1f")
id = &"Tree1"
metadata/_custom_type_script = "uid://bcelqd50co3p3"
[node name="Base2" type="MeshInstance3D" parent="Tree1" unique_id=627081052]
mesh = ExtResource("3_6x72r")
surface_material_override/0 = SubResource("StandardMaterial3D_oixbx")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Tree1" unique_id=1847158047]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.9956665, 9.836914, -4.9558372)
mesh = SubResource("CylinderMesh_g4v7s")
surface_material_override/0 = SubResource("StandardMaterial3D_yf5fn")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="Tree1" unique_id=770818071]
transform = Transform3D(0.515, 0, 0, 0, 0.515, 0, 0, 0, 0.515, 1.0043335, 2.9007664, 4.0441628)
mesh = SubResource("CylinderMesh_g4v7s")
surface_material_override/0 = SubResource("StandardMaterial3D_yf5fn")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Tree1" unique_id=1419584569]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.2411957, 7.078491, -4.7115307)
shape = SubResource("CylinderShape3D_sgwpe")
[node name="Tree2" type="StaticBody3D" parent="." unique_id=1777082018]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 120, 0, 0)
script = ExtResource("2_0fw1f")
id = &"Tree2"
metadata/_custom_type_script = "uid://bcelqd50co3p3"
[node name="Base2" type="MeshInstance3D" parent="Tree2" unique_id=1571316613]
mesh = ExtResource("3_6x72r")
surface_material_override/0 = SubResource("StandardMaterial3D_oixbx")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Tree2" unique_id=1159803776]
transform = Transform3D(1.375, 0, 0, 0, 1.375, 0, 0, 0, 1.375, 0.54029846, 11.831854, -0.09746361)
mesh = SubResource("CylinderMesh_g4v7s")
surface_material_override/0 = SubResource("StandardMaterial3D_yf5fn")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Tree2" unique_id=872651782]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.8638458, 7.078491, 0.41245174)
shape = SubResource("CylinderShape3D_yf5fn")
[node name="House" type="StaticBody3D" parent="." unique_id=2024806559 node_paths=PackedStringArray("life_bar", "house_model", "house_model_broke")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 160, 0, 0)
script = ExtResource("4_0fw1f")
life_bar = NodePath("LifeBar")
house_model = NodePath("HouseModel")
house_model_broke = NodePath("HouseModelBroke")
hp = 100.0
id = &"House"
mandatory_tile = true
mandatory_count = 3
metadata/_custom_type_script = "uid://bcelqd50co3p3"
[node name="Base2" type="MeshInstance3D" parent="House" unique_id=501829296]
mesh = ExtResource("3_6x72r")
surface_material_override/0 = SubResource("StandardMaterial3D_oixbx")
[node name="HouseModel" type="MeshInstance3D" parent="House" unique_id=1045312946]
unique_name_in_owner = true
transform = Transform3D(1.375, 0, 0, 0, 1.375, 0, 0, 0, 1.375, 0.54029846, 5.831854, -0.09746361)
mesh = SubResource("PrismMesh_sgwpe")
surface_material_override/0 = SubResource("StandardMaterial3D_0fw1f")
[node name="MeshInstance3D" type="MeshInstance3D" parent="House/HouseModel" unique_id=670837026]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 100, 0)
mesh = SubResource("CylinderMesh_yf5fn")
surface_material_override/0 = SubResource("StandardMaterial3D_57qmd")
[node name="HouseModelBroke" type="MeshInstance3D" parent="House" unique_id=107368671]
unique_name_in_owner = true
transform = Transform3D(1.375, 0, 0, 0, 1.375, 0, 0, 0, 1.375, 0.54029846, 5.831854, -0.09746361)
visible = false
mesh = SubResource("PrismMesh_sgwpe")
surface_material_override/0 = SubResource("StandardMaterial3D_6x72r")
[node name="CollisionShape3D" type="CollisionShape3D" parent="House" unique_id=907138474]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.8638458, 7.078491, 0.41245174)
shape = SubResource("CylinderShape3D_6x72r")
[node name="LifeBar" type="Sprite3D" parent="House" unique_id=501876162]
unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.53863525, 16.817535, 0)
billboard = 1
texture = SubResource("GradientTexture2D_g4v7s")
+14
View File
@@ -0,0 +1,14 @@
@tool
extends StaticBody3D
class_name HexTile
const BASE_TILE_SIZE = 40
@export var id = ""
@export_group("Mandatory Tile")
@export var mandatory_tile :bool = false
@export var mandatory_count : int = 5
func _ready():
id = name
+1
View File
@@ -0,0 +1 @@
uid://bcelqd50co3p3
+6
View File
@@ -0,0 +1,6 @@
@tool
extends Node3D
class_name HexTileSet
func get_all_hex_tiles() -> Array[HexTile]:
return get_children() as Array[HexTile]
+1
View File
@@ -0,0 +1 @@
uid://ovrpkbwq0piy
@@ -0,0 +1,30 @@
@tool
extends HexTile
class_name HouseHexTile
@export var life_bar : Sprite3D
@export var house_model : Node3D
@export var house_model_broke : Node3D
@export var max_hp : float = 100.
@export var hp : float = max_hp :
set(v):
hp = v
if is_node_ready():
life_bar.scale = Vector3.ONE * hp / max_hp
@export var destroyed : bool = false : set = set_destroyed
func hit(damage = 1.):
hp = max(0, hp - damage)
if hp == 0:
destroyed = true
func set_destroyed(_destroyed : bool = destroyed):
destroyed = _destroyed
if is_node_ready():
house_model.visible = not destroyed
house_model_broke.visible = destroyed
@@ -0,0 +1 @@
uid://boba1g0kd5n68