ItemComponent syncing fixes:
- Relay and lightcomponent states are synced (otherwise clients won't be notified if the state is, for example, toggled by a signal from a button). - Clients don't play door sounds if a signal attempts to set the state to the same value as the predicted state, but DO play if a correction from the server changes the state from the predicted one. - Clients are notified if a reactor receives a shutdown signal. - Powercontainer updates are sent if the charge changes by 1%, not by 1 unit.
This commit is contained in:
@@ -500,10 +500,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void SetState(bool open, bool isNetworkMessage, bool sendNetworkMessage = false)
|
||||
{
|
||||
|
||||
if (isStuck || isOpen == open) return;
|
||||
|
||||
|
||||
if (GameMain.Client != null && !isNetworkMessage)
|
||||
{
|
||||
//clients can "predict" that the door opens/closes when a signal is received
|
||||
@@ -511,14 +509,15 @@ namespace Barotrauma.Items.Components
|
||||
//the prediction will be reset after 1 second, setting the door to a state
|
||||
//sent by the server, or reverting it back to its old state if no msg from server was received
|
||||
|
||||
PlaySound(ActionType.OnUse, item.WorldPosition);
|
||||
if (open != predictedState) PlaySound(ActionType.OnUse, item.WorldPosition);
|
||||
|
||||
predictedState = open;
|
||||
resetPredictionTimer = CorrectionDelay;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isNetworkMessage) PlaySound(ActionType.OnUse, item.WorldPosition);
|
||||
if (!isNetworkMessage || open != predictedState) PlaySound(ActionType.OnUse, item.WorldPosition);
|
||||
|
||||
isOpen = open;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user