Add portable RV homes and decor prototype
This commit is contained in:
parent
81decf2b71
commit
fe099f47dd
56 changed files with 5459 additions and 112 deletions
59
homes/decor_catalog.gd
Normal file
59
homes/decor_catalog.gd
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
class_name DecorCatalog
|
||||
extends RefCounted
|
||||
|
||||
const BASIC_CUBE_ID: StringName = &"basic_cube"
|
||||
const MAX_OWNED_PER_PRODUCT: int = 32
|
||||
|
||||
const _PRODUCTS: Dictionary = {
|
||||
BASIC_CUBE_ID: {
|
||||
"display_name": "basic cube",
|
||||
"description": "a simple piece of decor for testing your RV layout.",
|
||||
"price": 1,
|
||||
"footprint": Vector2(1.0, 0.8),
|
||||
"height": 0.8,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
static func get_product_ids() -> Array[StringName]:
|
||||
var ids: Array[StringName] = []
|
||||
for value: Variant in _PRODUCTS.keys():
|
||||
ids.append(StringName(str(value)))
|
||||
ids.sort_custom(func(first: StringName, second: StringName) -> bool:
|
||||
return String(first) < String(second)
|
||||
)
|
||||
return ids
|
||||
|
||||
|
||||
static func has_product(product_id: StringName) -> bool:
|
||||
return _PRODUCTS.has(product_id)
|
||||
|
||||
|
||||
static func get_product(product_id: StringName) -> Dictionary:
|
||||
var value: Variant = _PRODUCTS.get(product_id)
|
||||
return (
|
||||
(value as Dictionary).duplicate(true)
|
||||
if typeof(value) == TYPE_DICTIONARY
|
||||
else {}
|
||||
)
|
||||
|
||||
|
||||
static func get_display_name(product_id: StringName) -> String:
|
||||
return str(get_product(product_id).get("display_name", product_id))
|
||||
|
||||
|
||||
static func get_description(product_id: StringName) -> String:
|
||||
return str(get_product(product_id).get("description", ""))
|
||||
|
||||
|
||||
static func get_price(product_id: StringName) -> int:
|
||||
return int(get_product(product_id).get("price", -1))
|
||||
|
||||
|
||||
static func get_footprint(product_id: StringName) -> Vector2:
|
||||
var value: Variant = get_product(product_id).get("footprint", Vector2.ZERO)
|
||||
return value as Vector2 if value is Vector2 else Vector2.ZERO
|
||||
|
||||
|
||||
static func get_height(product_id: StringName) -> float:
|
||||
return float(get_product(product_id).get("height", 0.0))
|
||||
Loading…
Add table
Add a link
Reference in a new issue