Item_Definition_Desc :: struct {
id: string;
name: string;
icon: string; // /res 中的路径(省略 "/res/")
stack_size: s64; // 1 = 不可堆叠,-1 = 无限
tier: Item_Tier;
}
Items :: struct {
// 物品栏
create_inventory :: proc(unique_id: string, capacity: s64) -> Inventory;
destroy_inventory :: proc(inventory: Inventory) -> bool;
set_capacity :: proc(inventory: Inventory, capacity: s64);
// 物品定义 + 实例
register_item_definition :: proc(desc: Item_Definition_Desc, $Definition_Type: typeid = Item_Definition, instance_type: typeid = Item_Instance) -> Definition_Type;
create_item_instance :: proc(definition: Item_Definition, count: s64 = 1) -> Item_Instance;
create_item_instance :: proc(definition: Item_Definition, $T: typeid, count: s64 = 1) -> T;
destroy_item_instance :: proc(instance: Item_Instance, count: s64 = -1);
// 在不同位置移动物品
can_move_item_to_inventory :: proc(instance: Item_Instance, inventory: Inventory, will_destroy_item: ref bool) -> bool;
move_item_to_inventory :: proc(instance: Item_Instance, inventory: Inventory);
move_as_many_items_as_possible_to_inventory :: proc(instance: Item_Instance, inventory: Inventory, destroyed_item: ref bool) -> s64;
remove_item_from_inventory :: proc(instance: Item_Instance, inventory: Inventory);
can_swap_items :: proc(inventory_a: Inventory, inventory_b: Inventory, slot_a: s64, slot_b: s64) -> bool;
swap_items :: proc(inventory_a: Inventory, inventory_b: Inventory, slot_a: s64, slot_b: s64);
// 界面(可选)
draw_inventory :: proc(rect: Rect, inventory: Inventory, options: Inventory_Draw_Options) -> bool;
draw_hotbar :: proc(player: Player, inventory: Inventory, options: Inventory_Draw_Options) -> Draw_Hotbar_Result;
}
Inventory :: class : Inventory_Base {
get_item :: proc(inventory: Inventory, index: s64) -> Item_Instance;
}
Item_Definition :: class : Item_Definition_Base {
get_name :: method() -> string;
get_id :: method() -> string;
get_icon :: method() -> Texture_Asset;
}
Item_Instance :: class : Item_Instance_Base {
get_definition :: method() -> Item_Definition;
}