inventory bug fixes, multiplayer pickup sync
This commit is contained in:
parent
04a9a299d7
commit
000269875a
14 changed files with 88 additions and 43 deletions
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
[sub_resource type="Resource" id="Resource_lowgp"]
|
||||
script = ExtResource("2_ihtnh")
|
||||
id = 1
|
||||
value = 100
|
||||
name = "Golden Goblet"
|
||||
weight = 10
|
||||
|
|
|
|||
|
|
@ -26,3 +26,7 @@ text = "Value"
|
|||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Weight"
|
||||
|
||||
[node name="Id" type="Label" parent="."]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
[gd_scene load_steps=26 format=3 uid="uid://cc1m2a1obsyn4"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c1um4tmthbbpk" path="res://Scripts/fpc/character.gd" id="1_0t4e8"]
|
||||
[ext_resource type="Script" uid="uid://darcj1vokaiv2" path="res://Scripts/Resources/inventory.gd" id="2_bmlhv"]
|
||||
[ext_resource type="Script" uid="uid://c5g0jt1apb2al" path="res://Scripts/fpc/EditorModule.gd" id="3_v3ckk"]
|
||||
[ext_resource type="Script" uid="uid://bhfftu01dsfk7" path="res://Scripts/fpc/debug.gd" id="3_x1wcc"]
|
||||
[ext_resource type="PackedScene" uid="uid://01ujg1e7atlb" path="res://Scenes/Menu/InventoryMenu.tscn" id="4_8j081"]
|
||||
[ext_resource type="Script" uid="uid://c1um4tmthbbpk" path="res://Scripts/fpc/player.gd" id="1_vk0jd"]
|
||||
[ext_resource type="Script" uid="uid://darcj1vokaiv2" path="res://Scripts/Resources/inventory.gd" id="2_v5t36"]
|
||||
[ext_resource type="Script" uid="uid://bhfftu01dsfk7" path="res://Scripts/fpc/debug.gd" id="3_y73r6"]
|
||||
[ext_resource type="PackedScene" uid="uid://01ujg1e7atlb" path="res://Scenes/Menu/InventoryMenu.tscn" id="4_pbnxc"]
|
||||
[ext_resource type="Script" uid="uid://c5g0jt1apb2al" path="res://Scripts/fpc/EditorModule.gd" id="5_v2gla"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_jcsm3"]
|
||||
script = ExtResource("2_bmlhv")
|
||||
script = ExtResource("2_v5t36")
|
||||
metadata/_custom_type_script = "uid://darcj1vokaiv2"
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_kp17n"]
|
||||
|
|
@ -397,9 +397,9 @@ properties/2/path = NodePath("Head:rotation")
|
|||
properties/2/spawn = true
|
||||
properties/2/replication_mode = 1
|
||||
|
||||
[node name="Character" type="CharacterBody3D" node_paths=PackedStringArray("HEAD", "CAMERA", "CAMERA_RAYCAST", "HEADBOB_ANIMATION", "JUMP_ANIMATION", "CROUCH_ANIMATION", "COLLISION_MESH")]
|
||||
[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("HEAD", "CAMERA", "CAMERA_RAYCAST", "HEADBOB_ANIMATION", "JUMP_ANIMATION", "CROUCH_ANIMATION", "COLLISION_MESH")]
|
||||
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, 0, 0)
|
||||
script = ExtResource("1_0t4e8")
|
||||
script = ExtResource("1_vk0jd")
|
||||
HEAD = NodePath("Head")
|
||||
CAMERA = NodePath("Head/Camera")
|
||||
CAMERA_RAYCAST = NodePath("Head/Camera/CamRayCast3D")
|
||||
|
|
@ -461,7 +461,7 @@ offset_top = 10.0
|
|||
offset_right = 453.0
|
||||
offset_bottom = 50.0
|
||||
theme = SubResource("Theme_wdf0f")
|
||||
script = ExtResource("3_x1wcc")
|
||||
script = ExtResource("3_y73r6")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="UserInterface/DebugPanel"]
|
||||
layout_mode = 2
|
||||
|
|
@ -469,7 +469,7 @@ layout_mode = 2
|
|||
[node name="VBoxContainer" type="VBoxContainer" parent="UserInterface/DebugPanel/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="InventoryMenu" parent="UserInterface" instance=ExtResource("4_8j081")]
|
||||
[node name="InventoryMenu" parent="UserInterface" instance=ExtResource("4_pbnxc")]
|
||||
|
||||
[node name="CrouchCeilingDetection" type="ShapeCast3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
|
|
@ -477,7 +477,10 @@ shape = SubResource("SphereShape3D_k4wwl")
|
|||
target_position = Vector3(0, 0.5, 0)
|
||||
|
||||
[node name="EditorModule" type="Node" parent="."]
|
||||
script = ExtResource("3_v3ckk")
|
||||
script = ExtResource("5_v2gla")
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_a88hh")
|
||||
|
||||
[node name="Item_holster" type="Marker3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.623649, 1.15944, 2.72606e-08)
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
[gd_scene load_steps=11 format=3 uid="uid://cjimt73bcja16"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://klp20wju1i26" path="res://Scripts/world.gd" id="1_8j60k"]
|
||||
[ext_resource type="PackedScene" uid="uid://x4ohd5qj3xpy" path="res://Scenes/Lobby.tscn" id="2_5a7ea"]
|
||||
[ext_resource type="PackedScene" uid="uid://dt1v3f2oc7vbw" path="res://Scenes/Menu/LobbyMenu.tscn" id="4_fo5ed"]
|
||||
[ext_resource type="Script" uid="uid://bsyvwqveefopb" path="res://Scripts/Level/level.gd" id="5_5ukr8"]
|
||||
[ext_resource type="PackedScene" uid="uid://d1ofd327cqcd1" path="res://Scenes/Server/Server.tscn" id="5_fo5ed"]
|
||||
[ext_resource type="PackedScene" uid="uid://b5lihf68rflsh" path="res://Scenes/town.tscn" id="5_o06y3"]
|
||||
[ext_resource type="PackedScene" uid="uid://dtpqexue3vgl6" path="res://Scenes/Chat/ChatMenu.tscn" id="7_k7acu"]
|
||||
[ext_resource type="Script" uid="uid://klp20wju1i26" path="res://Scripts/world.gd" id="1_1l0tm"]
|
||||
[ext_resource type="PackedScene" uid="uid://d1ofd327cqcd1" path="res://Scenes/Server/Server.tscn" id="2_v158k"]
|
||||
[ext_resource type="Script" uid="uid://bsyvwqveefopb" path="res://Scripts/Level/level.gd" id="3_h4fw4"]
|
||||
[ext_resource type="PackedScene" uid="uid://x4ohd5qj3xpy" path="res://Scenes/Lobby.tscn" id="4_ldgsr"]
|
||||
[ext_resource type="PackedScene" uid="uid://b5lihf68rflsh" path="res://Scenes/town.tscn" id="5_o5yvi"]
|
||||
[ext_resource type="PackedScene" uid="uid://dt1v3f2oc7vbw" path="res://Scenes/Menu/LobbyMenu.tscn" id="6_rku1e"]
|
||||
[ext_resource type="PackedScene" uid="uid://dtpqexue3vgl6" path="res://Scenes/Chat/ChatMenu.tscn" id="7_rfjv2"]
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_go701"]
|
||||
sky_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
|
||||
|
|
@ -21,13 +21,13 @@ sky = SubResource("Sky_5a7ea")
|
|||
tonemap_mode = 2
|
||||
glow_enabled = true
|
||||
|
||||
[node name="World" type="Node" node_paths=PackedStringArray("lobby_menu", "server", "level")]
|
||||
script = ExtResource("1_8j60k")
|
||||
[node name="Game" type="Node" node_paths=PackedStringArray("lobby_menu", "server", "level")]
|
||||
script = ExtResource("1_1l0tm")
|
||||
lobby_menu = NodePath("LobbyMenu")
|
||||
server = NodePath("Server")
|
||||
level = NodePath("Level")
|
||||
|
||||
[node name="Server" parent="." instance=ExtResource("5_fo5ed")]
|
||||
[node name="Server" parent="." instance=ExtResource("2_v158k")]
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource("Environment_8j60k")
|
||||
|
|
@ -37,20 +37,20 @@ transform = Transform3D(-0.866023, -0.433016, 0.250001, 0, 0.499998, 0.866027, -
|
|||
shadow_enabled = true
|
||||
|
||||
[node name="Level" type="Node" parent="." node_paths=PackedStringArray("lobby")]
|
||||
script = ExtResource("5_5ukr8")
|
||||
script = ExtResource("3_h4fw4")
|
||||
lobby = NodePath("Lobby")
|
||||
|
||||
[node name="Lobby" parent="Level" instance=ExtResource("2_5a7ea")]
|
||||
[node name="Lobby" parent="Level" instance=ExtResource("4_ldgsr")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 48.3442, -31.095, 21.7287)
|
||||
|
||||
[node name="MultiplayerSpawner" type="MultiplayerSpawner" parent="Level"]
|
||||
_spawnable_scenes = PackedStringArray("uid://cc1m2a1obsyn4")
|
||||
_spawnable_scenes = PackedStringArray("uid://cc1m2a1obsyn4", "uid://cfsot3wc41tx")
|
||||
spawn_path = NodePath("..")
|
||||
|
||||
[node name="Town" parent="Level" instance=ExtResource("5_o06y3")]
|
||||
[node name="Town" parent="Level" instance=ExtResource("5_o5yvi")]
|
||||
|
||||
[node name="LobbyMenu" parent="." instance=ExtResource("4_fo5ed")]
|
||||
[node name="LobbyMenu" parent="." instance=ExtResource("6_rku1e")]
|
||||
visible = false
|
||||
|
||||
[node name="ChatMenu" parent="." instance=ExtResource("7_k7acu")]
|
||||
[node name="ChatMenu" parent="." instance=ExtResource("7_rfjv2")]
|
||||
visible = false
|
||||
|
|
@ -2,4 +2,21 @@ extends RigidBody3D
|
|||
|
||||
@export var item : Item
|
||||
@onready var interactable : Interactable = $Interactable
|
||||
@onready var is_interactable : bool = true
|
||||
@onready var is_interactable : bool = true
|
||||
|
||||
|
||||
@rpc("any_peer", "call_local")
|
||||
func pickup_item(player_id : int, item_name : String):
|
||||
print(item_name, "penis")
|
||||
# var item = get_node(item_name) as RigidBody3D
|
||||
# item.set_controller(item_holster_one)
|
||||
freeze = true
|
||||
collision_layer = 0
|
||||
hide()
|
||||
change_authority.rpc_id(1, player_id)
|
||||
|
||||
@rpc("any_peer", "call_local")
|
||||
func change_authority(player_id : int):
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
set_multiplayer_authority.call_deferred(player_id)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
class_name Level
|
||||
extends Node
|
||||
|
||||
var player_scene : PackedScene = preload("res://Scenes/Mobs/character.tscn")
|
||||
var player_scene : PackedScene = preload("res://Scenes/Mobs/player.tscn")
|
||||
|
||||
@export var lobby : Lobby
|
||||
|
||||
|
|
|
|||
|
|
@ -24,10 +24,11 @@ func toggle_inventory() -> bool:
|
|||
|
||||
func update_inventory():
|
||||
for i in inventory.items:
|
||||
var match_found : bool = false
|
||||
var new_item = item_scene.instantiate()
|
||||
# new_item.set_values(i.item.name, i.item.value, i.item.weight)
|
||||
item_list.add_child(new_item)
|
||||
new_item.set_values(i.item.name, 10, 10)
|
||||
print(i.item.name)
|
||||
print(i)
|
||||
pass
|
||||
for j in item_list.get_children():
|
||||
if j.id.text != str(i.item.id):
|
||||
match_found = true
|
||||
if !match_found || item_list.get_children().size() == 1:
|
||||
item_list.add_child(new_item)
|
||||
new_item.set_values(i.item.id, i.item.name, 10, 10)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
extends Node
|
||||
|
||||
@onready var id : Label = $Id
|
||||
@onready var title : Label = $Name
|
||||
@onready var value : Label = $Value
|
||||
@onready var weight : Label = $Weight
|
||||
|
||||
|
||||
func set_values(new_title : String, new_value : int, new_weight : int) -> void:
|
||||
func set_values(new_id : int, new_title : String, new_value : int, new_weight : int) -> void:
|
||||
id.text = str(new_id)
|
||||
title.text = new_title
|
||||
value.text = str(new_value)
|
||||
weight.text = str(new_weight)
|
||||
|
|
|
|||
1
Scripts/Resources/entity_resource.gd
Normal file
1
Scripts/Resources/entity_resource.gd
Normal file
|
|
@ -0,0 +1 @@
|
|||
extends Node
|
||||
1
Scripts/Resources/entity_resource.gd.uid
Normal file
1
Scripts/Resources/entity_resource.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cd0o5lwehj6cl
|
||||
|
|
@ -10,6 +10,7 @@ func get_current_slot(index : int) -> RigidBody3D:
|
|||
|
||||
func add_item(item : RigidBody3D) -> void:
|
||||
items.append(item)
|
||||
print(item.item.id, " added id")
|
||||
|
||||
func remove_items(item : RigidBody3D) -> void:
|
||||
items.erase(item)
|
||||
|
|
@ -2,8 +2,17 @@ extends Resource
|
|||
|
||||
class_name Item
|
||||
|
||||
@export var id : int
|
||||
@export var value : int
|
||||
@export var name : String
|
||||
@export var weight : int
|
||||
@export var primary_objective : bool
|
||||
@export var secondary_objective : bool
|
||||
var controller : Marker3D
|
||||
|
||||
|
||||
func set_controller(new_controller : Marker3D):
|
||||
controller = new_controller
|
||||
|
||||
func get_controller() -> Marker3D:
|
||||
return controller
|
||||
|
|
@ -57,7 +57,8 @@ extends CharacterBody3D
|
|||
@export var CROUCH_ANIMATION : AnimationPlayer
|
||||
## A reference to the the player's collision shape for use in the character script.
|
||||
@export var COLLISION_MESH : CollisionShape3D
|
||||
|
||||
## A reference to the item holster
|
||||
@onready var item_holster_one : Marker3D
|
||||
#endregion
|
||||
|
||||
#region Controls Export Group
|
||||
|
|
@ -173,6 +174,7 @@ func _ready():
|
|||
CAMERA.current = true
|
||||
inventory_menu = $UserInterface/InventoryMenu
|
||||
inventory_menu.inventory = INVENTORY
|
||||
item_holster_one = $Item_holster
|
||||
|
||||
func _process(_delta):
|
||||
# if pausing_enabled:
|
||||
|
|
@ -230,6 +232,10 @@ func teleport_player(location: Vector3, new_rotation: Vector3) -> void:
|
|||
velocity = Vector3.ZERO
|
||||
|
||||
|
||||
|
||||
# assign controller to item
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Input Handling
|
||||
|
|
@ -304,13 +310,13 @@ func handle_interact():
|
|||
interactable.interactable.outline.show()
|
||||
if "item" in interactable:
|
||||
if Input.is_action_just_pressed(controls.INTERACT):
|
||||
print(CAMERA_RAYCAST.get_collider())
|
||||
var item = interactable as RigidBody3D
|
||||
item.freeze = true
|
||||
item.collision_layer = 0
|
||||
item.hide()
|
||||
var player_id : int = name.lstrip("Player").to_int()
|
||||
item.pickup_item.rpc(player_id, item.name)
|
||||
|
||||
print('adding a item, heheheheheheheh')
|
||||
print("adding ID: ", item.item.id)
|
||||
INVENTORY.add_item(item)
|
||||
print("This is a item")
|
||||
elif HIGHLIGHTED_ITEM != null:
|
||||
HIGHLIGHTED_ITEM.get_node("Interactable").outline.hide()
|
||||
HIGHLIGHTED_ITEM = null
|
||||
Loading…
Add table
Add a link
Reference in a new issue