Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 NewDerFolder

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
104 changes: 102 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,104 @@
# EasyBag
⚠️ Note: The underlying architecture is in flux right now. We plan to rewrite the Quick Start guide in the upcoming v0.5 release.
## 简介
EasyBag是Godot中的一个库存系统插件,着力于高度解耦和数据化,和可扩展性,致力于加速和稳固中大型角色扮演游戏亦或者是需要高度定制化库存系统的项目。
配合Godot的资源类,使其可以在Godot编辑器面板中比较物品的属性或标签。实现程序员与策划人员的有序合作。
同时EasyBag也提供了些类快速实现如物品随机掉落,物品配方合成等功能。当然你也可以自己自由扩展。
## 快速入门

### 创建资源文件
1. EasyBag基于Godot的资源文件,以此请先创建一个```EB_InventoryItem```类型的资源文件
2. 双击你创建的资源文件,可以看到右侧的属性面板
3. 你最好保持文件名和```item_name```属性相同,这是个潜规则
4. ```attribute_arr```空无一物,是时候创建了,添加元素吧,来个``` EB_IntAttribute```属性
5. 点开这个属性,可以看到```value```,```attribute_name```,```is_static```
6. 试着更改更改属性名称为```atk```,将值改成```10```
7. 添加一个标签吧,你得先创建一个标签
8. 新建```EB_BaseTag```类型的资源文件,记得保存文件名称和```tag_name```属性一致
9. 重写点回你之前创建的```EB_InventoryItem```类型资源文件,为其```tag_arr```添加tag,点击快速加载选择刚刚创建的tag

### 加载物品到库存
创建一个场景并且编辑其脚本
在```_ready```函数中
```gdscript
#加载物品
var my_item:=load("res://resource/你的文件路径.tres")
#创建库存容器
var my_inventory:=EB_Inventory.new()
#将物品添加进去
my_inventory.add_item(my_item)
```
是的这样子my_inventory中就有这个物品了

### 更加集中式的做法
1. 创建一个```EB_DictionaryCodex```的资源文件
2. 为其添加键值对,注意值应该快速加载你创建过的物品项
3. 加载物品到库存
```gdscript
#你可以选择用键或者是物品名称获取物品
codex.get_InventoryItem_by_name("")
codex.get_InventoryItem_by_id("")
var new_item=codex.get_InventoryItem_by_id("你的键")
#将物品添加进去
inventory.add_item(new_item)
```

### 还有很多
当然这个快速入门比较短,EasyBag中还有许多基础用法和进阶用法,比如说掉落池或者是配方类,未来我们会进一步完善文档。


# EasyBag
目前底层架构处于变动中,预计于0.5版本重写新版本的快速入门.

## Introduction
EasyBag is an inventory system plugin for Godot, focusing on high decoupling, data-driven design, and scalability. It is dedicated to accelerating and stabilizing medium-to-large RPG projects or any project requiring a highly customizable inventory system.

By leveraging Godot's Resource system, it allows you to compare item attributes and tags directly within the Godot editor panel, facilitating an organized workflow between programmers and game designers.

EasyBag also provides utility classes to quickly implement features like random item drops and crafting recipes. Of course, you are free to extend it however you like.

## Quick Start

### Creating Resource Files
1. EasyBag is built on Godot's Resource system. Start by creating a resource file of type `EB_InventoryItem`.
2. Double-click your newly created resource file to view its properties in the right-side panel.
3. **Pro Tip:** It's highly recommended to keep the file name identical to the `item_name` property. This is a widely accepted convention.
4. The `attribute_arr` is currently empty—time to create one! Add an element, such as an `EB_IntAttribute`.
5. Click on this attribute to reveal its properties: `value`, `attribute_name`, and `is_static`.
6. Try changing the attribute name to `atk` and setting the value to `10`.
7. Next, let's add a tag. First, you need to create the tag itself.
8. Create a new resource file of type `EB_BaseTag`. Remember to save the file with a name that matches the `tag_name` property.
9. Go back to your `EB_InventoryItem` resource file, add the tag to its `tag_arr`, and use the Quick Load feature to select the tag you just created.

### Loading Items into Inventory
Create a scene and edit its script. In the `_ready` function:

```gdscript
# Load the item
var my_item := load("res://resource/your_file_path.tres")

# Create an inventory container
var my_inventory := EB_Inventory.new()

# Add the item to the inventory
my_inventory.add_item(my_item)
```

And just like that, your item is now in `my_inventory`!

### A More Centralized Approach
1. Create a resource file of type `EB_DictionaryCodex`.
2. Add key-value pairs to it. Note that the values should be Quick Loaded from the item resources you've previously created.
3. Load items into the inventory:

```gdscript
# You can retrieve items using either a key or an item name
codex.get_InventoryItem_by_name("")
codex.get_InventoryItem_by_id("")

var new_item = codex.get_InventoryItem_by_id("your_key")

# Add the item to the inventory
inventory.add_item(new_item)
```

