Pawn changing chunks

pull/19/head
Valentin Stark 3 years ago
parent 04018cea06
commit 1581052ef2
  1. 3
      .godot/editor/Pawn.gd-folding-b04e9b08a79428657904b8cfd1905a85.cfg
  2. 170
      .godot/editor/Pawn.tscn-editstate-ee2e6b5eca20f2ef7fd9cfd9f9c666bc.cfg
  3. 5
      .godot/editor/Pawn.tscn-folding-ee2e6b5eca20f2ef7fd9cfd9f9c666bc.cfg
  4. 2
      .godot/editor/camera.tscn-editstate-171b6540a4c3cdae5b0905e52ed5116f.cfg
  5. 4
      .godot/editor/editor_layout.cfg
  6. 0
      .godot/editor/favorites
  7. 26
      .godot/editor/filesystem_cache8
  8. 8
      .godot/editor/filesystem_update4
  9. 2
      .godot/editor/project_metadata.cfg
  10. 50
      .godot/editor/script_editor_cache.cfg
  11. BIN
      .godot/uid_cache.bin
  12. 72
      scenes/Pawn.tscn
  13. 6
      scripts/Board.gd
  14. 41
      scripts/Chunk.gd
  15. 170
      scripts/Ground.gd
  16. 32
      scripts/Pawn.gd

@ -0,0 +1,3 @@
[folding]
sections_unfolded=PackedStringArray()

@ -0,0 +1,170 @@
[editor_states]
Anim={
"visible": false
}
2D={
"grid_offset": Vector2(0, 0),
"grid_snap_active": false,
"grid_step": Vector2(8, 8),
"grid_visibility": 1,
"ofs": Vector2(-114.654, -46.1878),
"primary_grid_steps": 8,
"show_edit_locks": true,
"show_guides": true,
"show_helpers": false,
"show_origin": true,
"show_rulers": true,
"show_transformation_gizmos": true,
"show_viewport": true,
"show_zoom_control": true,
"smart_snap_active": false,
"snap_guides": true,
"snap_node_anchors": true,
"snap_node_center": true,
"snap_node_parent": true,
"snap_node_sides": true,
"snap_other_nodes": true,
"snap_pixel": true,
"snap_relative": false,
"snap_rotation": false,
"snap_rotation_offset": 0.0,
"snap_rotation_step": 0.261799,
"snap_scale": false,
"snap_scale_step": 0.1,
"zoom": 5.65685
}
3D={
"fov": 70.01,
"gizmos_status": {
"AudioListener3D": 0,
"AudioStreamPlayer3D": 0,
"CPUParticles3D": 0,
"CSGShape3D": 0,
"Camera3D": 0,
"CollisionObject3D": 0,
"CollisionPolygon3D": 0,
"CollisionShape3D": 0,
"Decal": 0,
"FogVolume": 0,
"GPUParticles3D": 0,
"GPUParticlesCollision3D": 0,
"Joint3D": 0,
"Light3D": 0,
"LightmapGI": 0,
"LightmapProbe": 0,
"Marker3D": 0,
"NavigationLink3D": 0,
"NavigationRegion3D": 0,
"OccluderInstance3D": 0,
"Path3D": 0,
"PhysicalBone3D": 0,
"RayCast3D": 0,
"ReflectionProbe": 0,
"ShapeCast3D": 0,
"Skeleton3D": 0,
"SoftBody3D": 0,
"SpringArm3D": 0,
"VehicleWheel3D": 0,
"VisibleOnScreenNotifier3D": 0,
"VoxelGI": 0
},
"local_coords": false,
"preview_sun_env": {
"environ_ao_enabled": false,
"environ_enabled": true,
"environ_energy": 1.0,
"environ_gi_enabled": false,
"environ_glow_enabled": true,
"environ_ground_color": Color(0.2, 0.169, 0.133, 1),
"environ_sky_color": Color(0.385, 0.454, 0.55, 1),
"environ_tonemap_enabled": true,
"sun_color": Color(1, 1, 1, 1),
"sun_enabled": true,
"sun_energy": 1.0,
"sun_max_distance": 100.0,
"sun_rotation": Vector2(-1.0472, 2.61799)
},
"rotate_snap": 0.555556,
"scale_snap": 1.25,
"show_grid": true,
"show_origin": true,
"snap_enabled": false,
"translate_snap": 0.001,
"viewport_mode": 1,
"viewports": [{
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 6.89487,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": true,
"position": Vector3(0, 0.0473186, 0),
"use_environment": false,
"use_orthogonal": false,
"view_type": 0,
"x_rotation": 0.661445,
"y_rotation": -8.48052
}, {
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"use_orthogonal": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}, {
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"use_orthogonal": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}, {
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"use_orthogonal": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}],
"zfar": 4000.01,
"znear": 0.05
}

@ -0,0 +1,5 @@
[folding]
node_unfolds=[NodePath("."), PackedStringArray("Transform"), NodePath("Pivot"), PackedStringArray("Transform"), NodePath("Pivot/fox"), PackedStringArray("Visibility", "Transform"), NodePath("CollisionShape3D"), PackedStringArray("shape", "Transform"), NodePath("RayCast3D"), PackedStringArray("Transform")]
resource_unfolds=["res://scenes/Pawn.tscn::ArrayMesh_e2578", PackedStringArray(), "res://scenes/Pawn.tscn::Skin_ue8ij", PackedStringArray(), "res://scenes/Pawn.tscn::ArrayMesh_atpyt", PackedStringArray(), "res://scenes/Pawn.tscn::ArrayMesh_6pt58", PackedStringArray(), "res://scenes/Pawn.tscn::ArrayMesh_dsilq", PackedStringArray(), "res://scenes/Pawn.tscn::ArrayMesh_hauf1", PackedStringArray(), "res://scenes/Pawn.tscn::ArrayMesh_46uut", PackedStringArray(), "res://scenes/Pawn.tscn::ArrayMesh_cxm68", PackedStringArray(), "res://scenes/Pawn.tscn::CapsuleShape3D_ed37x", PackedStringArray(), "res://scenes/Pawn.tscn::AnimationNodeStateMachine_wao7v", PackedStringArray(), "res://scenes/Pawn.tscn::AnimationNodeStateMachinePlayback_r217c", PackedStringArray()]
nodes_folded=[NodePath("Pivot/fox")]

