Added buch of stuff

This commit is contained in:
douwe
2025-08-31 17:08:50 +02:00
parent 75770bb7ff
commit a232425980
32 changed files with 434 additions and 242 deletions

BIN
assets/base_settler.blend Normal file

Binary file not shown.

View File

@@ -0,0 +1,53 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://b6inciujfvriv"
path="res://.godot/imported/base_settler.blend-385f11519b8771f27b5c8804f07fc5a5.scn"
[deps]
source_file="res://assets/base_settler.blend"
dest_files=["res://.godot/imported/base_settler.blend-385f11519b8771f27b5c8804f07fc5a5.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
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=""
_subresources={}
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/colors=false
blender/meshes/uvs=true
blender/meshes/normals=true
blender/meshes/export_geometry_nodes_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

BIN
assets/base_settler.blend1 Normal file

Binary file not shown.

View File

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

View File

@@ -1,87 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://7q00x01xdsal"]
[ext_resource type="Script" uid="uid://brnfd6h7eh0n7" path="res://nodes/coding/code_runner.gd" id="1_mphwn"]
[node name="CodeRunner" type="Node"]
script = ExtResource("1_mphwn")
[node name="Timer" type="Timer" parent="."]
[node name="ProgrammerUI" type="PanelContainer" parent="."]
anchors_preset = 9
anchor_bottom = 1.0
offset_right = 314.0
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="ProgrammerUI"]
layout_mode = 2
theme_override_constants/separation = 10
[node name="Label" type="Label" parent="ProgrammerUI/VBoxContainer"]
layout_mode = 2
text = "Programming"
horizontal_alignment = 1
[node name="HBoxContainer" type="HBoxContainer" parent="ProgrammerUI/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
[node name="VBoxContainer" type="VBoxContainer" parent="ProgrammerUI/VBoxContainer/HBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="ProgrammerUI/VBoxContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2
text = " Source Code "
[node name="Code" type="CodeEdit" parent="ProgrammerUI/VBoxContainer/HBoxContainer/VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(200, 0)
layout_mode = 2
size_flags_vertical = 3
text = "Set 1 /2
Cpy /2 /3
Add /2 /3 /3
"
placeholder_text = "Code here"
symbol_tooltip_on_hover = true
line_length_guidelines = Array[int]([5, 7, 9, 11])
gutters_draw_executing_lines = true
gutters_draw_line_numbers = true
gutters_zero_pad_line_numbers = true
[node name="Memory" type="VBoxContainer" parent="ProgrammerUI/VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
[node name="HBoxContainer2" type="HBoxContainer" parent="ProgrammerUI/VBoxContainer"]
layout_mode = 2
theme_override_constants/separation = 10
alignment = 1
[node name="compileButton" type="Button" parent="ProgrammerUI/VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = "[C]"
[node name="StopButton" type="Button" parent="ProgrammerUI/VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = "[ ]"
[node name="PlayButton" type="Button" parent="ProgrammerUI/VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = ">"
[node name="PauseButton" type="Button" parent="ProgrammerUI/VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = "||"
[node name="StepButton" type="Button" parent="ProgrammerUI/VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = ">|"
[connection signal="timeout" from="Timer" to="." method="_tick"]
[connection signal="pressed" from="ProgrammerUI/VBoxContainer/HBoxContainer2/compileButton" to="." method="_on_compile_button_pressed"]
[connection signal="pressed" from="ProgrammerUI/VBoxContainer/HBoxContainer2/StopButton" to="." method="_on_stop_button_pressed"]
[connection signal="pressed" from="ProgrammerUI/VBoxContainer/HBoxContainer2/PlayButton" to="." method="_on_play_button_pressed"]
[connection signal="pressed" from="ProgrammerUI/VBoxContainer/HBoxContainer2/PauseButton" to="." method="_on_pause_button_pressed"]
[connection signal="pressed" from="ProgrammerUI/VBoxContainer/HBoxContainer2/StepButton" to="." method="_on_step_button_pressed"]

View File

@@ -0,0 +1,49 @@
[gd_scene load_steps=12 format=3 uid="uid://b84ihb5xw37pm"]
[ext_resource type="PackedScene" uid="uid://chem70rrdwjpg" path="res://nodes/robots/robot.tscn" id="1_p4ude"]
[ext_resource type="VoxelBlockyLibrary" uid="uid://bsue4rd3wdfsl" path="res://nodes/world/BlockLibrary.tres" id="2_x03q5"]
[ext_resource type="Material" uid="uid://de6s8en5fcyyw" path="res://nodes/world/BlockMaterial.tres" id="3_k18g4"]
[ext_resource type="PackedScene" uid="uid://ddyulj4dsrkms" path="res://nodes/world/terrain_editor.tscn" id="4_h5ql1"]
[ext_resource type="Script" uid="uid://cp4pflpo7neyq" path="res://nodes/world/Terrain.gd" id="4_x03q5"]
[ext_resource type="PackedScene" uid="uid://cy0nvmw51bwof" path="res://nodes/camera/controllable_camera.tscn" id="5_cctyy"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_e1sxe"]
sky_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
ground_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
[sub_resource type="Sky" id="Sky_llm6e"]
sky_material = SubResource("ProceduralSkyMaterial_e1sxe")
[sub_resource type="Environment" id="Environment_5yot8"]
background_mode = 2
sky = SubResource("Sky_llm6e")
[sub_resource type="VoxelGeneratorFlat" id="VoxelGeneratorFlat_llm6e"]
channel = 0
[sub_resource type="VoxelMesherBlocky" id="VoxelMesherBlocky_jq1ic"]
library = ExtResource("2_x03q5")
[node name="Robots" type="Node"]
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_5yot8")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(-0.866024, -0.433016, 0.250001, 0, 0.499998, 0.866026, -0.500003, 0.749999, -0.43301, 0, 0, 0)
shadow_enabled = true
[node name="Robot" parent="." instance=ExtResource("1_p4ude")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.5, 0.5)
[node name="VoxelTerrain" type="VoxelTerrain" parent="."]
generator = SubResource("VoxelGeneratorFlat_llm6e")
mesher = SubResource("VoxelMesherBlocky_jq1ic")
bounds = AABB(-1040, -32, -1040, 2080, 96, 2080)
material_override = ExtResource("3_k18g4")
script = ExtResource("4_x03q5")
[node name="TerrainEditor" parent="VoxelTerrain" instance=ExtResource("4_h5ql1")]
[node name="ControllableCamera" parent="." instance=ExtResource("5_cctyy")]
transform = Transform3D(0.97668, -0.143377, 0.159808, 0, 0.744336, 0.667805, -0.214699, -0.652232, 0.726979, 1.39679, 4.07542, 4.92893)

View File

@@ -1,109 +0,0 @@
[gd_scene load_steps=18 format=3 uid="uid://b84ihb5xw37pm"]
[ext_resource type="PackedScene" uid="uid://cy0nvmw51bwof" path="res://nodes/camera/controllable_camera.tscn" id="1_ecqtg"]
[ext_resource type="Script" uid="uid://bnw0h8cuyf3g5" path="res://nodes/robots/robot.gd" id="1_nnl6p"]
[ext_resource type="VoxelBlockyLibrary" uid="uid://bsue4rd3wdfsl" path="res://nodes/word/BlockLibrary.tres" id="1_r886l"]
[ext_resource type="Material" uid="uid://de6s8en5fcyyw" path="res://nodes/word/BlockMaterial.tres" id="2_nnl6p"]
[ext_resource type="PackedScene" uid="uid://ddyulj4dsrkms" path="res://nodes/word/terrain_editor.tscn" id="4_llm6e"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_e1sxe"]
sky_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
ground_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
[sub_resource type="Sky" id="Sky_0wfyh"]
sky_material = SubResource("ProceduralSkyMaterial_e1sxe")
[sub_resource type="Environment" id="Environment_5yot8"]
background_mode = 2
sky = SubResource("Sky_0wfyh")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_o5qli"]
albedo_color = Color(0.313808, 0.455394, 0.721014, 1)
[sub_resource type="BoxMesh" id="BoxMesh_oo1c2"]
material = SubResource("StandardMaterial3D_o5qli")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_r886l"]
albedo_color = Color(0.999686, 0.38438, 0, 1)
[sub_resource type="PrismMesh" id="PrismMesh_nnl6p"]
material = SubResource("StandardMaterial3D_r886l")
size = Vector3(0.5, 0.5, 0.25)
[sub_resource type="TorusMesh" id="TorusMesh_llm6e"]
inner_radius = 0.75
outer_radius = 0.8
rings = 20
ring_segments = 6
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_jq1ic"]
emission_enabled = true
emission = Color(0, 1, 1, 1)
emission_energy_multiplier = 3.0
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_llm6e"]
height = 1.0
[sub_resource type="VoxelGeneratorFlat" id="VoxelGeneratorFlat_llm6e"]
channel = 0
[sub_resource type="VoxelMesherBlocky" id="VoxelMesherBlocky_ofs8c"]
library = ExtResource("1_r886l")
[node name="Robots" type="Node"]
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_5yot8")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(-0.866024, -0.433016, 0.250001, 0, 0.499998, 0.866026, -0.500003, 0.749999, -0.43301, 0, 0, 0)
shadow_enabled = true
[node name="Robot" type="CharacterBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.5, 0.5)
script = ExtResource("1_nnl6p")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Robot"]
mesh = SubResource("BoxMesh_oo1c2")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="Robot"]
transform = Transform3D(-1, 1.50996e-07, -6.60024e-15, 0, -4.37114e-08, -1, -1.50996e-07, -1, 4.37114e-08, 0, 0.50484, -0.3)
mesh = SubResource("PrismMesh_nnl6p")
[node name="indicator" type="Node3D" parent="Robot"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0)
visible = false
[node name="MeshInstance3D3" type="MeshInstance3D" parent="Robot/indicator"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
mesh = SubResource("TorusMesh_llm6e")
skeleton = NodePath("../..")
surface_material_override/0 = SubResource("StandardMaterial3D_jq1ic")
[node name="MeshInstance3D4" type="MeshInstance3D" parent="Robot/indicator"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0)
mesh = SubResource("TorusMesh_llm6e")
skeleton = NodePath("../..")
surface_material_override/0 = SubResource("StandardMaterial3D_jq1ic")
[node name="MeshInstance3D5" type="MeshInstance3D" parent="Robot/indicator"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.2, 0)
mesh = SubResource("TorusMesh_llm6e")
skeleton = NodePath("../..")
surface_material_override/0 = SubResource("StandardMaterial3D_jq1ic")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Robot"]
shape = SubResource("CapsuleShape3D_llm6e")
[node name="VoxelTerrain" type="VoxelTerrain" parent="."]
generator = SubResource("VoxelGeneratorFlat_llm6e")
mesher = SubResource("VoxelMesherBlocky_ofs8c")
bounds = AABB(-1040, -32, -1040, 2080, 96, 2080)
material_override = ExtResource("2_nnl6p")
[node name="TerrainEditor" parent="VoxelTerrain" instance=ExtResource("4_llm6e")]
[node name="ControllableCamera" parent="." instance=ExtResource("1_ecqtg")]
transform = Transform3D(0.97668, -0.143377, 0.159808, 0, 0.744336, 0.667805, -0.214699, -0.652232, 0.726979, 1.39679, 4.07542, 4.92893)
[connection signal="input_event" from="Robot" to="Robot" method="_on_input_event"]

View File

@@ -0,0 +1,57 @@
class_name CPU
extends Node
signal cpu_tick
var cobor_vm := CoborVirtualMachine.new()
var running := false
var register_size := 8
var modules : Array[Module]
func _ready() -> void:
cobor_vm.set_registers(register_size,[])
var register_index := 1
for child in get_children():
if child is Module:
var module := child as Module
modules.push_back(module)
register_size += module.set_registers(register_index)
func run_step() -> void:
if not running:
cobor_vm.set_registers(register_size,[])
running = true
_tick()
func run() -> void:
if not running:
cobor_vm.set_registers(register_size,[])
running = true
$CPUClock.start()
func _tick()->void:
for module in modules:
module.early_tick()
var err := cobor_vm.run_step()
if not err.is_empty():
print(err)
if cobor_vm.get_program_counter() >= cobor_vm.get_program_size():
stop()
for module in modules:
module.late_tick()
emit_signal("cpu_tick")
func pause()->void:
$CPUClock.stop()
func stop()->void:
running = false
$CPUClock.stop()
func compile_code(source_code: String)->void:
var errors := cobor_vm.parse_source_code(source_code)
if errors.is_empty():
print("Compiling Ok!")
else:
for error in errors:
print(error)

View File

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

View File

@@ -0,0 +1,10 @@
[gd_scene load_steps=2 format=3 uid="uid://crtis0eyywl61"]
[ext_resource type="Script" uid="uid://b87ksbp5mjn2a" path="res://nodes/robots/coding/cpu.gd" id="1_mh3k1"]
[node name="CPU" type="Node"]
script = ExtResource("1_mh3k1")
[node name="CPUClock" type="Timer" parent="."]
[connection signal="timeout" from="CPUClock" to="." method="_tick"]

View File

@@ -14,3 +14,7 @@ allow_greater = true
allow_lesser = true allow_lesser = true
alignment = 1 alignment = 1
editable = false editable = false
[node name="name" type="Label" parent="."]
layout_mode = 2
text = "[X] Click"

View File

@@ -1,54 +1,47 @@
extends Node extends PanelContainer
@onready var code_editor := $%Code as CodeEdit @onready var code_editor := $%Code as CodeEdit
@onready var memory := $%Memory as VBoxContainer @onready var memory := $%Memory as VBoxContainer
@onready var memory_entry := load("uid://dqwi5rekytyds") as PackedScene @onready var memory_entry := load("uid://dqwi5rekytyds") as PackedScene
var cobor_vm := CoborVirtualMachine.new()
@export var cpu : CPU
func _ready() -> void: func _ready() -> void:
cobor_vm.set_registers(8,[]) for i in range(cpu.register_size):
for i in range(8):
var entry := memory_entry.instantiate() as Control var entry := memory_entry.instantiate() as Control
(entry.get_node("address") as Label).text = "/" + str(i) + " = " (entry.get_node("address") as Label).text = "[/" + str(i) + "]"
(entry.get_node("value") as SpinBox).value = 0 (entry.get_node("value") as SpinBox).value = 0
memory.add_child(entry) memory.add_child(entry)
func _tick() -> void: func _process(_delta: float) -> void:
if code_editor.editable: return # Set execution indicator
for line in code_editor.get_executing_lines(): for line in code_editor.get_executing_lines():
code_editor.set_line_as_executing(line, false) code_editor.set_line_as_executing(line, false)
code_editor.set_line_as_executing(cobor_vm.get_program_counter(), true) code_editor.set_line_as_executing(cpu.cobor_vm.get_program_counter(), true)
var err := cobor_vm.run_step() # Show register values
if not err.is_empty(): var registers := cpu.cobor_vm.get_registers()
print(err); for i in range(registers.size()):
var registers := cobor_vm.get_registers()
for i in range(8):
var entry := memory.get_child(i) as Control var entry := memory.get_child(i) as Control
(entry.get_node("value") as SpinBox).value = registers[i] (entry.get_node("value") as SpinBox).value = registers[i]
func _on_compile_button_pressed() -> void: func _on_compile_button_pressed() -> void:
var text := code_editor.text cpu.compile_code(code_editor.text)
var errors := cobor_vm.parse_source_code(text)
if errors.is_empty():
print("Compiling Ok!")
else:
for error in errors:
print(error)
func _on_stop_button_pressed() -> void: func _on_stop_button_pressed() -> void:
code_editor.editable = true code_editor.editable = true
$Timer.stop() cpu.stop()
cobor_vm.set_registers(8,[])
func _on_play_button_pressed() -> void: func _on_play_button_pressed() -> void:
if code_editor.editable:
cpu.compile_code(code_editor.text)
code_editor.editable = false code_editor.editable = false
_on_compile_button_pressed(); cpu.run()
$Timer.start()
func _on_pause_button_pressed() -> void: func _on_pause_button_pressed() -> void:
$Timer.stop() cpu.pause()
func _on_step_button_pressed() -> void: func _on_step_button_pressed() -> void:
if code_editor.editable:
cpu.compile_code(code_editor.text)
code_editor.editable = false code_editor.editable = false
_tick() cpu.run_step()

View File

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

View File

@@ -0,0 +1,77 @@
[gd_scene load_steps=2 format=3 uid="uid://c2es6v8lb8tug"]
[ext_resource type="Script" uid="uid://csub2er5wvqj3" path="res://nodes/robots/coding/programming_ui.gd" id="1_qk3c3"]
[node name="ProgrammingUI" type="PanelContainer"]
anchors_preset = 9
anchor_bottom = 1.0
offset_right = 314.0
grow_vertical = 2
script = ExtResource("1_qk3c3")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 2
theme_override_constants/separation = 10
[node name="Label" type="Label" parent="VBoxContainer"]
layout_mode = 2
text = "Programming"
horizontal_alignment = 1
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/HBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2
text = " Source Code "
[node name="Code" type="CodeEdit" parent="VBoxContainer/HBoxContainer/VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(200, 0)
layout_mode = 2
size_flags_vertical = 3
placeholder_text = "Code here..."
symbol_tooltip_on_hover = true
gutters_draw_executing_lines = true
gutters_draw_line_numbers = true
gutters_zero_pad_line_numbers = true
indent_automatic = true
[node name="Memory" type="VBoxContainer" parent="VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer"]
layout_mode = 2
theme_override_constants/separation = 10
alignment = 1
[node name="compileButton" type="Button" parent="VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = "[C]"
[node name="StopButton" type="Button" parent="VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = "[ ]"
[node name="PlayButton" type="Button" parent="VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = ">"
[node name="PauseButton" type="Button" parent="VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = "||"
[node name="StepButton" type="Button" parent="VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = ">|"
[connection signal="pressed" from="VBoxContainer/HBoxContainer2/compileButton" to="." method="_on_compile_button_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer2/StopButton" to="." method="_on_stop_button_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer2/PlayButton" to="." method="_on_play_button_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer2/PauseButton" to="." method="_on_pause_button_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer2/StepButton" to="." method="_on_step_button_pressed"]

View File

@@ -0,0 +1,12 @@
class_name Module extends Node
@onready var cpu := get_parent() as CPU
func set_registers(index:int)->int:
return 0
func early_tick()->void:
pass
func late_tick()->void:
pass

View File

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

View File

@@ -0,0 +1,39 @@
extends Module
var enabled := true
var pos_x_register_index:int
var pos_y_register_index:int
var pos_z_register_index:int
func _ready() -> void:
if Terrain.instance == null:
print("No terrain to get clicks from")
func set_registers(index:int)->int:
pos_x_register_index = index
pos_y_register_index = index+1
pos_z_register_index = index+2
return 3
func _unhandled_input(event: InputEvent) -> void:
if not enabled: return
if event is InputEventMouseButton and event.is_pressed():
var button_event = event as InputEventMouseButton
if button_event.button_index == MOUSE_BUTTON_LEFT:
set_click_registers()
elif button_event.button_index == MOUSE_BUTTON_RIGHT:
pass
func set_click_registers()->void:
var mouse_pos_2d := get_viewport().get_mouse_position()
var current_camera := get_viewport().get_camera_3d()
var origin := current_camera.project_ray_origin(mouse_pos_2d)
var dir := current_camera.project_ray_normal(mouse_pos_2d)
var res := Terrain.instance.get_voxel_tool().raycast(origin, dir, 100)
var registers := cpu.cobor_vm.get_registers()
registers[pos_x_register_index] = res.previous_position.x
registers[pos_y_register_index] = res.previous_position.y
registers[pos_z_register_index] = res.previous_position.z
cpu.cobor_vm.set_registers(cpu.register_size, registers)

View File

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

View File

@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://d22umiybuk0xf"]
[ext_resource type="Script" uid="uid://dii2n2xcatyuh" path="res://nodes/robots/modules/player_click_module.gd" id="1_few5k"]
[node name="PlayerClickModule" type="Node"]
script = ExtResource("1_few5k")

View File

@@ -9,10 +9,10 @@ func _on_input_event(camera: Node, event: InputEvent, event_position: Vector3, n
if event is InputEventMouseButton and event.is_pressed(): if event is InputEventMouseButton and event.is_pressed():
var button_event = event as InputEventMouseButton var button_event = event as InputEventMouseButton
if button_event.button_index == MOUSE_BUTTON_LEFT: if button_event.button_index == MOUSE_BUTTON_LEFT:
$indicator.visible = true $ProgrammingUI.visible = true
selected = true selected = true
elif button_event.button_index == MOUSE_BUTTON_RIGHT: elif button_event.button_index == MOUSE_BUTTON_RIGHT:
$indicator.visible = false $ProgrammingUI.visible = false
selected = false selected = false
func _unhandled_input(event: InputEvent) -> void: func _unhandled_input(event: InputEvent) -> void:
@@ -34,6 +34,7 @@ func move_to_mouse_click():
path_finder.set_terrain(terrain) path_finder.set_terrain(terrain)
path_finder.set_region(AABB(Vector3.ONE * -100, Vector3.ONE * 200)) path_finder.set_region(AABB(Vector3.ONE * -100, Vector3.ONE * 200))
path = path_finder.find_path(Vector3i(global_position), res.previous_position) path = path_finder.find_path(Vector3i(global_position), res.previous_position)
if not path.is_empty():
path.append(res.previous_position) path.append(res.previous_position)
for step in path: for step in path:
print(step) print(step)

48
nodes/robots/robot.tscn Normal file
View File

@@ -0,0 +1,48 @@
[gd_scene load_steps=10 format=3 uid="uid://chem70rrdwjpg"]
[ext_resource type="Script" uid="uid://bnw0h8cuyf3g5" path="res://nodes/robots/robot.gd" id="1_suikl"]
[ext_resource type="PackedScene" uid="uid://c2es6v8lb8tug" path="res://nodes/robots/coding/programming_ui.tscn" id="3_tmdoi"]
[ext_resource type="PackedScene" uid="uid://d22umiybuk0xf" path="res://nodes/robots/modules/player_click_module.tscn" id="4_hm8dm"]
[ext_resource type="PackedScene" uid="uid://crtis0eyywl61" path="res://nodes/robots/coding/cpu.tscn" id="5_r4wpy"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_hm8dm"]
albedo_color = Color(0, 0.52959, 0.856942, 1)
[sub_resource type="BoxMesh" id="BoxMesh_hm8dm"]
material = SubResource("StandardMaterial3D_hm8dm")
size = Vector3(1, 0.9, 1)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_r4wpy"]
albedo_color = Color(1, 0.447059, 0, 1)
[sub_resource type="PrismMesh" id="PrismMesh_hm8dm"]
material = SubResource("StandardMaterial3D_r4wpy")
size = Vector3(0.4, 0.7, 0.1)
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_llm6e"]
radius = 0.4
height = 0.8
[node name="Robot" type="CharacterBody3D"]
script = ExtResource("1_suikl")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.1, 0)
mesh = SubResource("BoxMesh_hm8dm")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="MeshInstance3D"]
transform = Transform3D(1.91069e-15, -1, -4.37114e-08, -4.37114e-08, -4.37114e-08, 1, -1, 0, -4.37114e-08, 0, 0.5, 0)
mesh = SubResource("PrismMesh_hm8dm")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("CapsuleShape3D_llm6e")
[node name="ProgrammingUI" parent="." node_paths=PackedStringArray("cpu") instance=ExtResource("3_tmdoi")]
cpu = NodePath("../CPU")
[node name="CPU" parent="." instance=ExtResource("5_r4wpy")]
[node name="PlayerClickModule" parent="CPU" instance=ExtResource("4_hm8dm")]
[connection signal="input_event" from="." to="." method="_on_input_event"]
[connection signal="cpu_tick" from="CPU" to="ProgrammingUI" method="_on_cpu_tick"]

View File

@@ -1,6 +1,6 @@
[gd_resource type="VoxelBlockyLibrary" load_steps=4 format=3 uid="uid://bsue4rd3wdfsl"] [gd_resource type="VoxelBlockyLibrary" load_steps=4 format=3 uid="uid://bsue4rd3wdfsl"]
[ext_resource type="Material" uid="uid://de6s8en5fcyyw" path="res://nodes/word/BlockMaterial.tres" id="1_evy8o"] [ext_resource type="Material" uid="uid://de6s8en5fcyyw" path="res://nodes/world/BlockMaterial.tres" id="1_evy8o"]
[sub_resource type="VoxelBlockyModelEmpty" id="VoxelBlockyModelEmpty_o5qli"] [sub_resource type="VoxelBlockyModelEmpty" id="VoxelBlockyModelEmpty_o5qli"]

View File

@@ -1,6 +1,6 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://de6s8en5fcyyw"] [gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://de6s8en5fcyyw"]
[ext_resource type="Texture2D" uid="uid://bcctuptks33yd" path="res://nodes/word/blocky_game_atlas.webp" id="1_nmlo6"] [ext_resource type="Texture2D" uid="uid://bcctuptks33yd" path="res://nodes/world/blocky_game_atlas.webp" id="1_nmlo6"]
[resource] [resource]
albedo_texture = ExtResource("1_nmlo6") albedo_texture = ExtResource("1_nmlo6")

6
nodes/world/Terrain.gd Normal file
View File

@@ -0,0 +1,6 @@
class_name Terrain extends VoxelTerrain
static var instance:Terrain
func _init() -> void:
instance = self

View File

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

View File

@@ -1,9 +1,10 @@
[gd_scene load_steps=11 format=3 uid="uid://bp6ewa3urgac8"] [gd_scene load_steps=12 format=3 uid="uid://bp6ewa3urgac8"]
[ext_resource type="VoxelBlockyLibrary" uid="uid://bsue4rd3wdfsl" path="res://nodes/word/BlockLibrary.tres" id="1_yf87h"] [ext_resource type="VoxelBlockyLibrary" uid="uid://bsue4rd3wdfsl" path="res://nodes/world/BlockLibrary.tres" id="1_4rm5p"]
[ext_resource type="Material" uid="uid://de6s8en5fcyyw" path="res://nodes/word/BlockMaterial.tres" id="2_j4yt8"] [ext_resource type="Material" uid="uid://de6s8en5fcyyw" path="res://nodes/world/BlockMaterial.tres" id="2_yirul"]
[ext_resource type="PackedScene" uid="uid://cy0nvmw51bwof" path="res://nodes/camera/controllable_camera.tscn" id="3_tcius"] [ext_resource type="PackedScene" uid="uid://ddyulj4dsrkms" path="res://nodes/world/terrain_editor.tscn" id="3_heupn"]
[ext_resource type="PackedScene" uid="uid://ddyulj4dsrkms" path="res://nodes/word/terrain_editor.tscn" id="3_v3kfg"] [ext_resource type="Script" uid="uid://cp4pflpo7neyq" path="res://nodes/world/Terrain.gd" id="3_yirul"]
[ext_resource type="PackedScene" uid="uid://cy0nvmw51bwof" path="res://nodes/camera/controllable_camera.tscn" id="4_ublpu"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_gadlc"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_gadlc"]
sky_horizon_color = Color(0.662243, 0.671743, 0.686743, 1) sky_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
@@ -25,7 +26,7 @@ height_range = 20.0
noise = SubResource("FastNoiseLite_v3kfg") noise = SubResource("FastNoiseLite_v3kfg")
[sub_resource type="VoxelMesherBlocky" id="VoxelMesherBlocky_3tbtj"] [sub_resource type="VoxelMesherBlocky" id="VoxelMesherBlocky_3tbtj"]
library = ExtResource("1_yf87h") library = ExtResource("1_4rm5p")
[node name="VoxelWorld" type="Node"] [node name="VoxelWorld" type="Node"]
@@ -41,9 +42,10 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4, 0)
generator = SubResource("VoxelGeneratorNoise2D_mko3u") generator = SubResource("VoxelGeneratorNoise2D_mko3u")
mesher = SubResource("VoxelMesherBlocky_3tbtj") mesher = SubResource("VoxelMesherBlocky_3tbtj")
bounds = AABB(-1040, -32, -1040, 2080, 96, 2080) bounds = AABB(-1040, -32, -1040, 2080, 96, 2080)
material_override = ExtResource("2_j4yt8") material_override = ExtResource("2_yirul")
script = ExtResource("3_yirul")
[node name="TerrainEditor" parent="VoxelTerrain" instance=ExtResource("3_v3kfg")] [node name="TerrainEditor" parent="VoxelTerrain" instance=ExtResource("3_heupn")]
[node name="ControllableCamera" parent="." instance=ExtResource("3_tcius")] [node name="ControllableCamera" parent="." instance=ExtResource("4_ublpu")]
transform = Transform3D(-0.61081, -0.620921, 0.491291, 0, 0.620492, 0.784213, -0.791777, 0.479005, -0.379003, 34.4662, 28.9798, -20.4) transform = Transform3D(-0.61081, -0.620921, 0.491291, 0, 0.620492, 0.784213, -0.791777, 0.479005, -0.379003, 34.4662, 28.9798, -20.4)

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -3,7 +3,7 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://bcctuptks33yd" uid="uid://bcctuptks33yd"
path.s3tc="res://.godot/imported/blocky_game_atlas.webp-87ad14449ec94b96fe28d0038a51ce08.s3tc.ctex" path.s3tc="res://.godot/imported/blocky_game_atlas.webp-23ee11425f1b691f850e88290909a9fb.s3tc.ctex"
metadata={ metadata={
"imported_formats": ["s3tc_bptc"], "imported_formats": ["s3tc_bptc"],
"vram_texture": true "vram_texture": true
@@ -11,8 +11,8 @@ metadata={
[deps] [deps]
source_file="res://nodes/word/blocky_game_atlas.webp" source_file="res://nodes/world/blocky_game_atlas.webp"
dest_files=["res://.godot/imported/blocky_game_atlas.webp-87ad14449ec94b96fe28d0038a51ce08.s3tc.ctex"] dest_files=["res://.godot/imported/blocky_game_atlas.webp-23ee11425f1b691f850e88290909a9fb.s3tc.ctex"]
[params] [params]

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://ddyulj4dsrkms"] [gd_scene load_steps=2 format=3 uid="uid://ddyulj4dsrkms"]
[ext_resource type="Script" uid="uid://vnjdiql72brq" path="res://nodes/word/terrain_editor.gd" id="1_6evft"] [ext_resource type="Script" uid="uid://vnjdiql72brq" path="res://nodes/world/terrain_editor.gd" id="1_6evft"]
[node name="TerrainEditor" type="Node"] [node name="TerrainEditor" type="Node"]
script = ExtResource("1_6evft") script = ExtResource("1_6evft")

View File

@@ -15,6 +15,33 @@ run/main_scene="uid://d0b7m4vykcfy2"
config/features=PackedStringArray("4.4") config/features=PackedStringArray("4.4")
config/icon="res://icon.svg" config/icon="res://icon.svg"
[importer_defaults]
scene={
"_subresources": {},
"animation/fps": 30,
"animation/import": true,
"animation/import_rest_as_RESET": false,
"animation/remove_immutable_tracks": true,
"animation/trimming": false,
"gltf/embedded_image_handling": 0,
"gltf/naming_version": 1,
"import_script/path": "",
"meshes/create_shadow_meshes": true,
"meshes/ensure_tangents": true,
"meshes/force_disable_compression": false,
"meshes/generate_lods": true,
"meshes/light_baking": 1,
"meshes/lightmap_texel_size": 0.2,
"nodes/apply_root_scale": true,
"nodes/import_as_skeleton_bones": false,
"nodes/root_name": "",
"nodes/root_scale": 1.0,
"nodes/root_type": "",
"nodes/use_node_type_suffixes": true,
"skins/use_named_skins": true
}
[input] [input]
camera_control={ camera_control={