Paint brush
This commit is contained in:
parent
6a7d3d0e45
commit
1c20d54651
4 changed files with 21 additions and 21 deletions
|
@ -1,26 +1,15 @@
|
||||||
[gd_scene load_steps=8 format=3 uid="uid://cteh8r405wqwk"]
|
[gd_scene load_steps=5 format=3 uid="uid://cteh8r405wqwk"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://bbd7o2st8kmgl" path="res://scripts/structure.gd" id="1_uhivg"]
|
[ext_resource type="Script" uid="uid://bbd7o2st8kmgl" path="res://scripts/structure.gd" id="1_uhivg"]
|
||||||
[ext_resource type="Script" uid="uid://bd4ojfqrl8idm" path="res://scripts/inventory/inventory_slot.gd" id="2_0phsd"]
|
[ext_resource type="Texture2D" uid="uid://gfkhedfdi7ug" path="res://sprites/atlasses/Popekko.png" id="2_evk1q"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dinyjq8853usn" path="res://sprites/atlasses/Popekko.png" id="2_evk1q"]
|
|
||||||
[ext_resource type="Script" uid="uid://1scdy7mttx5h" path="res://scripts/inventory/storage.gd" id="3_nh3xp"]
|
|
||||||
[ext_resource type="Script" uid="uid://v3j1d3qyg30i" path="res://scripts/structures/debug_item_deposit.gd" id="5_nh3xp"]
|
[ext_resource type="Script" uid="uid://v3j1d3qyg30i" path="res://scripts/structures/debug_item_deposit.gd" id="5_nh3xp"]
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_vi75d"]
|
|
||||||
resource_local_to_scene = true
|
|
||||||
script = ExtResource("3_nh3xp")
|
|
||||||
capacity = 1
|
|
||||||
internal_array = Array[ExtResource("2_0phsd")]([Object(RefCounted,"script":ExtResource("2_0phsd"),"held_item":null,"amount":0)
|
|
||||||
])
|
|
||||||
metadata/_custom_type_script = "uid://1scdy7mttx5h"
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wxqk4"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_wxqk4"]
|
||||||
atlas = ExtResource("2_evk1q")
|
atlas = ExtResource("2_evk1q")
|
||||||
region = Rect2(16, 0, 16, 16)
|
region = Rect2(16, 0, 16, 16)
|
||||||
|
|
||||||
[node name="DebugItemDeposit" type="Node2D"]
|
[node name="DebugItemDeposit" type="Node2D"]
|
||||||
script = ExtResource("1_uhivg")
|
script = ExtResource("1_uhivg")
|
||||||
inventory = SubResource("Resource_vi75d")
|
|
||||||
metadata/_custom_type_script = "uid://bbd7o2st8kmgl"
|
metadata/_custom_type_script = "uid://bbd7o2st8kmgl"
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
|
|
@ -2,6 +2,7 @@ extends Node2D
|
||||||
|
|
||||||
## Currently held structure
|
## Currently held structure
|
||||||
var held_construction : Structure
|
var held_construction : Structure
|
||||||
|
var selected_prototype : Prototype
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
GuiEventBus.construction_selected.connect(on_construction_selected)
|
GuiEventBus.construction_selected.connect(on_construction_selected)
|
||||||
|
@ -11,23 +12,25 @@ func _input(event: InputEvent) -> void:
|
||||||
return
|
return
|
||||||
if event.is_action_pressed("plc_place"):
|
if event.is_action_pressed("plc_place"):
|
||||||
var zone = try_get_zone(held_construction.global_position)
|
var zone = try_get_zone(held_construction.global_position)
|
||||||
if zone == null:
|
if zone != null and held_construction.try_place(zone):
|
||||||
held_construction.queue_free()
|
var facing = held_construction.facing
|
||||||
else:
|
held_construction = selected_prototype.scene.instantiate()
|
||||||
if held_construction.try_place(zone):
|
add_child(held_construction)
|
||||||
held_construction = null
|
held_construction.set_facing(facing)
|
||||||
if event.is_action_pressed("plc_rotate_up"):
|
if event.is_action_pressed("plc_rotate_up"):
|
||||||
if held_construction != null:
|
if held_construction != null:
|
||||||
held_construction.cycle_up_facing()
|
held_construction.cycle_up_facing()
|
||||||
|
|
||||||
if event.is_action_pressed("plc_cancel"):
|
if event.is_action_pressed("plc_cancel"):
|
||||||
held_construction.queue_free()
|
held_construction.queue_free()
|
||||||
|
selected_prototype = null
|
||||||
|
|
||||||
func on_construction_selected(constructible : Prototype):
|
func on_construction_selected(constructible : Prototype):
|
||||||
if held_construction:
|
if held_construction:
|
||||||
held_construction.queue_free()
|
held_construction.queue_free()
|
||||||
held_construction = constructible.scene.instantiate()
|
held_construction = constructible.scene.instantiate()
|
||||||
add_child(held_construction)
|
add_child(held_construction)
|
||||||
|
selected_prototype = constructible
|
||||||
|
|
||||||
|
|
||||||
func _process(_delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
|
|
|
@ -83,8 +83,16 @@ func get_dimension_points() -> Array[Vector2]:
|
||||||
result[x + y * dimensions.size.x] = (Vector2(x,y)*Globals.GRID_SIZE + Vector2(dimensions.position))
|
result[x + y * dimensions.size.x] = (Vector2(x,y)*Globals.GRID_SIZE + Vector2(dimensions.position))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
func set_facing(to : Facing) -> void:
|
||||||
|
facing = to
|
||||||
|
switched_facing.emit(facing)
|
||||||
|
|
||||||
func cycle_up_facing() -> void:
|
func cycle_up_facing() -> void:
|
||||||
if facing == Facing.UNDIRECTIONAL:
|
if facing == Facing.UNDIRECTIONAL:
|
||||||
return
|
return
|
||||||
facing = wrapi(facing+1,1,5) as Facing
|
set_facing(wrapi(facing+1,1,5))
|
||||||
switched_facing.emit(facing)
|
|
||||||
|
func cycle_down_facing() -> void:
|
||||||
|
if facing == Facing.UNDIRECTIONAL:
|
||||||
|
return
|
||||||
|
set_facing(wrapi(facing-1,1,5))
|
||||||
|
|
|
@ -5,5 +5,5 @@ const test_item :=preload("res://generic/items/dbg_item.tres")
|
||||||
func _process(_delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
for point in [Vector2(-1,0),Vector2(1,0),Vector2(0,1),Vector2(0,-1)]:
|
for point in [Vector2(-1,0),Vector2(1,0),Vector2(0,1),Vector2(0,-1)]:
|
||||||
var found_structure = get_parent().get_relative(point)
|
var found_structure = get_parent().get_relative(point)
|
||||||
if found_structure:
|
if found_structure and found_structure.inventory:
|
||||||
found_structure.inventory.add(Stack.new(test_item,1))
|
found_structure.inventory.add(Stack.new(test_item,1))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue