Add basic building framework

This commit is contained in:
Ategon 2024-09-08 21:17:35 -04:00
parent 83b519823f
commit df83dce3a6
11 changed files with 131 additions and 18 deletions

View file

@ -0,0 +1,7 @@
[plugin]
name="Laia Highlighter"
description="A highlighter to highting laia scripting files"
author="Ategon"
version="v1.0.0"
script="plugin.gd"

View file

@ -0,0 +1,81 @@
@tool
extends EditorPlugin
var dialogue_highlighter:DialogueHighlighter
func _enter_tree() -> void:
dialogue_highlighter = DialogueHighlighter.new()
var script_editor = EditorInterface.get_script_editor()
print(script_editor)
print(dialogue_highlighter)
script_editor.register_syntax_highlighter(dialogue_highlighter)
print(script_editor.get_current_script())
print(script_editor.get_open_scripts())
script_editor.goto_line(20)
func _exit_tree() -> void:
if is_instance_valid(dialogue_highlighter):
var script_editor = EditorInterface.get_script_editor()
script_editor.unregister_syntax_highlighter(dialogue_highlighter)
dialogue_highlighter = null
class DialogueHighlighter extends EditorSyntaxHighlighter:
func _get_name() -> String:
return "Laia"
func _get_supported_languages() -> PackedStringArray:
return ["TextFile"]
func _get_line_syntax_highlighting(line: int) -> Dictionary:
var color_map = {}
var text_editor = get_text_edit()
var str = text_editor.get_line(line)
# Comment
if str.strip_edges().begins_with("#"):
color_map[0] = { "color": Color.WEB_GRAY }
return color_map
# Key
var regex3 = RegEx.new()
regex3.compile("([a-zA-Z0-9_]+:).*")
var result3 = regex3.search(str)
if result3:
color_map[result3.get_start(1)] = { "color": Color.SEA_GREEN }
color_map[result3.get_end(1)] = { "color": Color.WHITE }
# Array
var regex = RegEx.new()
regex.compile("([a-zA-Z0-9_\\-])+\\[\\]")
var result = regex.search(str)
if result:
color_map[result.get_start()] = { "color": Color.CYAN }
color_map[result.get_end(1)] = { "color": Color.LIGHT_CYAN }
# Enum
var regex4 = RegEx.new()
regex4.compile("[a-zA-Z0-9_]+(\\.[a-zA-Z0-9_]+)")
var result4 = regex4.search(str)
if result4:
color_map[result4.get_start()] = { "color": Color.ORANGE }
color_map[result4.get_start(1)] = { "color": Color.ORANGE_RED }
color_map[result4.get_end()] = { "color": Color.WHITE }
# Color
var regex2 = RegEx.new()
regex2.compile("#[a-zA-Z0-9]+")
var result2 = regex2.search(str)
if result2:
color_map[result2.get_start()] = { "color": Color(result2.get_string()) }
return color_map

8
buildings/Building.tscn Normal file
View file

@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=3 uid="uid://daicnavgi0gpo"]
[ext_resource type="Script" path="res://buildings/building.gd" id="1_db3yd"]
[node name="Building" type="Node2D"]
script = ExtResource("1_db3yd")
[node name="Sprite2D" type="Sprite2D" parent="."]

12
buildings/building.gd Normal file
View file

@ -0,0 +1,12 @@
extends Node2D
@onready var sprite_2d: Sprite2D = $Sprite2D
var key
@onready var data = Data.data.buildings[key]
#@onready var image = Data.data.images[key]
func _ready() -> void:
#sprite_2d.texture = image
pass

1
main.gd Normal file
View file

@ -0,0 +1 @@
extends Node2D

View file

@ -0,0 +1 @@
name: Stone Miner

View file

@ -0,0 +1 @@
name: Woodcutter

View file

@ -1 +1,15 @@
time_to_flood_change: 5
flood_levels[]
0
1
0
2
1
3
1
0
2
1
4
2
5

View file

@ -30,6 +30,10 @@ window/size/viewport_width=640
window/size/viewport_height=360
window/stretch/mode="canvas_items"
[editor_plugins]
enabled=PackedStringArray("res://addons/laia_highlighter/plugin.cfg")
[input]
lclick={

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://n2lpy72tkyc8"]
[ext_resource type="Script" path="res://storm_manager.gd" id="1_wwjtb"]
[ext_resource type="Script" path="res://storm/storm_manager.gd" id="1_wwjtb"]
[node name="StormManager" type="Node"]
script = ExtResource("1_wwjtb")

View file

@ -2,26 +2,10 @@ extends Node
@onready var globals = Data.data.globals
var game_time = 0
var last_flood_time = 0
var current_flood_state = 0
var flood_levels = [
0,
1,
0,
2,
1,
3,
1,
0,
2,
1,
4,
2,
5
]
func _process(delta: float) -> void:
game_time += delta
@ -30,4 +14,4 @@ func _process(delta: float) -> void:
last_flood_time += globals.time_to_flood_change
current_flood_state += 1
Persister.persist_data("flood_level", flood_levels[current_flood_state])
Persister.persist_data("flood_level", globals.flood_levels[current_flood_state])