-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BackpackComponent: - This component is used to extend/change the player inventory size (for grid based inventories). - The InventoryBag example item is added to the Lobby demo scene to show how this works. Note: Shrinking the player inventory can lead to unexpected behavior/errors, so use with caution.
- Loading branch information
1 parent
0fd1fa3
commit 3305d63
Showing
9 changed files
with
156 additions
and
57 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
[remap] | ||
|
||
importer="scene" | ||
importer_version=1 | ||
type="PackedScene" | ||
uid="uid://debjsdl174kkw" | ||
path="res://.godot/imported/bag.glb-a8733057fb7dca17295aee3f8ed71bcb.scn" | ||
|
||
[deps] | ||
|
||
source_file="res://addons/cogito/Assets/Models/Kenney/bag.glb" | ||
dest_files=["res://.godot/imported/bag.glb-a8733057fb7dca17295aee3f8ed71bcb.scn"] | ||
|
||
[params] | ||
|
||
nodes/root_type="" | ||
nodes/root_name="" | ||
nodes/apply_root_scale=true | ||
nodes/root_scale=1.0 | ||
nodes/import_as_skeleton_bones=false | ||
meshes/ensure_tangents=true | ||
meshes/generate_lods=true | ||
meshes/create_shadow_meshes=true | ||
meshes/light_baking=1 | ||
meshes/lightmap_texel_size=0.2 | ||
meshes/force_disable_compression=false | ||
skins/use_named_skins=true | ||
animation/import=true | ||
animation/fps=30 | ||
animation/trimming=false | ||
animation/remove_immutable_tracks=true | ||
animation/import_rest_as_RESET=false | ||
import_script/path="" | ||
_subresources={} | ||
gltf/naming_version=1 | ||
gltf/embedded_image_handling=1 |
24 changes: 24 additions & 0 deletions
24
addons/cogito/Components/Interactions/BackpackComponent.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
extends InteractionComponent | ||
class_name BackpackComponent | ||
|
||
@export_group("Backpack Settings") | ||
## Sound that plays when backpack is interacted with | ||
@export var sound_on_use: AudioStream | ||
## The new inventory grid size. | ||
@export var new_inventory_size : Vector2i = Vector2i(8,6) | ||
|
||
|
||
func interact(_player_interaction_component:PlayerInteractionComponent): | ||
update_player_inventory(_player_interaction_component.player) | ||
|
||
if sound_on_use: | ||
Audio.play_sound(sound_on_use) | ||
|
||
get_parent().queue_free() | ||
|
||
|
||
func update_player_inventory(player: CogitoPlayer): | ||
var player_inventory = player.inventory_data | ||
player_inventory.inventory_size = new_inventory_size | ||
player_inventory.inventory_slots.resize(player_inventory.inventory_size.x * player_inventory.inventory_size.y) | ||
player_inventory.force_inventory_update() |
10 changes: 10 additions & 0 deletions
10
addons/cogito/Components/Interactions/BackpackComponent.tscn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://1qmp8w30u0jy"] | ||
|
||
[ext_resource type="Script" path="res://addons/cogito/Components/Interactions/BackpackComponent.gd" id="1_pwtt8"] | ||
[ext_resource type="AudioStream" uid="uid://bhce82qflwaur" path="res://addons/cogito/Assets/Audio/Kenney/cardPlace1.ogg" id="2_7ni17"] | ||
|
||
[node name="BackpackComponent" type="Node3D"] | ||
script = ExtResource("1_pwtt8") | ||
sound_on_use = ExtResource("2_7ni17") | ||
input_map_action = "interact" | ||
interaction_text = "Extend inventory" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[gd_scene load_steps=6 format=3 uid="uid://cuwptpgheq4l5"] | ||
|
||
[ext_resource type="Script" path="res://addons/cogito/CogitoObjects/cogito_object.gd" id="1_avnnw"] | ||
[ext_resource type="PackedScene" uid="uid://cio4x05ipvslu" path="res://addons/cogito/Components/Interactions/CarryableComponent.tscn" id="2_da5wv"] | ||
[ext_resource type="PackedScene" uid="uid://1qmp8w30u0jy" path="res://addons/cogito/Components/Interactions/BackpackComponent.tscn" id="3_fg43q"] | ||
[ext_resource type="PackedScene" uid="uid://debjsdl174kkw" path="res://addons/cogito/Assets/Models/Kenney/bag.glb" id="4_skhg5"] | ||
|
||
[sub_resource type="BoxShape3D" id="BoxShape3D_rd5pj"] | ||
size = Vector3(0.213806, 0.597458, 0.408279) | ||
|
||
[node name="InventoryBag" type="RigidBody3D"] | ||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0) | ||
collision_layer = 3 | ||
script = ExtResource("1_avnnw") | ||
|
||
[node name="CarryableComponent" parent="." instance=ExtResource("2_da5wv")] | ||
|
||
[node name="BackpackComponent" parent="." instance=ExtResource("3_fg43q")] | ||
|
||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] | ||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00131226, -0.200554, -0.000480652) | ||
shape = SubResource("BoxShape3D_rd5pj") | ||
|
||
[node name="bag2" parent="." instance=ExtResource("4_skhg5")] | ||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0) |
Oops, something went wrong.