@ -97,7 +97,7 @@ Anim={
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 7.40374,
"distance": 8.63572,
"doppler": false,
"frame_time": false,
"gizmos": true,

@ -16,11 +16,11 @@ dock_5="Inspector,Node,History"
[EditorNode]
open_scenes=["res://scenes/WorldGeneration.tscn", "res://scenes/camera.tscn"]
open_scenes=["res://scenes/WorldGeneration.tscn", "res://scenes/camera.tscn", "res://scenes/Pawn.tscn"]
[ScriptEditor]
open_scripts=["res://scripts/Board.gd", "res://scripts/Camera3D.gd", "res://scripts/Chunk.gd", "res://scripts/Entity.gd", "res://scripts/Ground.gd", "res://scripts/Instance3D.gd", "res://scripts/Map.gd", "res://scripts/Map_Cursor.gd", "res://scripts/World.gd", "res://scripts/WorldGeneration.gd"]
open_scripts=["res://scripts/Board.gd", "res://scripts/Camera3D.gd", "res://scripts/Chunk.gd", "res://scripts/Entity.gd", "res://scripts/Ground.gd", "res://scripts/Pawn.gd", "res://scripts/Map.gd", "res://scripts/Map_Cursor.gd", "res://scripts/World.gd", "res://scripts/WorldGeneration.gd"]
open_help=["Vector2i"]
script_split_offset=70
list_split_offset=0

@ -1,15 +1,15 @@
2a60927148abd1d33b818b535e306557
::res://::1680452417
::res://::1680636497
export_presets.cfg::TextFile::-1::1680357289::0::1::::<><>::
icon.png::CompressedTexture2D::4672001524465425285::1676578483::1676582905::1::::<><>::
README.md::TextFile::-1::1676578483::0::1::::<><>::
test.tscn::PackedScene::2574507083474873372::1680357289::0::1::::<><>::res://scripts/Camera3D.gd
::res://assets/::1680376641
::res://assets/::1680632745
animestyled_hdr.hdr::CompressedTexture2D::7983615197667896801::1680357289::1680357289::1::::<><>::
environment.tres::Environment::8600195688495287911::1680362965::0::1::::<><>::uid://dl0k8gegahjf2
sky.exr::CompressedTexture2D::3639266560030997135::1680357289::1680357289::1::::<><>::
water.gdshader::Shader::-1::1680370267::0::1::::<><>::
water.material::ShaderMaterial::9221375527372224942::1680376641::0::1::::<><>::res://assets/water.gdshader
water.material::ShaderMaterial::9221375527372224942::1680632745::0::1::::<><>::res://assets/water.gdshader
::res://assets/blocs/::1680365982
0_sides.glb::PackedScene::7036506600244808940::1677174532::1677174532::1::::<><>::
0_sides_grass.png::CompressedTexture2D::4551055068461159203::1677174532::1677174532::1::::<><>::
@ -43,29 +43,29 @@ untitled_sword_metal.png::CompressedTexture2D::4375004727585147220::1679673440::
::res://assets/ui/::1680363317
bloc_select.png::CompressedTexture2D::1141775147858261351::1677618805::1677619095::1::::<><>::
cursor.png::CompressedTexture2D::1407698875963358091::1664126270::1680363317::1::::<><>::
::res://scenes/::1680384607
::res://scenes/::1680636497
3DWorld.gdshader::Shader::-1::1680357289::0::1::::<><>::
3DWorld.tscn::PackedScene::3599411568061770725::1680365982::0::1::::<><>::res://scripts/Ground.gd<>res://scripts/Board.gd<>uid://dur874iy77jjr<>uid://qjc4ttmkxbch<>uid://dd7byfyvsblbw
3DWorld.VoxelGI_data.res::VoxelGIData::7277764935364316181::1680357289::0::1::::<><>::
camera.tscn::PackedScene::7435992546840103852::1680384607::0::1::::<><>::res://scripts/Camera3D.gd
camera.tscn::PackedScene::7435992546840103852::1680636506::0::1::::<><>::res://scripts/Camera3D.gd
fog.gdshader::Shader::-1::1680357289::0::1::::<><>::
Game.tscn::PackedScene::9075056520838281688::1680365982::0::1::::<><>::uid://brjt1u0dgbmi4<>uid://d1sd7pxywgunu
HUD.tscn::PackedScene::9021570906125339886::1680365982::0::1::::<><>::uid://dla77ra2m245t
Instance.tscn::PackedScene::4220804716574195494::1680365982::0::1::::<><>::res://scripts/Instance3D.gd<>uid://dw2latnr2vbxc<>uid://cfd2s833ldeuy<>uid://bavhx67iarml6<>uid://b3ljxodmxmuhg<>uid://c831hydrcv4i6
Instance.tscn::PackedScene::-1::1680636497::0::1::::<><>::res://scripts/Pawn.gd<>uid://dw2latnr2vbxc<>uid://cfd2s833ldeuy<>uid://bavhx67iarml6<>uid://b3ljxodmxmuhg<>uid://c831hydrcv4i6
Map.tscn::PackedScene::7933340314411983611::1680365982::0::1::::<><>::res://scripts/Map.gd<>uid://ub5uhu2a7etv<>res://scripts/Map_Cursor.gd
WorldGeneration.tscn::PackedScene::1108513713840477990::1680384593::0::1::::<><>::res://scripts/WorldGeneration.gd
WorldGeneration.tscn::PackedScene::1108513713840477990::1680636283::0::1::::<><>::res://scripts/WorldGeneration.gd
::res://scenes/MultiColorFog/::1680357289
MultiColorFogMaterial.tres::ShaderMaterial::-1::1680357289::0::1::::<><>::res://MultiColorFog/MultiColorFog.shader
MultiColorFogOverlay.tscn::PackedScene::-1::1680357289::0::1::::<><>::res://MultiColorFog/MultiColorFogMaterial.tres
::res://scripts/::1680384607
::res://scripts/::1680636497
Board.gd::GDScript::-1::1680373251::0::1::::<>Node3D<>::
Camera3D.gd::GDScript::-1::1680363887::0::1::::<>Camera3D<>::
Chunk.gd::GDScript::-1::1680376608::0::1::::Chunk<>GridMap<>::
Entity.gd::GDScript::-1::1680384607::0::1::::Entity<>Node<>::
Chunk.gd::GDScript::-1::1680636506::0::1::::Chunk<>GridMap<>::
Entity.gd::GDScript::-1::1680460427::0::1::::Entity<>Node<>::
Global.gd::GDScript::-1::1677174532::0::1::::<>Node<>::
Ground.gd::GDScript::-1::1680372500::0::1::::<>Node3D<>::
Instance3D.gd::GDScript::-1::1680384004::0::1::::<>CharacterBody3D<>::
Ground.gd::GDScript::-1::1680634654::0::1::::<>Node3D<>::
Map.gd::GDScript::-1::1678219623::0::1::::<>TextureRect<>::
Map_Cursor.gd::GDScript::-1::1680365687::0::1::::<>TextureRect<>::
World.gd::GDScript::-1::1680372338::0::1::::World<>Node<>::
Pawn.gd::GDScript::-1::1680636330::0::1::::<>CharacterBody3D<>::
World.gd::GDScript::-1::1680636085::0::1::::World<>Node<>::
WorldGeneration.gd::GDScript::-1::1680357289::0::1::::<>Control<>::

@ -1,6 +1,10 @@
res://scenes/WorldGeneration.tscn
res://assets/water.material
res://scenes/camera.tscn
res://scripts/Entity.gd
res://scripts/World.gd
res://scripts/Instance3D.gd
res://scripts/Chunk.gd
res://scripts/Ground.gd
res://scripts/World.gd
res://scenes/Pawn.tscn
res://scripts/Board.gd
res://scripts/Pawn.gd

@ -11,7 +11,7 @@ run_reload_scripts=true
[recent_files]
scenes=["res://scenes/camera.tscn", "res://scenes/WorldGeneration.tscn", "res://scenes/Game.tscn", "res://scenes/Map.tscn", "res://scenes/Instance.tscn", "res://scenes/HUD.tscn", "res://assets/blocs/blocs.tscn", "res://scenes/3DWorld.tscn", "res://test.tscn", "res://assets/entities/fox.tscn"]
scenes=["res://scenes/Instance.tscn", "res://scenes/camera.tscn", "res://scenes/WorldGeneration.tscn", "res://scenes/Game.tscn", "res://scenes/Map.tscn", "res://scenes/HUD.tscn", "res://assets/blocs/blocs.tscn", "res://scenes/3DWorld.tscn", "res://test.tscn", "res://assets/entities/fox.tscn"]
scripts=["Vector2i", "res://scripts/Map_Cursor.gd", "res://scripts/Map.gd", "res://scripts/Camera3D.gd", "res://scripts/Entity.gd", "res://scripts/Chunk.gd", "res://scripts/Instance3D.gd", "res://scripts/WorldGeneration.gd", "res://scripts/World.gd", "res://scripts/Board.gd"]
[color_picker]

@ -17,11 +17,11 @@ state={
state={
"bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(),
"column": 16,
"column": 19,
"folded_lines": Array[int]([]),
"h_scroll_position": 0,
"row": 119,
"scroll_position": 94.0,
"row": 14,
"scroll_position": 12.0,
"selection": false,
"syntax_highlighter": "GDScript"
}
@ -31,11 +31,11 @@ state={
state={
"bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(),
"column": 0,
"column": 40,
"folded_lines": Array[int]([]),
"h_scroll_position": 0,
"row": 63,
"scroll_position": 112.0,
"row": 25,
"scroll_position": 16.0,
"selection": false,
"syntax_highlighter": "GDScript"
}
@ -82,72 +82,68 @@ state={
"syntax_highlighter": "GDScript"
}
[res://scripts/Instance3D.gd]
[res://scripts/Board.gd]
state={
"bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(),
"column": 0,
"column": 39,
"folded_lines": Array[int]([]),
"h_scroll_position": 0,
"row": 18,
"row": 4,
"scroll_position": 0.0,
"selection": false,
"syntax_highlighter": "GDScript"
}
[res://scripts/Board.gd]
[res://scripts/Chunk.gd]
state={
"bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(),
"column": 103,
"column": 46,
"folded_lines": Array[int]([]),
"h_scroll_position": 0,
"row": 26,
"scroll_position": 23.0,
"row": 3,
"scroll_position": 0.0,
"selection": false,
"syntax_highlighter": "GDScript"
}
[res://scripts/Chunk.gd]
[res://scripts/Ground.gd]
state={
"bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(),
"column": 44,
"column": 25,
"folded_lines": Array[int]([]),
"h_scroll_position": 0,
"row": 141,
"row": 41,
"scroll_position": 0.0,
"selection": true,
"selection_from_column": 29,
"selection_from_line": 141,
"selection_to_column": 44,
"selection_to_line": 141,
"selection": false,
"syntax_highlighter": "GDScript"
}
[res://scripts/Ground.gd]
[res://scripts/Map_Cursor.gd]
state={
"bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(),
"column": 15,
"column": 87,
"folded_lines": Array[int]([]),
"h_scroll_position": 0,
"row": 29,
"scroll_position": 4.0,
"row": 6,
"scroll_position": 0.0,
"selection": false,
"syntax_highlighter": "GDScript"
}
[res://scripts/Map_Cursor.gd]
[res://scripts/Pawn.gd]
state={
"bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(),
"column": 87,
"column": 29,
"folded_lines": Array[int]([]),
"h_scroll_position": 0,
"row": 6,

Binary file not shown.

@ -1,11 +1,11 @@
[gd_scene load_steps=32 format=3 uid="uid://b1eubi13cfb4a"]
[gd_scene load_steps=32 format=3 uid="uid://dvueb8v1addy"]
[ext_resource type="Script" path="res://scripts/Instance3D.gd" id="1_64ypb"]
[ext_resource type="Texture2D" uid="uid://dw2latnr2vbxc" path="res://assets/entities/untitled_Diffuse.png" id="2_2km6u"]
[ext_resource type="Texture2D" uid="uid://cfd2s833ldeuy" path="res://assets/entities/untitled_Normal.png" id="3_mhlot"]
[ext_resource type="Texture2D" uid="uid://bavhx67iarml6" path="res://assets/entities/untitled_sword_diffuse.png" id="4_ety7m"]
[ext_resource type="Texture2D" uid="uid://b3ljxodmxmuhg" path="res://assets/entities/untitled_sword_metal.png" id="5_0rkpf"]
[ext_resource type="Texture2D" uid="uid://c831hydrcv4i6" path="res://assets/entities/untitled_bow_normal.png" id="6_ipgab"]
[ext_resource type="Script" path="res://scripts/Pawn.gd" id="1_j0tk8"]
[ext_resource type="Texture2D" uid="uid://dw2latnr2vbxc" path="res://assets/entities/untitled_Diffuse.png" id="2_ujifv"]
[ext_resource type="Texture2D" uid="uid://cfd2s833ldeuy" path="res://assets/entities/untitled_Normal.png" id="3_l4y1c"]
[ext_resource type="Texture2D" uid="uid://bavhx67iarml6" path="res://assets/entities/untitled_sword_diffuse.png" id="4_823cg"]
[ext_resource type="Texture2D" uid="uid://b3ljxodmxmuhg" path="res://assets/entities/untitled_sword_metal.png" id="5_aba8u"]
[ext_resource type="Texture2D" uid="uid://c831hydrcv4i6" path="res://assets/entities/untitled_bow_normal.png" id="6_wu0aa"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_0rurb"]
resource_name = "Material.001"
@ -14,9 +14,9 @@ alpha_scissor_threshold = 0.5
alpha_antialiasing_mode = 0
cull_mode = 2
vertex_color_use_as_albedo = true
albedo_texture = ExtResource("2_2km6u")
albedo_texture = ExtResource("2_ujifv")
normal_enabled = true
normal_texture = ExtResource("3_mhlot")
normal_texture = ExtResource("3_l4y1c")
[sub_resource type="ArrayMesh" id="ArrayMesh_e2578"]
resource_name = "untitled_Circle003"
@ -214,15 +214,15 @@ blend_shape_mode = 0
resource_name = "Material.008"
cull_mode = 2
vertex_color_use_as_albedo = true
albedo_texture = ExtResource("4_ety7m")
albedo_texture = ExtResource("4_823cg")
metallic = 1.0
metallic_texture = ExtResource("5_0rkpf")
metallic_texture = ExtResource("5_aba8u")
metallic_texture_channel = 2
roughness = 0.5
roughness_texture = ExtResource("5_0rkpf")
roughness_texture = ExtResource("5_aba8u")
roughness_texture_channel = 1
normal_enabled = true
normal_texture = ExtResource("6_ipgab")
normal_texture = ExtResource("6_wu0aa")
[sub_resource type="ArrayMesh" id="ArrayMesh_46uut"]
resource_name = "untitled_Cube010"
@ -2050,7 +2050,7 @@ transitions = ["Start", "Idle", SubResource("AnimationNodeStateMachineTransition
[sub_resource type="AnimationNodeStateMachinePlayback" id="AnimationNodeStateMachinePlayback_r217c"]
[node name="Instance3D" type="CharacterBody3D"]
script = ExtResource("1_64ypb")
script = ExtResource("1_j0tk8")
[node name="Pivot" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0473186, 0)
@ -2092,15 +2092,15 @@ bones/4/name = "Bone"
bones/4/parent = -1
bones/4/rest = Transform3D(1, -2.5291e-08, -6.43127e-08, 6.49611e-08, 0.0265338, 0.999648, -2.35757e-08, -0.999648, 0.0265338, 1.86265e-09, 0.417916, -2.98023e-08)
bones/4/enabled = true
bones/4/position = Vector3(3.35222e-09, 0.394763, -0.000614595)
bones/4/rotation = Quaternion(-0.616304, 0.148683, 0.122054, 0.763653)
bones/4/position = Vector3(3.91239e-09, 0.386056, -0.000845708)
bones/4/rotation = Quaternion(-0.607638, 0.193784, 0.160594, 0.753282)
bones/4/scale = Vector3(1, 1, 1)
bones/5/name = "Bone.001"
bones/5/parent = 4
bones/5/rest = Transform3D(1, 6.49611e-08, 3.22196e-08, 3.04846e-08, 0.0265337, -0.999648, -6.57931e-08, 0.999648, 0.0265337, 5.25223e-09, 1.53668e-08, 0.132351)
bones/5/enabled = true
bones/5/position = Vector3(5.25223e-09, 1.53668e-08, 0.132351)
bones/5/rotation = Quaternion(0.66786, 4.48033e-08, -4.04325e-09, 0.744287)
bones/5/rotation = Quaternion(0.634022, 2.33342e-08, -2.31092e-08, 0.773315)
bones/5/scale = Vector3(1, 1, 1)
bones/6/name = "Hood"
bones/6/parent = 5
@ -2121,14 +2121,14 @@ bones/8/parent = 7
bones/8/rest = Transform3D(0.432955, 0.625736, -0.648848, 0.0448991, 0.703947, 0.708832, 0.900297, -0.336025, 0.276682, 5.82709e-08, 0.177444, -2.03371e-08)
bones/8/enabled = true
bones/8/position = Vector3(5.82709e-08, 0.177444, -2.03371e-08)
bones/8/rotation = Quaternion(-0.645783, -0.12472, -0.202985, 0.725401)
bones/8/rotation = Quaternion(-0.63615, -0.134884, -0.266328, 0.71147)
bones/8/scale = Vector3(1, 1, 1)
bones/9/name = "Bone.007"
bones/9/parent = 8
bones/9/rest = Transform3D(0.993116, 0.117134, -5.41402e-07, -0.117134, 0.993116, 5.5995e-07, 6.03264e-07, -4.92679e-07, 1, -7.73984e-09, 0.162903, -8.55013e-08)
bones/9/enabled = true
bones/9/position = Vector3(-7.73984e-09, 0.162903, -8.55013e-08)
bones/9/rotation = Quaternion(-1.59936e-06, -2.75824e-07, -0.57764, 0.816291)
bones/9/rotation = Quaternion(-1.49501e-06, -2.65761e-07, -0.500688, 0.865628)
bones/9/scale = Vector3(1, 1, 1)
bones/10/name = "Sword"
bones/10/parent = 9
@ -2141,15 +2141,15 @@ bones/11/name = "Bone.008"
bones/11/parent = 4
bones/11/rest = Transform3D(1, 3.55271e-15, -3.8117e-08, 3.81036e-08, -0.0265341, 0.999648, -1.0114e-09, -0.999648, -0.0265341, 0.480619, 0.00333734, 0.125734)
bones/11/enabled = true
bones/11/position = Vector3(0.327701, 0.00479431, -0.0836176)
bones/11/rotation = Quaternion(-0.763653, 0.122055, -0.148684, 0.616304)
bones/11/position = Vector3(0.327701, 0.0041771, -0.106871)
bones/11/rotation = Quaternion(-0.753282, 0.160594, -0.193783, 0.607638)
bones/11/scale = Vector3(1, 1, 1)
bones/12/name = "Bone.011"
bones/12/parent = 4
bones/12/rest = Transform3D(1, 3.10862e-15, -6.95332e-09, 6.95087e-09, -0.0265341, 0.999648, -1.84497e-10, -0.999648, -0.0265341, 0.287738, 0.203267, 0.120427)
bones/12/enabled = true
bones/12/position = Vector3(0.291431, 0.236535, 0.000400938)
bones/12/rotation = Quaternion(-0.763653, 0.122054, -0.148683, 0.616304)
bones/12/rotation = Quaternion(-0.753282, 0.160594, -0.193783, 0.607638)
bones/12/scale = Vector3(1, 1, 1)
bones/13/name = "Bone.019"
bones/13/parent = 4
@ -2163,91 +2163,91 @@ bones/14/parent = 13
bones/14/rest = Transform3D(0.432955, -0.625736, 0.648848, -0.044899, 0.703947, 0.708832, -0.900297, -0.336025, 0.276683, 4.20827e-08, 0.177444, 3.85194e-08)
bones/14/enabled = true
bones/14/position = Vector3(4.20827e-08, 0.177444, 3.85194e-08)
bones/14/rotation = Quaternion(-0.672768, 0.460852, 0.267779, 0.513121)
bones/14/rotation = Quaternion(-0.679914, 0.46201, 0.243231, 0.514881)
bones/14/scale = Vector3(1, 1, 1)
bones/15/name = "Bone.021"
bones/15/parent = 14
bones/15/rest = Transform3D(0.993116, -0.117134, 4.12768e-07, 0.117134, 0.993116, 8.259e-07, -5.06667e-07, -7.71865e-07, 1, 1.81458e-10, 0.162903, -8.5116e-09)
bones/15/enabled = true
bones/15/position = Vector3(1.81458e-10, 0.162903, -8.5116e-09)
bones/15/rotation = Quaternion(-1.9142e-06, 2.48061e-07, 0.441444, 0.897289)
bones/15/rotation = Quaternion(-2.07644e-06, 2.74793e-07, 0.491034, 0.871141)
bones/15/scale = Vector3(1, 1, 1)
bones/16/name = "Bone.022"
bones/16/parent = 4
bones/16/rest = Transform3D(1, 3.55271e-15, -3.8117e-08, 3.81036e-08, -0.0265341, 0.999648, -1.0114e-09, -0.999648, -0.0265341, -0.480619, 0.00333737, 0.125734)
bones/16/enabled = true
bones/16/position = Vector3(-0.358609, -0.12896, -0.0470895)
bones/16/rotation = Quaternion(-0.763653, 0.122054, -0.148683, 0.616304)
bones/16/position = Vector3(-0.358609, -0.128533, -0.0309968)
bones/16/rotation = Quaternion(-0.753282, 0.160594, -0.193783, 0.607638)
bones/16/scale = Vector3(1, 1, 1)
bones/17/name = "Bone.023"
bones/17/parent = 4
bones/17/rest = Transform3D(1, 4.88498e-15, -6.95333e-09, 6.95088e-09, -0.0265341, 0.999648, -1.84495e-10, -0.999648, -0.0265341, -0.287738, 0.203267, 0.120427)
bones/17/enabled = true
bones/17/position = Vector3(-0.285902, 0.16505, -0.138443)
bones/17/rotation = Quaternion(-0.763653, 0.122054, -0.148683, 0.616304)
bones/17/rotation = Quaternion(-0.753282, 0.160594, -0.193783, 0.607638)
bones/17/scale = Vector3(1, 1, 1)
bones/18/name = "Tail_1"
bones/18/parent = 4
bones/18/rest = Transform3D(1, 2.31377e-08, 6.49611e-08, -2.48533e-08, 0.999648, 0.0265338, -6.43243e-08, -0.0265338, 0.999648, 7.52368e-09, 0.139991, -0.0720165)
bones/18/enabled = true
bones/18/position = Vector3(7.52368e-09, 0.139991, -0.0720165)
bones/18/rotation = Quaternion(0.0702261, 3.01488e-08, -1.78576e-08, 0.997531)
bones/18/rotation = Quaternion(-0.0990091, 3.0505e-08, -2.27192e-08, 0.995087)
bones/18/scale = Vector3(1, 1, 1)
bones/19/name = "Tail_2"
bones/19/parent = 18
bones/19/rest = Transform3D(1, -3.40006e-15, -2.66127e-15, 3.40006e-15, 1, 7.45058e-09, 2.66127e-15, -7.45058e-09, 1, 5.70345e-16, 0.132915, -2.04718e-09)
bones/19/enabled = true
bones/19/position = Vector3(5.70345e-16, 0.132915, -2.04718e-09)
bones/19/rotation = Quaternion(0.0911433, -8.20852e-10, 1.38384e-08, 0.995838)
bones/19/rotation = Quaternion(0.0816468, 1.23589e-09, 1.11246e-10, 0.996661)
bones/19/scale = Vector3(1, 1, 1)
bones/20/name = "Tail_3"
bones/20/parent = 19
bones/20/rest = Transform3D(1, 9.71445e-17, -8.4713e-22, -9.71445e-17, 1, 2.13933e-24, 8.4713e-22, -2.13933e-24, 1, -1.10819e-15, 0.132915, -2.98023e-08)
bones/20/enabled = true
bones/20/position = Vector3(-1.10819e-15, 0.132915, -2.98023e-08)
bones/20/rotation = Quaternion(0.0560446, 1.04804e-09, 9.63864e-10, 0.998428)
bones/20/rotation = Quaternion(0.223623, -9.96787e-09, 4.20528e-09, 0.974676)
bones/20/scale = Vector3(1, 1, 1)
bones/21/name = "Tail_4"
bones/21/parent = 20
bones/21/rest = Transform3D(1, 9.71445e-17, -9.72421e-26, -9.71445e-17, 1, 2.13933e-24, 9.72421e-26, -2.13933e-24, 1, -1.16371e-15, 0.132915, -2.98023e-08)
bones/21/enabled = true
bones/21/position = Vector3(-1.16371e-15, 0.132915, -2.98023e-08)
bones/21/rotation = Quaternion(0.186877, 1.51832e-08, 7.26407e-09, 0.982383)
bones/21/rotation = Quaternion(0.196233, -1.68012e-10, -1.19982e-08, 0.980557)
bones/21/scale = Vector3(1, 1, 1)
bones/22/name = "Bone.003"
bones/22/parent = 4
bones/22/rest = Transform3D(1, -6.49611e-08, -1.74055e-08, 1.56754e-08, -0.0265388, 0.999648, -6.54002e-08, -0.999648, -0.0265388, -2.83161e-15, -1.57499e-10, -3.06139e-08)
bones/22/enabled = true
bones/22/position = Vector3(-2.27119e-09, -0.00627534, -0.0291115)
bones/22/rotation = Quaternion(-0.763654, 0.122054, -0.148683, 0.616302)
bones/22/rotation = Quaternion(-0.753283, 0.160595, -0.193783, 0.607637)
bones/22/scale = Vector3(0.963893, 0.963829, 0.963391)
bones/23/name = "Bone.002"
bones/23/parent = 22
bones/23/rest = Transform3D(1, -5.68103e-08, -1.28744e-07, 7.358e-08, 0.990947, 0.13425, 1.19952e-07, -0.13425, 0.990947, 0.103074, 0.0448339, 0.0144274)
bones/23/enabled = true
bones/23/position = Vector3(0.103074, 0.0448339, 0.0144274)
bones/23/rotation = Quaternion(-0.302203, -0.33774, -0.150595, 0.878594)
bones/23/rotation = Quaternion(-0.333369, -0.332199, -0.163174, 0.867112)
bones/23/scale = Vector3(1.00015, 0.999976, 0.999842)
bones/24/name = "L_leg_3"
bones/24/parent = 23
bones/24/rest = Transform3D(1, 1.46768e-07, 1.41892e-07, -1.08988e-07, 0.97155, -0.236835, -1.72615e-07, 0.236835, 0.97155, -1.09502e-08, 0.131148, -7.90992e-09)
bones/24/enabled = true
bones/24/position = Vector3(-1.09502e-08, 0.131148, -7.90992e-09)
bones/24/rotation = Quaternion(0.503263, 4.05288e-08, -2.28607e-07, 0.864134)
bones/24/rotation = Quaternion(0.54995, 2.17932e-08, -2.59321e-07, 0.835198)
bones/24/scale = Vector3(1, 0.999986, 1.00002)
bones/25/name = "R_leg_1"
bones/25/parent = 22
bones/25/rest = Transform3D(1, 5.68103e-08, 2.09964e-07, -8.44838e-08, 0.990947, 0.13425, -2.00436e-07, -0.13425, 0.990947, -0.103074, 0.0448339, 0.0144275)
bones/25/enabled = true
bones/25/position = Vector3(-0.103074, 0.0448339, 0.0144275)
bones/25/rotation = Quaternion(-0.234407, 0.230208, 0.199313, 0.923218)
bones/25/rotation = Quaternion(-0.267903, 0.223457, 0.212234, 0.912826)
bones/25/scale = Vector3(1.00008, 0.999967, 0.999928)
bones/26/name = "R_leg_2"
bones/26/parent = 25
bones/26/rest = Transform3D(1, -1.57459e-07, -1.39286e-07, 1.19991e-07, 0.97155, -0.236835, 1.72615e-07, 0.236835, 0.97155, 1.35965e-08, 0.131148, -5.11595e-09)
bones/26/enabled = true
bones/26/position = Vector3(1.35965e-08, 0.131148, -5.11595e-09)
bones/26/rotation = Quaternion(0.447938, -7.90506e-08, 2.07422e-07, 0.894065)
bones/26/rotation = Quaternion(0.499845, -4.26834e-08, 2.42754e-07, 0.866115)
bones/26/scale = Vector3(1, 0.99997, 1.00006)
bones/27/name = "Bone.013"
bones/27/parent = -1

@ -1,14 +1,8 @@
extends Node3D
const Entity3D = preload("res://scenes/Instance.tscn")
@onready var ground = $Ground
@onready var camera =$Camera
@onready var highlighter = $Highlighter
@onready var gridmap = $GridMap
var highlight = {}

@ -1,17 +1,18 @@
extends GridMap
class_name Chunk
const Entity3D = preload("res://scenes/Instance.tscn")
const Pawn = preload("res://scenes/Pawn.tscn")
var x = 0
var z = 0
var location: Vector2i
var size = 0
var should_remove = false
var chunks_array: Array
func _init(x: int, z: int, size: int):
self.x = x
self.z = z
func _init(x: int, z: int, size: int, chunks_array: Array):
self.location.x = x
self.location.y = z
self.size = size
self.chunks_array = chunks_array
mesh_library = load("res://assets/blocs/blocs.meshlib")
cell_size = Vector3(1, 1, 1)
cell_center_x = false
@ -31,7 +32,7 @@ func _init(x: int, z: int, size: int):
func create_chunk():
for mx in size:
for mz in size:
var position = Vector2i(mx + (size) * x, mz + (size) * z)
var position = Vector2i(mx + (size) * location.x, mz + (size) * location.y)
# position.x = min(position.x, Global.world.width - 1)
# position.y = min(position.y, Global.world.height - 1)
var bloc = Global.world.get_bloc(position)
@ -113,20 +114,20 @@ func create_water():
add_child(static_body)
func is_inside_chunk(position: Vector2i) :
var min_x = x * size
var max_x = (x + 1) * size - 1
var min_y = z * size
var max_y = (z + 1) * size - 1
var min_x = location.x * size
var max_x = (location.x + 1) * size - 1
var min_y = location.y * size
var max_y = (location.y + 1) * size - 1
if position.x >= min_x and position.x <= max_x and position.y >= min_y and position.y <= max_y:
return true
return false
func get_chunk_position(position: Vector2i):
var min_x = x * size
var max_x = (x + 1) * size - 1
var min_y = z * size
var max_y = (z + 1) * size - 1
var min_x = location.x * size
var max_x = (location.x + 1) * size - 1
var min_y = location.y * size
var max_y = (location.y + 1) * size - 1
var chunk_position = Vector2i(position.x - min_x, position.y - min_y)
if chunk_position.x > max_x or chunk_position.y > max_y:
@ -137,8 +138,8 @@ func _on_new_entity(entity):
if is_inside_chunk(entity.position):
var chunk_position = get_chunk_position(entity.position)
var entity_position = Vector3(chunk_position.x, entity.get_height(), chunk_position.y)
var entity_instance = Entity3D.instantiate()
entity_instance.id = entity.id
entity_instance.position = entity_position
entity_instance.connect_to_world(entity_instance.id)
add_child(entity_instance)
var pawn = Pawn.instantiate()
pawn.id = entity.id
pawn.position = entity_position
pawn.connect_to_world(pawn.id, chunks_array)
add_child(pawn)

@ -1,175 +1,25 @@
extends Node3D
const Entity3D = preload("res://scenes/Instance.tscn")
var thread
var displayed_chunks = {} # displayed_chunks
var displayed_chunks = {}
var unready_chunks = {}
#@onready var camera = get_node("Camera3D")
#@export @onready var camera = get_node(camera)
@export var camera: Camera3D
var chunks: Array
func _ready():
thread = Thread.new()
# pass
init_chunks()
# setFloor()
# setEntities()
func init_chunks():
for x in Global.world.width / Global.world.chunk_size:
chunks.append([])
for y in Global.world.height / Global.world.chunk_size:
chunks[x].append([])
chunks[x][y] = Chunk.new(x, y, Global.world.chunk_size)
chunks[x][y] = Chunk.new(x, y, Global.world.chunk_size, chunks)
chunks[x][y].set_name("Chunk")
chunks[x][y]
# print(chunks)
#
#func create_chunk(coord: Vector2i):
# var chunk = GridMap.new()
# for mx in Global.world.chunk_size:
# for mz in Global.world.chunk_size:
# var bloc = Global.world.get_bloc(Vector2i(mx * Global.world.chunk_size, mz * Global.world.chunk_size))
# var my: float = bloc.position.y
# var meshID
# var mesh_rotation
# if bloc.type != 0:
# var neighbours = Global.world.get_neighbours_4_at_same_height(Vector2i(mx, mz))
# if neighbours == Global.directions_4.RIGHT:
# meshID = Global.bloc_sides_id.SIDE_3
# mesh_rotation = Global.GRID_ROTATION[3]
# elif neighbours == Global.directions_4.LEFT:
# meshID = Global.bloc_sides_id.SIDE_3
# mesh_rotation = Global.GRID_ROTATION[1]
# elif neighbours == Global.directions_4.LEFT + Global.directions_4.RIGHT:
# meshID = Global.bloc_sides_id.SIDE_2_OPPOSITE
# mesh_rotation = Global.GRID_ROTATION[0]
# elif neighbours == Global.directions_4.BOTTOM:
# meshID = Global.bloc_sides_id.SIDE_3
# mesh_rotation = Global.GRID_ROTATION[0]
# elif neighbours == Global.directions_4.BOTTOM + Global.directions_4.RIGHT:
# meshID = Global.bloc_sides_id.SIDE_2_ANGLE
# mesh_rotation = Global.GRID_ROTATION[3]
# elif neighbours == Global.directions_4.BOTTOM + Global.directions_4.LEFT:
# meshID = Global.bloc_sides_id.SIDE_2_ANGLE
# mesh_rotation = Global.GRID_ROTATION[0]
# elif neighbours == Global.directions_4.BOTTOM + Global.directions_4.LEFT + Global.directions_4.RIGHT:
# meshID = Global.bloc_sides_id.SIDE_1
# mesh_rotation = Global.GRID_ROTATION[0]
# elif neighbours == Global.directions_4.TOP:
# meshID = Global.bloc_sides_id.SIDE_3
# mesh_rotation = Global.GRID_ROTATION[2]
# elif neighbours == Global.directions_4.TOP + Global.directions_4.RIGHT:
# meshID = Global.bloc_sides_id.SIDE_2_ANGLE
# mesh_rotation = Global.GRID_ROTATION[2]
# elif neighbours == Global.directions_4.TOP + Global.directions_4.LEFT:
# meshID = Global.bloc_sides_id.SIDE_2_ANGLE
# mesh_rotation = Global.GRID_ROTATION[1]
# elif neighbours == Global.directions_4.TOP + Global.directions_4.LEFT + Global.directions_4.RIGHT:
# meshID = Global.bloc_sides_id.SIDE_1
# mesh_rotation = Global.GRID_ROTATION[2]
# elif neighbours == Global.directions_4.TOP + Global.directions_4.BOTTOM:
# meshID = Global.bloc_sides_id.SIDE_2_OPPOSITE
# mesh_rotation = Global.GRID_ROTATION[1]
# elif neighbours == Global.directions_4.TOP + Global.directions_4.BOTTOM + Global.directions_4.RIGHT:
# meshID = Global.bloc_sides_id.SIDE_1
# mesh_rotation = Global.GRID_ROTATION[3]
# elif neighbours == Global.directions_4.TOP + Global.directions_4.BOTTOM + Global.directions_4.LEFT:
# meshID = Global.bloc_sides_id.SIDE_1
# mesh_rotation = Global.GRID_ROTATION[1]
# elif neighbours == Global.directions_4.TOP + Global.directions_4.BOTTOM + Global.directions_4.LEFT + Global.directions_4.RIGHT:
# meshID = Global.bloc_sides_id.SIDE_0
# mesh_rotation = Global.GRID_ROTATION[0]
# elif neighbours == 0:
# meshID = Global.bloc_sides_id.SIDE_4
# mesh_rotation = Global.GRID_ROTATION[0]
#
# chunk.set_cell_item( Vector3(mx, my, mz) , meshID, mesh_rotation)
# return chunk
#func setFloor():
# clear()
# for mz in range(0, Global.world.width - 1):
# for mx in range(0, Global.world.height - 1):
# var bloc = Global.world.get_bloc(Vector2i(mx, mz))
# var my: float = bloc.position.y
# var meshID
# var mesh_rotation
# if bloc.type != 0:
# var neighbours = Global.world.get_neighbours_4_at_same_height(Vector2i(mx, mz))
# if neighbours == Global.directions_4.RIGHT:
# meshID = Global.bloc_sides_id.SIDE_3
# mesh_rotation = Global.GRID_ROTATION[3]
# elif neighbours == Global.directions_4.LEFT:
# meshID = Global.bloc_sides_id.SIDE_3
# mesh_rotation = Global.GRID_ROTATION[1]
# elif neighbours == Global.directions_4.LEFT + Global.directions_4.RIGHT:
# meshID = Global.bloc_sides_id.SIDE_2_OPPOSITE
# mesh_rotation = Global.GRID_ROTATION[0]
# elif neighbours == Global.directions_4.BOTTOM:
# meshID = Global.bloc_sides_id.SIDE_3
# mesh_rotation = Global.GRID_ROTATION[0]
# elif neighbours == Global.directions_4.BOTTOM + Global.directions_4.RIGHT:
# meshID = Global.bloc_sides_id.SIDE_2_ANGLE
# mesh_rotation = Global.GRID_ROTATION[3]
# elif neighbours == Global.directions_4.BOTTOM + Global.directions_4.LEFT:
# meshID = Global.bloc_sides_id.SIDE_2_ANGLE
# mesh_rotation = Global.GRID_ROTATION[0]
# elif neighbours == Global.directions_4.BOTTOM + Global.directions_4.LEFT + Global.directions_4.RIGHT:
# meshID = Global.bloc_sides_id.SIDE_1
# mesh_rotation = Global.GRID_ROTATION[0]
# elif neighbours == Global.directions_4.TOP:
# meshID = Global.bloc_sides_id.SIDE_3
# mesh_rotation = Global.GRID_ROTATION[2]
# elif neighbours == Global.directions_4.TOP + Global.directions_4.RIGHT:
# meshID = Global.bloc_sides_id.SIDE_2_ANGLE
# mesh_rotation = Global.GRID_ROTATION[2]
# elif neighbours == Global.directions_4.TOP + Global.directions_4.LEFT:
# meshID = Global.bloc_sides_id.SIDE_2_ANGLE
# mesh_rotation = Global.GRID_ROTATION[1]
# elif neighbours == Global.directions_4.TOP + Global.directions_4.LEFT + Global.directions_4.RIGHT:
# meshID = Global.bloc_sides_id.SIDE_1
# mesh_rotation = Global.GRID_ROTATION[2]
# elif neighbours == Global.directions_4.TOP + Global.directions_4.BOTTOM:
# meshID = Global.bloc_sides_id.SIDE_2_OPPOSITE
# mesh_rotation = Global.GRID_ROTATION[1]
# elif neighbours == Global.directions_4.TOP + Global.directions_4.BOTTOM + Global.directions_4.RIGHT:
# meshID = Global.bloc_sides_id.SIDE_1
# mesh_rotation = Global.GRID_ROTATION[3]
# elif neighbours == Global.directions_4.TOP + Global.directions_4.BOTTOM + Global.directions_4.LEFT:
# meshID = Global.bloc_sides_id.SIDE_1
# mesh_rotation = Global.GRID_ROTATION[1]
# elif neighbours == Global.directions_4.TOP + Global.directions_4.BOTTOM + Global.directions_4.LEFT + Global.directions_4.RIGHT:
# meshID = Global.bloc_sides_id.SIDE_0
# mesh_rotation = Global.GRID_ROTATION[0]
# elif neighbours == 0:
# meshID = Global.bloc_sides_id.SIDE_4
# mesh_rotation = Global.GRID_ROTATION[0]
#
# set_cell_item( Vector3(mx, my, mz) , meshID, mesh_rotation)
#
#func setEntities():
# for entity in Global.world.entities:
# var entity_instance = Entity3D.instantiate()
# entity_instance.id = entity.id
# entity_instance.position = map_to_local(Vector3(entity.position.x, entity.position.y, entity.position.z))
# entity_instance.connect_to_world(entity_instance.id)
# add_child(entity_instance)
func add_chunk(x, z):
var key = str(x) + "," + str(z)
@ -178,21 +28,7 @@ func add_chunk(x, z):
if not thread.is_started():
thread.start(Callable(self, "load_chunk").bind([thread, x, z]))
# thread.start(self, "load_chunk", [thread, x, z])
unready_chunks[key] = 1
#
#func gen_chunk(array):
# var thread = array[0]
# var x = array[1]
# var z = array[2]
# var chunk = {
# "x": x,
# "y": z,
# "should_remove": true
# }
#
# call_deferred("load_done", chunk, thread)
func load_chunk(array):
var thread = array[0]
@ -204,8 +40,6 @@ func load_chunk(array):
#
# # Chargement du chunk
var chunk = chunks[x][z]
## var chunk = Chunk.new()
# chunk.translate(Vector3(posX * Global.world.chunk_size, 0, posZ * Global.world.chunk_size))
var chunk_position = Vector2(posX, posZ)
chunk.position = Vector3(posX * Global.world.chunk_size, 0, posZ * Global.world.chunk_size)
call_deferred("load_done", chunk, thread, chunk_position)

@ -3,6 +3,7 @@ extends CharacterBody3D
var id = -1
var world_entity
var chunks_array: Array
@onready var ray = $RayCast3D
func _process(delta):
@ -11,29 +12,42 @@ func _process(delta):
var tween = get_tree().create_tween()
tween.tween_property(self, "position:y", height, 0.1)
func connect_to_world(id):
func get_belonging_chunk():
return (world_entity.position / Global.world.chunk_size)
func set_belonging_chunk():
pass
func connect_to_world(id, chunks_array):
world_entity = Global.world.entities[id]
world_entity.moving.connect(_on_entity_moving)
world_entity.changed_state.connect(_on_changed_state)
self.chunks_array = chunks_array
func _on_entity_moving(new_position, speed):
var x_tween = Engine.get_main_loop().create_tween()
var z_tween = Engine.get_main_loop().create_tween()
var rot_tween = Engine.get_main_loop().create_tween()
var position2d = Vector2i(round(position.x), round(position.z))
var distance = Global.world.vec_distance(world_entity.position, new_position)
var new_pawn_position = position2d + distance
x_tween.tween_property(self, "position:x", new_pawn_position.x, 1.0/speed)
z_tween.tween_property(self, "position:z", new_pawn_position.y, 1.0/speed)
var tween = Engine.get_main_loop().create_tween()
tween.set_parallel(true)
tween.tween_property(self, "position:x", new_pawn_position.x, 1.0/speed)
tween.tween_property(self, "position:z", new_pawn_position.y, 1.0/speed)
tween.tween_callback(Callable(self, "update_chunk")).set_delay(1.0/speed)
var vector = Vector2(new_pawn_position.y, new_pawn_position.x) - Vector2(self.position.z, self.position.x)
var angle = vector.angle()
var new_rotation = lerp_angle(position.y, angle, 1)
rot_tween.tween_property(self, "rotation:y", new_rotation, 0.1)
tween.tween_property(self, "rotation:y", new_rotation, 0.1)
func update_chunk():
if get_parent().location != get_belonging_chunk():
var saved_global_position = global_position
get_parent().remove_child(self)
chunks_array[get_belonging_chunk().x][get_belonging_chunk().y].add_child(self)
global_position = saved_global_position
func _on_changed_state(state):
if state == 0:
Loading…
Cancel
Save