### And There's More!
Of course, this quick start guide is quite brief. EasyBag includes many basic and advanced features, such as drop pools and crafting recipes. We will continue to improve and expand the documentation in the future.
11 changes: 11 additions & 0 deletions Task/page/aaa.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ extends Node
@export var inventory:=EB_CapacityInventory.new()

func _ready() -> void:

var my_item:=load("res://resource/eb/itmes/new_resource.tres")
var my_inventory:=EB_Inventory.new()
my_inventory.add_item(my_item)
var codex:EB_DictionaryCodex=load("res://resource/eb/codex.tres")
#你可以选择用键或者是物品名称获取物品
codex.get_InventoryItem_by_name("")
codex.get_InventoryItem_by_id("")
var new_item=codex.get_InventoryItem_by_id("你的键")
inventory.add_item(new_item)

inventory.stack_attribute=preload("res://resource/eb/late_attribute/stack.gd").new()
inventory.max_stack_attribute=preload("res://resource/eb/static_attribute/max_stack.gd").new()

Expand Down
209 changes: 209 additions & 0 deletions Task/page/grid_page.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
[gd_scene format=3 uid="uid://bywy28p0m81xm"]

[ext_resource type="Texture2D" uid="uid://c7o37ili224i7" path="res://addons/easy_bag/asset/icon/apple.png" id="1_2k051"]
[ext_resource type="Texture2D" uid="uid://bwp5ku0hu00q8" path="res://addons/easy_bag/asset/icon/EasyBagResource.png" id="2_1x1f4"]
[ext_resource type="Texture2D" uid="uid://pdqc3qr88h6b" path="res://addons/easy_bag/asset/icon/hpIcon.png" id="3_3ulxc"]
[ext_resource type="Texture2D" uid="uid://d202aoymh587g" path="res://addons/easy_bag/asset/icon/GreenApple.png" id="4_3ulxc"]
[ext_resource type="Texture2D" uid="uid://65lwgvhknhkn" path="res://addons/easy_bag/asset/icon/book.png" id="5_ek0ie"]

[node name="GridPage" type="Control" unique_id=873143751]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

[node name="PanelContainer" type="PanelContainer" parent="." unique_id=425836410]
layout_mode = 0
offset_left = 668.0
offset_top = 223.0
offset_right = 941.0
offset_bottom = 385.0

[node name="HFlowContainer" type="HFlowContainer" parent="PanelContainer" unique_id=669937720]
layout_mode = 2

[node name="PanelContainer" type="PanelContainer" parent="PanelContainer/HFlowContainer" unique_id=1156746990]
layout_mode = 2

[node name="TextureRect" type="TextureRect" parent="PanelContainer/HFlowContainer/PanelContainer" unique_id=1220313199]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
texture = ExtResource("1_2k051")
expand_mode = 1

[node name="PanelContainer2" type="PanelContainer" parent="PanelContainer/HFlowContainer" unique_id=180352666]
layout_mode = 2

[node name="TextureRect" type="TextureRect" parent="PanelContainer/HFlowContainer/PanelContainer2" unique_id=50591591]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
texture = ExtResource("2_1x1f4")
expand_mode = 1

[node name="PanelContainer3" type="PanelContainer" parent="PanelContainer/HFlowContainer" unique_id=593770944]
layout_mode = 2

[node name="TextureRect" type="TextureRect" parent="PanelContainer/HFlowContainer/PanelContainer3" unique_id=12606192]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
texture = ExtResource("3_3ulxc")
expand_mode = 1

[node name="PanelContainer4" type="PanelContainer" parent="PanelContainer/HFlowContainer" unique_id=1420462990]
layout_mode = 2

[node name="TextureRect" type="TextureRect" parent="PanelContainer/HFlowContainer/PanelContainer4" unique_id=1766944062]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
expand_mode = 1

[node name="PanelContainer5" type="PanelContainer" parent="PanelContainer/HFlowContainer" unique_id=479447553]
layout_mode = 2

[node name="TextureRect" type="TextureRect" parent="PanelContainer/HFlowContainer/PanelContainer5" unique_id=1492489588]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
expand_mode = 1

[node name="PanelContainer6" type="PanelContainer" parent="PanelContainer/HFlowContainer" unique_id=1374439643]
layout_mode = 2

[node name="TextureRect" type="TextureRect" parent="PanelContainer/HFlowContainer/PanelContainer6" unique_id=1148355071]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
expand_mode = 1

[node name="PanelContainer7" type="PanelContainer" parent="PanelContainer/HFlowContainer" unique_id=25768683]
layout_mode = 2

[node name="TextureRect" type="TextureRect" parent="PanelContainer/HFlowContainer/PanelContainer7" unique_id=1546133697]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
expand_mode = 1

[node name="PanelContainer8" type="PanelContainer" parent="PanelContainer/HFlowContainer" unique_id=632134745]
layout_mode = 2

[node name="TextureRect" type="TextureRect" parent="PanelContainer/HFlowContainer/PanelContainer8" unique_id=291430643]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
expand_mode = 1

