Add files via upload
72
addons/brackets/dock.tscn
Normal file
@ -0,0 +1,72 @@
|
||||
[gd_scene format=2]
|
||||
|
||||
[node name="Brackets" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="[" type="Button" parent="."]
|
||||
margin_right = 50.0
|
||||
margin_bottom = 50.0
|
||||
text = "["
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="]" type="Button" parent="."]
|
||||
margin_left = 50.0
|
||||
margin_right = 100.0
|
||||
margin_bottom = 50.0
|
||||
text = "]"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="[]" type="Button" parent="."]
|
||||
margin_left = 100.0
|
||||
margin_right = 150.0
|
||||
margin_bottom = 50.0
|
||||
text = "[]"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="{" type="Button" parent="."]
|
||||
margin_top = 50.0
|
||||
margin_right = 50.0
|
||||
margin_bottom = 100.0
|
||||
text = "{"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="}" type="Button" parent="."]
|
||||
margin_left = 50.0
|
||||
margin_top = 50.0
|
||||
margin_right = 100.0
|
||||
margin_bottom = 100.0
|
||||
text = "}"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="{}" type="Button" parent="."]
|
||||
margin_left = 100.0
|
||||
margin_top = 50.0
|
||||
margin_right = 150.0
|
||||
margin_bottom = 100.0
|
||||
text = "{}"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="$" type="Button" parent="."]
|
||||
margin_left = 150.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 50.0
|
||||
text = "$"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
7
addons/brackets/plugin.cfg
Normal file
@ -0,0 +1,7 @@
|
||||
[plugin]
|
||||
|
||||
name="Brackets"
|
||||
description="Gives brackets"
|
||||
author="AiTechEye"
|
||||
version="1.0"
|
||||
script="script.gd"
|
33
addons/brackets/script.gd
Normal file
@ -0,0 +1,33 @@
|
||||
tool
|
||||
extends EditorPlugin
|
||||
var dock
|
||||
|
||||
func _enter_tree():
|
||||
dock = preload("res://addons/brackets/dock.tscn").instance()
|
||||
add_control_to_dock(EditorPlugin.DOCK_SLOT_LEFT_BR,dock)
|
||||
dock.get_node("[").connect("button_down",self,"b1")
|
||||
dock.get_node("]").connect("button_down",self,"b2")
|
||||
dock.get_node("[]").connect("button_down",self,"b3")
|
||||
dock.get_node("{").connect("button_down",self,"b4")
|
||||
dock.get_node("}").connect("button_down",self,"b5")
|
||||
dock.get_node("{}").connect("button_down",self,"b6")
|
||||
dock.get_node("$").connect("button_down",self,"b7")
|
||||
func _exit_tree():
|
||||
remove_control_from_docks(dock)
|
||||
func b1():
|
||||
OS.set_clipboard("[")
|
||||
func b2():
|
||||
OS.set_clipboard("]")
|
||||
func b3():
|
||||
OS.set_clipboard("[]")
|
||||
func b4():
|
||||
OS.set_clipboard("{")
|
||||
func b5():
|
||||
OS.set_clipboard("}")
|
||||
func b6():
|
||||
OS.set_clipboard("{}")
|
||||
func b7():
|
||||
OS.set_clipboard("$")
|
||||
|
||||
|
||||
|
7
default_env.tres
Normal file
@ -0,0 +1,7 @@
|
||||
[gd_resource type="Environment" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="ProceduralSky" id=1]
|
||||
|
||||
[resource]
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
225
engine/MainManu/MainManu.gd
Normal file
@ -0,0 +1,225 @@
|
||||
extends Control
|
||||
|
||||
var new_world = false
|
||||
var del_world = false
|
||||
var del_mod = false
|
||||
var worlds = {}
|
||||
var mods = {}
|
||||
var selected = {mod=0,world=0}
|
||||
func _ready():
|
||||
scan()
|
||||
$Camera/mesh.mesh = core.item2mesh("default:grassy")
|
||||
for i in mapgen.mapgens:
|
||||
$panel/new/mapagens.add_item(i)
|
||||
|
||||
func _process(delta):
|
||||
delta *= 0.5
|
||||
$Camera/mesh.rotation += Vector3(randf()*delta,randf()*delta,randf()*delta)
|
||||
|
||||
func scan():
|
||||
worlds.clear()
|
||||
$panel/worlds.clear()
|
||||
var DIR = "user://worlds"
|
||||
var d = Directory.new()
|
||||
d.open(DIR)
|
||||
d.list_dir_begin()
|
||||
var dir = d.get_next()
|
||||
while dir != "":
|
||||
if dir.begins_with(".") == false:
|
||||
var cd = str(d.get_current_dir(),"/",dir)
|
||||
if dir.get_extension() == "mworld":
|
||||
load_world_properties(cd)
|
||||
dir = d.get_next()
|
||||
d.list_dir_end()
|
||||
$panel/mods.clear()
|
||||
mods = WaEngine.scan("user://mods",{},true)
|
||||
$panel/worlds.select(0)
|
||||
worlds_selected(0)
|
||||
for i in $panel/mods.get_selected_items():
|
||||
var m = $panel/mods.get_item_text(i)
|
||||
mod_info(m)
|
||||
for ii in $panel/worlds.get_selected_items():
|
||||
var w = $panel/worlds.get_item_text(ii)
|
||||
$panel/modding/enable.pressed = true if worlds[w].get(m) == true else false
|
||||
break
|
||||
break
|
||||
if mods.size() == 0:
|
||||
$panel/modding/DelMod.disabled = true
|
||||
func mod_info(m):
|
||||
var i = mods.get(m)
|
||||
if i == null or i.get("broken"):
|
||||
$panel/modding/enable.disabled = true
|
||||
return
|
||||
var w = $panel/worlds.get_item_text(selected.world)
|
||||
$panel/modding/actor_info.text = i.actor
|
||||
$panel/modding/version_info.text = str(i.mod_version)
|
||||
$panel/modding/build_info.text = str(i.game_version)
|
||||
$panel/modding/Description_text.text = i.description
|
||||
$panel/modding/enable.pressed = true if worlds.get(w) != null and worlds[w].get(m) == true else false
|
||||
$panel/modding/enable.disabled = false
|
||||
func update_mod_list(w):
|
||||
$panel/mods.clear()
|
||||
var n = 0
|
||||
for i in mods:
|
||||
if mods[i] == null or mods[i].get("broken"):
|
||||
$panel/mods.add_item(str(i," (broken)"))
|
||||
$panel/mods.set_item_custom_bg_color(n,Color(1,0,0,0.2))
|
||||
else:
|
||||
$panel/mods.add_item(mods[i].name)
|
||||
if w != "" and worlds[w].get(mods[i].name) == true:
|
||||
$panel/mods.set_item_custom_bg_color(n,Color(0,1,0,0.2))
|
||||
n += 1
|
||||
|
||||
func load_world_properties(path):
|
||||
var file = File.new()
|
||||
file.open(path,file.READ)
|
||||
var s = file.get_var()
|
||||
file.close()
|
||||
var name = path.get_file().replace(str(".",path.get_extension()),"")
|
||||
worlds[name] = s.mods
|
||||
$panel/worlds.add_item(name)
|
||||
|
||||
func new_pressed():
|
||||
if new_world:
|
||||
if $panel/new/name.text.is_valid_filename():
|
||||
core.world_name = $panel/new/name.text
|
||||
core.world.mapgen = mapgen.mapgens[$panel/new/mapagens.selected]
|
||||
core.save_data()
|
||||
cancel()
|
||||
scan()
|
||||
else:
|
||||
core.option_flash($panel/new/name,"Invalid name")
|
||||
else:
|
||||
$panel/new.text = "Create"
|
||||
$panel/new/name.visible = true
|
||||
$panel/play.text = "Cancel"
|
||||
$panel/play.text = "Cancel"
|
||||
$panel/new/mapagens.visible = true
|
||||
var file = File.new()
|
||||
var i = 1
|
||||
while file.file_exists(str("user://worlds/world",i,".mworld")):
|
||||
i += 1
|
||||
$panel/new/name.text = str("world",i)
|
||||
$panel/new/name.select_all()
|
||||
new_world = true
|
||||
func cancel():
|
||||
$panel/new.text = "New world"
|
||||
$panel/new/name.visible = false
|
||||
$panel/new/name.text = ""
|
||||
$panel/play.text = "Play"
|
||||
$panel/del.text = "Delete"
|
||||
$panel/new.visible = true
|
||||
$panel/modding/DelMod.text = "Delete mod"
|
||||
$panel/modding/DelMod.rect_size = Vector2(1,1)
|
||||
$panel/modding/OpenDir.text = "Game folder"
|
||||
$panel/new/mapagens.visible = false
|
||||
del_mod = false
|
||||
new_world = false
|
||||
del_world = false
|
||||
|
||||
func play():
|
||||
if new_world or del_world:
|
||||
cancel()
|
||||
return
|
||||
var name
|
||||
for i in $panel/worlds.get_selected_items():
|
||||
name = $panel/worlds.get_item_text(i)
|
||||
break
|
||||
if name != null:
|
||||
core.world_name = name
|
||||
var file = File.new()
|
||||
if not file.file_exists(str("user://worlds/",name,".mworld")):
|
||||
core.world_name = ""
|
||||
core.option_flash($panel/play,"The world doesn't exists anymore")
|
||||
scan()
|
||||
else:
|
||||
core.world_main()
|
||||
queue_free()
|
||||
func delworld():
|
||||
var name
|
||||
for i in $panel/worlds.get_selected_items():
|
||||
name = $panel/worlds.get_item_text(i)
|
||||
break
|
||||
if del_world:
|
||||
$panel/del.text = "Delete"
|
||||
core.delete_data(name)
|
||||
cancel()
|
||||
scan()
|
||||
elif $panel/del.text != "":
|
||||
$panel/del.text = str("Delete ",name," ?")
|
||||
$panel/play.text = "Cancel"
|
||||
$panel/new.visible = false
|
||||
del_world = true
|
||||
|
||||
func _input(event):
|
||||
if Input.is_action_just_pressed("ui_cancel"):
|
||||
get_tree().quit()
|
||||
func _notification(what):
|
||||
if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST:
|
||||
get_tree().quit()
|
||||
|
||||
func OpenGF():
|
||||
if del_mod:
|
||||
cancel()
|
||||
return
|
||||
OS.shell_open(ProjectSettings.globalize_path("user://"))
|
||||
|
||||
func enable_mod():
|
||||
var w
|
||||
var m
|
||||
var mi
|
||||
for i in $panel/worlds.get_selected_items():
|
||||
w = $panel/worlds.get_item_text(i)
|
||||
break
|
||||
for i in $panel/mods.get_selected_items():
|
||||
m = $panel/mods.get_item_text(i)
|
||||
mi = i
|
||||
break
|
||||
if w != null and m != null:
|
||||
worlds[w][m] = $panel/modding/enable.pressed
|
||||
update_mod_list(w)
|
||||
$panel/mods.select(mi)
|
||||
|
||||
var file = File.new()
|
||||
if file.file_exists(str("user://worlds/",w,".mworld")):
|
||||
file.open(str("user://worlds/",w,".mworld"),file.READ)
|
||||
var s = file.get_var()
|
||||
file.close()
|
||||
file.open(str("user://worlds/",w,".mworld"),file.WRITE_READ)
|
||||
s.mods = worlds[w]
|
||||
file.store_var(s)
|
||||
file.close()
|
||||
|
||||
func mods_selected(index):
|
||||
var w
|
||||
var m
|
||||
for i in $panel/worlds.get_selected_items():
|
||||
w = $panel/worlds.get_item_text(i)
|
||||
break
|
||||
for i in $panel/mods.get_selected_items():
|
||||
m = $panel/mods.get_item_text(i)
|
||||
break
|
||||
if w != null and m != null:
|
||||
$panel/modding/enable.pressed = true if worlds[w].get(m) == true else false
|
||||
selected.mod = index
|
||||
mod_info(m)
|
||||
|
||||
func worlds_selected(index):
|
||||
update_mod_list($panel/worlds.get_item_text(index))
|
||||
selected.world = index
|
||||
if $panel/mods.get_item_count() > 0:
|
||||
$panel/mods.select(selected.mod)
|
||||
mod_info($panel/mods.get_item_text(selected.mod))
|
||||
|
||||
func DelMod():
|
||||
if del_mod:
|
||||
selected.mod = 0
|
||||
cancel()
|
||||
var d = Directory.new()
|
||||
var p = mods[$panel/mods.get_item_text(selected.mod).replace(" (broken)","")].path
|
||||
d.remove(p)
|
||||
scan()
|
||||
else:
|
||||
del_mod = true
|
||||
$panel/modding/OpenDir.text = "Cancel"
|
||||
$panel/modding/DelMod.text = str("Delete ",$panel/mods.get_item_text(selected.mod)," ?")
|
225
engine/MainManu/MainManu.tscn
Normal file
@ -0,0 +1,225 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://engine/MainManu/MainManu.gd" type="Script" id=1]
|
||||
|
||||
[node name="MainManu" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_lock_": true,
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Camera" type="Camera" parent="."]
|
||||
current = true
|
||||
|
||||
[node name="mesh" type="MeshInstance" parent="Camera"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1.47059 )
|
||||
|
||||
[node name="panel" type="ColorRect" parent="."]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -237.0
|
||||
margin_top = -144.0
|
||||
margin_right = 237.0
|
||||
margin_bottom = 144.0
|
||||
color = Color( 0.145098, 0.145098, 0.145098, 0.145098 )
|
||||
__meta__ = {
|
||||
"_edit_lock_": true,
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="play" type="Button" parent="panel"]
|
||||
margin_left = 205.0
|
||||
margin_top = 4.0
|
||||
margin_right = 286.0
|
||||
margin_bottom = 24.0
|
||||
text = "Play"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="del" type="Button" parent="panel"]
|
||||
margin_left = 205.0
|
||||
margin_top = 26.0
|
||||
margin_right = 286.0
|
||||
margin_bottom = 46.0
|
||||
text = "Delete"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="new" type="Button" parent="panel"]
|
||||
margin_left = 286.0
|
||||
margin_top = 4.0
|
||||
margin_right = 367.0
|
||||
margin_bottom = 24.0
|
||||
text = "New world"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="name" type="LineEdit" parent="panel/new"]
|
||||
visible = false
|
||||
margin_left = 83.0
|
||||
margin_top = -2.0
|
||||
margin_right = 188.0
|
||||
margin_bottom = 22.0
|
||||
hint_tooltip = "World name"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="mapagens" type="OptionButton" parent="panel/new"]
|
||||
visible = false
|
||||
margin_left = 83.0
|
||||
margin_top = 22.0
|
||||
margin_right = 188.0
|
||||
margin_bottom = 42.0
|
||||
text = "mapgen"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="worlds" type="ItemList" parent="panel"]
|
||||
margin_right = 200.0
|
||||
margin_bottom = 130.0
|
||||
__meta__ = {
|
||||
"_edit_lock_": true,
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="mods" type="ItemList" parent="panel"]
|
||||
margin_top = 130.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 288.0
|
||||
__meta__ = {
|
||||
"_edit_lock_": true,
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="modding" type="Control" parent="panel"]
|
||||
margin_left = 200.0
|
||||
margin_top = 130.0
|
||||
margin_right = 424.0
|
||||
margin_bottom = 449.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="OpenDir" type="Button" parent="panel/modding"]
|
||||
margin_left = 180.854
|
||||
margin_right = 271.854
|
||||
margin_bottom = 20.0
|
||||
text = "Game folder"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="DelMod" type="Button" parent="panel/modding"]
|
||||
margin_left = 180.854
|
||||
margin_top = 24.0
|
||||
margin_right = 271.854
|
||||
margin_bottom = 44.0
|
||||
text = "Delete mod"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="enable" type="CheckBox" parent="panel/modding"]
|
||||
margin_left = 5.0
|
||||
margin_right = 83.0
|
||||
margin_bottom = 24.0
|
||||
text = "Enabled"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="actor_info" type="Label" parent="panel/modding"]
|
||||
margin_left = 112.0
|
||||
margin_top = 24.0
|
||||
margin_right = 274.0
|
||||
margin_bottom = 38.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="actor" type="Label" parent="panel/modding"]
|
||||
margin_left = 5.0
|
||||
margin_top = 24.0
|
||||
margin_right = 112.0
|
||||
margin_bottom = 38.0
|
||||
text = "Actor: "
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="version" type="Label" parent="panel/modding"]
|
||||
margin_left = 5.0
|
||||
margin_top = 38.0
|
||||
margin_right = 112.0
|
||||
margin_bottom = 52.0
|
||||
text = "Version:"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="version_info" type="Label" parent="panel/modding"]
|
||||
margin_left = 112.0
|
||||
margin_top = 38.0
|
||||
margin_right = 274.0
|
||||
margin_bottom = 52.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Build in version" type="Label" parent="panel/modding"]
|
||||
margin_left = 5.0
|
||||
margin_top = 52.0
|
||||
margin_right = 112.0
|
||||
margin_bottom = 66.0
|
||||
text = "Build in version:"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="build_info" type="Label" parent="panel/modding"]
|
||||
margin_left = 112.0
|
||||
margin_top = 52.0
|
||||
margin_right = 274.0
|
||||
margin_bottom = 66.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Description" type="Label" parent="panel/modding"]
|
||||
margin_left = 5.0
|
||||
margin_top = 66.0
|
||||
margin_right = 112.0
|
||||
margin_bottom = 80.0
|
||||
text = "Description:"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Description_text" type="TextEdit" parent="panel/modding"]
|
||||
margin_left = 5.0
|
||||
margin_top = 80.0
|
||||
margin_right = 274.0
|
||||
margin_bottom = 158.0
|
||||
readonly = true
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[connection signal="pressed" from="panel/play" to="." method="play"]
|
||||
[connection signal="pressed" from="panel/del" to="." method="delworld"]
|
||||
[connection signal="pressed" from="panel/new" to="." method="new_pressed"]
|
||||
[connection signal="item_selected" from="panel/worlds" to="." method="worlds_selected"]
|
||||
[connection signal="item_selected" from="panel/mods" to="." method="mods_selected"]
|
||||
[connection signal="pressed" from="panel/modding/OpenDir" to="." method="OpenGF"]
|
||||
[connection signal="pressed" from="panel/modding/DelMod" to="." method="DelMod"]
|
||||
[connection signal="pressed" from="panel/modding/enable" to="." method="enable_mod"]
|
721
engine/WAEditor/WAEditor.gd
Normal file
@ -0,0 +1,721 @@
|
||||
extends Control
|
||||
var paswc = WaEngine.paswc
|
||||
var password
|
||||
var mod_file = ""
|
||||
var enabled = false setget enable
|
||||
var nodes = {}
|
||||
var lines = []
|
||||
var select = {object=null,output=null,value=null,del=false}
|
||||
var del = [Color(0,0,0),Color(0.1,0.1,0.1)]
|
||||
|
||||
var datatype_texture = {
|
||||
"texture":load("res://engine/WAEditor/texture.png"),
|
||||
}
|
||||
var datatype_color = {
|
||||
number=Color(0,0,1),
|
||||
string=Color(1,1,0),
|
||||
variant=Color(1,0,0.51),
|
||||
"bool":Color(1,0,0),
|
||||
"array":Color(0.7,0,1),
|
||||
"tree":Color(0,1,1),
|
||||
"vector3":Color(0,1,0.5),
|
||||
"vector2":Color(0,0.5,1),
|
||||
"object":Color(1,0.3,0),
|
||||
"texture":Color(1,1,1),
|
||||
}
|
||||
var nodereg = {
|
||||
"invalid":{
|
||||
label="Invalid",
|
||||
color = Color(0.5,0.5,0.5),
|
||||
op=[{type="label",text="",w=100,h=100}],
|
||||
},
|
||||
"timer":{
|
||||
label="Timer",
|
||||
color=Color(1,0.4,0.9),
|
||||
op=[{type="number",w=100,tooltip="Value"},{type="checkbox",on_toggle=["timeout","interval"]}],
|
||||
input={"Start":"variant","Stop":"variant","Set":"number"},
|
||||
output={Timeout="variant"},
|
||||
},
|
||||
"var":{
|
||||
label="Var",
|
||||
color=Color(1,0,0.51),
|
||||
input={In="variant",Set="variant"},
|
||||
output={Value="variant"},
|
||||
},
|
||||
string={
|
||||
label="String",
|
||||
color=Color(0,0.3,0.9),
|
||||
op=[{type="text",w=100,tooltip="Value"},{type="text",w=100,tooltip="Replace"}],
|
||||
input={In="variant","Set (1)":"string","Set (2)":"string","Number to string (1)":"number",Replace="string","Add front":"string","Add back":"string"},
|
||||
output={Value="string"},
|
||||
},
|
||||
"number":{
|
||||
label="Number",
|
||||
color=Color(0,0.3,0.9),
|
||||
op=[{type="number",w=100,tooltip="Value"},{type="checkbox",on_toggle=["Int","Float"]}],
|
||||
input={In="variant",Set="number","String to number":"string","+":"number","-":"number","*":"number","/":"number"},
|
||||
output={Value="number"},
|
||||
},
|
||||
world={
|
||||
init=true,
|
||||
label="World",
|
||||
color=Color(1,0,0),
|
||||
output={Enter="variant",Quit="variant","Wolrd name":"string"},
|
||||
},
|
||||
gate={
|
||||
label="Gate",
|
||||
color=Color(0.5,0,0.1),
|
||||
op=[{type="checkbox",pressed=false,on_toggle=["Open","Closed"]}],
|
||||
input={In="variant",Open="variant",Close="variant",Toggle="variant"},
|
||||
output={Opened="variant",Closed="variant"},
|
||||
},
|
||||
"counter":{
|
||||
label="Counter",
|
||||
color=Color(1,0.5,0.5),
|
||||
op=[{type="number",w=100,tooltip="Value1"},{type="number",w=100,tooltip="Value2"}],
|
||||
input={In="variant",Reset="variant","Add (variant: 1, number: value)":"variant","Set (1)":"number","Set (2)":"number"},
|
||||
output={Value="number","<":"variant","<=":"variant","=":"variant",">":"variant",">=":"variant","~":"variant"},
|
||||
},
|
||||
texture={
|
||||
label="Texture",
|
||||
color=Color(1,1,1),
|
||||
op=[{type="text",w=100}],
|
||||
input={"In":"variant","Set":"string"},
|
||||
output={"Value":"texture"}
|
||||
},
|
||||
itemstack={
|
||||
label="Itemstack",
|
||||
color=Color(0,0,1.1),
|
||||
op=[{name="item_name",type="text",w=100},{name="count",type="number",w=100,step=1,min_value=1,default=1}],
|
||||
input={"In":"variant","Item name":"string","Count":"number"},
|
||||
output={Stack="variant"},
|
||||
},
|
||||
player={
|
||||
label="Get player",
|
||||
color=Color(0,1,0),
|
||||
output={Player="object"},
|
||||
input={"In":"variant"},
|
||||
},
|
||||
vector={
|
||||
label="Vector",
|
||||
color=Color(0,0.5,0.2),
|
||||
op=[{type="text",w=100,tooltip="Vector3 = 0,2,1\nVector2 = 234.67,78",default="0,0,0"},],
|
||||
input={"In":"variant"},
|
||||
output={"Vector2":"vector2","Vector3":"vector3"},
|
||||
},
|
||||
add_to_inventory={
|
||||
label="Add to inventory",
|
||||
color=Color(0,1,0.1),
|
||||
op=[{name="listname",type="text",w=100,default="main",tooltip="List name (eg main, craft, output)"},{name="label",type="label",w=100,h=100,text="Object\nVector3 (node)"}],
|
||||
input={"Stack input":"variant","Listname":"string","Set object":"object","Set position":"vector3"},
|
||||
output={Leftover="variant"},
|
||||
},
|
||||
change_world={
|
||||
label="Change world",
|
||||
color=Color(0,0,0),
|
||||
size = 300,
|
||||
op=[
|
||||
{name="name",type="text",w=200,tooltip="World name"},{type="label",text="name",w=100},
|
||||
{name="mapgen",type="manu",w=200,manu=mapgen.mapgens},{type="label",text="Mapgen",w=100},
|
||||
],
|
||||
input={"Change":"variant"},
|
||||
},
|
||||
delay={
|
||||
label="Delay",
|
||||
color=Color(1,0.3,0),
|
||||
op=[{type="number",w=100,default=0.1,min_value=0.001}],
|
||||
input={"In:":"variant"},
|
||||
output={"Out":"variant"},
|
||||
},
|
||||
default_chest_inventory={
|
||||
label="Show Default chest inventory",
|
||||
color=Color(0.1,0,1),
|
||||
input={"In:":"vector3"},
|
||||
},
|
||||
distribute={
|
||||
output_labels = true,
|
||||
label="Distribute",
|
||||
color=Color(1,0,0.51),
|
||||
input={"Input":"variant"},
|
||||
output={
|
||||
"Variant":"variant",
|
||||
"String":"string",
|
||||
"Number":"number",
|
||||
"Bool":"bool",
|
||||
"Array":"array",
|
||||
"Tree":"tree",
|
||||
"Vector3":"vector3",
|
||||
"Vector2":"vector2",
|
||||
"Object":"object",
|
||||
"Mob":"variant",
|
||||
"Player":"variant",
|
||||
"Texture":"variant",
|
||||
"Itemstack":"variant",
|
||||
},
|
||||
},
|
||||
set_node={
|
||||
label="Set node",
|
||||
color=Color(1,0,0),
|
||||
input={"set":"vector3","node":"string"},
|
||||
op=[{name="node",type="text",w=100,default="air",tooltip="node name, eg default:grassy"}],
|
||||
},
|
||||
register_item={
|
||||
init=true,
|
||||
size = 250,
|
||||
label="Register item",
|
||||
color=Color(1,0,0),
|
||||
output={"on_use":"variant"},
|
||||
op=[
|
||||
{name="name",type="text",w=100,default="piackaxe"},{type="label",text="name",w=150},
|
||||
{name="inv_image",type="text",w=100,default="res://game/textures/default_axe_stone.png",text="item texture (URL)"},{type="label",w=150},
|
||||
{name="max_count",type="number",w=100,step=1,allow_lesser=false,default=100,min_value=1,tooltip="Will be 1 if tool"},{type="label",text="max count",w=150},
|
||||
{name="item_groups",type="text",w=100,default="",tooltip="group1=n, group2=n...\nUsed to determined item in groups\n eg Useful with craft recipes"},{type="label",text="groups",w=150},
|
||||
{type="label",text="item capabilities",w=150},{type="checkbox",w=100,pressed=true,on_toggle=["Tool","Item"],tooltip="Enable/disable item capabilities (The properties below)",name="capabilities"},
|
||||
{name="punch_interval",type="number",w=100,default=1,allow_lesser=false,allow_greater=false,max_value=60},{type="label",text="punch interval",w=150},
|
||||
{name="damage",type="number",w=100,default=1,allow_lesser=false},{type="label",text="damage",w=150},
|
||||
{name="durability",type="number",w=100,allow_lesser=false,default=100},{type="label",text="durability",w=150},
|
||||
{name="groups",type="text",w=100,default="cracky=1",tooltip="group1=n, group2=n...\nUsed to determine nodes that is breakable with this tool"},{type="label",text="groups",w=150},
|
||||
],
|
||||
},
|
||||
register_node={
|
||||
init=true,
|
||||
size = 250,
|
||||
label="Register node",
|
||||
color=Color(1,0,0),
|
||||
output={"on_register":"variant","pos":"vector3","on_touch":"object","on_untouch":"object","on_activate":"object"},
|
||||
op=[
|
||||
{name="name",type="text",w=100,tooltip="eg stone"},{type="label",text="name",w=150},
|
||||
{name="max_count",type="number",w=100,step=1,allow_lesser=false,default=100,min_value=1},{type="label",text="max count",w=150},
|
||||
{name="groups",type="text",w=100,default="cracky=1",tooltip="group1=n, group2=n...\nUsed to determined item in groups\n eg Useful with craft recipes"},{type="label",text="groups",w=150},
|
||||
{name="drawtype",type="manu",w=100,manu=["default","none","liquid"]},{type="label",text="Drawtype",w=150},
|
||||
{name="replaceable",type="checkbox",pressed=false,tooltip="Replaceable (Replace while you placing a node on it)"},
|
||||
{name="collidable",type="checkbox",pressed=true,tooltip="Collidable (Has collision)"},
|
||||
{name="transparent",type="checkbox",pressed=false,tooltip="Transparent"},
|
||||
{name="solid_surface",type="checkbox",pressed=false,tooltip="Solid surface (Visible from inside from blocks, usefull for transparent nodes)"},
|
||||
{name="touchable",type="checkbox",pressed=false,tooltip="Touchable (enables touch signals), activated after the node is rendered"},
|
||||
{name="activatable",type="checkbox",w=150,pressed=false,tooltip="activatable (activated instead of showing the players inventory)"},
|
||||
{name="drops",type="text",w=100,tooltip="You can ignore this field for a default drop\nmod:name=1 sets a drop (Required)\nchance=10 chance to drop (Optional)\n+=false if added, this drop will not be overwrited by other drops (Optional)\n ; for new drops\n\ndefault:grassy=1, chance=10, +=false; default:cobble=4..."},{type="label",text="drops",w=150},
|
||||
{name="tile1",type="text",w=100,default="res://game/textures/stone.png"},{type="label",text="tile 1 (URL/textures)",w=150},
|
||||
{name="tile2",type="text",w=100},{type="label",text="tile 2",w=150},
|
||||
{name="tile3",type="text",w=100},{type="label",text="tile 3",w=150},
|
||||
{name="tile4",type="text",w=100},{type="label",text="tile 4",w=150},
|
||||
{name="tile5",type="text",w=100},{type="label",text="tile 5",w=150},
|
||||
{name="tile6",type="text",w=100},{type="label",text="tile 6",w=150},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
func enable(v:bool):
|
||||
enabled = v
|
||||
visible = v
|
||||
func _ready():
|
||||
core.WaEditor = self
|
||||
var n = 0
|
||||
for i in nodereg:
|
||||
$manu/nodes.add_item(i)
|
||||
var c = nodereg[i].color
|
||||
c.a = 0.1
|
||||
$manu/nodes.set_item_custom_bg_color(n,c)
|
||||
n += 1
|
||||
$manu/nodes.remove_item(0)
|
||||
func new_node(name,def={id=0,options={},connections={}}):
|
||||
var id = def.id
|
||||
while nodes.get(id) != null:
|
||||
id += 1
|
||||
|
||||
var y = 0
|
||||
var next_y = 0
|
||||
var x = 0
|
||||
var w = 25
|
||||
var h = 25
|
||||
var h2 = 25
|
||||
|
||||
var b = ColorRect.new()
|
||||
var frame = ReferenceRect.new()
|
||||
var label = Label.new()
|
||||
#system
|
||||
var a = nodereg.get(name)
|
||||
if a == null:
|
||||
a = nodereg["invalid"]
|
||||
a.op[0].text = name
|
||||
name = "Invalid"
|
||||
def.connections = {}
|
||||
|
||||
var s = 100 if a.get("size") == null else a.size
|
||||
var n = {
|
||||
node=b,
|
||||
input={},
|
||||
output={},
|
||||
name=name,
|
||||
id=id,
|
||||
options=def.options,
|
||||
connections=def.connections
|
||||
}
|
||||
|
||||
#set basics
|
||||
b.rect_position = Vector2() if def.get("pos") == null else def.pos
|
||||
b.rect_size = Vector2(s,s)
|
||||
b.color = Color(0.3,0.3,0.3,0.7)
|
||||
|
||||
frame.rect_size = Vector2(s,s)
|
||||
frame.border_color = Color(1,0,0) if a.get("color") == null else a.color
|
||||
frame.border_width = 2
|
||||
frame.editor_only = false
|
||||
b.add_child(frame)
|
||||
label.text = a.label
|
||||
label.align = Label.ALIGN_CENTER
|
||||
label.valign = Label.VALIGN_CENTER
|
||||
label.rect_size.y = 20
|
||||
label.rect_position = Vector2((b.rect_size.x/2)-(label.rect_size.x/2),-20)
|
||||
b.add_child(label)
|
||||
#conntections
|
||||
if a.get("input"):
|
||||
for i in a.input:
|
||||
var p
|
||||
var c = datatype_color[a.input[i]]
|
||||
var t = datatype_texture.get(a.input[i])
|
||||
if t == null:
|
||||
p = ColorRect.new()
|
||||
p.color = datatype_color[a.input[i]]
|
||||
else:
|
||||
p = TextureRect.new()
|
||||
p.texture = t
|
||||
p.hint_tooltip = i
|
||||
p.rect_size = Vector2(10,10)
|
||||
p.rect_position = Vector2(-10,y)
|
||||
y+= 15
|
||||
b.add_child(p)
|
||||
n.input[i] = {node=p,color=c,name=i,type=a.input[i]}
|
||||
if y > h2:
|
||||
h2 = y
|
||||
y = 0
|
||||
if a.get("output"):
|
||||
for i in a.output:
|
||||
var p
|
||||
var c = datatype_color[a.output[i]]
|
||||
var t = datatype_texture.get(a.output[i])
|
||||
if t == null:
|
||||
p = ColorRect.new()
|
||||
p.color = c
|
||||
else:
|
||||
p = TextureRect.new()
|
||||
p.texture = t
|
||||
p.hint_tooltip = i
|
||||
p.rect_size = Vector2(10,10)
|
||||
p.rect_position = Vector2(s,y)
|
||||
y+= 15
|
||||
b.add_child(p)
|
||||
n.output[i] = {node=p,color=c,name=i,type=a.output[i]}
|
||||
|
||||
if a.get("output_labels"):
|
||||
var l = Label.new()
|
||||
l.text = i
|
||||
l.rect_size = Vector2(s,5)
|
||||
l.rect_position = Vector2(-l.rect_size.x,0)
|
||||
l.align = Label.ALIGN_CENTER
|
||||
l.valign = Label.VALIGN_CENTER
|
||||
p.add_child(l)
|
||||
if y > h2:
|
||||
h2 = y
|
||||
y = 0
|
||||
#options
|
||||
if a.get("op"):
|
||||
var opn = {}
|
||||
for i in a.op:
|
||||
opn[i.type] = 1 if opn.get(i.type) == null else opn[i.type] +1
|
||||
var p
|
||||
var opname = str(i.type,opn[i.type]) if i.get("name") == null else i.name
|
||||
var W = w if i.get("w") == null else i.w
|
||||
var H = h if i.get("h") == null else i.h
|
||||
var v = def.options.get(opname) if def.options.get(opname) != null else i.get("default")
|
||||
var sv
|
||||
var connect_type
|
||||
var connect_input
|
||||
if i.type == "text":
|
||||
p = LineEdit.new()
|
||||
p.rect_size = Vector2(W,h)
|
||||
p.rect_position = Vector2(x,y)
|
||||
p.text = "" if v == null else v
|
||||
sv = p.text
|
||||
connect_type = "text_changed"
|
||||
connect_input = "text"
|
||||
elif i.type == "number":
|
||||
p = SpinBox.new()
|
||||
p.rect_size = Vector2(W,H)
|
||||
p.rect_position = Vector2(x,y)
|
||||
p.allow_greater = true if i.get("allow_greater") == null else i.allow_greater
|
||||
p.allow_lesser = true if i.get("allow_lesser") == null else i.allow_lesser
|
||||
p.min_value = 0 if i.get("min_value") == null else i.min_value
|
||||
p.max_value = 100 if i.get("max_value") == null else i.max_value
|
||||
p.align = LineEdit.ALIGN_CENTER
|
||||
p.step = 0.001 if i.get("step") == null else i.step
|
||||
p.value = 0 if v == null else v
|
||||
sv = p.value
|
||||
connect_type = "value_changed"
|
||||
connect_input = "value"
|
||||
elif i.type == "checkbox":
|
||||
p = CheckBox.new()
|
||||
p.rect_size = Vector2(W,H)
|
||||
p.rect_position = Vector2(x,y)
|
||||
p.pressed = v if v != null else i.get("pressed") == true
|
||||
p.text = "" if i.get("on_toggle") == null else i.on_toggle[0 if p.pressed == true else 1]
|
||||
sv = p.pressed
|
||||
connect_type = "toggled"
|
||||
connect_input = "pressed"
|
||||
elif i.type == "button":
|
||||
p = Button.new()
|
||||
p.rect_size = Vector2(W,H)
|
||||
p.rect_position = Vector2(x,y)
|
||||
p.text = "OK" if i.get("text") == null else i.text
|
||||
elif i.type == "label":
|
||||
p = Label.new()
|
||||
p.text = i.text
|
||||
p.rect_size = Vector2(W,H)
|
||||
p.rect_position = Vector2(x,y)
|
||||
p.align = Label.ALIGN_CENTER
|
||||
p.valign = Label.VALIGN_CENTER
|
||||
elif i.type == "manu":
|
||||
p = OptionButton.new()
|
||||
for o in i.manu:
|
||||
p.add_item(o)
|
||||
p.rect_size = Vector2(W,H)
|
||||
p.rect_position = Vector2(x,y)
|
||||
p.selected = 0 if v == null else v
|
||||
sv = p.selected
|
||||
connect_type = "item_selected"
|
||||
connect_input = "selected"
|
||||
|
||||
if i.get("tooltip") != null:
|
||||
p.hint_tooltip = i.tooltip
|
||||
p.name = opname if i.get("name") == null else i.name
|
||||
frame.add_child(p)
|
||||
n.options[p.name] = {node=p,type=i.type,value=sv,method=connect_input}
|
||||
if i.type == "button":
|
||||
p.connect("pressed",self,"button_pressed",[i.ref,i.get("value")],name,i)
|
||||
elif connect_type != null:
|
||||
p.connect(connect_type,self,"option_value_changed",[{option=n.options[p.name],method=connect_input,opreg=i}])
|
||||
x += W
|
||||
if H != h and H > next_y:
|
||||
next_y = H
|
||||
|
||||
if x >= s:
|
||||
x = 0
|
||||
y += h if next_y == 0 else next_y
|
||||
next_y = 0
|
||||
if y > h2:
|
||||
h2 = y
|
||||
b.rect_size = Vector2(s,h2)
|
||||
frame.rect_size = Vector2(s,h2)
|
||||
|
||||
#add
|
||||
add_child(b)
|
||||
nodes[id] = n
|
||||
return n
|
||||
|
||||
func run_mod():
|
||||
WaEngine.reload_mod(save_data(true),self)
|
||||
|
||||
func button_pressed(ref,v,opreg):
|
||||
if ref != null:
|
||||
ref.call_func(v,opreg)
|
||||
|
||||
func option_value_changed(a=null,b=null):
|
||||
var op = a if b == null else b
|
||||
op.option.value = op.option.node.get(op.method)
|
||||
if op.option.type == "checkbox":
|
||||
if op.opreg.get("on_toggle") != null:
|
||||
op.option.node.text = op.opreg.on_toggle[0 if op.option.value else 1]
|
||||
|
||||
func _input(event):
|
||||
if core.game == null:
|
||||
return
|
||||
elif Input.is_action_just_pressed("actioneditor"):
|
||||
if core.player.object.gui == null and enabled == false:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
core.player.object.gui = {}
|
||||
enable(true)
|
||||
else:
|
||||
var pos = get_viewport().get_mouse_position()
|
||||
for i in nodes:
|
||||
var ob = nodes[i]
|
||||
var s = ob.node.rect_size
|
||||
var p = ob.node.rect_position
|
||||
if pos.x >= p.x-10 and pos.x <= p.x+s.x+10 and pos.y >= p.y-10 and pos.y <= p.y+s.y+10:
|
||||
return
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
core.player.object.gui = null
|
||||
enable(false)
|
||||
return
|
||||
elif enabled == false:
|
||||
return
|
||||
elif Input.is_key_pressed(KEY_CONTROL) and Input.is_key_pressed(KEY_S):
|
||||
save_data()
|
||||
elif event is InputEventMouseButton:
|
||||
var pos = event.position
|
||||
var relessed = Input.is_action_just_released("LMB")
|
||||
var pressed = Input.is_action_just_pressed("LMB")
|
||||
|
||||
if pressed:
|
||||
for l in lines:
|
||||
var a = (l.pos2-l.pos1).normalized().dot((event.position-l.pos2).normalized())
|
||||
var b = (l.pos1-l.pos2).normalized().dot((event.position-l.pos1).normalized())
|
||||
if floor(a*10000)*0.0001 == -1 and floor(b*10000)*0.0001 == -1:
|
||||
nodes[l.id1].connections[l.output].erase(str(l.input,l.id2))
|
||||
update_lines()
|
||||
break
|
||||
|
||||
if (relessed or pressed) and select.object == null:
|
||||
for i in nodes:
|
||||
var ob = nodes[i]
|
||||
var s = ob.node.rect_size
|
||||
var p = ob.node.rect_position
|
||||
|
||||
if pos.x >= p.x-10 and pos.x <= p.x+s.x+10 and pos.y >= p.y-10 and pos.y <= p.y+s.y+10:
|
||||
if pressed and pos.x >= p.x and pos.x <= p.x+s.x and pos.y >= p.y and pos.y <= p.y+s.y:
|
||||
select.object = ob
|
||||
select.pos = ob.node.rect_position-pos
|
||||
return
|
||||
elif pressed:
|
||||
for put in ob.output:
|
||||
var o = ob.output[put]
|
||||
var os = o.node.rect_size
|
||||
var op = o.node.rect_global_position
|
||||
if pos.x >= op.x and pos.x <= op.x+os.x and pos.y >= op.y and pos.y <= op.y+os.y:
|
||||
select.output = {ob=ob,output=o,name=o.name,pos=op+os/2,type=o.type}
|
||||
return
|
||||
elif relessed and select.output != null:#not same node
|
||||
for put in ob.input:
|
||||
var o = ob.input[put]
|
||||
var os = o.node.rect_size
|
||||
var op = o.node.rect_global_position
|
||||
if pos.x >= op.x and pos.x <= op.x+os.x and pos.y >= op.y and pos.y <= op.y+os.y:
|
||||
if o.type == "variant" or o.type == select.output.type:
|
||||
var sob = select.output.ob
|
||||
sob.connections[select.output.name] = {} if sob.connections.get(select.output.name) == null else sob.connections[select.output.name]
|
||||
sob.connections[select.output.name][str(o.name,ob.id)] = {id=ob.id,name=o.name}
|
||||
select.output = null
|
||||
update_lines()
|
||||
return
|
||||
if lines.size() > 0 and lines[0].node.name == "tmp":
|
||||
lines[0].node.free()
|
||||
lines.remove(0)
|
||||
select.output = null
|
||||
elif Input.is_action_just_released("LMB"):
|
||||
if select.del:
|
||||
$manu/del.color = del[0]
|
||||
select.del = false
|
||||
del_node(select.object)
|
||||
select.object = null
|
||||
elif event is InputEventMouseMotion:
|
||||
#remove select.object
|
||||
if select.object != null:
|
||||
var pos = event.position
|
||||
select.object.node.rect_position = event.position+select.pos
|
||||
update_lines()
|
||||
if pos.y >= 550 and pos.x <= 50:
|
||||
if select.del == false:
|
||||
select.del = true
|
||||
$manu/del.color = del[1]
|
||||
elif select.del:
|
||||
select.del = false
|
||||
$manu/del.color = del[0]
|
||||
elif select.output != null:
|
||||
#tmp line
|
||||
if lines.size() > 0 and lines[0].node.name == "tmp":
|
||||
lines[0].node.points=[select.output.pos,event.position]
|
||||
else:
|
||||
var l = Line2D.new()
|
||||
l.default_color = datatype_color[select.output.type]
|
||||
l.points=[select.output.pos,event.position]
|
||||
l.width = 2
|
||||
l.z_index = 1000
|
||||
l.name = "tmp"
|
||||
add_child(l)
|
||||
lines.push_front({node=l})
|
||||
elif Input.is_action_pressed("LMB"):
|
||||
#remove line
|
||||
for l in lines:
|
||||
var a = (l.pos2-l.pos1).normalized().dot((event.position-l.pos2).normalized())
|
||||
var b = (l.pos1-l.pos2).normalized().dot((event.position-l.pos1).normalized())
|
||||
if floor(a*10000)*0.0001 == -1 and floor(b*10000)*0.0001 == -1:
|
||||
nodes[l.id1].connections[l.output].erase(str(l.input,l.id2))
|
||||
update_lines()
|
||||
break
|
||||
|
||||
func update_lines():
|
||||
var new_lines = []
|
||||
for id1 in nodes:
|
||||
var ob1 = nodes[id1]
|
||||
for output in ob1.connections:
|
||||
var list = ob1.connections[output]
|
||||
var op1 = ob1.output.get(output)
|
||||
if op1 == null:
|
||||
continue
|
||||
var p1 = op1.node.rect_global_position
|
||||
var s1 = op1.node.rect_size/2
|
||||
for ci in list:
|
||||
var c = list[ci]
|
||||
var ob2 = nodes.get(c.id)
|
||||
if ob2 == null:
|
||||
continue
|
||||
var inp = nodes[c.id].input.get(c.name)
|
||||
if inp == null:
|
||||
ob1.connections[output].erase(str(c.name,c.id))
|
||||
continue
|
||||
var c2 = inp.node
|
||||
var p2 = c2.rect_global_position
|
||||
var s2 = c2.rect_size/2
|
||||
var l = Line2D.new()
|
||||
|
||||
l.default_color = datatype_color[ob1.output[output].type]
|
||||
l.points=[p1+s1,p2+s2]
|
||||
l.width = 2
|
||||
l.z_index = 1000
|
||||
add_child(l)
|
||||
new_lines.push_back({node=l,output=output,input=c.name,id1=id1,id2=ob2.id,pos1=p1+s1,pos2=p2+s2})
|
||||
for l in lines:
|
||||
l.node.free()
|
||||
lines = new_lines
|
||||
|
||||
func del_node(ob1):
|
||||
var id = ob1.id
|
||||
for ob2 in nodes:
|
||||
for k in nodes[ob2].connections:
|
||||
var output = nodes[ob2].connections[k]
|
||||
for c in output:
|
||||
if output[c].id == id:
|
||||
output.erase(c)
|
||||
ob1.node.free()
|
||||
nodes.erase(id)
|
||||
update_lines()
|
||||
|
||||
func load_data():
|
||||
var file_mmode = str("user://mods/",$manu/name.text,".mmode")
|
||||
var file_mmodt = str("user://mods/",$manu/name.text,".mmodt")
|
||||
var file = File.new()
|
||||
if file.file_exists(file_mmode):
|
||||
file_mmodt = null
|
||||
elif file.file_exists(file_mmodt):
|
||||
file_mmode = null
|
||||
|
||||
else:
|
||||
core.option_flash($manu/name,"File doesn't exists",Color(1,1,0),true)
|
||||
return
|
||||
var s
|
||||
if file_mmode != null:
|
||||
file.open_encrypted_with_pass(file_mmode,File.READ,paswc)
|
||||
s = file.get_var()
|
||||
else:
|
||||
file.open(file_mmodt,File.READ)
|
||||
s = str2var(file.get_as_text())
|
||||
if s is String:
|
||||
file.close()
|
||||
core.option_flash($manu/name,"File is broken",Color(1,1,0),true)
|
||||
return
|
||||
file.close()
|
||||
|
||||
if s != null and s.password != "" and s.password != $manu/password.text:
|
||||
core.option_flash($manu/password/passerr,"Wrong password",Color(1,0,0))
|
||||
return
|
||||
elif s == null:
|
||||
core.option_flash($manu/password/passerr,"Broken file",Color(1,0,0))
|
||||
return
|
||||
|
||||
password = null if s == null else s.get("password")
|
||||
mod_file = file_mmode if file_mmodt == null else file_mmodt
|
||||
$manu/password.text = password if password != null else ""
|
||||
for id in nodes:
|
||||
nodes[id].node.free()
|
||||
nodes.clear()
|
||||
|
||||
for id in s.data:
|
||||
var ob = s.data[id]
|
||||
new_node(ob.name,ob)
|
||||
|
||||
update_lines()
|
||||
core.option_flash($manu/name,"Loaded",Color(0,1,0),true)
|
||||
func save_data(test:bool=false):
|
||||
|
||||
if $manu/name.text == "":
|
||||
core.option_flash($manu/name,"Name it!",Color(1,1,0),true)
|
||||
return
|
||||
|
||||
var s = {}
|
||||
for id in nodes:
|
||||
var ob = nodes[id]
|
||||
var options = {}
|
||||
for o in ob.options:
|
||||
var op = ob.options[o]
|
||||
options[op.node.name] = op.value
|
||||
s[ob.id] = {
|
||||
pos = ob.node.rect_position,
|
||||
name=ob.name,
|
||||
id=ob.id,
|
||||
connections = ob.connections,
|
||||
options = options,
|
||||
}
|
||||
var save = {
|
||||
actor=$manu/more/morei/actor.text,
|
||||
description=$manu/more/morei/description.text,
|
||||
name=$manu/name.text,
|
||||
game_version = core.version,
|
||||
mod_version = $manu/more/morei/version.value,
|
||||
password=password,
|
||||
data=s,
|
||||
}
|
||||
if test:
|
||||
return save
|
||||
|
||||
var D = Directory.new()
|
||||
var file_mmode = str("user://mods/",$manu/name.text,".mmode")
|
||||
var file_mmodt = str("user://mods/",$manu/name.text,".mmodt")
|
||||
if D.dir_exists("user://mods") == false:
|
||||
D.make_dir("user://mods")
|
||||
|
||||
if D.file_exists(file_mmode) and file_mmode != mod_file:
|
||||
var passw_file = File.new()
|
||||
passw_file.open_encrypted_with_pass(file_mmode,File.READ,paswc)
|
||||
var ls = passw_file.get_var()
|
||||
passw_file.close()
|
||||
if ls != null and ls.password != "" and ls.password != password:
|
||||
core.option_flash($manu/password/passerr,"Load before overwrite",Color(1,0,0))
|
||||
return
|
||||
save.password = $manu/password.text
|
||||
|
||||
var file = File.new()
|
||||
if save.password != "":
|
||||
if mod_file != null and mod_file.get_extension() == "mmodt":
|
||||
var rnf = Directory.new()
|
||||
rnf.rename(mod_file,renpath(mod_file,"mmode"))
|
||||
|
||||
file.open_encrypted_with_pass(file_mmode,File.WRITE,paswc)
|
||||
file.store_var(save)
|
||||
mod_file = file_mmode
|
||||
else:
|
||||
if mod_file != null and mod_file.get_extension() == "mmode":
|
||||
var rnf = Directory.new()
|
||||
rnf.rename(mod_file,renpath(mod_file,"mmodt"))
|
||||
|
||||
file.open(file_mmodt,file.WRITE_READ)
|
||||
file.store_string(var2str(save))
|
||||
mod_file = file_mmodt
|
||||
file.close()
|
||||
core.option_flash($manu/name,"Saved",Color(0,1,0),true)
|
||||
|
||||
func renpath(p,n):
|
||||
var filex = p.get_file()
|
||||
var fname = filex.substr(0,filex.find("."))
|
||||
return p.replace(filex,str(fname,".",n))
|
||||
|
||||
|
||||
func _on_nodes_manu_selected(i):
|
||||
var name = $manu/nodes.get_item_text(i)
|
||||
var ob = new_node(name)
|
||||
ob.node.rect_position = get_viewport().get_mouse_position()-(ob.node.rect_size/2)
|
||||
select.object = ob
|
||||
select.pos = -ob.node.rect_size/2
|
||||
|
||||
|
||||
|
||||
func more():
|
||||
$manu/more/morei.visible = $manu/more/morei.visible == false
|
158
engine/WAEditor/WAEditor.tscn
Normal file
@ -0,0 +1,158 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://engine/WAEditor/WAEditor.gd" type="Script" id=1]
|
||||
|
||||
[node name="Editor" type="ColorRect"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
color = Color( 0, 0, 0, 0.0784314 )
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_lock_": true,
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="manu" type="Panel" parent="."]
|
||||
margin_right = 100.0
|
||||
margin_bottom = 600.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="name" type="LineEdit" parent="manu"]
|
||||
margin_right = 100.0
|
||||
margin_bottom = 24.0
|
||||
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
||||
text = "Unamed"
|
||||
align = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false,
|
||||
"_editor_description_": "Mod name"
|
||||
}
|
||||
|
||||
[node name="nodes" type="ItemList" parent="manu"]
|
||||
margin_top = 88.0
|
||||
margin_right = 100.0
|
||||
margin_bottom = 550.0
|
||||
allow_reselect = true
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="save" type="Button" parent="manu"]
|
||||
margin_top = 48.0
|
||||
margin_right = 50.0
|
||||
margin_bottom = 68.0
|
||||
text = "Save"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="run" type="Button" parent="manu"]
|
||||
margin_top = 68.0
|
||||
margin_right = 50.0
|
||||
margin_bottom = 88.0
|
||||
text = "Run"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="more" type="Button" parent="manu"]
|
||||
margin_left = 50.0
|
||||
margin_top = 68.0
|
||||
margin_right = 100.0
|
||||
margin_bottom = 88.0
|
||||
text = "More"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="morei" type="ColorRect" parent="manu/more"]
|
||||
visible = false
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = 25.0
|
||||
margin_top = -10.0
|
||||
margin_right = 225.0
|
||||
margin_bottom = 118.0
|
||||
color = Color( 0.3, 0.3, 0.3, 0.7 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="description" type="TextEdit" parent="manu/more/morei"]
|
||||
margin_top = 24.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 128.0
|
||||
hint_tooltip = "Description"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="actor" type="LineEdit" parent="manu/more/morei"]
|
||||
margin_right = 124.0
|
||||
margin_bottom = 24.0
|
||||
hint_tooltip = "Actor"
|
||||
align = 1
|
||||
|
||||
[node name="version" type="SpinBox" parent="manu/more/morei"]
|
||||
margin_left = 124.3
|
||||
margin_right = 198.3
|
||||
margin_bottom = 24.0
|
||||
hint_tooltip = "Version"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="password" type="LineEdit" parent="manu"]
|
||||
margin_top = 24.0
|
||||
margin_right = 100.0
|
||||
margin_bottom = 48.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false,
|
||||
"_editor_description_": "Add a password if you want to prevent people to open and or edit your mod"
|
||||
}
|
||||
|
||||
[node name="passerr" type="ColorRect" parent="manu/password"]
|
||||
visible = false
|
||||
margin_right = 100.0
|
||||
margin_bottom = 24.0
|
||||
color = Color( 1, 0, 0, 0.396078 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Label" type="Label" parent="manu/password/passerr"]
|
||||
margin_right = 100.0
|
||||
margin_bottom = 24.0
|
||||
custom_colors/font_color = Color( 1, 0, 0, 1 )
|
||||
text = "Password"
|
||||
align = 1
|
||||
valign = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="load" type="Button" parent="manu"]
|
||||
margin_left = 50.0
|
||||
margin_top = 48.0
|
||||
margin_right = 100.0
|
||||
margin_bottom = 68.0
|
||||
text = "Load"
|
||||
|
||||
[node name="del" type="ColorRect" parent="manu"]
|
||||
margin_top = 550.0
|
||||
margin_right = 50.0
|
||||
margin_bottom = 600.0
|
||||
color = Color( 0, 0, 0, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[connection signal="item_selected" from="manu/nodes" to="." method="_on_nodes_manu_selected"]
|
||||
[connection signal="pressed" from="manu/save" to="." method="save_data"]
|
||||
[connection signal="pressed" from="manu/run" to="." method="run_mod"]
|
||||
[connection signal="pressed" from="manu/more" to="." method="more"]
|
||||
[connection signal="pressed" from="manu/load" to="." method="load_data"]
|
554
engine/WAEditor/WAEngine.gd
Normal file
@ -0,0 +1,554 @@
|
||||
extends Control
|
||||
var paswc = "9n#3d!fnDSFP¤&(=)90&¤/TVba+v89H)(¤Hpo0F?)"
|
||||
var nodes = {}
|
||||
var tmpnodes = {}
|
||||
var nodereg
|
||||
var timer = 0
|
||||
var events = 0
|
||||
var stackoverflow = 400
|
||||
var editor
|
||||
func _ready():
|
||||
var e = load("res://engine/WAEditor/WAEditor.gd").new()
|
||||
nodereg = e.nodereg
|
||||
|
||||
func _process(delta):
|
||||
timer += delta
|
||||
if timer > 0.01:
|
||||
timer = 0
|
||||
events = 0
|
||||
|
||||
func scan(DIR="user://mods",getlist={},get=false):
|
||||
var d = Directory.new()
|
||||
d.open(DIR)
|
||||
d.list_dir_begin()
|
||||
var dir = d.get_next()
|
||||
while dir != "":
|
||||
if dir.begins_with(".") == false:
|
||||
var cd = str(d.get_current_dir(),"/",dir)
|
||||
var ex = dir.get_extension()
|
||||
if d.current_is_dir():
|
||||
getlist = scan(cd,getlist,get)
|
||||
elif ex == "mmode" or ex == "mmodt":
|
||||
getlist = load_mod(cd,getlist,get)
|
||||
dir = d.get_next()
|
||||
d.list_dir_end()
|
||||
return getlist
|
||||
|
||||
func reload_mod(s,edit=null):
|
||||
editor = edit
|
||||
var l = s.name.length()
|
||||
for id in nodes:
|
||||
if id.substr(0,l) == s.name:
|
||||
nodes.erase(id)
|
||||
if tmpnodes.get(s.name):
|
||||
for node in tmpnodes[s.name]:
|
||||
if is_instance_valid(node):
|
||||
node.free()
|
||||
tmpnodes[s.name] = null
|
||||
|
||||
for id in s.data:
|
||||
var d = s.data[id]
|
||||
if nodereg.get(d.name) == null:
|
||||
core.Error(str("ERROR: invalid node: ",d.name))
|
||||
return
|
||||
d.mod_name = s.name
|
||||
d.mod_idname = str(s.name,":",id)
|
||||
nodes[d.mod_idname] = d
|
||||
|
||||
for idname in nodes:
|
||||
var ob = nodes[idname]
|
||||
var def = nodereg.get(ob.name)
|
||||
if def.get("init") != null and idname.substr(0,l) == s.name:
|
||||
node_actions(ob,"init",null)
|
||||
|
||||
func load_mod(path,getlist,get=false):
|
||||
var file = File.new()
|
||||
var ex = path.get_extension()
|
||||
var s
|
||||
if ex == "mmodt":
|
||||
file.open(path,File.READ)
|
||||
s = str2var(file.get_as_text())
|
||||
file.close()
|
||||
if s is String:
|
||||
core.Error(str("ERROR: modfile not valid: ",path))
|
||||
return
|
||||
elif ex == "mmode":
|
||||
file.open_encrypted_with_pass(path,File.READ,paswc)
|
||||
s = file.get_var()
|
||||
file.close()
|
||||
if s != null:
|
||||
if get:
|
||||
s.path = path
|
||||
getlist[s.name] = s
|
||||
return getlist
|
||||
elif core.save.mods.get(s.name) != true:
|
||||
return
|
||||
for id in s.data:
|
||||
var d = s.data[id]
|
||||
if nodereg.get(d.name) == null:
|
||||
core.Error(str('A fatal error occorpted:\nMod "',s.name,'" is outdated (invalid node: "',d.name,'")\nCurrent game version: ',core.version,"\nBuild in version: ",s.game_version))
|
||||
return
|
||||
d.mod_name = s.name
|
||||
d.mod_idname = str(s.name,":",id)
|
||||
nodes[d.mod_idname] = d
|
||||
elif getlist != null:
|
||||
var fn = path.get_file()
|
||||
getlist[fn.replace(str(".",fn.get_extension()),"")] = {path=path,broken=true}
|
||||
return getlist
|
||||
func init():
|
||||
for idname in nodes:
|
||||
var ob = nodes[idname]
|
||||
var def = nodereg.get(ob.name)
|
||||
if def.get("init") != null:
|
||||
node_actions(ob,"init",null)
|
||||
|
||||
func connection_flash(n):
|
||||
var u = ColorRect.new()
|
||||
u.rect_size = Vector2(10,10)
|
||||
u.rect_position = n.rect_global_position
|
||||
u.color = Color(1,1,1)
|
||||
core.add_child(u)
|
||||
yield(get_tree().create_timer(0.1),"timeout")
|
||||
u.free()
|
||||
|
||||
func next_connection(ob1,output:String,value=null):
|
||||
events += 1
|
||||
if events > stackoverflow:
|
||||
return
|
||||
|
||||
if is_by_editor(ob1):
|
||||
var edob = editor.nodes[ob1.id]
|
||||
var edop = edob.options
|
||||
for op1name in ob1.options:
|
||||
var op1value = ob1.options[op1name]
|
||||
if op1value != null:
|
||||
var op2 = edop[op1name]
|
||||
op2.node.set(op2.method,op1value)
|
||||
#op2.node[op2.method] = op1value
|
||||
var out = edob.output.get(output)
|
||||
if out != null:
|
||||
connection_flash(out.node)
|
||||
|
||||
var c = ob1.connections.get(output)
|
||||
if c != null:
|
||||
var outputs = c
|
||||
for ob2_input_key in outputs:
|
||||
var ob2_input = outputs[ob2_input_key]
|
||||
var ob2 = nodes[str(ob1.mod_name,":",ob2_input.id)]
|
||||
node_actions(ob2,ob2_input.name,value)
|
||||
|
||||
func tempnodes(ob,node):
|
||||
tmpnodes[ob.mod_name] = [] if tmpnodes.get(ob.mod_name) == null else tmpnodes[ob.mod_name]
|
||||
tmpnodes[ob.mod_name].push_back(node)
|
||||
|
||||
func text_to_groups(a):
|
||||
a = a.replace(" ","")
|
||||
var g = {}
|
||||
for i in a.split(",",false):
|
||||
var l = i.find("=")
|
||||
if l == -1:
|
||||
return str("invalid input: ",i)
|
||||
var name = i.substr(0,l)
|
||||
var n = i.substr(l+1,-1)
|
||||
var I = n.is_valid_integer()
|
||||
if name.is_valid_identifier() == false:
|
||||
return str("invalid name: ",name)
|
||||
elif I == false and n.is_valid_float() == false:
|
||||
return str("invalid value: ",n)
|
||||
var intn = int(n)
|
||||
g[name] = intn if I else float(n)
|
||||
return g
|
||||
func text_to_drop(a):
|
||||
a = a.replace(" ","")
|
||||
var g = {}
|
||||
for d in a.split(";",false):
|
||||
|
||||
var count = 1
|
||||
var additional = true
|
||||
var item = ""
|
||||
var chance = 10
|
||||
|
||||
for i in d.split(",",false):
|
||||
var l = i.find("=")
|
||||
if l == -1:
|
||||
return str("invalid input: ",i)
|
||||
var name = i.substr(0,l)
|
||||
var n = i.substr(l+1,-1)
|
||||
var I = n.is_valid_integer()
|
||||
#var p = false
|
||||
#if I == false:
|
||||
# return str("invalid value: ",n)
|
||||
|
||||
if name == "+" and not (n == "false" or n == "true"):
|
||||
return str("invalid + value: ",n)
|
||||
elif name == "+" and n == "false":
|
||||
additional = false
|
||||
|
||||
elif (name == "chance" and I == false):
|
||||
return str("invalid chance value: ",n)
|
||||
elif name == "chance":
|
||||
chance = int(n)
|
||||
|
||||
elif name.find(":") > 0:
|
||||
var ndef = name.split(":")
|
||||
if ndef.size() != 2 or not (ndef[0].is_valid_identifier() and ndef[1].is_valid_identifier()):
|
||||
return str("invalid item name: ",name)
|
||||
elif I == false:
|
||||
return str("invalid item count: ",name)
|
||||
else:
|
||||
count = int(n)
|
||||
item = name
|
||||
else:
|
||||
return str("invalid option: ",name)
|
||||
if item == "":
|
||||
return str("invalid drop: no item")
|
||||
g[item] = {chance=chance,count=count,additional=additional}
|
||||
return g
|
||||
func is_valid_itemstack(s):
|
||||
if s is Dictionary:
|
||||
if s.get("name") is String:
|
||||
return core.get_item_reg(s.name) != null
|
||||
return false
|
||||
|
||||
func is_by_editor(ob):
|
||||
return editor != null and editor.get_node("manu/name").text == ob.mod_name
|
||||
func editor_error(ob,opname,message):
|
||||
if is_by_editor(ob):
|
||||
core.option_flash(editor.nodes[ob.id].options[opname].node,message)
|
||||
|
||||
func get_opmanu_value(nodedef,name,i):
|
||||
for op in nodereg[nodedef].op:
|
||||
if op.get("name") == name:
|
||||
return op.manu[i]
|
||||
|
||||
# ==================================================================
|
||||
# functions ========================================================
|
||||
# ==================================================================
|
||||
|
||||
func node_actions(ob,input:String="",value=null):
|
||||
|
||||
if is_by_editor(ob):
|
||||
var inp = editor.nodes[ob.id].input.get(input)
|
||||
if inp != null:
|
||||
connection_flash(inp.node)
|
||||
|
||||
var name = ob.name
|
||||
match name:
|
||||
"print":
|
||||
print(value)
|
||||
"world":
|
||||
if input == "init":
|
||||
next_connection(ob,"Enter")
|
||||
next_connection(ob,"Wolrd name",core.world.name)
|
||||
else:
|
||||
next_connection(ob,"Quit")
|
||||
"string":
|
||||
match input:
|
||||
"Set (1)":
|
||||
ob.options.text1 = value
|
||||
"Set (2)":
|
||||
ob.options.text2 = value
|
||||
"Number to string (1)":
|
||||
ob.options.text2 = str(value)
|
||||
"Replace":
|
||||
next_connection(ob,"Value",value.replace(ob.options.text1,ob.options.text2))
|
||||
"Add front":
|
||||
ob.options.text1 = str(value,ob.options.text1)
|
||||
"Add back":
|
||||
ob.options.text1 = str(ob.options.text1,value)
|
||||
next_connection(ob,"Value",ob.options.text1)
|
||||
"gate":
|
||||
match input:
|
||||
"In":
|
||||
if ob.options.checkbox1:
|
||||
next_connection(ob,"Opened",value)
|
||||
else:
|
||||
next_connection(ob,"Closed",value)
|
||||
"Open":
|
||||
ob.options.checkbox1 = true
|
||||
"Close":
|
||||
ob.options.checkbox1 = false
|
||||
"Toggle":
|
||||
ob.options.checkbox1 = ob.options.checkbox1 == false
|
||||
"number":
|
||||
if input == "In":
|
||||
next_connection(ob,"Value",ob.options.number1)
|
||||
return
|
||||
elif ob.options.checkbox1:
|
||||
value = int(value)
|
||||
elif ob.options.checkbox1 == false:
|
||||
value = float(value)
|
||||
ob.options.number1 = 0 if ob.options.number1 == null else ob.options.number1
|
||||
match input:
|
||||
#"In":
|
||||
"Set":
|
||||
ob.options.number1 = value
|
||||
"String to number":
|
||||
ob.options.number1 = value
|
||||
"+":
|
||||
ob.options.number1 += value
|
||||
"-":
|
||||
ob.options.number1 -= value
|
||||
"*":
|
||||
ob.options.number1 *= value
|
||||
"/":
|
||||
ob.options.number1 /= value
|
||||
next_connection(ob,"Value",ob.options.number1)
|
||||
"timer":
|
||||
match input:
|
||||
"Start":
|
||||
var t
|
||||
ob.options.number1 = 0 if ob.options.number1 == null else ob.options.number1
|
||||
if ob.get("timer") == null:
|
||||
t = Timer.new()
|
||||
ob.timer = t
|
||||
tempnodes(ob,t)
|
||||
core.add_child(t)
|
||||
else:
|
||||
t = ob.timer
|
||||
t.disconnect("timeout",self,"node_actions")
|
||||
t.one_shot = false if ob.options.checkbox1 != true else true
|
||||
t.connect("timeout",self,"node_actions",[ob,"Timeout",value])
|
||||
t.wait_time = ob.options.number1
|
||||
ob.timer.start()
|
||||
"Stop":
|
||||
if ob.get("timer") != null:
|
||||
ob.timer.stop()
|
||||
"Set":
|
||||
ob.options.number1 = value
|
||||
ob.timer.wait_time = value
|
||||
"Timeout":
|
||||
next_connection(ob,"Timeout",value)
|
||||
"delay":
|
||||
yield(get_tree().create_timer(ob.options.number1),"timeout")
|
||||
next_connection(ob,"Out",value)
|
||||
"set_node":
|
||||
if input == "node":
|
||||
ob.options.text1 = input
|
||||
else:
|
||||
var r = core.get_node_reg(ob.options.node)
|
||||
if r == null:
|
||||
editor_error(ob,"text1",str("invalid node"))
|
||||
else:
|
||||
core.set_node({name=ob.options.node,pos=value})
|
||||
"vector":
|
||||
ob.options.text1 = ob.options.text1.replace(" ","")
|
||||
var s = ob.options.text1.split(",",false)
|
||||
var msg
|
||||
var n = s.size()
|
||||
if n < 2 or n > 3:
|
||||
msg = "2 or 3 numbers allowed"
|
||||
else:
|
||||
for i in s:
|
||||
if i.is_valid_integer() == false and i.is_valid_float() == false:
|
||||
msg = "Invalid vector\n(only numbers allowed)"
|
||||
if msg != null and is_by_editor(ob):
|
||||
core.option_flash(editor.nodes[ob.id].options["text1"].node,msg)
|
||||
return
|
||||
if n == 2:
|
||||
value = str2var(str("Vector2(",s[0],",",s[1],")"))
|
||||
else:
|
||||
value = str2var(str("Vector3(",s[0],",",s[1],",",s[2],")"))
|
||||
next_connection(ob,str("Vector",n),value)
|
||||
|
||||
# "get_player_by_name":
|
||||
# if input == "Player name":
|
||||
# ob.options.playername = value
|
||||
# else:
|
||||
# var p = core.players.get(ob.options.playername)
|
||||
# if p != null:
|
||||
# next_connection(ob,"Player",core.player.object)
|
||||
"player":
|
||||
next_connection(ob,"Player",core.player.object)
|
||||
"add_to_inventory":
|
||||
match input:
|
||||
"Stack input":
|
||||
if is_valid_itemstack(value) and ob.options.get("object_var") != null:
|
||||
var stack2
|
||||
if ob.options.object_var is Vector3:
|
||||
stack2 = core.add_to_inventory(ob.options.object_var,ob.options.listname,value)
|
||||
elif is_instance_valid(ob.options.object_var):
|
||||
# wrong ob.options.listname will crash
|
||||
var o = ob.options.object_var
|
||||
if o.get("player"):
|
||||
o = o.player
|
||||
elif o.get("mob"):
|
||||
o = o.mob
|
||||
elif o.get("object"):
|
||||
o = o.object
|
||||
else:
|
||||
return
|
||||
stack2 = core.add_to_inventory(o,ob.options.listname,value)
|
||||
if ob.options.object_var.get("player"):
|
||||
ob.options.object_var.update_player()
|
||||
if stack2.count > 0:
|
||||
next_connection(ob,"Leftover",stack2)
|
||||
"listname":
|
||||
ob.options.listname = value
|
||||
"Set object":
|
||||
if value is KinematicBody and (value.get("player") != null or value.get("mob") != null):
|
||||
ob.options.object_var = value
|
||||
elif is_by_editor(ob):
|
||||
core.option_flash(editor.nodes[ob.id].options["label"].node,"Not valid")
|
||||
return
|
||||
"Set position":
|
||||
ob.options.object_var = value
|
||||
"itemstack":
|
||||
match input:
|
||||
"In":
|
||||
if ob.options.item_name != null and core.get_item_reg(ob.options.item_name) != null:
|
||||
next_connection(ob,"Stack",core.itemstack(ob.options.item_name,{count=ob.options.count}))
|
||||
"Item name":
|
||||
if core.get_item_reg(value) == null:
|
||||
if is_by_editor(ob):
|
||||
core.option_flash(editor.nodes[ob.id].options["item_name"].node,"Invalid item")
|
||||
return
|
||||
ob.options.item_name = value
|
||||
"Count":
|
||||
ob.options.count = value
|
||||
"distribute":
|
||||
var v = typeof(value)
|
||||
if v == TYPE_INT or v == TYPE_REAL:
|
||||
next_connection(ob,"Number",value)
|
||||
elif v == TYPE_STRING:
|
||||
next_connection(ob,"String",value)
|
||||
elif v == TYPE_BOOL:
|
||||
next_connection(ob,"Bool",value)
|
||||
elif v == TYPE_ARRAY:
|
||||
next_connection(ob,"Array",value)
|
||||
elif v == TYPE_DICTIONARY:
|
||||
next_connection(ob,"Tree",value)
|
||||
elif v == TYPE_VECTOR3:
|
||||
next_connection(ob,"Vector3",value)
|
||||
elif v == TYPE_VECTOR2:
|
||||
next_connection(ob,"Vector2",value)
|
||||
elif is_instance_valid(value) and value.get("player") != null:
|
||||
next_connection(ob,"Player",value)
|
||||
elif is_instance_valid(value) and value.get("mob") != null:
|
||||
next_connection(ob,"Mob",value)
|
||||
elif value is StreamTexture:
|
||||
next_connection(ob,"Texture",value)
|
||||
elif is_instance_valid(value):
|
||||
next_connection(ob,"Object",value)
|
||||
else:
|
||||
next_connection(ob,"Variant",value)
|
||||
"counter":
|
||||
if ob.options.number1 == null:
|
||||
ob.options.number1 = 1
|
||||
match input:
|
||||
"In":
|
||||
next_connection(ob,"Value",ob.options.number1)
|
||||
"Reset":
|
||||
ob.options.number1 = 0
|
||||
"Add (variant: 1, number: value)":
|
||||
ob.options.number1 += 1 if typeof(value) != TYPE_REAL and typeof(value) != TYPE_INT else value
|
||||
"Set (1)":
|
||||
ob.options.number1 = value
|
||||
"Set (2)":
|
||||
ob.options.number2 = value
|
||||
var a = 0 if ob.options.number1 == null else ob.options.number1
|
||||
var b = 0 if ob.options.number2 == null else ob.options.number2
|
||||
if a < b:
|
||||
next_connection(ob,"<",value)
|
||||
elif a <= b:
|
||||
next_connection(ob,"<=",value)
|
||||
if a > b:
|
||||
next_connection(ob,">",value)
|
||||
elif a >= b:
|
||||
next_connection(ob,">=",value)
|
||||
if a == b:
|
||||
next_connection(ob,"==",value)
|
||||
elif a != b:
|
||||
next_connection(ob,"~",value)
|
||||
"texture":
|
||||
if input == "In":
|
||||
var l = load(ob.options.text1)
|
||||
if l is StreamTexture:
|
||||
next_connection(ob,"Value", l)
|
||||
else:
|
||||
ob.options.text1 = value if value != null else ""
|
||||
|
||||
"default_chest_inventory":
|
||||
if core.existsMeta(value) == false:
|
||||
core.create_node_inventory(value,"main")
|
||||
GUI.show(core.player,"background[8;8.5]inventory[player:player1;main;0;4.5;8;4]inventory[node:"+var2str(value)+";main;0;0;8;4]")
|
||||
"change_world":
|
||||
if ob.options.name != "":
|
||||
core.world.name = ob.options.name
|
||||
core.world.mapgen = get_opmanu_value("change_world","mapgen",ob.options.mapgen)
|
||||
core.world_main(true)
|
||||
"register_item":
|
||||
var o = ob.options
|
||||
var inv_image = load(ob.options.inv_image)
|
||||
var groups = text_to_groups(ob.options.groups)
|
||||
var item_groups = text_to_groups(ob.options.item_groups)
|
||||
if o.name.is_valid_filename() == false:
|
||||
if is_by_editor(ob):
|
||||
core.option_flash(editor.nodes[ob.id].options["name"].node,"Invalid name")
|
||||
return
|
||||
elif not inv_image is StreamTexture:
|
||||
if is_by_editor(ob):
|
||||
core.option_flash(editor.nodes[ob.id].options["inv_image"].node,"Texture not found")
|
||||
return
|
||||
elif groups is String:
|
||||
if is_by_editor(ob):
|
||||
core.option_flash(editor.nodes[ob.id].options["groups"].node,groups)
|
||||
return
|
||||
elif item_groups is String:
|
||||
if is_by_editor(ob):
|
||||
core.option_flash(editor.nodes[ob.id].options["item_groups"].node,item_groups)
|
||||
return
|
||||
var reg_item_name = str(ob.mod_name,":",o.name)
|
||||
core.register.items[reg_item_name] = {
|
||||
name = reg_item_name,
|
||||
type = "item",
|
||||
inv_image = inv_image,
|
||||
max_count = o.max_count,
|
||||
groups = o.item_groups,
|
||||
}
|
||||
if o.capabilities:
|
||||
core.register.items[reg_item_name].item_capabilities = {
|
||||
punch_interval = o.punch_interval,
|
||||
damage = o.damage,
|
||||
durability = o.durability,
|
||||
groups = groups,
|
||||
}
|
||||
"register_node":
|
||||
var groups = text_to_groups(ob.options.groups)
|
||||
var drops = text_to_drop(ob.options.drops)
|
||||
var tiles = []
|
||||
if ob.options.name.is_valid_identifier() == false:
|
||||
editor_error(ob,"name","invalid name")
|
||||
elif groups is String:
|
||||
editor_error(ob,"groups",groups)
|
||||
return
|
||||
elif ob.options.drops != "" and drops is String:
|
||||
editor_error(ob,"drops",drops)
|
||||
return
|
||||
if ob.options.drops == "":
|
||||
drops = null
|
||||
|
||||
for i in range(1,6):
|
||||
var t = ob.options[str("tile",i)]
|
||||
if t != "":
|
||||
var l = load(t)
|
||||
if l is StreamTexture:
|
||||
tiles.push_back(l)
|
||||
else:
|
||||
editor_error(ob,str("tile",i),str("not found"))
|
||||
return
|
||||
core.register_node({
|
||||
name = str(ob.mod_name,":",ob.options.name),
|
||||
drop = drops,
|
||||
drawtype = get_opmanu_value("register_node","drawtype",ob.options.drawtype),
|
||||
groups=groups,
|
||||
max_count = ob.options.max_count,
|
||||
replaceable = ob.options.replaceable,
|
||||
collidable = ob.options.collidable,
|
||||
transparent = ob.options.transparent,
|
||||
solid_surface = ob.options.solid_surface,
|
||||
touchable = ob.options.touchable,
|
||||
activatable = ob.options.activatable,
|
||||
tiles = tiles,
|
||||
})
|
||||
next_connection(ob,"on_register")
|
BIN
engine/WAEditor/texture.png
Normal file
After Width: | Height: | Size: 573 B |
36
engine/WAEditor/texture.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/texture.png-58a69bc50f674bb833ebe6ab83cad48a.s3tc.stex"
|
||||
path.etc2="res://.import/texture.png-58a69bc50f674bb833ebe6ab83cad48a.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://engine/WAEditor/texture.png"
|
||||
dest_files=[ "res://.import/texture.png-58a69bc50f674bb833ebe6ab83cad48a.s3tc.stex", "res://.import/texture.png-58a69bc50f674bb833ebe6ab83cad48a.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
169
engine/chunk/chunk.gd
Normal file
@ -0,0 +1,169 @@
|
||||
extends Spatial
|
||||
|
||||
var timer = 0
|
||||
var chunks_in_progress = {}
|
||||
var progress2del = {}#ca t delete chunks in the for loop, remove it after instead
|
||||
var dim = 0
|
||||
|
||||
|
||||
func _init():
|
||||
core.chunk=self
|
||||
|
||||
func new_chunk(pos):
|
||||
var id = pos_to_chunkid(pos)
|
||||
var chunk_pos = to_chunk_pos(pos)
|
||||
var none = core.get_node_reg("none").id
|
||||
for x in range(-core.chunk_size/2,core.chunk_size/2):
|
||||
for y in range(-core.chunk_size/2,core.chunk_size/2):
|
||||
for z in range(-core.chunk_size/2,core.chunk_size/2):
|
||||
var p = chunk_pos+Vector3(x,y,z)
|
||||
var saved_node = core.save.map.get(p)
|
||||
core.inset_map_node_id(none if saved_node == null else saved_node,p)
|
||||
core.chunks[id] = MeshInstance.new()
|
||||
var chunk = core.chunks[id]
|
||||
chunk.transform.origin = chunk_pos
|
||||
add_child(chunk)
|
||||
var staticbody = StaticBody.new()
|
||||
staticbody.name = "body"
|
||||
chunk.add_child(staticbody)
|
||||
var collision = CollisionShape.new()
|
||||
collision.name = "collision"
|
||||
staticbody.add_child(collision)
|
||||
var timeout = Timer.new()
|
||||
timeout.wait_time = 10
|
||||
timeout.autostart = true
|
||||
timeout.connect("timeout",self,"chunk_timer",[id,chunk_pos])
|
||||
chunk.add_child(timeout)
|
||||
|
||||
func unload_chunk(id,chunk_pos):
|
||||
for x in range(-core.chunk_size/2,core.chunk_size/2):
|
||||
for y in range(-core.chunk_size/2,core.chunk_size/2):
|
||||
for z in range(-core.chunk_size/2,core.chunk_size/2):
|
||||
core.map.erase(chunk_pos+Vector3(x,y,z))
|
||||
core.chunks[id].queue_free()
|
||||
core.chunks.erase(id)
|
||||
|
||||
func chunk_timer(id,chunk_pos):
|
||||
if core.player.object.global_transform.origin.distance_to(chunk_pos) > core.settings.unload_chunk_distance:
|
||||
unload_chunk(id,chunk_pos)
|
||||
|
||||
func to_chunk_pos(pos):
|
||||
var c = core.chunk_size
|
||||
var s = core.chunk_size/2
|
||||
return ((pos+Vector3(s,s,s))/c).floor()*c
|
||||
|
||||
func chunk_loaded_at_pos(pos):
|
||||
var c = core.chunk_size
|
||||
var s = core.chunk_size/2
|
||||
var c_pos = ((pos+Vector3(s,s,s))/c).floor()
|
||||
return core.chunks.get(c_pos) != null
|
||||
|
||||
func get_chunk_at_pos(pos):
|
||||
var c = core.chunk_size
|
||||
var s = core.chunk_size/2
|
||||
var c_pos = ((pos+Vector3(s,s,s))/c).floor()
|
||||
return core.chunks.get(c_pos)
|
||||
|
||||
func pos_to_chunkid(pos):
|
||||
var c = core.chunk_size
|
||||
var s = core.chunk_size/2
|
||||
return ((pos+Vector3(s,s,s))/c).floor()
|
||||
|
||||
func get_chunk(id):
|
||||
return core.chunks.get(id)
|
||||
|
||||
func _process(delta):
|
||||
timer += delta
|
||||
if timer > 0.0:
|
||||
timer = 0
|
||||
|
||||
for i in progress2del:
|
||||
chunks_in_progress.erase(i)
|
||||
progress2del.clear()
|
||||
var max_nodes = core.settings.max_update_nodes
|
||||
for di in chunks_in_progress:
|
||||
var data = chunks_in_progress.get(di)
|
||||
var chunk_mesh = get_chunk(data.chunkid)
|
||||
if chunk_mesh == null:
|
||||
data = chunks_in_progress.erase(di)
|
||||
continue
|
||||
for x in range(data.range_x.a,data.range_x.b):
|
||||
for y in range(data.range_y.a,data.range_y.b):
|
||||
for z in range(data.range_z.a,data.range_z.b):
|
||||
var lpos = Vector3(x,y,z)
|
||||
var id = core.map.get(lpos+data.chunk_pos)
|
||||
var n = core.register.id.get(id)# if id != null else "default"
|
||||
if n == null:
|
||||
core.map.erase(data.chunk_pos)
|
||||
core.save.map.erase(data.chunk_pos)
|
||||
unload_chunk(pos_to_chunkid(data.chunk_pos),data.chunk_pos)
|
||||
update(data.chunk_pos)
|
||||
return
|
||||
core.node_set(id,lpos+data.chunk_pos)
|
||||
max_nodes -= 1
|
||||
if max_nodes < 0:
|
||||
data.range_x.a = x
|
||||
data.range_y.a = y
|
||||
data.range_z.a = z
|
||||
return
|
||||
|
||||
var reg = core.register.nodes.get(n)
|
||||
var tile = "" if reg.tiles.size() < 1 else reg.tiles[0]
|
||||
if reg.drawtype != "none":
|
||||
for f in core.default_node.faces.size():
|
||||
var neighbour_id = core.map.get(lpos+core.default_node.dir[f]+data.chunk_pos)
|
||||
var neighbour_name = core.register.id.get(neighbour_id) if neighbour_id != null else "default"
|
||||
var neighbour_reg = core.register.nodes.get(neighbour_name)
|
||||
|
||||
if neighbour_reg == null:
|
||||
core.map.erase(lpos+core.default_node.dir[f]+data.chunk_pos)
|
||||
core.save.map.erase(lpos+core.default_node.dir[f]+data.chunk_pos)
|
||||
continue
|
||||
elif neighbour_id != id and neighbour_reg.get("solid_surface") == false:
|
||||
data.st.begin(Mesh.PRIMITIVE_TRIANGLE_FAN)
|
||||
var mat = SpatialMaterial.new()
|
||||
var transparent = reg.get("transparent") == true
|
||||
if f < reg.tiles.size():
|
||||
tile = reg.tiles[f]
|
||||
mat.albedo_texture = tile
|
||||
mat.flags_transparent = transparent
|
||||
data.st.set_material(mat)
|
||||
#data.st.add_color(Color(0,1,1))
|
||||
var cmf = []
|
||||
for v in range(0,4):
|
||||
data.st.add_uv(core.default_node.uv[v])
|
||||
data.st.add_vertex(core.default_node.faces[f][v]+lpos)
|
||||
cmf.push_back(core.default_node.faces[f][v]+lpos)
|
||||
|
||||
data.st.commit(data.mesh)
|
||||
if reg.get("collidable") != false:
|
||||
data.cst.begin(Mesh.PRIMITIVE_TRIANGLES)
|
||||
data.cst.add_triangle_fan(cmf)
|
||||
data.cst.commit(data.collision_mesh)
|
||||
data.st.clear()
|
||||
data.cst.clear()
|
||||
chunk_mesh.mesh = data.mesh
|
||||
chunk_mesh.get_node_or_null("body/collision").shape = data.collision_mesh.create_trimesh_shape()
|
||||
chunks_in_progress.erase(di)
|
||||
progress2del[di] = di
|
||||
|
||||
func update(pos):
|
||||
if get_chunk_at_pos(pos) == null:
|
||||
new_chunk(pos)
|
||||
core.current_mapgen.call_func(to_chunk_pos(pos))
|
||||
return
|
||||
|
||||
var chunkid = pos_to_chunkid(pos)
|
||||
var data = {
|
||||
vertex = {},
|
||||
mesh = Mesh.new(),
|
||||
collision_mesh = Mesh.new(),
|
||||
chunkid = chunkid,
|
||||
chunk_pos = get_chunk(chunkid).transform.origin,
|
||||
st = SurfaceTool.new(),
|
||||
cst = SurfaceTool.new(),
|
||||
range_x = {a=-core.chunk_size/2,b=core.chunk_size/2},
|
||||
range_y = {a=-core.chunk_size/2,b=core.chunk_size/2},
|
||||
range_z = {a=-core.chunk_size/2,b=core.chunk_size/2},
|
||||
}
|
||||
chunks_in_progress[chunkid] = data
|
7
engine/chunk/chunk.tscn
Normal file
@ -0,0 +1,7 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://engine/chunk/chunk.gd" type="Script" id=1]
|
||||
|
||||
[node name="chunks" type="Spatial"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, 0.5, -0.5 )
|
||||
script = ExtResource( 1 )
|
792
engine/core.gd
Normal file
@ -0,0 +1,792 @@
|
||||
extends Node
|
||||
|
||||
#woody
|
||||
#cracky
|
||||
#elastic
|
||||
#crumbly
|
||||
var error = false
|
||||
var version = 0.1
|
||||
var save = {player={}, objects={}, mods={},map={}}
|
||||
var save_timer = 0
|
||||
var chunk #noderef functions
|
||||
var main #noderef functions
|
||||
var WaEditor #noderef functions
|
||||
var ui #noderef functions
|
||||
var Loader #noderef functions
|
||||
var chunks = {}
|
||||
var chunk_size=8#16
|
||||
var player
|
||||
var objects = {}
|
||||
var viewport_items = {}
|
||||
var game_paused = true
|
||||
var world_name = ""
|
||||
|
||||
var world = {name="earth",mapgen="super_flatland",meta={}}
|
||||
var game
|
||||
var map = {}
|
||||
var meta = {}
|
||||
var settings = {
|
||||
update_chunk_rules=[Vector3(-1,0,0),Vector3(1,0,0),Vector3(0,0,-1),Vector3(0,0,1),Vector3(0,-1,0),Vector3(0,1,0)],
|
||||
ganerate_chunk_range = 4,
|
||||
max_update_nodes = 512,
|
||||
save_timeout = 5,
|
||||
unload_chunk_distance = 100,
|
||||
item_drop_timeout = 300,
|
||||
}
|
||||
|
||||
var default_node_id = 7
|
||||
var current_mapgen # funcref
|
||||
var register = {
|
||||
items = {
|
||||
max_count = 1,
|
||||
"wieldhand":{name="wieldhand",
|
||||
type = "item",
|
||||
max_count = 1,
|
||||
inv_image=load("res://game/textures/wieldhand.png"),
|
||||
item_capabilities = {
|
||||
punch_interval = 1,
|
||||
damage = 1,
|
||||
groups = {crumbly=1},
|
||||
},
|
||||
},
|
||||
"default:stone_pick":{name="default:stone_pick",
|
||||
max_count = 1,
|
||||
type = "item",
|
||||
inv_image=load("res://game/textures/default_pick_stone.png"),
|
||||
item_capabilities = {
|
||||
punch_interval = 1,
|
||||
damage = 1,
|
||||
durability = 100,
|
||||
groups = {cracky=1},
|
||||
},
|
||||
},
|
||||
"default:stone_hoe":{name="default:stone_hoe",
|
||||
max_count = 1,
|
||||
type = "item",
|
||||
inv_image=load("res://game/textures/default_hoe_stone.png"),
|
||||
item_capabilities = {
|
||||
punch_interval = 1,
|
||||
damage = 1,
|
||||
durability = 100,
|
||||
groups = {crumbly=1},
|
||||
}
|
||||
},
|
||||
"default:stone_shovel":{name="default:stone_shovel",
|
||||
max_count = 1,
|
||||
type = "item",
|
||||
inv_image=load("res://game/textures/default_shovel_stone.png"),
|
||||
item_capabilities = {
|
||||
punch_interval = 1,
|
||||
damage = 1,
|
||||
durability = 100,
|
||||
groups = {crumbly=2},
|
||||
}
|
||||
},
|
||||
"default:axe_stone":{name="default:axe_stone",
|
||||
max_count = 1,
|
||||
type = "item",
|
||||
inv_image=load("res://game/textures/default_axe_stone.png"),
|
||||
item_capabilities = {
|
||||
punch_interval = 1,
|
||||
damage = 1,
|
||||
durability = 100,
|
||||
groups = {woody=1},
|
||||
}
|
||||
},
|
||||
"default:stick":{name="default:stick",
|
||||
max_count = 100,
|
||||
type = "item",
|
||||
inv_image=load("res://game/textures/default_stick.png"),
|
||||
groups = {"stick":1},
|
||||
},
|
||||
},
|
||||
nodes = {
|
||||
none={id=0,name="none",drawtype="none",tiles=[],type="node",groups={},max_count=100,},
|
||||
air={id=1,name="air",drawtype="none",tiles=[],collidable=false,solid_surface=false,type="node",groups={},max_count=100,},
|
||||
default={id=2,name="default",drawtype="default",tiles=[load("res://game/textures/default.png")],type="node",groups={cracky=1},max_count=100,},
|
||||
},
|
||||
id = {0:"none",1:"air",2:"default"}
|
||||
}
|
||||
var default_node = {
|
||||
texture = load("res://game/textures/default.png"),
|
||||
uv = [Vector2(0,0),Vector2(0,1),Vector2(1,1),Vector2(1,0)],
|
||||
dir = [Vector3(0,1,0),Vector3(0,-1,0),Vector3(1,0,0),Vector3(-1,0,0),Vector3(0,0,-1),Vector3(0,0,1)],
|
||||
faces = [
|
||||
[Vector3(1,0,0),Vector3(1,0,1),Vector3(0,0,1),Vector3(0,0,0)], #up y+
|
||||
[Vector3(0,-1,0),Vector3(0,-1,1),Vector3(1,-1,1),Vector3(1,-1,0)], #down y-
|
||||
[Vector3(1,0,0),Vector3(1,-1,0),Vector3(1,-1,1),Vector3(1,0,1)], #north x+
|
||||
[Vector3(0,0,1),Vector3(0,-1,1),Vector3(0,-1,0),Vector3(0,0,0)], #south x-
|
||||
[Vector3(0,0,0),Vector3(0,-1,0),Vector3(1,-1,0),Vector3(1,0,0)], #east z+
|
||||
[Vector3(1,0,1),Vector3(1,-1,1),Vector3(0,-1,1),Vector3(0,0,1)], #west z-
|
||||
]
|
||||
}
|
||||
|
||||
func _init():
|
||||
set_process(false)
|
||||
|
||||
func register_node(def):
|
||||
var id = register.id.size()
|
||||
if def.get("tiles") != null:
|
||||
for i in range(0,def.tiles.size()):
|
||||
var t = def.tiles[i]
|
||||
if t is String:
|
||||
var l = load(t)
|
||||
if l is StreamTexture:
|
||||
def.tiles[i] = l
|
||||
|
||||
def.id = id
|
||||
def.type = "node"
|
||||
def.drop = def.get("drops")
|
||||
def.drawtype = "normal" if def.get("drawtype") == null else def.drawtype
|
||||
def.groups = {} if def.get("groups") == null else def.groups
|
||||
def.max_count = 100 if def.get("max_count") == null else def.max_count
|
||||
def.replaceable = false if def.get("replaceable") == null else def.replaceable
|
||||
def.collidable = true if def.get("collidable") == null else def.collidable
|
||||
def.transparent = false if def.get("transparent") == null else def.transparent
|
||||
def.solid_surface = false if def.get("solid_surface") == null else def.solid_surface
|
||||
def.touchable = false if def.get("touchable") == null else def.touchable
|
||||
def.activatable = false if def.get("activatable") == null else def.activatable
|
||||
def.tiles = [] if def.get("tiles") == null else def.tiles
|
||||
#on_activate func ref
|
||||
|
||||
|
||||
register.id[id] = def.name
|
||||
register.nodes[def.name] = def
|
||||
|
||||
func world_main(change=false):
|
||||
Loader.start(100,{0:"World",1:"Saves",2:"Mods",3:"Preparing the map"})
|
||||
if change:
|
||||
save_data()
|
||||
world_quit(false,false)
|
||||
world.meta = {}
|
||||
game = Spatial.new()
|
||||
main.add_child(core.game)
|
||||
var w = load("res://engine/chunk/chunk.tscn").instance()
|
||||
game.add_child(w)
|
||||
Loader.setprogress(1)
|
||||
load_data()
|
||||
load_player()
|
||||
Loader.setprogress(2)
|
||||
WaEngine.scan()
|
||||
if core.error:
|
||||
Loader.end()
|
||||
return
|
||||
WaEngine.init()
|
||||
Loader.setprogress(3)
|
||||
current_mapgen = funcref(mapgen,world.mapgen)
|
||||
set_process(true)
|
||||
mapgen.set_process(true)
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
ui.visible = true
|
||||
game_paused = false
|
||||
get_tree().paused = false
|
||||
yield(get_tree().create_timer(1),"timeout")
|
||||
var l = chunk.chunks_in_progress.size()
|
||||
var s = l
|
||||
Loader.start(l,{0:"loading map"})
|
||||
while l > 0:
|
||||
l = chunk.chunks_in_progress.size()
|
||||
Loader.setprogress(s-l)
|
||||
yield(get_tree().create_timer(0),"timeout")
|
||||
|
||||
func world_quit(quit=false,to_mainmanu=true):
|
||||
core.save_data()
|
||||
if quit:
|
||||
get_tree().quit()
|
||||
return
|
||||
ui.visible = false
|
||||
WaEditor.visible = false
|
||||
set_process(false)
|
||||
mapgen.set_process(false)
|
||||
chunk.queue_free()
|
||||
game.queue_free()
|
||||
game = null
|
||||
player.object.queue_free()
|
||||
player = null
|
||||
map.clear()
|
||||
meta.clear()
|
||||
chunks.clear()
|
||||
objects.clear()
|
||||
WaEngine.nodes.clear()
|
||||
chunk.chunks_in_progress.clear()
|
||||
if to_mainmanu:
|
||||
var manu = load("res://engine/MainManu/MainManu.tscn").instance()
|
||||
main.add_child(manu)
|
||||
|
||||
func game_pause():
|
||||
game_paused = game_paused == false
|
||||
get_tree().paused = game_paused
|
||||
if game_paused:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
ui.get_node("manu").visible = true
|
||||
else:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
|
||||
ui.get_node("manu").visible = false
|
||||
func add_object(ob,type="",url=null):
|
||||
var id = 0
|
||||
while objects.get(id) != null:
|
||||
id += 1
|
||||
objects[id] = {
|
||||
name = str(id),
|
||||
id = id,
|
||||
type = type,
|
||||
inventory = {main=new_inventory(1)},
|
||||
object = ob,
|
||||
meta = {},
|
||||
url = url,
|
||||
}
|
||||
return objects[id]
|
||||
|
||||
func load_objects():
|
||||
for i in save.objects:
|
||||
var s = save.objects[i]
|
||||
objects[s.id] = {}
|
||||
var o = objects[s.id]
|
||||
o.id = s.id
|
||||
o.name = s.name
|
||||
o.type = s.type
|
||||
o.inventory = s.inventory
|
||||
o.url = s.url
|
||||
o.meta = s.meta
|
||||
o.object = load(o.url).instance()
|
||||
o.object.transform.origin = s.pos
|
||||
o.object.rotation = s.rotation
|
||||
o.object.scale = s.scale
|
||||
inv_remove_invalid_items(s.inventory)
|
||||
game.add_child(o.object)
|
||||
if o.object.has_method("on_load"):
|
||||
o.object.on_load(o)
|
||||
|
||||
func load_player(name:String="player"):
|
||||
player = {
|
||||
player=true,
|
||||
name = name,
|
||||
id = 0,
|
||||
right_item = null,
|
||||
left_item = null,
|
||||
inventory = {
|
||||
main=new_inventory(32),
|
||||
craft=new_inventory(9),
|
||||
craftoutput=new_inventory(1)
|
||||
},
|
||||
slot_index = 0,
|
||||
hotbar_count = 8,
|
||||
right_slot = 4,
|
||||
left_slot = 0,
|
||||
object = load("res://engine/player/player.tscn").instance(),
|
||||
meta = {}
|
||||
}
|
||||
var s = save.player
|
||||
player.object.player = player
|
||||
|
||||
if s != null and s.size() > 0:
|
||||
player.object.transform.origin = s.pos
|
||||
player.object.rotation = s.rotation
|
||||
for i in s:
|
||||
player[i] = s[i]
|
||||
inv_remove_invalid_items(player.inventory)
|
||||
else:
|
||||
player.object.transform.origin = Vector3(0,2,0)
|
||||
player.inventory={
|
||||
main=core.new_inventory(32,[
|
||||
core.itemstack("default:chest",{count=10}),
|
||||
core.itemstack("default:stone_pick"),
|
||||
]),
|
||||
|
||||
craft=core.new_inventory(9),
|
||||
craftoutput=core.new_inventory(1)
|
||||
}
|
||||
game.add_child(player.object)
|
||||
|
||||
func save_player_objects():
|
||||
if player != null:
|
||||
var sp = {}
|
||||
sp.slot_index = player.slot_index
|
||||
sp.right_slot = player.right_slot
|
||||
sp.left_slot = player.left_slot
|
||||
sp.pos = player.object.transform.origin
|
||||
sp.inventory = player.inventory
|
||||
sp.rotation = player.object.rotation
|
||||
sp.meta = player.meta
|
||||
save.player = sp
|
||||
|
||||
var ob2s = {}
|
||||
for i in objects:
|
||||
var o = objects[i]
|
||||
if o.get("object") != null and o.url != null and is_instance_valid(o.object):
|
||||
var s = {}
|
||||
s.id = o.id
|
||||
s.name = o.name
|
||||
s.type = o.type
|
||||
s.inventory = o.inventory
|
||||
s.url = o.url
|
||||
s.meta = o.meta
|
||||
s.pos = o.object.global_transform.origin
|
||||
s.rotation = o.object.rotation
|
||||
s.scale = o.object.scale
|
||||
ob2s[i] = s
|
||||
else:
|
||||
objects.erase(i)
|
||||
save.objects = ob2s
|
||||
|
||||
func load_file(path):
|
||||
var file = File.new()
|
||||
if not file.file_exists(path):
|
||||
return
|
||||
file.open(path,file.READ)
|
||||
var l = file.get_var()
|
||||
file.close()
|
||||
return l
|
||||
|
||||
func save_file(path,s):
|
||||
var D = Directory.new()
|
||||
var dir = path.get_base_dir().get_file()
|
||||
if D.dir_exists(str("user://",dir)) == false:
|
||||
D.make_dir(str("user://",dir))
|
||||
var file = File.new()
|
||||
file.open(str(path),file.WRITE_READ)
|
||||
file.store_var(s)
|
||||
file.close()
|
||||
|
||||
func load_data():
|
||||
var s = load_file(str("user://worlds/",world_name,".mworld"))
|
||||
save.mods = s.mods
|
||||
save.player = s.player
|
||||
if s.get(world.name):
|
||||
world = s[world.name].world
|
||||
save.objects = s[world.name].objects
|
||||
save.map = s[world.name].map.duplicate()
|
||||
meta = s[world.name].meta.duplicate()
|
||||
load_objects()
|
||||
else:
|
||||
world = world
|
||||
save.objects = {}
|
||||
save.map = {}
|
||||
meta = {}
|
||||
return true
|
||||
|
||||
func save_data():
|
||||
if world_name == "":
|
||||
return
|
||||
save_player_objects()
|
||||
var s = load_file(str("user://worlds/",world_name,".mworld"))
|
||||
if s == null:
|
||||
s = {}
|
||||
s.player = save.player
|
||||
s.mods = save.mods
|
||||
s[world.name] = {
|
||||
world=world,
|
||||
objects=save.objects,
|
||||
meta=meta,
|
||||
map=save.map,
|
||||
}
|
||||
save_file(str("user://worlds/",world_name,".mworld"),s)
|
||||
|
||||
func delete_data(wn=world_name):
|
||||
var d = Directory.new()
|
||||
d.remove(str("user://worlds/",wn,".mworld"))
|
||||
|
||||
func _process(delta):
|
||||
save_timer += delta
|
||||
if save_timer > settings.save_timeout:
|
||||
save_timer = 0
|
||||
save_data()
|
||||
|
||||
func get_pointed_pos():
|
||||
var pos = player.object.get_translation()
|
||||
var aim = player.object.get_node("head/Camera").get_global_transform().basis
|
||||
var hpos = player.object.get_node("head").get_translation()
|
||||
#var lpos = (pos + hpos+aim.z).round()
|
||||
for i in range(-1,-500,-1):
|
||||
var p = (pos + hpos+(aim.z*Vector3(i*0.01,i*0.01,i*0.01)))#.round()
|
||||
var rp = p.round()
|
||||
var id = map.get(rp)
|
||||
var reg = get_node_reg(id)
|
||||
if reg != null and reg.get("drawtype") != "none" and reg.get("collidable") != false:
|
||||
if (p.x >= rp.x-0.5 and p.x <= rp.x+0.5) and (p.y >= rp.y-0.5 and p.y <= rp.y+0.5) and (p.z >= rp.z-0.5 and p.z <= rp.z+0.5):
|
||||
return {inside=rp,outside=p}
|
||||
#lpos = rp
|
||||
return {inside=null,outside=null}
|
||||
|
||||
func place_node(node,inside:bool=false):
|
||||
var pos = player.object.get_translation()
|
||||
var aim = player.object.get_node("head/Camera").get_global_transform().basis
|
||||
var hpos = player.object.get_node("head").get_translation()
|
||||
var lpos = (pos + hpos+aim.z).round()
|
||||
|
||||
for i in range(-1,-500,-1):
|
||||
var p = (pos + hpos+(aim.z*Vector3(i*0.01,i*0.01,i*0.01)))#.round()
|
||||
var rp = p.round()
|
||||
var id = map.get(rp)
|
||||
var reg = get_node_reg(id)
|
||||
if reg != null and reg.get("drawtype") != "none" and reg.get("collidable") != false and chunk.get_chunk_at_pos(rp):
|
||||
if (p.x >= rp.x-0.5 and p.x <= rp.x+0.5) and (p.y >= rp.y-0.5 and p.y <= rp.y+0.5) and (p.z >= rp.z-0.5 and p.z <= rp.z+0.5):
|
||||
if get_node_reg(node).get("collidable") == false or (pos-hpos).distance_to(p) > 0.9 and (pos+hpos).distance_to(p) > 1:
|
||||
var pp = rp if inside == true or reg.get("replaceable") == true else lpos
|
||||
set_node({name=node,pos=pp})
|
||||
return true
|
||||
return false
|
||||
lpos = rp
|
||||
return false
|
||||
|
||||
func get_item_reg(v):
|
||||
var it = register.items.get(v)
|
||||
if it:
|
||||
return it
|
||||
elif v is Vector3:
|
||||
v = v.round()
|
||||
v = map.get(v)
|
||||
elif v is String:
|
||||
return register.nodes.get(v)
|
||||
var n = register.id.get(v)
|
||||
return register.nodes.get(n)
|
||||
|
||||
func get_node_reg(v):
|
||||
if v is Vector3:
|
||||
v = v.round()
|
||||
v = map.get(v)
|
||||
elif v is String:
|
||||
return register.nodes.get(v)
|
||||
var n = register.id.get(v)
|
||||
return register.nodes.get(n)
|
||||
|
||||
func set_node(def:Dictionary):# set node
|
||||
assert(typeof(def.get("pos")) == TYPE_VECTOR3 and typeof(def.get("name")) == TYPE_STRING,"ERROR: set_node: def.pos & def.name required!")
|
||||
var n = register.nodes.get(def.name)
|
||||
assert(n != null,str('ERROR: set_node: "',def.name,'"', " doesn't exists"))
|
||||
var rpos = def.pos.round()
|
||||
var reg = get_node_reg(def.name)
|
||||
node_removed(map[rpos],rpos)
|
||||
map[rpos] = reg.id
|
||||
save.map[rpos] = reg.id
|
||||
var cid = chunk.pos_to_chunkid(rpos)
|
||||
for r in settings.update_chunk_rules.size():
|
||||
var near_chunk = rpos+settings.update_chunk_rules[r]
|
||||
if chunk.pos_to_chunkid(near_chunk) != cid:
|
||||
chunk.update(near_chunk)
|
||||
chunk.update(rpos)
|
||||
|
||||
func inset_map_node_id(id,pos):
|
||||
map[pos] = id
|
||||
|
||||
func item2mesh(item, priority_render:bool = false):
|
||||
var reg = get_item_reg(item)
|
||||
var mesh = Mesh.new()
|
||||
var st = SurfaceTool.new()
|
||||
|
||||
if reg.type == "node":
|
||||
var tiles = reg.tiles
|
||||
var tile
|
||||
if reg.drawtype == "none":
|
||||
return mesh
|
||||
for f in default_node.faces.size()+1:
|
||||
st.begin(Mesh.PRIMITIVE_TRIANGLE_FAN)
|
||||
var mat = SpatialMaterial.new()
|
||||
if tiles.size() >= f:
|
||||
tile = tiles[f-1]
|
||||
mat.flags_transparent = (reg.get("transparent") == true)
|
||||
mat.albedo_texture = tile
|
||||
st.set_material(mat)
|
||||
for v in range(0,4):
|
||||
st.add_uv(default_node.uv[v])
|
||||
st.add_vertex(default_node.faces[f-1][v]-Vector3(0.5,-0.5,0.5))#-Vector3(0,0,0.5)
|
||||
st.commit(mesh)
|
||||
st.clear()
|
||||
else:
|
||||
var texture = reg.inv_image
|
||||
var faces = default_node.faces
|
||||
var img = texture.get_data()
|
||||
var s = img.get_size()
|
||||
img.decompress()
|
||||
img.flip_y()
|
||||
img.flip_x()
|
||||
img.lock()
|
||||
var size = Vector3(0.075,0.075,0.075)
|
||||
for y in s.y:
|
||||
for x in s.x:
|
||||
var c = img.get_pixel(x,y)
|
||||
if c.a != 0:
|
||||
var f = [4,5]
|
||||
var mat = SpatialMaterial.new()
|
||||
mat.albedo_color = c
|
||||
mat.flags_no_depth_test = priority_render
|
||||
if y == s.y-1 or img.get_pixel(x,y+1).a == 0:
|
||||
f.push_back(0)
|
||||
if y == 0 or img.get_pixel(x,y-1).a == 0:
|
||||
f.push_back(1)
|
||||
if x == s.x-1 or img.get_pixel(x+1,y).a == 0:
|
||||
f.push_back(2)
|
||||
if x == 0 or img.get_pixel(x-1,y).a == 0:
|
||||
f.push_back(3)
|
||||
for n in f:
|
||||
st.begin(Mesh.PRIMITIVE_TRIANGLE_FAN)
|
||||
st.set_material(mat)
|
||||
for v in 4:
|
||||
st.add_vertex((faces[n][v]+Vector3(x-7,y-7,0))*size)
|
||||
st.commit(mesh)
|
||||
st.clear()
|
||||
img.unlock()
|
||||
return mesh
|
||||
|
||||
func new_inventory(size:int = 32,items:Array=[]):
|
||||
items.resize(size)
|
||||
return items
|
||||
|
||||
func itemstack(item:String,def:Dictionary={}):
|
||||
var reg = get_item_reg(item)
|
||||
if reg == null:
|
||||
return null
|
||||
var durability = 0 if reg.get("item_capabilities") == null or reg.item_capabilities.get("durability") == null else reg.item_capabilities.durability
|
||||
return {
|
||||
name = item if def.get("item") == null else def.get("item"),
|
||||
count = def.get("count") if def.get("count") != null and def.get("count") <= reg.max_count else reg.max_count,
|
||||
durability = durability if def.get("durability") == null else def.get("durability"),
|
||||
meta = {} if def.get("meta") == null else def.get("meta"),
|
||||
}
|
||||
func item_groups(item):
|
||||
var it = register.items.get(item)
|
||||
var nu = register.nodes.get(item)
|
||||
if it:
|
||||
var cap = it.get("item_capabilities")
|
||||
if cap != null:
|
||||
return cap.groups
|
||||
elif nu:
|
||||
return nu.groups
|
||||
|
||||
func stack_2invitem(stack):
|
||||
var t = TextureRect.new()
|
||||
var reg = get_item_reg(stack.name)
|
||||
t.texture = item3Dimg(stack.name)
|
||||
#t.texture = reg.get("inv_image") if reg.type == "item" else reg.tiles[0]
|
||||
t.expand = true
|
||||
t.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
t.rect_size = Vector2(100,100)
|
||||
t.rect_clip_content = true
|
||||
t.name = "item"
|
||||
var d = Node2D.new()
|
||||
d.add_child(t)
|
||||
|
||||
var c = reg.get("item_capabilities")
|
||||
if c != null and c.get("durability") != null:
|
||||
var bar1 = ColorRect.new()
|
||||
bar1.rect_size = Vector2(100,3)
|
||||
bar1.rect_position = Vector2(0,96)
|
||||
bar1.color = Color(255,0,0)
|
||||
t.add_child(bar1)
|
||||
var bar2 = ColorRect.new()
|
||||
var d1 = float(stack.durability)/float(c.durability)
|
||||
bar2.rect_size = Vector2(100*d1,3)
|
||||
bar2.color = Color(0,255,0)
|
||||
bar1.add_child(bar2)
|
||||
else:
|
||||
var p = Label.new()
|
||||
p.text = str(stack.count)
|
||||
p.rect_size = Vector2(50,5)
|
||||
p.rect_position = Vector2(0,70)
|
||||
p.rect_scale = Vector2(2,2)
|
||||
p.align = HALIGN_RIGHT
|
||||
p.name = "text"
|
||||
t.add_child(p)
|
||||
return d
|
||||
|
||||
func setMeta(pos:Vector3,label,set=null):
|
||||
if label == null:
|
||||
meta.erase(pos)
|
||||
return
|
||||
meta[pos] = {} if meta.get(pos) == null else meta[pos]
|
||||
var lab = meta[pos].get(label)
|
||||
meta[pos][label] = {} if lab == null else meta[pos][label]
|
||||
if lab == null:
|
||||
meta[pos].erase(pos)
|
||||
else:
|
||||
meta[pos][label] = set
|
||||
func getMeta(pos:Vector3,label=null):
|
||||
if meta.get(pos) == null or label == null:
|
||||
return
|
||||
return meta[pos].get(label)
|
||||
|
||||
func existsMeta(pos):
|
||||
return meta.get(pos) != null
|
||||
|
||||
func create_node_inventory(pos:Vector3,name,size:int=32,add_to_stack=null):
|
||||
meta[pos] = {} if meta.get(pos) == null else meta[pos]
|
||||
meta[pos].inventory = {} if meta[pos].get("inventory") == null else meta[pos].inventory
|
||||
meta[pos].inventory[name] = new_inventory(size,add_to_stack)
|
||||
|
||||
func get_inventory(ref,name):
|
||||
var inv
|
||||
if ref is Vector3:
|
||||
if meta.get(ref):
|
||||
if meta[ref].get("inventory") != null and meta[ref].inventory.get(name):
|
||||
inv = meta[ref].inventory[name]
|
||||
elif ref.get("player"):
|
||||
inv = ref.inventory[name]
|
||||
elif objects.get(ref.id):
|
||||
inv = ref.inventory[name]
|
||||
return inv
|
||||
|
||||
func get_inventory_stack(ref,name,i):
|
||||
var inv = get_inventory(ref,name)
|
||||
var stack = inv[i]
|
||||
if stack != null:
|
||||
var reg = get_item_reg(stack.name)
|
||||
if reg == null:
|
||||
inv[i] = null
|
||||
else:
|
||||
return stack
|
||||
|
||||
func add_to_inventory(ref,name,stack):
|
||||
var inv
|
||||
var reg = get_item_reg(stack.name)
|
||||
var stack2 = stack.duplicate()
|
||||
if reg == null:
|
||||
return stack2
|
||||
elif ref is Vector3:
|
||||
if meta.get(ref):
|
||||
if meta[ref].get("inventory") != null and meta[ref].inventory.get(name):
|
||||
inv = meta[ref].inventory[name]
|
||||
elif player.get(ref.name):
|
||||
inv = ref.inventory[name]
|
||||
elif objects.get(ref.id):
|
||||
inv = ref.inventory[name]
|
||||
else:
|
||||
return stack2
|
||||
var c = stack.count
|
||||
var m = reg.max_count
|
||||
|
||||
for i in inv.size():
|
||||
var slot = inv[i]
|
||||
if slot != null and slot.name == stack.name:
|
||||
var can_add = m - slot.count
|
||||
if can_add <= c:
|
||||
slot.count += can_add
|
||||
c -= can_add
|
||||
else:
|
||||
slot.count += c
|
||||
c = 0
|
||||
stack2.count = c
|
||||
if c <= 0:
|
||||
return stack2
|
||||
for i in inv.size():
|
||||
var slot = inv[i]
|
||||
if slot == null:
|
||||
if m <= c:
|
||||
inv[i] = itemstack(reg.name,{count=m})
|
||||
c -= m
|
||||
else:
|
||||
inv[i] = itemstack(reg.name,{count=c})
|
||||
c = 0
|
||||
stack2.count = c
|
||||
if c <= 0:
|
||||
return stack2
|
||||
return stack2
|
||||
|
||||
func get_drop(name_pos_id):
|
||||
var reg = get_item_reg(name_pos_id)
|
||||
var drop = reg.get("drop")
|
||||
var drops = {}
|
||||
var a = {}
|
||||
if drop == null:
|
||||
drops[reg.name] = 1
|
||||
elif drop is String:
|
||||
drops[drop] = 1
|
||||
elif drop is Dictionary:
|
||||
for i in drop:
|
||||
var d = drop[i]
|
||||
if d.get("chance") == null or round(rand_range(0,d.chance)) == d.chance:
|
||||
var count = 1 if d.get("count") == null else d.count
|
||||
drops[i] = count if drops.get(i) == null else drops[i]+count
|
||||
if d.get("additional") == false:
|
||||
drops = {}
|
||||
drops[i] = count
|
||||
break
|
||||
for i in drops:
|
||||
a[i]=itemstack(i,{count=drops[i]})
|
||||
return a
|
||||
|
||||
func item3Dimg(item):
|
||||
var texture = viewport_items.get(item)
|
||||
if texture == null:
|
||||
var tex = load("res://engine/item_to_texture/item_to_texture.tscn").instance()
|
||||
add_child(tex)
|
||||
texture = tex.texture(item)
|
||||
viewport_items[item] = texture
|
||||
return texture
|
||||
|
||||
func spawn_drop_item(pos,stack,droper=null):
|
||||
var d = load("res://game/item_drop/item_drop.tscn").instance()
|
||||
var ob = add_object(d,"item_drop",d.filename)
|
||||
if d.has_method("on_spawn"):
|
||||
d.on_spawn(ob)
|
||||
d.spawn(pos,stack,droper,ob)
|
||||
add_child(d)
|
||||
return d
|
||||
|
||||
func inv_remove_invalid_items(inv):
|
||||
for list in inv:
|
||||
var i = 0
|
||||
for stack in inv[list]:
|
||||
if stack != null and get_item_reg(stack.name) == null:
|
||||
inv[list][i] = null
|
||||
i += 1
|
||||
func Error(msg):
|
||||
error = true
|
||||
world_quit()
|
||||
main.get_node("exitmsg/center/text").text = msg
|
||||
main.move_child(main.get_node("exitmsg"),main.get_child_count())
|
||||
main.get_node("exitmsg").visible = true
|
||||
yield(get_tree().create_timer(0.01),"timeout")
|
||||
error = false
|
||||
func option_flash(o,text="",color=Color(1,0,0,0.8),blacktext=false):
|
||||
var b = Node2D.new()
|
||||
b.z_index = 1000
|
||||
add_child(b)
|
||||
var u = ColorRect.new()
|
||||
u.rect_size = o.rect_size
|
||||
u.rect_position = o.rect_global_position
|
||||
u.color = color
|
||||
b.add_child(u)
|
||||
var l = Label.new()
|
||||
l.text = text
|
||||
l.align = Label.ALIGN_CENTER
|
||||
l.valign = Label.VALIGN_CENTER
|
||||
l.rect_size = o.rect_size
|
||||
u.add_child(l)
|
||||
u.rect_size.x = l.rect_size.x
|
||||
l.add_color_override("font_color",Color(0,0,0) if blacktext else Color(1,1,1))
|
||||
yield(get_tree().create_timer(1),"timeout")
|
||||
u.free()
|
||||
|
||||
func node_set(id,pos):
|
||||
var reg = get_node_reg(id)
|
||||
if reg.get("touchable"):
|
||||
var c = chunk.get_chunk_at_pos(pos)
|
||||
var a = Area.new()
|
||||
var col = CollisionShape.new()
|
||||
col.shape = BoxShape.new()
|
||||
col.scale = Vector3(0.51,0.51,0.51)
|
||||
c.add_child(a)
|
||||
a.add_child(col)
|
||||
a.name = str(var2str(pos),"touchable")
|
||||
a.global_transform.origin = pos
|
||||
a.connect("body_entered",self,"node_touch",[id,pos,true])
|
||||
a.connect("body_exited",self,"node_touch",[id,pos,false])
|
||||
func node_removed(id,pos):
|
||||
var reg = get_node_reg(id)
|
||||
if reg.get("touchable"):
|
||||
var c = chunk.get_chunk_at_pos(pos)
|
||||
var n = str(var2str(pos),"touchable")
|
||||
if c.has_node(n):
|
||||
c.get_node(n).queue_free()
|
||||
func node_touch(body,id,pos,touch):
|
||||
if not body is StaticBody:
|
||||
var reg = get_node_reg(id)
|
||||
for i in WaEngine.nodes:
|
||||
var ob = WaEngine.nodes[i]
|
||||
if ob.name == "register_node" and ob.options.touchable and ob.options.name == reg.name:
|
||||
if touch:
|
||||
WaEngine.next_connection(ob,"on_touch",body)
|
||||
else:
|
||||
WaEngine.next_connection(ob,"on_untouch",body)
|
||||
yield(get_tree().create_timer(0.1),"timeout")
|
||||
WaEngine.next_connection(ob,"pos",pos)
|
79
engine/gui.gd
Normal file
@ -0,0 +1,79 @@
|
||||
extends Node
|
||||
|
||||
func show(player:Dictionary,text:String):
|
||||
var s = text.split("]",false)
|
||||
var Gui = {player=player,player_object=player.object}
|
||||
assert(s[0].substr(0,10) == "background","ERROR: GUI.create: first element must be background!")
|
||||
for v in s:
|
||||
var n = v.find("[")
|
||||
var ob = v.substr(0,n)
|
||||
var op = [Gui]
|
||||
var ops = v.substr(n+1,-1).split(";",false)
|
||||
for i in ops:
|
||||
op.push_back(i)
|
||||
var S = ops.size()
|
||||
if ob == "background" and GUI.get("background") == null:
|
||||
callv("background",op)
|
||||
elif ob == "inventory" and S >= 3:
|
||||
callv("inventory",op)
|
||||
player.object.add_child(Gui.background.object)
|
||||
player.object.gui = Gui
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CONFINED)
|
||||
|
||||
func background(Gui,x="8",y="4",color="Color(0.1,0.1,0.1,0.9)"):
|
||||
x = float(x)*50
|
||||
y = float(y)*50
|
||||
color = str2var(color)
|
||||
var size = Vector2(x,y)
|
||||
var vs = core.ui.get_viewport_rect().size
|
||||
var pos = (vs/2) - (size/2)
|
||||
var back = ColorRect.new()
|
||||
back.rect_size = size
|
||||
back.rect_position = pos
|
||||
back.color = color
|
||||
Gui.background = {size=size,pos=pos,object=back}
|
||||
return Gui
|
||||
|
||||
func inventory(Gui,inv,name,x,y,w="1",h="1",size="50"):
|
||||
x = float(x)*50
|
||||
y = float(y)*50
|
||||
w = int(w)
|
||||
h = int(h)
|
||||
size = int(size)
|
||||
var X = 0
|
||||
var Y = 0
|
||||
|
||||
if inv.substr(0,7) == "player:":
|
||||
inv = core.player.inventory[name]
|
||||
elif inv.substr(0,7) == "object:":
|
||||
inv = core.objects[inv.substr(7)].inventory[name]
|
||||
elif inv.substr(0,5) == "node:":
|
||||
|
||||
inv = core.meta[str2var(inv.substr(5))].inventory[name]
|
||||
|
||||
Gui.inventory = {ref={},selected=null} if Gui.get("inventory") == null else Gui.inventory
|
||||
var lab = str(Gui.inventory.ref.size())
|
||||
Gui.inventory.ref[lab] = {inv=inv,slots={},name=name}
|
||||
|
||||
for i in w*h:
|
||||
var it = inv[i]
|
||||
var slot = TextureRect.new()
|
||||
slot.texture = load("res://game/textures/slot.png")
|
||||
slot.rect_size = Vector2(size,size)
|
||||
slot.rect_position = Vector2(x+X,y+Y)
|
||||
slot.name = str(i)
|
||||
Gui.inventory.ref[lab].slots[slot.name]={slot=slot}
|
||||
X += size
|
||||
|
||||
if X >= w*size:
|
||||
X = 0
|
||||
Y += size
|
||||
if it != null:
|
||||
var item = core.stack_2invitem(it)
|
||||
item.get_node("item").rect_scale = item.get_node("item").rect_scale/2
|
||||
Gui.inventory.ref[lab].slots[slot.name].item = item
|
||||
slot.add_child(item)
|
||||
else:
|
||||
Gui.inventory.ref[lab].slots[slot.name].item = null
|
||||
Gui.background.object.add_child(slot)
|
||||
return Gui
|
10
engine/item_to_texture/item_to_texture.gd
Normal file
@ -0,0 +1,10 @@
|
||||
extends Spatial
|
||||
|
||||
func texture(a):
|
||||
$viewport/mesh.mesh = core.item2mesh(a)
|
||||
var reg = core.get_item_reg(a)
|
||||
if reg.type == "item":
|
||||
$viewport/mesh.transform.origin = Vector3(0.3,-0.1,0)
|
||||
$viewport/mesh.scale = Vector3(1.2,1.2,1.2)
|
||||
$viewport/mesh.rotation = Vector3(0,3.5,0)
|
||||
return $viewport.get_texture()
|
32
engine/item_to_texture/item_to_texture.tscn
Normal file
@ -0,0 +1,32 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://engine/item_to_texture/item_to_texture.gd" type="Script" id=1]
|
||||
[ext_resource path="res://default_env.tres" type="Environment" id=2]
|
||||
|
||||
[sub_resource type="World" id=1]
|
||||
environment = ExtResource( 2 )
|
||||
|
||||
[sub_resource type="CubeMesh" id=2]
|
||||
|
||||
[node name="viewport" type="Spatial"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="viewport" type="Viewport" parent="."]
|
||||
size = Vector2( 100, 100 )
|
||||
own_world = true
|
||||
world = SubResource( 1 )
|
||||
transparent_bg = true
|
||||
render_target_v_flip = true
|
||||
render_target_update_mode = 1
|
||||
|
||||
[node name="light" type="OmniLight" parent="viewport"]
|
||||
transform = Transform( 1, 2.98023e-08, -2.98023e-08, -2.98023e-08, 1, 1.49012e-08, 2.98023e-08, -1.49012e-08, 1, 1, 0.5, 2 )
|
||||
|
||||
[node name="mesh" type="MeshInstance" parent="viewport"]
|
||||
transform = Transform( 0.699393, 0.0190852, -0.714482, -0.453154, 0.784886, -0.422618, 0.552721, 0.619347, 0.557592, 0, 0, 0 )
|
||||
mesh = SubResource( 2 )
|
||||
material/0 = null
|
||||
|
||||
[node name="cam" type="Camera" parent="viewport"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.15, 1.2 )
|
||||
current = true
|
21
engine/loader/loader.gd
Normal file
@ -0,0 +1,21 @@
|
||||
extends Control
|
||||
|
||||
var progressions = {0:"loading..."}
|
||||
func _ready():
|
||||
core.Loader = self
|
||||
|
||||
func setprogress(v):
|
||||
$progressbar.value = v
|
||||
for i in progressions:
|
||||
if v >= i:
|
||||
$progressbar/label.text = progressions[i]
|
||||
if v >= $progressbar.max_value:
|
||||
visible = false
|
||||
func end():
|
||||
visible = false
|
||||
func start(end,p=null):
|
||||
#core.main.move_child(core.main.get_node("loader"),core.main.get_child_count())
|
||||
progressions = p
|
||||
$progressbar.value = 0
|
||||
$progressbar.max_value = end
|
||||
visible = true
|
33
engine/loader/loader.tscn
Normal file
@ -0,0 +1,33 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://engine/loader/loader.gd" type="Script" id=1]
|
||||
[ext_resource path="res://game/textures/stone.png" type="Texture" id=2]
|
||||
|
||||
[node name="loader" type="TextureRect"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
texture = ExtResource( 2 )
|
||||
expand = true
|
||||
stretch_mode = 7
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="progressbar" type="ProgressBar" parent="."]
|
||||
margin_top = 560.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
step = 0.1
|
||||
|
||||
[node name="label" type="Label" parent="progressbar"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_top = -14.0
|
||||
margin_bottom = -40.0
|
||||
text = "Loading..."
|
||||
align = 1
|
||||
valign = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
88
engine/mapgen.gd
Normal file
@ -0,0 +1,88 @@
|
||||
extends Node
|
||||
|
||||
var timer = 1
|
||||
var n2gc_timer = -0.01
|
||||
var n2gc_time = 0
|
||||
var mapgens = ["super_flatland","none","super_flatstoneland"]
|
||||
|
||||
func _ready():
|
||||
set_process(false)
|
||||
|
||||
|
||||
func _process(delta):
|
||||
timer += delta
|
||||
if timer > n2gc_time and core.player != null:
|
||||
if n2gc_timer >= 1:
|
||||
n2gc_timer = 0
|
||||
n2gc_time = 1
|
||||
else:
|
||||
n2gc_timer += timer
|
||||
timer = 0
|
||||
|
||||
var player = core.player
|
||||
var ppos = player.object.global_transform.origin
|
||||
var pos = core.chunk.to_chunk_pos(ppos)
|
||||
if core.chunk.get_chunk_at_pos(pos) == null:
|
||||
core.chunk.new_chunk(pos)
|
||||
core.current_mapgen.call_func(pos)
|
||||
n2gc_time = 0
|
||||
n2gc_timer = 0
|
||||
for i in range(1,core.settings.ganerate_chunk_range):
|
||||
var r = core.chunk_size*i
|
||||
var s = core.chunk_size
|
||||
for x in range(-r,r,s):
|
||||
for y in range(-r,r,s):
|
||||
for z in range(-r,r,s):
|
||||
pos = Vector3(x,y,z) + core.chunk.to_chunk_pos(ppos)
|
||||
if core.chunk.get_chunk_at_pos(pos) == null:
|
||||
core.chunk.new_chunk(pos)
|
||||
core.current_mapgen.call_func(pos)
|
||||
n2gc_time = 0
|
||||
n2gc_timer = 0
|
||||
|
||||
func none(pos):
|
||||
pass
|
||||
|
||||
func super_flatland(pos):
|
||||
var id
|
||||
var grassy = core.get_node_reg("default:grassy").id
|
||||
var dirt = core.get_node_reg("default:dirt").id
|
||||
var stone = core.get_node_reg("default:stone").id
|
||||
var air = core.get_node_reg("air").id
|
||||
var Y
|
||||
for x in range(-core.chunk_size/2,core.chunk_size/2):
|
||||
for y in range(-core.chunk_size/2,core.chunk_size/2):
|
||||
for z in range(-core.chunk_size/2,core.chunk_size/2):
|
||||
var p = Vector3(x,y,z)+pos
|
||||
Y = pos.y+y
|
||||
if core.map.get(p) != 0:
|
||||
continue
|
||||
elif Y == 0:
|
||||
id = grassy
|
||||
elif Y < -3:
|
||||
id = stone
|
||||
elif Y < 0:
|
||||
id = dirt
|
||||
else:
|
||||
id = air
|
||||
core.inset_map_node_id(id,p)
|
||||
core.chunk.update(pos)
|
||||
|
||||
func super_flatstoneland(pos):
|
||||
var id
|
||||
var stone = core.get_node_reg("default:cobble").id
|
||||
var air = core.get_node_reg("air").id
|
||||
var Y
|
||||
for x in range(-core.chunk_size/2,core.chunk_size/2):
|
||||
for y in range(-core.chunk_size/2,core.chunk_size/2):
|
||||
for z in range(-core.chunk_size/2,core.chunk_size/2):
|
||||
var p = Vector3(x,y,z)+pos
|
||||
Y = pos.y+y
|
||||
if core.map.get(p) != 0:
|
||||
continue
|
||||
elif Y <= 0:
|
||||
id = stone
|
||||
else:
|
||||
id = air
|
||||
core.inset_map_node_id(id,p)
|
||||
core.chunk.update(pos)
|
3
engine/mob/mob.gd
Normal file
@ -0,0 +1,3 @@
|
||||
extends KinematicBody
|
||||
|
||||
var mob = {}
|
6
engine/mob/mob.tscn
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://engine/mob/mob.gd" type="Script" id=1]
|
||||
|
||||
[node name="mob" type="KinematicBody"]
|
||||
script = ExtResource( 1 )
|
422
engine/player/player.gd
Normal file
@ -0,0 +1,422 @@
|
||||
extends KinematicBody
|
||||
|
||||
var direction = Vector3()
|
||||
var velocity = Vector3()
|
||||
|
||||
var gravity = -27
|
||||
var phys_object = {right=null,left=null}
|
||||
onready var phys_ray = $head/Camera/phys_ray
|
||||
var jump_height = 10
|
||||
var walk_speed = 10
|
||||
var player
|
||||
var using = {time=0,wear=0,right_time=0,left_time=0,right=false,left=false,pos=Vector3()}
|
||||
var cam_mode = 1
|
||||
var gui
|
||||
var fpv_camera_angle = 0
|
||||
var fpv_mouse_sensitivity = 0.3
|
||||
var tpv_camera_speed = 0.001
|
||||
var fly_mode = false
|
||||
var item_drop_timer = 0.1
|
||||
onready var last_pos_before_fall = transform.origin
|
||||
|
||||
func _ready():
|
||||
update_player()
|
||||
core.ui.slot_index(player.right_slot)
|
||||
core.ui.slot_index(player.left_slot)
|
||||
core.ui.slot_index(player.slot_index)
|
||||
func _input(event):
|
||||
if Input.is_action_just_pressed("SCREENSHOT"):
|
||||
var img = get_viewport().get_texture().get_data()
|
||||
img.flip_y()
|
||||
var d = Directory.new()
|
||||
var i = 1
|
||||
var saved = false
|
||||
while saved == false:
|
||||
var s = str("screenshots/screenshot",i,".png")
|
||||
if d.file_exists(s):
|
||||
i += 1
|
||||
else:
|
||||
if d.dir_exists("screenshots") == false:
|
||||
d.make_dir("screenshots")
|
||||
var file = File.new()
|
||||
file.open("screenshots/.gdignore",file.WRITE_READ)
|
||||
file.store_string("")
|
||||
file.close()
|
||||
img.save_png(s)
|
||||
saved = true
|
||||
elif core.WaEditor.enabled:
|
||||
return
|
||||
elif Input.is_action_just_pressed("use"):
|
||||
if gui != null:
|
||||
gui.background.object.queue_free()
|
||||
gui = null
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
update_player()
|
||||
else:
|
||||
var pointed = core.get_pointed_pos()
|
||||
if pointed.inside != null:
|
||||
var reg = core.get_node_reg(pointed.inside)
|
||||
var activated = false
|
||||
if reg.get("activatable") == true:
|
||||
for i in WaEngine.nodes:
|
||||
var ob = WaEngine.nodes[i]
|
||||
if ob.name == "register_node" and ob.options.activatable and str(ob.mod_name,":",ob.options.name) == reg.name:
|
||||
activated = true
|
||||
WaEngine.next_connection(ob,"on_activate",self)
|
||||
yield(get_tree().create_timer(0.1),"timeout")
|
||||
WaEngine.next_connection(ob,"pos",pointed.inside)
|
||||
elif reg.get("on_activate"):
|
||||
reg.on_activate.call_func(pointed.inside,reg)
|
||||
return
|
||||
elif activated:
|
||||
return
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
GUI.show(player,"background[8;8]inventory[player:player1;main;0;4;8;4]inventory[player:player1;craft;3;0.5;3;3]inventory[player:player1;craftoutput;6.5;1.5]")
|
||||
|
||||
if gui != null:
|
||||
if gui.get("inventory") != null:
|
||||
if event is InputEventMouseButton:
|
||||
var key_pressed = Input.is_action_just_pressed("LMB")
|
||||
var key_released = Input.is_action_just_released("LMB")
|
||||
var p = event.position
|
||||
var inv# = player.inventory
|
||||
var slot
|
||||
var index
|
||||
var stack
|
||||
var stack_reg
|
||||
var cur_ref
|
||||
|
||||
for ref in gui.inventory.ref:
|
||||
cur_ref = gui.inventory.ref[ref]
|
||||
for i in cur_ref.slots:
|
||||
var s = cur_ref.slots[i]
|
||||
var pos = s.slot.rect_global_position
|
||||
var size = s.slot.rect_size
|
||||
var a = pos+size/2
|
||||
if p.distance_to(a) <= s.slot.rect_size.x/2:
|
||||
inv = cur_ref.inv
|
||||
slot = s
|
||||
index = int(i)
|
||||
stack = cur_ref.inv[index]
|
||||
stack_reg = core.get_item_reg(stack.name) if stack != null else null
|
||||
if key_pressed:
|
||||
gui.inventory.selected = {ref=cur_ref,slot=s,index=index,stack=stack,name=s.slot.name}
|
||||
break
|
||||
if slot != null:
|
||||
break
|
||||
|
||||
if gui.inventory.get("selected") == null:
|
||||
return
|
||||
elif key_pressed:
|
||||
if gui.inventory.selected.slot.item != null:
|
||||
gui.inventory.selected.slot.item.z_index = 1000
|
||||
elif key_released:
|
||||
if gui.inventory.selected.slot.item != null:
|
||||
gui.inventory.selected.slot.item.z_index = 100
|
||||
var b = gui.background
|
||||
if p.x < b.pos.x or p.x > b.size.x+b.pos.x or p.y < b.pos.y or p.y > b.size.y+b.pos.y:
|
||||
#del item outside
|
||||
core.spawn_drop_item(transform.origin,gui.inventory.selected.stack,player.name)
|
||||
gui.inventory.selected.slot.item.queue_free()
|
||||
gui.inventory.selected.slot.item = null
|
||||
gui.inventory.selected.ref.inv[gui.inventory.selected.index] = null
|
||||
gui.inventory.selected = null
|
||||
update_player()
|
||||
elif index != null and gui.inventory.selected.index != index and stack == null:
|
||||
#drop on empty slot
|
||||
gui.inventory.selected.slot.item.get_node("item").rect_global_position = slot.slot.rect_global_position
|
||||
inv[index] = gui.inventory.selected.stack
|
||||
gui.inventory.selected.ref.inv[gui.inventory.selected.index] = null
|
||||
slot.item = gui.inventory.selected.slot.item
|
||||
gui.inventory.selected.slot.item = null
|
||||
gui.inventory.selected = null
|
||||
update_player()
|
||||
elif index != null and gui.inventory.selected.index != index and gui.inventory.selected.stack.name == stack.name and stack.count < stack_reg.max_count:
|
||||
#drop on stack
|
||||
var can_add = stack_reg.max_count - stack.count
|
||||
if can_add >= gui.inventory.selected.stack.count:
|
||||
inv[index].count += gui.inventory.selected.stack.count
|
||||
inv[gui.inventory.selected.index] = null
|
||||
slot.item.get_node("item/text").text = str(inv[index].count)
|
||||
gui.inventory.selected.slot.item.free()
|
||||
gui.inventory.selected.slot.item = null
|
||||
gui.inventory.selected = null
|
||||
else:
|
||||
inv[index].count += can_add
|
||||
gui.inventory.selected.ref.inv[gui.inventory.selected.index].count -= can_add
|
||||
slot.item.get_node("item/text").text = str(inv[index].count)
|
||||
gui.inventory.selected.slot.item.get_node("item/text").text = str(gui.inventory.selected.ref.inv[gui.inventory.selected.index].count)
|
||||
gui.inventory.selected.slot.item.get_node("item").rect_global_position = gui.inventory.selected.slot.slot.rect_global_position
|
||||
gui.inventory.selected = null
|
||||
update_player()
|
||||
else:
|
||||
gui.inventory.selected.slot.item.get_node("item").rect_global_position = gui.inventory.selected.slot.slot.rect_global_position
|
||||
gui.inventory.selected = null
|
||||
elif event is InputEventMouseMotion and gui.inventory.get("selected") != null and gui.inventory.selected.slot.get("item") != null:
|
||||
gui.inventory.selected.slot.item.get_node("item").rect_global_position = event.position-gui.inventory.selected.slot.item.get_node("item").rect_size/3
|
||||
return
|
||||
elif Input.is_action_just_pressed("switch_index_side"):
|
||||
var i = player.slot_index
|
||||
var r = player.right_slot
|
||||
var l = player.left_slot
|
||||
player.slot_index = l if i == r else r
|
||||
core.ui.slot_index(player.slot_index)
|
||||
change_wield_item()
|
||||
elif Input.is_action_just_pressed("throw_item"):
|
||||
var inv = core.get_inventory(player,"main")
|
||||
var stack = inv[player.slot_index]
|
||||
if stack != null:
|
||||
var pos = transform.origin
|
||||
var aim = -$head/Camera.get_global_transform().basis.z*15
|
||||
var stack2 = stack.duplicate()
|
||||
if Input.is_key_pressed(KEY_SHIFT):
|
||||
stack.count -= 1
|
||||
stack2.count = 1
|
||||
else:
|
||||
inv[player.slot_index] = null
|
||||
|
||||
var d = core.spawn_drop_item($head.transform.origin+pos,stack2,player.name)
|
||||
d.set_linear_velocity(aim)
|
||||
update_player()
|
||||
|
||||
elif Input.is_key_pressed(KEY_G) and cam_mode == 2:
|
||||
cam_mode = 1
|
||||
$head/Camera.current = true
|
||||
$head/tpv/Camera.current = false
|
||||
$mesh.visible = false
|
||||
#$head/tpv/Camera.set_cull_mask(1)
|
||||
elif Input.is_key_pressed(KEY_H) and cam_mode == 1:
|
||||
# == fps
|
||||
cam_mode = 2
|
||||
$head/Camera.current = false
|
||||
$head/tpv/Camera.current = true
|
||||
$mesh.visible = true
|
||||
elif event is InputEventMouseMotion:
|
||||
if cam_mode == 1:
|
||||
# == First player view
|
||||
rotate_y(deg2rad(-event.relative.x * fpv_mouse_sensitivity))
|
||||
var change = -event.relative.y * fpv_mouse_sensitivity
|
||||
if change + fpv_camera_angle < 90 and change + fpv_camera_angle > -90:
|
||||
$head/Camera.rotate_x(deg2rad(change))
|
||||
fpv_camera_angle += change
|
||||
elif cam_mode == 2:
|
||||
# == Third player view
|
||||
rotate_y(-event.relative.x * tpv_camera_speed)
|
||||
$head/tpv.rotate_x(-event.relative.y * tpv_camera_speed)
|
||||
elif event is InputEventMouseButton:
|
||||
if Input.is_action_just_pressed("RMB"):
|
||||
phys_pickingup()
|
||||
using.right = true
|
||||
$head/Camera/right/anim.play("pick")
|
||||
$head/Camera/right/anim.get_animation("pick").set_loop(true)
|
||||
elif Input.is_action_just_released("RMB"):
|
||||
phys_pickingup(null,null,true)
|
||||
using.right = false
|
||||
using.right_time = 0
|
||||
$head/Camera/right/anim.get_animation("pick").set_loop(false)
|
||||
elif Input.is_action_just_pressed("LMB"):
|
||||
phys_pickingup()
|
||||
using.left = true
|
||||
$head/Camera/left/anim.play("pick")
|
||||
$head/Camera/left/anim.get_animation("pick").set_loop(true)
|
||||
elif Input.is_action_just_released("LMB"):
|
||||
phys_pickingup(null,null,true)
|
||||
using.left = false
|
||||
using.left_time = 0
|
||||
$head/Camera/left/anim.get_animation("pick").set_loop(false)
|
||||
if Input.is_action_just_pressed("WHEEL_DOWN"):
|
||||
player.slot_index += 1
|
||||
if player.slot_index >= player.hotbar_count:
|
||||
player.slot_index = 0
|
||||
core.ui.slot_index(player.slot_index)
|
||||
change_wield_item()
|
||||
elif Input.is_action_just_pressed("WHEEL_UP"):
|
||||
player.slot_index -= 1
|
||||
if player.slot_index < 0:
|
||||
player.slot_index = player.hotbar_count-1
|
||||
core.ui.slot_index(player.slot_index)
|
||||
change_wield_item()
|
||||
|
||||
|
||||
func change_wield_item(inx:int = player.slot_index):
|
||||
var stack = player.inventory["main"][inx]
|
||||
stack = stack if stack != null else core.itemstack("wieldhand")
|
||||
var mesh = core.item2mesh(stack.name,true)
|
||||
if inx >= 4:
|
||||
player.right_slot = inx
|
||||
$head/Camera/right/anim.get_animation("pick").set_loop(false)
|
||||
$head/Camera/right/hand/item.mesh = mesh
|
||||
using.right_time = 0
|
||||
else:
|
||||
player.left_slot = inx
|
||||
$head/Camera/left/hand/item.mesh = mesh
|
||||
$head/Camera/left/anim.get_animation("pick").set_loop(false)
|
||||
$head/Camera/left/hand/item.mesh = mesh
|
||||
using.left_time = 0
|
||||
|
||||
func hand(right):
|
||||
var stack = player.inventory["main"][player.right_slot] if right else player.inventory["main"][player.left_slot]
|
||||
var pos = core.get_pointed_pos()
|
||||
stack = core.itemstack("wieldhand") if stack == null else stack
|
||||
var stack_reg = core.get_item_reg(stack.name)
|
||||
if stack_reg.type == "node" and core.place_node(stack.name):
|
||||
stack.count -= 1
|
||||
if stack.count <= 0:
|
||||
if right:
|
||||
player.inventory["main"][player.right_slot] = null
|
||||
$head/Camera/right/hand/item.mesh = null
|
||||
change_wield_item()
|
||||
else:
|
||||
player.inventory["main"][player.left_slot] = null
|
||||
$head/Camera/left/hand/item.mesh = null
|
||||
change_wield_item()
|
||||
elif stack_reg.type == "item":
|
||||
var dur = stack_reg.get("item_capabilities")
|
||||
if dur != null and pos.inside != null:
|
||||
var node_reg = core.get_node_reg(pos.inside)
|
||||
var ngroups = core.item_groups(node_reg.name)
|
||||
var igroups = dur.groups
|
||||
for ig in igroups:
|
||||
for ng in ngroups:
|
||||
if ig == ng:
|
||||
if using.time <= 0:
|
||||
using.wear = ngroups[ng]
|
||||
using.pos = pos.inside
|
||||
using.time = ngroups[ng]
|
||||
if right:
|
||||
using.right_time = igroups[ig]
|
||||
else:
|
||||
using.left_time = igroups[ig]
|
||||
break
|
||||
break
|
||||
if using.time > 0 and (right and using.right_time > 0 or right == false and using.left_time > 0):
|
||||
var t = using.right_time + using.left_time
|
||||
if t == 0 or pos.inside != using.pos:
|
||||
using.time = 0
|
||||
else:
|
||||
using.time -= t
|
||||
if using.time <= 0:
|
||||
var wear = using.wear/2 if using.right_time > 0 and using.left_time > 0 else using.wear
|
||||
if using.right_time > 0:
|
||||
var s = player.inventory["main"][player.right_slot]
|
||||
if s != null and s.get("durability") != null:
|
||||
s.durability -= wear
|
||||
if s.durability <= 0:
|
||||
player.inventory["main"][player.right_slot] = null
|
||||
$head/Camera/right/hand/item.mesh = null
|
||||
change_wield_item()
|
||||
if using.left_time > 0:
|
||||
var s = player.inventory["main"][player.left_slot]
|
||||
if s != null and s.get("durability") != null:
|
||||
s.durability -= wear
|
||||
if s.durability <= 0:
|
||||
player.inventory["main"][player.left_slot] = null
|
||||
$head/Camera/left/hand/item.mesh = null
|
||||
change_wield_item()
|
||||
using.right_time = 0
|
||||
using.left_time = 0
|
||||
var drops = core.get_drop(using.pos)
|
||||
for i in drops:
|
||||
var stack2 = core.add_to_inventory(player,"main",drops[i])
|
||||
if stack2.count > 0:
|
||||
core.spawn_drop_item(transform.origin,stack2,player.name)
|
||||
|
||||
core.set_node({name="air",pos=using.pos})
|
||||
core.ui.update_hotbar(player.inventory["main"])
|
||||
|
||||
func update_player():
|
||||
core.ui.update_hotbar(player.inventory["main"])
|
||||
change_wield_item(player.right_slot)
|
||||
change_wield_item(player.left_slot)
|
||||
|
||||
func _process(delta):
|
||||
if gui != null:
|
||||
return
|
||||
# == walking
|
||||
direction = Vector3()
|
||||
var aim = $head/Camera.get_global_transform().basis
|
||||
var pos = transform.origin
|
||||
var con = Vector3()
|
||||
|
||||
if phys_ray.enabled:
|
||||
phys_pickingup(pos,aim)
|
||||
if Input.is_key_pressed(KEY_W):
|
||||
con -= aim.z
|
||||
if Input.is_key_pressed(KEY_S):
|
||||
con += aim.z
|
||||
if Input.is_key_pressed(KEY_A):
|
||||
con -= aim.x
|
||||
if Input.is_key_pressed(KEY_D):
|
||||
con += aim.x
|
||||
if Input.is_action_just_pressed("fly_mode"):
|
||||
fly_mode = fly_mode == false
|
||||
$Collision.disabled = fly_mode
|
||||
velocity = Vector3(0,0,0)
|
||||
|
||||
if fly_mode:
|
||||
if Input.is_key_pressed(KEY_SHIFT):
|
||||
con*=0.1
|
||||
transform.origin += con*0.2
|
||||
else:
|
||||
var on_floor = is_on_floor()
|
||||
direction = con
|
||||
direction = direction.normalized()
|
||||
if on_floor:
|
||||
velocity.y = 0
|
||||
elif core.chunk.chunk_loaded_at_pos(pos) == false:
|
||||
velocity.y = 0
|
||||
return
|
||||
else:
|
||||
#if player is inside a collidable block, freeze the movement to prevent falling through the ground
|
||||
var reg = core.get_node_reg(pos)
|
||||
if reg == null or reg.get("collidable") != false or reg.name == "none":
|
||||
if last_pos_before_fall != Vector3():
|
||||
last_pos_before_fall.y += 1
|
||||
transform.origin = last_pos_before_fall
|
||||
last_pos_before_fall = Vector3()
|
||||
return
|
||||
last_pos_before_fall = pos
|
||||
velocity.y += gravity * delta
|
||||
var tv = velocity
|
||||
tv = velocity.linear_interpolate(direction * walk_speed,15 * delta)
|
||||
velocity.x = tv.x
|
||||
velocity.z = tv.z
|
||||
velocity = move_and_slide(velocity,Vector3(0,1,0))
|
||||
# == jumping
|
||||
if on_floor and Input.is_key_pressed(KEY_SPACE):
|
||||
velocity.y = jump_height
|
||||
|
||||
func phys_pickingup(pos=null,aim=null,disable=false):
|
||||
var r = phys_object.right
|
||||
var l = phys_object.left
|
||||
var ur = using.right
|
||||
var ul = using.left
|
||||
|
||||
if (r != null or l != null) and pos != null:
|
||||
if r != null and (is_instance_valid(r) == false or ur == false):
|
||||
phys_object.right = null
|
||||
return
|
||||
if l != null and (is_instance_valid(l) == false or ul == false):
|
||||
phys_object.left = null
|
||||
return
|
||||
if r != null and l != null:
|
||||
r.set_linear_velocity(((pos+$head.transform.origin+((-aim.z*3)+aim.x*1.2))-r.global_transform.origin)*10)
|
||||
l.set_linear_velocity(((pos+$head.transform.origin+((-aim.z*3)-aim.x*1.2))-l.global_transform.origin)*10)
|
||||
else:
|
||||
var ob = r if l == null else l
|
||||
ob.set_linear_velocity(((pos+$head.transform.origin+(-aim.z*3))-ob.global_transform.origin)*10)
|
||||
if r == null and l == null and disable:
|
||||
phys_ray.enabled = false
|
||||
else:
|
||||
phys_ray.enabled = true
|
||||
if phys_ray.is_colliding():
|
||||
var inv = player.inventory["main"]
|
||||
if using.right and inv[player.right_slot] == null or using.left and inv[player.left_slot] == null:
|
||||
var ob = phys_ray.get_collider()
|
||||
if ob is RigidBody:
|
||||
if using.right and phys_object.right == null:
|
||||
$head/Camera/right/anim.get_animation("pick").set_loop(false)
|
||||
phys_object.right = ob
|
||||
elif using.left and phys_object.left == null:
|
||||
$head/Camera/left/anim.get_animation("pick").set_loop(false)
|
||||
phys_object.left = ob
|
149
engine/player/player.tscn
Normal file
@ -0,0 +1,149 @@
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://engine/player/player.gd" type="Script" id=1]
|
||||
|
||||
[sub_resource type="CubeMesh" id=1]
|
||||
|
||||
[sub_resource type="SpatialMaterial" id=2]
|
||||
albedo_color = Color( 1, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="BoxShape" id=3]
|
||||
|
||||
[sub_resource type="Animation" id=4]
|
||||
length = 0.6
|
||||
step = 0.01
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("hand:translation")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.1, 0.2, 0.4, 0.6 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, 0, -0.291107 ), Vector3( 0, -0.211775, -0.445232 ), Vector3( 0, -0.372039, -0.250472 ), Vector3( 0, 0, 0 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("hand:rotation_degrees")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0, 0.2, 0.6 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector3( 0, 90, -45 ), Vector3( 0, 90, -135 ), Vector3( 0, 90, -45 ) ]
|
||||
}
|
||||
tracks/2/type = "method"
|
||||
tracks/2/path = NodePath("../../..")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"times": PoolRealArray( 0.19 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"values": [ {
|
||||
"args": [ true ],
|
||||
"method": "hand"
|
||||
} ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=5]
|
||||
length = 0.6
|
||||
step = 0.01
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("hand:translation")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.1, 0.2, 0.4, 0.6 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, 0, -0.291107 ), Vector3( 0, -0.211775, -0.445232 ), Vector3( 0, -0.372039, -0.250472 ), Vector3( 0, 0, 0 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("hand:rotation_degrees")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0, 0.2, 0.6 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector3( 0, 90, -45 ), Vector3( 0, 90, -135 ), Vector3( 0, 90, -45 ) ]
|
||||
}
|
||||
tracks/2/type = "method"
|
||||
tracks/2/path = NodePath("../../..")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"times": PoolRealArray( 0.2 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"values": [ {
|
||||
"args": [ false ],
|
||||
"method": "hand"
|
||||
} ]
|
||||
}
|
||||
|
||||
[node name="player" type="KinematicBody"]
|
||||
pause_mode = 1
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="mesh" type="MeshInstance" parent="."]
|
||||
transform = Transform( 0.4, 0, 0, 0, 1, 0, 0, 0, 0.4, 0, 0, 0 )
|
||||
mesh = SubResource( 1 )
|
||||
material/0 = SubResource( 2 )
|
||||
|
||||
[node name="Collision" type="CollisionShape" parent="."]
|
||||
transform = Transform( 0.4, 0, 0, 0, 1, 0, 0, 0, 0.4, 0, 0, 0 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="head" type="Spatial" parent="."]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0 )
|
||||
|
||||
[node name="Camera" type="Camera" parent="head"]
|
||||
cull_mask = 524289
|
||||
current = true
|
||||
|
||||
[node name="right" type="Spatial" parent="head/Camera"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.3, -0.1, -0.3 )
|
||||
|
||||
[node name="anim" type="AnimationPlayer" parent="head/Camera/right"]
|
||||
anims/pick = SubResource( 4 )
|
||||
|
||||
[node name="hand" type="Spatial" parent="head/Camera/right"]
|
||||
transform = Transform( -3.09086e-08, -3.09086e-08, 1, -0.707107, 0.707107, 0, -0.707107, -0.707107, -4.37114e-08, 0, 0, 0 )
|
||||
|
||||
[node name="item" type="MeshInstance" parent="head/Camera/right/hand"]
|
||||
transform = Transform( 0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, 0, 0 )
|
||||
layers = 524288
|
||||
|
||||
[node name="left" type="Spatial" parent="head/Camera"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.3, -0.1, -0.3 )
|
||||
|
||||
[node name="anim" type="AnimationPlayer" parent="head/Camera/left"]
|
||||
anims/pick = SubResource( 5 )
|
||||
|
||||
[node name="hand" type="Spatial" parent="head/Camera/left"]
|
||||
transform = Transform( -3.09086e-08, -3.09086e-08, 1, -0.707107, 0.707107, 0, -0.707107, -0.707107, -4.37114e-08, 0, 0, 0 )
|
||||
|
||||
[node name="item" type="MeshInstance" parent="head/Camera/left/hand"]
|
||||
transform = Transform( 0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, 0, 0 )
|
||||
layers = 524288
|
||||
|
||||
[node name="phys_ray" type="RayCast" parent="head/Camera"]
|
||||
cast_to = Vector3( 0, 0, -4 )
|
||||
|
||||
[node name="tpv" type="Spatial" parent="head"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.8, 0, 2 )
|
||||
|
||||
[node name="Camera" type="Camera" parent="head/tpv"]
|
||||
cull_mask = 1048573
|
70
engine/ui/ui.gd
Normal file
@ -0,0 +1,70 @@
|
||||
extends Control
|
||||
|
||||
func center(node):
|
||||
var s = get_viewport_rect().size/2
|
||||
var c = node.rect_size / 2
|
||||
node.rect_position = s - c
|
||||
func buttom(node):
|
||||
var s = get_viewport_rect().size
|
||||
node.rect_position = Vector2(node.rect_position.x,s.y-node.rect_size.y)
|
||||
func slot_index(i):
|
||||
if i > 3:
|
||||
$hotbar/slotr.rect_position.x = (($hotbar/slotr.rect_size.x))*i
|
||||
$hotbar/slotr/active.visible = true
|
||||
$hotbar/slotl/active.visible = false
|
||||
else:
|
||||
$hotbar/slotl.rect_position.x = (($hotbar/slotl.rect_size.x))*i
|
||||
$hotbar/slotl/active.visible = true
|
||||
$hotbar/slotr/active.visible = false
|
||||
func update_hotbar(inv):
|
||||
var s = $hotbar/slotr.rect_size
|
||||
var l = 8 if inv.size() >= 8 else inv.size()
|
||||
for i in l:
|
||||
var c = $hotbar.get_node_or_null(str(i))
|
||||
if c != null:
|
||||
c.free()
|
||||
for i in l:
|
||||
var it = inv[i]
|
||||
if it != null:
|
||||
var t = core.stack_2invitem(it)
|
||||
t.get_node("item").rect_position = Vector2((s.x*i)+4,4)
|
||||
#t.rect_size = Vector2(s.x-8,s.x-8)
|
||||
t.get_node("item").rect_scale = Vector2(s.x*0.0091,s.x*0.0091)
|
||||
t.name = str(i)
|
||||
$hotbar.add_child(t)
|
||||
|
||||
func _ready():
|
||||
core.ui = self
|
||||
center($crosshair)
|
||||
center($hotbar)
|
||||
buttom($hotbar)
|
||||
|
||||
var p = OS.get_screen_size()/2
|
||||
var s = OS.window_size/2
|
||||
var winpos = p-s
|
||||
winpos.y = 0 #now we can see the output
|
||||
OS.set_window_position(winpos)
|
||||
#yield(get_tree().create_timer(0.1),"timeout")
|
||||
#OS.window_size = Vector2(700,700)
|
||||
#OS.window_maximized = true
|
||||
#OS.window_fullscreen = true
|
||||
|
||||
|
||||
func pause():
|
||||
core.game_pause()
|
||||
$manu.visible = core.game_paused
|
||||
|
||||
func quit_to_main():
|
||||
$manu.visible = false
|
||||
core.world_quit()
|
||||
func quit_game():
|
||||
core.world_quit(true)
|
||||
|
||||
func _input(event):
|
||||
if core.game != null and core.player.object.gui == null and Input.is_action_just_pressed("ui_cancel"):
|
||||
if core.game_paused:
|
||||
core.game_pause()
|
||||
$manu.visible = false
|
||||
else:
|
||||
core.game_pause()
|
||||
$manu.visible = true
|
123
engine/ui/ui.tscn
Normal file
@ -0,0 +1,123 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://engine/ui/ui.gd" type="Script" id=1]
|
||||
[ext_resource path="res://game/textures/crosshair.png" type="Texture" id=2]
|
||||
[ext_resource path="res://game/textures/hotbar.png" type="Texture" id=3]
|
||||
[ext_resource path="res://game/textures/hotbar_slot.png" type="Texture" id=4]
|
||||
[ext_resource path="res://game/textures/hotbar_select.png" type="Texture" id=5]
|
||||
|
||||
[node name="ui" type="Control"]
|
||||
pause_mode = 2
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="crosshair" type="TextureRect" parent="."]
|
||||
margin_left = 60.1041
|
||||
margin_top = 207.182
|
||||
margin_right = 80.1041
|
||||
margin_bottom = 227.182
|
||||
texture = ExtResource( 2 )
|
||||
expand = true
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="hotbar" type="TextureRect" parent="."]
|
||||
margin_left = 247.0
|
||||
margin_top = 514.0
|
||||
margin_right = 871.0
|
||||
margin_bottom = 592.0
|
||||
texture = ExtResource( 3 )
|
||||
stretch_mode = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="slotl" type="TextureRect" parent="hotbar"]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
texture = ExtResource( 4 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="active" type="TextureRect" parent="hotbar/slotl"]
|
||||
visible = false
|
||||
margin_right = 78.0
|
||||
margin_bottom = 78.0
|
||||
texture = ExtResource( 5 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="slotr" type="TextureRect" parent="hotbar"]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
texture = ExtResource( 4 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="active" type="TextureRect" parent="hotbar/slotr"]
|
||||
visible = false
|
||||
margin_right = 78.0
|
||||
margin_bottom = 78.0
|
||||
texture = ExtResource( 5 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="manu" type="ColorRect" parent="."]
|
||||
visible = false
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
color = Color( 0.2, 0.2, 0.2, 0.5 )
|
||||
__meta__ = {
|
||||
"_edit_lock_": true,
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="back" type="ColorRect" parent="manu"]
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
margin_left = -128.0
|
||||
margin_top = 106.0
|
||||
margin_right = 128.0
|
||||
margin_bottom = -86.0
|
||||
color = Color( 0.2, 0.2, 0.2, 0.4 )
|
||||
|
||||
[node name="main" type="Button" parent="manu/back"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -64.0
|
||||
margin_top = -118.0
|
||||
margin_right = 65.0
|
||||
margin_bottom = -68.0
|
||||
text = "Quit to main manu"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="quit" type="Button" parent="manu/back"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -64.0
|
||||
margin_top = 10.0
|
||||
margin_right = 65.0
|
||||
margin_bottom = 60.0
|
||||
text = "Quit Game"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[connection signal="pressed" from="manu/back/main" to="." method="quit_to_main"]
|
||||
[connection signal="pressed" from="manu/back/quit" to="." method="quit_game"]
|
23
game/game_base.gd
Normal file
@ -0,0 +1,23 @@
|
||||
extends Node
|
||||
|
||||
func chest(pos,reg):
|
||||
if reg.name == "default:chest":
|
||||
if core.existsMeta(pos) == false:
|
||||
core.create_node_inventory(pos,"main",32,[
|
||||
core.itemstack("default:chest",{count=10}),
|
||||
core.itemstack("default:stone_pick",{count=100}),
|
||||
core.itemstack("default:grassy",{count=100}),
|
||||
core.itemstack("default:stone_hoe"),
|
||||
core.itemstack("default:stone_shovel"),
|
||||
core.itemstack("default:axe_stone"),
|
||||
core.itemstack("default:stone_pick"),
|
||||
core.itemstack("default:stick",{count=100}),
|
||||
core.itemstack("default",{count=100}),
|
||||
core.itemstack("default:stone",{count=100}),
|
||||
core.itemstack("default:cobble",{count=1000}),
|
||||
core.itemstack("default:dirt",{count=100}),
|
||||
core.itemstack("default:water_source",{count=100}),
|
||||
core.itemstack("default:glass",{count=100}),
|
||||
core.itemstack("default:wood",{count=100})
|
||||
])
|
||||
GUI.show(core.player,"background[8;8.5]inventory[player:player1;main;0;4.5;8;4]inventory[node:"+var2str(pos)+";main;0;0;8;4]")
|
71
game/game_items.gd
Normal file
@ -0,0 +1,71 @@
|
||||
extends Node
|
||||
|
||||
func _ready():
|
||||
core.register_node({
|
||||
name = "default:chest",
|
||||
groups={woody=3},
|
||||
on_activate=funcref(GameBase,"chest"),
|
||||
tiles = [
|
||||
"res://game/textures/default_chest_top.png",
|
||||
"res://game/textures/default_chest_top.png"
|
||||
,"res://game/textures/default_chest_front.png"
|
||||
,"res://game/textures/default_chest_side.png"
|
||||
,"res://game/textures/default_chest_side.png"
|
||||
,"res://game/textures/default_chest_side.png"
|
||||
]
|
||||
})
|
||||
core.register_node({
|
||||
name="default:stone",
|
||||
tiles=["res://game/textures/stone.png"],
|
||||
groups={cracky=3},
|
||||
max_count=100,
|
||||
drop={"default:cobble":{count=1},"default:stone":{count=1,chance=10,additional=false}}
|
||||
})
|
||||
core.register_node({
|
||||
name="default:cobble",
|
||||
tiles=["res://game/textures/cobble.png"],
|
||||
groups={cracky=3},
|
||||
max_count=1000,
|
||||
})
|
||||
core.register_node({
|
||||
name="default:grassy",
|
||||
groups={crumbly=3},
|
||||
drop={"default:dirt":{count=1},"default:grassy":{count=1,chance=10,additional=false}},
|
||||
tiles=[
|
||||
"res://game/textures/grass.png",
|
||||
"res://game/textures/dirt.png",
|
||||
"res://game/textures/grass_dirt.png",
|
||||
"res://game/textures/grass_dirt.png",
|
||||
"res://game/textures/grass_dirt.png",
|
||||
"res://game/textures/grass_dirt.png"
|
||||
]
|
||||
})
|
||||
core.register_node({
|
||||
name="default:dirt",
|
||||
tiles=["res://game/textures/dirt.png"],
|
||||
groups={crumbly=3},
|
||||
})
|
||||
core.register_node({
|
||||
name="default:water_source",
|
||||
replaceable=true,
|
||||
drawtype="liquid",
|
||||
collidable=false,
|
||||
transparent=true,
|
||||
solid_surface=false,
|
||||
tiles=["res://game/textures/water.png"],
|
||||
max_count=100
|
||||
})
|
||||
core.register_node({
|
||||
name="default:glass",
|
||||
transparent=true,
|
||||
solid_surface=false,
|
||||
tiles=["res://game/textures/default_glass.png"],
|
||||
groups={cracky=3}
|
||||
})
|
||||
core.register_node({
|
||||
name="default:wood",
|
||||
tiles=["res://game/textures/default_wood.png"],
|
||||
groups={woody=3}
|
||||
})
|
||||
|
||||
|
81
game/item_drop/item_drop.gd
Normal file
@ -0,0 +1,81 @@
|
||||
extends RigidBody
|
||||
|
||||
var object
|
||||
var timer = 300
|
||||
var droper
|
||||
var sleep = false
|
||||
var last_pos = Vector3()
|
||||
|
||||
func spawn(pos,stack,der=null,ob=null):
|
||||
object = ob
|
||||
droper = der
|
||||
last_pos = pos
|
||||
transform.origin = pos
|
||||
$mesh.mesh = core.item2mesh(stack.name)
|
||||
var reg = core.get_item_reg(stack.name)
|
||||
if reg.type == "item":
|
||||
$collision.scale = Vector3(0.62,0.65,0.1)
|
||||
core.add_to_inventory(object,"main",stack)
|
||||
item()
|
||||
func _process(delta):
|
||||
timer -= delta
|
||||
var pos = transform.origin.round()
|
||||
if core.map.get(pos) == null:
|
||||
sleep = true
|
||||
sleeping = true
|
||||
elif sleep:
|
||||
sleeping = false
|
||||
sleep = false
|
||||
var reg = core.get_node_reg(pos)
|
||||
if reg != null and reg.drawtype == "default":
|
||||
transform.origin = last_pos
|
||||
else:
|
||||
last_pos = pos
|
||||
if timer < 0:
|
||||
set_process(false)
|
||||
queue_free()
|
||||
|
||||
func _ready():
|
||||
timer = core.settings.item_drop_timeout
|
||||
|
||||
func item():
|
||||
var stack = core.get_inventory(object,"main")[0]
|
||||
if stack == null:
|
||||
set_process(false)
|
||||
queue_free()
|
||||
return
|
||||
$mesh.mesh = core.item2mesh(stack.name)
|
||||
var reg = core.get_item_reg(stack.name)
|
||||
if reg.type == "item":
|
||||
$collision.scale = Vector3(0.62,0.65,0.1)
|
||||
func on_spawn(ob):
|
||||
object = ob
|
||||
func on_load(ob):
|
||||
object = ob
|
||||
sleeping = true
|
||||
item()
|
||||
|
||||
func _on_area_body_entered(body):
|
||||
var ob = body.get("player")
|
||||
var itemdrop = false
|
||||
if body.get("object") != null and body.object.type == "item_drop" and body.object.id != object.id:
|
||||
ob = body.object
|
||||
var inv1 = core.get_inventory(object,"main")[0]
|
||||
var inv2 = core.get_inventory(ob,"main")[0]
|
||||
if inv1.name == inv2.name and (inv1.count < core.get_item_reg(inv2.name).max_count):
|
||||
itemdrop = true
|
||||
|
||||
if ob != null and droper != ob.name or itemdrop:
|
||||
var stack = core.get_inventory(object,"main")[0]
|
||||
var leftover = core.add_to_inventory(ob,"main",stack)
|
||||
if body.get("player") != null:
|
||||
body.update_player()
|
||||
if leftover.count > 0:
|
||||
stack.count = leftover.count
|
||||
else:
|
||||
queue_free()
|
||||
return
|
||||
|
||||
func _on_Timer_timeout():
|
||||
droper = null
|
||||
$collision.disabled = false
|
32
game/item_drop/item_drop.tscn
Normal file
@ -0,0 +1,32 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://game/item_drop/item_drop.gd" type="Script" id=1]
|
||||
|
||||
[sub_resource type="BoxShape" id=1]
|
||||
|
||||
[sub_resource type="SphereShape" id=2]
|
||||
|
||||
[node name="item" type="RigidBody"]
|
||||
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0 )
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="collision" type="CollisionShape" parent="."]
|
||||
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0 )
|
||||
shape = SubResource( 1 )
|
||||
disabled = true
|
||||
|
||||
[node name="mesh" type="MeshInstance" parent="."]
|
||||
|
||||
[node name="area" type="Area" parent="."]
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="area"]
|
||||
transform = Transform( 0.7, 0, 0, 0, 0.7, 0, 0, 0, 0.7, 0, 0, 0 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
wait_time = 0.1
|
||||
one_shot = true
|
||||
autostart = true
|
||||
|
||||
[connection signal="body_entered" from="area" to="." method="_on_area_body_entered"]
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
BIN
game/textures/cobble.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
36
game/textures/cobble.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/cobble.png-a5cd07a19bcd7364be6560d90de8f841.s3tc.stex"
|
||||
path.etc2="res://.import/cobble.png-a5cd07a19bcd7364be6560d90de8f841.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/cobble.png"
|
||||
dest_files=[ "res://.import/cobble.png-a5cd07a19bcd7364be6560d90de8f841.s3tc.stex", "res://.import/cobble.png-a5cd07a19bcd7364be6560d90de8f841.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/crosshair.png
Normal file
After Width: | Height: | Size: 602 B |
34
game/textures/crosshair.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/crosshair.png-a632d3a8fde0361a0a6a457a1d905efb.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/crosshair.png"
|
||||
dest_files=[ "res://.import/crosshair.png-a632d3a8fde0361a0a6a457a1d905efb.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
BIN
game/textures/default.png
Normal file
After Width: | Height: | Size: 395 B |
36
game/textures/default.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/default.png-3a80372a995c7b2104901b5150b65194.s3tc.stex"
|
||||
path.etc2="res://.import/default.png-3a80372a995c7b2104901b5150b65194.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/default.png"
|
||||
dest_files=[ "res://.import/default.png-3a80372a995c7b2104901b5150b65194.s3tc.stex", "res://.import/default.png-3a80372a995c7b2104901b5150b65194.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/default_axe_stone.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
36
game/textures/default_axe_stone.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/default_axe_stone.png-f56c343a82f31ecb8acd0d9eb04a7ed4.s3tc.stex"
|
||||
path.etc2="res://.import/default_axe_stone.png-f56c343a82f31ecb8acd0d9eb04a7ed4.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/default_axe_stone.png"
|
||||
dest_files=[ "res://.import/default_axe_stone.png-f56c343a82f31ecb8acd0d9eb04a7ed4.s3tc.stex", "res://.import/default_axe_stone.png-f56c343a82f31ecb8acd0d9eb04a7ed4.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/default_chest_front.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
36
game/textures/default_chest_front.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/default_chest_front.png-3838fcd9fb13d8e6d4257a46b45e2cbf.s3tc.stex"
|
||||
path.etc2="res://.import/default_chest_front.png-3838fcd9fb13d8e6d4257a46b45e2cbf.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/default_chest_front.png"
|
||||
dest_files=[ "res://.import/default_chest_front.png-3838fcd9fb13d8e6d4257a46b45e2cbf.s3tc.stex", "res://.import/default_chest_front.png-3838fcd9fb13d8e6d4257a46b45e2cbf.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/default_chest_side.png
Normal file
After Width: | Height: | Size: 5.1 KiB |
36
game/textures/default_chest_side.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/default_chest_side.png-832ad968dfbb478d087bb0cbd2df847a.s3tc.stex"
|
||||
path.etc2="res://.import/default_chest_side.png-832ad968dfbb478d087bb0cbd2df847a.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/default_chest_side.png"
|
||||
dest_files=[ "res://.import/default_chest_side.png-832ad968dfbb478d087bb0cbd2df847a.s3tc.stex", "res://.import/default_chest_side.png-832ad968dfbb478d087bb0cbd2df847a.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/default_chest_top.png
Normal file
After Width: | Height: | Size: 5.1 KiB |
36
game/textures/default_chest_top.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/default_chest_top.png-d4c495f2f2693cdf8ca9c47ce92d6b82.s3tc.stex"
|
||||
path.etc2="res://.import/default_chest_top.png-d4c495f2f2693cdf8ca9c47ce92d6b82.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/default_chest_top.png"
|
||||
dest_files=[ "res://.import/default_chest_top.png-d4c495f2f2693cdf8ca9c47ce92d6b82.s3tc.stex", "res://.import/default_chest_top.png-d4c495f2f2693cdf8ca9c47ce92d6b82.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/default_glass.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
36
game/textures/default_glass.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/default_glass.png-a9d11d32fd371b74dd2730916cf0e2b6.s3tc.stex"
|
||||
path.etc2="res://.import/default_glass.png-a9d11d32fd371b74dd2730916cf0e2b6.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/default_glass.png"
|
||||
dest_files=[ "res://.import/default_glass.png-a9d11d32fd371b74dd2730916cf0e2b6.s3tc.stex", "res://.import/default_glass.png-a9d11d32fd371b74dd2730916cf0e2b6.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/default_hoe_stone.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
36
game/textures/default_hoe_stone.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/default_hoe_stone.png-f6474afbb06978fb1364473148aec872.s3tc.stex"
|
||||
path.etc2="res://.import/default_hoe_stone.png-f6474afbb06978fb1364473148aec872.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/default_hoe_stone.png"
|
||||
dest_files=[ "res://.import/default_hoe_stone.png-f6474afbb06978fb1364473148aec872.s3tc.stex", "res://.import/default_hoe_stone.png-f6474afbb06978fb1364473148aec872.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/default_pick_stone.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
36
game/textures/default_pick_stone.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/default_pick_stone.png-cb4cb36b47782f7c0f0124c43a8305eb.s3tc.stex"
|
||||
path.etc2="res://.import/default_pick_stone.png-cb4cb36b47782f7c0f0124c43a8305eb.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/default_pick_stone.png"
|
||||
dest_files=[ "res://.import/default_pick_stone.png-cb4cb36b47782f7c0f0124c43a8305eb.s3tc.stex", "res://.import/default_pick_stone.png-cb4cb36b47782f7c0f0124c43a8305eb.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/default_shovel_stone.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
36
game/textures/default_shovel_stone.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/default_shovel_stone.png-842bb2b831e95260b723894265efd907.s3tc.stex"
|
||||
path.etc2="res://.import/default_shovel_stone.png-842bb2b831e95260b723894265efd907.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/default_shovel_stone.png"
|
||||
dest_files=[ "res://.import/default_shovel_stone.png-842bb2b831e95260b723894265efd907.s3tc.stex", "res://.import/default_shovel_stone.png-842bb2b831e95260b723894265efd907.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/default_stick.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
36
game/textures/default_stick.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/default_stick.png-05d04fdabe29d64063adb4145abbbaf0.s3tc.stex"
|
||||
path.etc2="res://.import/default_stick.png-05d04fdabe29d64063adb4145abbbaf0.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/default_stick.png"
|
||||
dest_files=[ "res://.import/default_stick.png-05d04fdabe29d64063adb4145abbbaf0.s3tc.stex", "res://.import/default_stick.png-05d04fdabe29d64063adb4145abbbaf0.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/default_wood.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
36
game/textures/default_wood.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/default_wood.png-6246b07c17ae4801cdf76b04324b58f3.s3tc.stex"
|
||||
path.etc2="res://.import/default_wood.png-6246b07c17ae4801cdf76b04324b58f3.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/default_wood.png"
|
||||
dest_files=[ "res://.import/default_wood.png-6246b07c17ae4801cdf76b04324b58f3.s3tc.stex", "res://.import/default_wood.png-6246b07c17ae4801cdf76b04324b58f3.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/dirt.png
Normal file
After Width: | Height: | Size: 862 B |
36
game/textures/dirt.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/dirt.png-d0b014972030e6906ac5b43dcf4dcb32.s3tc.stex"
|
||||
path.etc2="res://.import/dirt.png-d0b014972030e6906ac5b43dcf4dcb32.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/dirt.png"
|
||||
dest_files=[ "res://.import/dirt.png-d0b014972030e6906ac5b43dcf4dcb32.s3tc.stex", "res://.import/dirt.png-d0b014972030e6906ac5b43dcf4dcb32.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/grass.png
Normal file
After Width: | Height: | Size: 676 B |
36
game/textures/grass.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/grass.png-44a5fd3cbf0051ff30cc83e1d5e5fc65.s3tc.stex"
|
||||
path.etc2="res://.import/grass.png-44a5fd3cbf0051ff30cc83e1d5e5fc65.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/grass.png"
|
||||
dest_files=[ "res://.import/grass.png-44a5fd3cbf0051ff30cc83e1d5e5fc65.s3tc.stex", "res://.import/grass.png-44a5fd3cbf0051ff30cc83e1d5e5fc65.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/grass_dirt.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
36
game/textures/grass_dirt.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/grass_dirt.png-318396c70c7e341ec3ae884703ae263c.s3tc.stex"
|
||||
path.etc2="res://.import/grass_dirt.png-318396c70c7e341ec3ae884703ae263c.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/grass_dirt.png"
|
||||
dest_files=[ "res://.import/grass_dirt.png-318396c70c7e341ec3ae884703ae263c.s3tc.stex", "res://.import/grass_dirt.png-318396c70c7e341ec3ae884703ae263c.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/grass_side.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
36
game/textures/grass_side.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/grass_side.png-6ba854bc112263ee9b0fe367b051939c.s3tc.stex"
|
||||
path.etc2="res://.import/grass_side.png-6ba854bc112263ee9b0fe367b051939c.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/grass_side.png"
|
||||
dest_files=[ "res://.import/grass_side.png-6ba854bc112263ee9b0fe367b051939c.s3tc.stex", "res://.import/grass_side.png-6ba854bc112263ee9b0fe367b051939c.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/hotbar.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
36
game/textures/hotbar.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/hotbar.png-5f886928fc446ebdf51b5902264666c7.s3tc.stex"
|
||||
path.etc2="res://.import/hotbar.png-5f886928fc446ebdf51b5902264666c7.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/hotbar.png"
|
||||
dest_files=[ "res://.import/hotbar.png-5f886928fc446ebdf51b5902264666c7.s3tc.stex", "res://.import/hotbar.png-5f886928fc446ebdf51b5902264666c7.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/hotbar_select.png
Normal file
After Width: | Height: | Size: 8.1 KiB |
36
game/textures/hotbar_select.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/hotbar_select.png-b3d7d25ca444a29e3b47a2289729e3eb.s3tc.stex"
|
||||
path.etc2="res://.import/hotbar_select.png-b3d7d25ca444a29e3b47a2289729e3eb.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/hotbar_select.png"
|
||||
dest_files=[ "res://.import/hotbar_select.png-b3d7d25ca444a29e3b47a2289729e3eb.s3tc.stex", "res://.import/hotbar_select.png-b3d7d25ca444a29e3b47a2289729e3eb.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/hotbar_slot.png
Normal file
After Width: | Height: | Size: 7.3 KiB |
36
game/textures/hotbar_slot.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/hotbar_slot.png-4ffbecdbac11b2c0cc20530198258acc.s3tc.stex"
|
||||
path.etc2="res://.import/hotbar_slot.png-4ffbecdbac11b2c0cc20530198258acc.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/hotbar_slot.png"
|
||||
dest_files=[ "res://.import/hotbar_slot.png-4ffbecdbac11b2c0cc20530198258acc.s3tc.stex", "res://.import/hotbar_slot.png-4ffbecdbac11b2c0cc20530198258acc.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/slot.png
Normal file
After Width: | Height: | Size: 5.0 KiB |
36
game/textures/slot.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/slot.png-898b36c05433cdcbd0afe264ec28a28a.s3tc.stex"
|
||||
path.etc2="res://.import/slot.png-898b36c05433cdcbd0afe264ec28a28a.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/slot.png"
|
||||
dest_files=[ "res://.import/slot.png-898b36c05433cdcbd0afe264ec28a28a.s3tc.stex", "res://.import/slot.png-898b36c05433cdcbd0afe264ec28a28a.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/stone.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
36
game/textures/stone.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/stone.png-458b02e5ad66a70773b2ca118ada654e.s3tc.stex"
|
||||
path.etc2="res://.import/stone.png-458b02e5ad66a70773b2ca118ada654e.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/stone.png"
|
||||
dest_files=[ "res://.import/stone.png-458b02e5ad66a70773b2ca118ada654e.s3tc.stex", "res://.import/stone.png-458b02e5ad66a70773b2ca118ada654e.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
BIN
game/textures/water.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
34
game/textures/water.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/water.png-fc6d8597996cbe40611cc540182aeb29.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/water.png"
|
||||
dest_files=[ "res://.import/water.png-fc6d8597996cbe40611cc540182aeb29.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
BIN
game/textures/wieldhand.png
Normal file
After Width: | Height: | Size: 327 B |
36
game/textures/wieldhand.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/wieldhand.png-dbc36933fe5deed47aeeb403693393fd.s3tc.stex"
|
||||
path.etc2="res://.import/wieldhand.png-dbc36933fe5deed47aeeb403693393fd.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://game/textures/wieldhand.png"
|
||||
dest_files=[ "res://.import/wieldhand.png-dbc36933fe5deed47aeeb403693393fd.s3tc.stex", "res://.import/wieldhand.png-dbc36933fe5deed47aeeb403693393fd.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
36
icon.png.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.s3tc.stex"
|
||||
path.etc2="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.etc2.stex"
|
||||
metadata={
|
||||
"imported_formats": [ "s3tc", "etc2" ],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.s3tc.stex", "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=false
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
7
main.gd
Normal file
@ -0,0 +1,7 @@
|
||||
extends Spatial
|
||||
|
||||
func _init():
|
||||
core.main = self
|
||||
set_process(false)
|
||||
func close_msg():
|
||||
$exitmsg.visible = false
|
80
main.tscn
Normal file
@ -0,0 +1,80 @@
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://engine/MainManu/MainManu.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://engine/WAEditor/WAEditor.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://main.gd" type="Script" id=3]
|
||||
[ext_resource path="res://engine/ui/ui.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://engine/loader/loader.tscn" type="PackedScene" id=5]
|
||||
|
||||
[sub_resource type="Environment" id=1]
|
||||
background_mode = 1
|
||||
background_color = Color( 0.447059, 0.666667, 0.858824, 1 )
|
||||
ambient_light_color = Color( 1, 1, 1, 1 )
|
||||
|
||||
[node name="main" type="Spatial"]
|
||||
pause_mode = 2
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="MainManu" parent="." instance=ExtResource( 1 )]
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource( 1 )
|
||||
|
||||
[node name="Editor" parent="." instance=ExtResource( 2 )]
|
||||
visible = false
|
||||
|
||||
[node name="ui" parent="." instance=ExtResource( 4 )]
|
||||
visible = false
|
||||
|
||||
[node name="exitmsg" type="ColorRect" parent="."]
|
||||
visible = false
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
color = Color( 0.2, 0.2, 0.2, 0.92 )
|
||||
__meta__ = {
|
||||
"_edit_lock_": true,
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="center" type="CenterContainer" parent="exitmsg"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_right = -512.0
|
||||
margin_bottom = -300.0
|
||||
rect_scale = Vector2( 2, 2 )
|
||||
__meta__ = {
|
||||
"_edit_lock_": true,
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="text" type="Label" parent="exitmsg/center"]
|
||||
margin_left = 171.0
|
||||
margin_top = 134.0
|
||||
margin_right = 340.0
|
||||
margin_bottom = 165.0
|
||||
custom_colors/font_color = Color( 1, 1, 0, 1 )
|
||||
text = "A fatal error occoupted.
|
||||
No information about that."
|
||||
align = 1
|
||||
valign = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="close" type="Button" parent="exitmsg"]
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
margin_left = -23.0
|
||||
margin_top = 514.0
|
||||
margin_right = 24.0
|
||||
margin_bottom = -50.0
|
||||
text = "Close"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="loader" parent="." instance=ExtResource( 5 )]
|
||||
visible = false
|
||||
|
||||
[connection signal="pressed" from="exitmsg/close" to="." method="close_msg"]
|
121
project.godot
Normal file
@ -0,0 +1,121 @@
|
||||
; Engine configuration file.
|
||||
; It's best edited using the editor UI and not directly,
|
||||
; since the parameters that go here are not all obvious.
|
||||
;
|
||||
; Format:
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=4
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Mineshafts"
|
||||
run/main_scene="res://main.tscn"
|
||||
config/use_custom_user_dir=true
|
||||
config/custom_user_dir_name="Mineshafts"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[autoload]
|
||||
|
||||
mapgen="*res://engine/mapgen.gd"
|
||||
core="*res://engine/core.gd"
|
||||
WaEngine="*res://engine/WAEditor/WAEngine.gd"
|
||||
item2texture="*res://engine/item_to_texture/item_to_texture.tscn"
|
||||
GUI="*res://engine/gui.gd"
|
||||
GameBase="*res://game/game_base.gd"
|
||||
GameItems="*res://game/game_items.gd"
|
||||
|
||||
[debug]
|
||||
|
||||
gdscript/warnings/unused_argument=false
|
||||
gdscript/warnings/return_value_discarded=false
|
||||
|
||||
[display]
|
||||
|
||||
window/stretch/mode="2d"
|
||||
|
||||
[editor_plugins]
|
||||
|
||||
enabled=PoolStringArray( "res://addons/brackets/plugin.cfg" )
|
||||
|
||||
[importer_defaults]
|
||||
|
||||
texture={
|
||||
"compress/bptc_ldr": 0,
|
||||
"compress/hdr_mode": 0,
|
||||
"compress/lossy_quality": 0.7,
|
||||
"compress/mode": 2,
|
||||
"compress/normal_map": 0,
|
||||
"detect_3d": false,
|
||||
"flags/anisotropic": false,
|
||||
"flags/filter": false,
|
||||
"flags/mipmaps": true,
|
||||
"flags/repeat": true,
|
||||
"flags/srgb": 1,
|
||||
"process/HDR_as_SRGB": false,
|
||||
"process/fix_alpha_border": false,
|
||||
"process/invert_color": false,
|
||||
"process/premult_alpha": false,
|
||||
"size_limit": 0,
|
||||
"stream": false,
|
||||
"svg/scale": 1.0
|
||||
}
|
||||
|
||||
[input]
|
||||
|
||||
fly_mode={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":70,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
LMB={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null)
|
||||
]
|
||||
}
|
||||
RMB={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":2,"pressed":false,"doubleclick":false,"script":null)
|
||||
]
|
||||
}
|
||||
SCREENSHOT={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":80,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
WHEEL_UP={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":4,"pressed":false,"doubleclick":false,"script":null)
|
||||
]
|
||||
}
|
||||
WHEEL_DOWN={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":5,"pressed":false,"doubleclick":false,"script":null)
|
||||
]
|
||||
}
|
||||
switch_index_side={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":81,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
use={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
throw_item={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":86,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
actioneditor={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":85,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[rendering]
|
||||
|
||||
environment/default_environment="res://default_env.tres"
|
||||
quality/dynamic_fonts/use_oversampling=false
|