added machine item slots so ican start building gameplay
This commit is contained in:
@@ -64,7 +64,7 @@ func runCommand(message: String):
|
||||
if (arg.begins_with("\"") and arg.ends_with("\"")) or (arg.begins_with("'") and arg.ends_with("'")):
|
||||
arg = arg.substr(1, arg.length() - 2)
|
||||
commandArgs.append(arg)
|
||||
if commandArgs.size() > 0:
|
||||
if commandArgs.size() > 0:
|
||||
var command_name = commandArgs[0]
|
||||
if Commands.has(command_name):
|
||||
Commands[command_name].runCommand(commandArgs.slice(1))
|
||||
|
||||
21
GameShit/PlayerController/ControllerSystem/Highlight.gd
Normal file
21
GameShit/PlayerController/ControllerSystem/Highlight.gd
Normal file
@@ -0,0 +1,21 @@
|
||||
extends RayCast3D
|
||||
|
||||
# Keep track of what we were just looking at
|
||||
var current_target: Object = null
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
if is_colliding():
|
||||
var collider = get_collider()
|
||||
if current_target != collider:
|
||||
_clear_current_highlight()
|
||||
current_target = collider
|
||||
if current_target.has_method("startHighlight"):
|
||||
current_target.startHighlight()
|
||||
else:
|
||||
_clear_current_highlight()
|
||||
|
||||
func _clear_current_highlight() -> void:
|
||||
if current_target != null:
|
||||
if current_target.has_method("stopHighlight"):
|
||||
current_target.stopHighlight()
|
||||
current_target = null
|
||||
@@ -0,0 +1 @@
|
||||
uid://peb1cm1x2b2u
|
||||
@@ -56,7 +56,7 @@ func _input(event: InputEvent) -> void:
|
||||
|
||||
if is_left:
|
||||
if event.pressed:
|
||||
spawnObjectByID(MainGame.selectedBlockID, get_collision_point(), rot)
|
||||
spawnObjectByID(MainGame.selectedBlockID, get_collision_point() + Vector3(0, 0.5, 0), rot)
|
||||
if MainGame.currentHeldItemID == "base:hammer":
|
||||
var is_left = event.button_index == MOUSE_BUTTON_LEFT
|
||||
if is_left:
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://cjdago36f5tk1" path="res://GameShit/PlayerController/Hotbar/HotbarSlot.tscn" id="7_eb4xd"]
|
||||
[ext_resource type="Resource" uid="uid://ng8hm4a1u2ya" path="res://GameShit/PlayerController/Hotbar/MainBar.res" id="8_jteqg"]
|
||||
[ext_resource type="PackedScene" uid="uid://bliihydr5ja7g" path="res://GameShit/PlayerController/ChatSystem/ChatBox.tscn" id="8_x05u2"]
|
||||
[ext_resource type="Script" uid="uid://peb1cm1x2b2u" path="res://GameShit/PlayerController/ControllerSystem/Highlight.gd" id="9_dt52j"]
|
||||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_3mwrl"]
|
||||
|
||||
@@ -95,6 +96,12 @@ grow_horizontal = 1
|
||||
pivot_offset = Vector2(0, 120)
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="HighlightRaycast" type="RayCast3D" parent="Camera3D" unique_id=1504301830]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, -0.51586515)
|
||||
target_position = Vector3(0, -4, 0)
|
||||
script = ExtResource("9_dt52j")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=639269486]
|
||||
transform = Transform3D(0.5, 0, 0, 0, 1, 0, 0, 0, 0.5, 0, 0, 0)
|
||||
shape = SubResource("CapsuleShape3D_3mwrl")
|
||||
|
||||
@@ -20,7 +20,7 @@ func updateHotbar(hotbar: HotbarResource):
|
||||
MainGame.currentHeldItemID = item.ID
|
||||
slotInstance.setItem(item, is_selected)
|
||||
|
||||
func givePlayerItem(ID:String, ):
|
||||
func givePlayerItem(ID:String):
|
||||
var segments = ID.split(":")
|
||||
|
||||
for index in hotbar.slots.size():
|
||||
@@ -29,15 +29,17 @@ func givePlayerItem(ID:String, ):
|
||||
hotbar.slots[index] = load("res://GameShit/ItemHandlers/{namespace}/{id}.tres".format({"namespace": segments[0], "id": segments[1]}))
|
||||
updateHotbar(hotbar)
|
||||
return
|
||||
else:
|
||||
print("there will be a UIThrowException call eventually but im too lazy to implement it rn")
|
||||
print("UI.Command.give.InventoryFullException")
|
||||
|
||||
func removePlayerHeldItem():
|
||||
hotbar.slots[MainGame.selectedSlot] = load("res://GameShit/ItemHandlers/base/air.tres")
|
||||
updateHotbar(hotbar)
|
||||
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
## connect the InventoryBus signal for the shit
|
||||
InventoryBus.givePlayerItem.connect(givePlayerItem)
|
||||
InventoryBus.removeHeldItem.connect(removePlayerHeldItem)
|
||||
|
||||
## throw in some default slots
|
||||
if hotbar.slots.is_empty():
|
||||
|
||||
Reference in New Issue
Block a user