[node name="PanelContainer9" type="PanelContainer" parent="PanelContainer/HFlowContainer" unique_id=322857949]
layout_mode = 2

[node name="TextureRect" type="TextureRect" parent="PanelContainer/HFlowContainer/PanelContainer9" unique_id=150642780]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
expand_mode = 1

[node name="PanelContainer10" type="PanelContainer" parent="PanelContainer/HFlowContainer" unique_id=1082505126]
layout_mode = 2

[node name="TextureRect" type="TextureRect" parent="PanelContainer/HFlowContainer/PanelContainer10" unique_id=729404147]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
expand_mode = 1

[node name="PanelContainer11" type="PanelContainer" parent="PanelContainer/HFlowContainer" unique_id=1575815679]
layout_mode = 2

[node name="TextureRect" type="TextureRect" parent="PanelContainer/HFlowContainer/PanelContainer11" unique_id=189320247]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
expand_mode = 1

[node name="PanelContainer12" type="PanelContainer" parent="PanelContainer/HFlowContainer" unique_id=2047006448]
layout_mode = 2

[node name="TextureRect" type="TextureRect" parent="PanelContainer/HFlowContainer/PanelContainer12" unique_id=1596046235]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
expand_mode = 1

[node name="PanelContainer13" type="PanelContainer" parent="PanelContainer/HFlowContainer" unique_id=144750887]
layout_mode = 2

[node name="TextureRect" type="TextureRect" parent="PanelContainer/HFlowContainer/PanelContainer13" unique_id=590999782]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
expand_mode = 1

[node name="PanelContainer14" type="PanelContainer" parent="PanelContainer/HFlowContainer" unique_id=596743739]
layout_mode = 2

[node name="TextureRect" type="TextureRect" parent="PanelContainer/HFlowContainer/PanelContainer14" unique_id=275655839]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
expand_mode = 1

[node name="PanelContainer15" type="PanelContainer" parent="PanelContainer/HFlowContainer" unique_id=2038510521]
layout_mode = 2

[node name="TextureRect" type="TextureRect" parent="PanelContainer/HFlowContainer/PanelContainer15" unique_id=329376707]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
expand_mode = 1

[node name="CenterContainer" type="CenterContainer" parent="PanelContainer" unique_id=1131789826]
layout_mode = 2

[node name="PanelContainer2" type="PanelContainer" parent="." unique_id=1439799268]
layout_mode = 0
offset_left = 411.0
offset_top = 225.0
offset_right = 542.0
offset_bottom = 383.0

[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer2" unique_id=1096500789]
layout_mode = 2

[node name="PanelContainer" type="PanelContainer" parent="PanelContainer2/VBoxContainer" unique_id=1526053230]
layout_mode = 2

[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer2/VBoxContainer/PanelContainer" unique_id=1431859195]
layout_mode = 2

[node name="TextureRect" type="TextureRect" parent="PanelContainer2/VBoxContainer/PanelContainer/HBoxContainer" unique_id=1112973318]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
texture = ExtResource("4_3ulxc")

[node name="Label" type="Label" parent="PanelContainer2/VBoxContainer/PanelContainer/HBoxContainer" unique_id=1112073964]
layout_mode = 2
theme_type_variation = &"HeaderLarge"
text = "Apple"

[node name="PanelContainer2" type="PanelContainer" parent="PanelContainer2/VBoxContainer" unique_id=2054898374]
layout_mode = 2

[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer2/VBoxContainer/PanelContainer2" unique_id=1999692848]
layout_mode = 2

[node name="TextureRect" type="TextureRect" parent="PanelContainer2/VBoxContainer/PanelContainer2/HBoxContainer" unique_id=1177668137]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
texture = ExtResource("2_1x1f4")

[node name="Label" type="Label" parent="PanelContainer2/VBoxContainer/PanelContainer2/HBoxContainer" unique_id=264481604]
layout_mode = 2
theme_type_variation = &"HeaderLarge"
text = "Box"

[node name="PanelContainer3" type="PanelContainer" parent="PanelContainer2/VBoxContainer" unique_id=302590660]
layout_mode = 2

[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer2/VBoxContainer/PanelContainer3" unique_id=1117947507]
layout_mode = 2

[node name="TextureRect" type="TextureRect" parent="PanelContainer2/VBoxContainer/PanelContainer3/HBoxContainer" unique_id=1546825021]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
texture = ExtResource("5_ek0ie")

[node name="Label" type="Label" parent="PanelContainer2/VBoxContainer/PanelContainer3/HBoxContainer" unique_id=1888740149]
layout_mode = 2
theme_type_variation = &"HeaderLarge"
text = "Book"
Binary file added addons/easy_bag/asset/background/EasyBagBg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions addons/easy_bag/asset/background/EasyBagBg.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://c8582iad3yhqa"
path="res://.godot/imported/EasyBagBg.png-3238f94400bf6c430f10ad177852a4d7.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/easy_bag/asset/background/EasyBagBg.png"
dest_files=["res://.godot/imported/EasyBagBg.png-3238f94400bf6c430f10ad177852a4d7.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Loading