onion test 0
This commit is contained in:
23
scripts/Entity/OnionSprig.gd
Normal file
23
scripts/Entity/OnionSprig.gd
Normal file
@@ -0,0 +1,23 @@
|
||||
class_name OnionSprig extends StaticBody3D
|
||||
|
||||
@export var itemType:ItemType = ItemType.ONION;
|
||||
|
||||
func _ready() -> void:
|
||||
$Entity/EntityInteractable.onInteract.connect(
|
||||
self.onEntityInteract
|
||||
)
|
||||
|
||||
func _exit_tree() -> void:
|
||||
$Entity/EntityInteractable.onInteract.disconnect(
|
||||
self.onEntityInteract
|
||||
)
|
||||
|
||||
func onEntityInteract(
|
||||
interactor:EntityInteractor,
|
||||
interactee:EntityInteractable
|
||||
) -> void:
|
||||
ITEM.PLAYER_INVENTORY.addItem(ITEM.ONION);
|
||||
|
||||
# Dispose self
|
||||
get_parent().remove_child(self)
|
||||
self.queue_free()
|
1
scripts/Entity/OnionSprig.gd.uid
Normal file
1
scripts/Entity/OnionSprig.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://0nn3ix2nwk3f
|
13
scripts/Item/Ingredient/Onion.gd
Normal file
13
scripts/Item/Ingredient/Onion.gd
Normal file
@@ -0,0 +1,13 @@
|
||||
class_name Onion extends "res://scripts/Item/Item.gd"
|
||||
|
||||
func getName() -> String:
|
||||
return "Onion"
|
||||
|
||||
func getCategory() -> ItemCategory:
|
||||
return ItemCategory.MEDICINE;
|
||||
|
||||
func isConsumable() -> bool:
|
||||
return true;
|
||||
|
||||
func consume() -> void:
|
||||
print("Consuming Potion");
|
1
scripts/Item/Ingredient/Onion.gd.uid
Normal file
1
scripts/Item/Ingredient/Onion.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bmfaw3kid1pqx
|
4
scripts/Item/ItemType.gd
Normal file
4
scripts/Item/ItemType.gd
Normal file
@@ -0,0 +1,4 @@
|
||||
enum ItemType {
|
||||
POTION,
|
||||
ONION
|
||||
}
|
1
scripts/Item/ItemType.gd.uid
Normal file
1
scripts/Item/ItemType.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://nibssdy3ardv
|
@@ -3,6 +3,7 @@ const Inventory = preload("res://scripts/Item/Inventory.gd")
|
||||
|
||||
# Item Constants
|
||||
static var POTION = preload("res://scripts/Item/Potion.gd").new();
|
||||
static var ONION = preload("res://scripts/Item/Ingredient/Onion.gd").new();
|
||||
|
||||
# Static inventories
|
||||
static var PLAYER_INVENTORY = Inventory.new();
|
||||
|
Reference in New Issue
Block a user