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:
Regalis
2017-04-11 20:36:52 +03:00
parent 347f549ac1
commit 9a36df0f52
5 changed files with 49 additions and 16 deletions
@@ -2,10 +2,12 @@
using Barotrauma.Lights;
using System;
using System.Xml.Linq;
using Barotrauma.Networking;
using Lidgren.Network;
namespace Barotrauma.Items.Components
{
class LightComponent : Powered, IDrawableComponent
class LightComponent : Powered, IServerSerializable, IDrawableComponent
{
private Color lightColor;
@@ -47,7 +49,10 @@ namespace Barotrauma.Items.Components
get { return IsActive; }
set
{
if (IsActive == value) return;
IsActive = value;
if (GameMain.Server != null) item.CreateServerEvent(this);
}
}
@@ -205,5 +210,15 @@ namespace Barotrauma.Items.Components
break;
}
}
public void ServerWrite(NetBuffer msg, Client c, object[] extraData = null)
{
msg.Write(IsOn);
}
public void ClientRead(ServerNetObject type, NetBuffer msg, float sendingTime)
{
IsOn = msg.ReadBoolean();
}
}
}