Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Multiplayer-arena-game
/
Multiplayer-arena-game-GameObjects
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
34572d18
authored
Jan 19, 2025
by
alsunj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove unnecessary calls in chest script
parent
9573686b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
32 deletions
Assets/_Game/Code/Interactables/Chests/Chest.cs
Assets/_Game/Code/Interactables/Chests/Chest.cs
View file @
34572d18
...
...
@@ -7,19 +7,8 @@ public class Chest : NetworkBehaviour, IInteractable
{
private
GameObject
_chestLid
;
private
bool
_chestFound
;
private
NetworkVariable
<
bool
>
_chestFound
=
new
NetworkVariable
<
bool
>(
false
)
;
[
ServerRpc
(
RequireOwnership
=
false
)]
private
void
CmdOpenChestForEveryoneServerRpc
()
{
RpcOpenChestForEveryoneClientRpc
();
}
[
ClientRpc
]
private
void
RpcOpenChestForEveryoneClientRpc
()
{
Interacted
();
}
private
void
Awake
()
{
...
...
@@ -30,15 +19,18 @@ public class Chest : NetworkBehaviour, IInteractable
}
}
private
void
ChestFound
()
[
ServerRpc
(
RequireOwnership
=
false
)]
private
void
ChestFoundServerRpc
()
{
_chestLid
.
transform
.
DORotate
(
_chestLid
.
transform
.
eulerAngles
+
new
Vector3
(-
130
,
0
,
0
),
1f
)
.
SetEase
(
Ease
.
OutBounce
);
CmdOpenChestForEveryoneServerRpc
();
if
(!
_chestFound
.
Value
)
{
ChestFoundClientRpc
();
_chestFound
.
Value
=
true
;
}
}
private
void
ChestFoundForOtherClients
()
[
ClientRpc
]
private
void
ChestFoundClientRpc
()
{
_chestLid
.
transform
.
DORotate
(
_chestLid
.
transform
.
eulerAngles
+
new
Vector3
(-
130
,
0
,
0
),
1f
)
...
...
@@ -48,19 +40,6 @@ public class Chest : NetworkBehaviour, IInteractable
public
void
Interact
()
{
if
(!
_chestFound
)
{
ChestFound
();
_chestFound
=
true
;
}
}
public
void
Interacted
()
{
if
(!
_chestFound
)
{
ChestFoundForOtherClients
();
_chestFound
=
true
;
}
ChestFoundServerRpc
();
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment