Unstable 0.17.1.0
This commit is contained in:
@@ -31,32 +31,43 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
partial void UpdateDamage(float deltaTime)
|
||||
public void ServerWrite(IWriteMessage msg, IEventData eventData)
|
||||
{
|
||||
if (damageUpdateTimer <= 0)
|
||||
msg.Write((byte)eventData.NetworkHeader);
|
||||
|
||||
switch (eventData)
|
||||
{
|
||||
foreach (BallastFloraBranch branch in Branches)
|
||||
{
|
||||
if (Math.Abs(branch.AccumulatedDamage) > 1.0f)
|
||||
{
|
||||
SendNetworkMessage(this, NetworkHeader.BranchDamage, branch);
|
||||
branch.AccumulatedDamage = 0f;
|
||||
}
|
||||
}
|
||||
damageUpdateTimer = 1f;
|
||||
case SpawnEventData spawnEventData:
|
||||
ServerWriteSpawn(msg);
|
||||
break;
|
||||
case KillEventData killEventData:
|
||||
//do nothing
|
||||
break;
|
||||
case BranchCreateEventData branchCreateEventData:
|
||||
ServerWriteBranchGrowth(msg, branchCreateEventData.NewBranch, branchCreateEventData.Parent.ID);
|
||||
break;
|
||||
case BranchDamageEventData branchDamageEventData:
|
||||
ServerWriteBranchDamage(msg, branchDamageEventData.Branch);
|
||||
break;
|
||||
case InfectEventData infectEventData:
|
||||
ServerWriteInfect(msg, infectEventData.Item.ID, infectEventData.Infect, infectEventData.Infector);
|
||||
break;
|
||||
case BranchRemoveEventData branchRemoveEventData:
|
||||
ServerWriteBranchRemove(msg, branchRemoveEventData.Branch);
|
||||
break;
|
||||
}
|
||||
damageUpdateTimer -= deltaTime;
|
||||
|
||||
msg.Write(PowerConsumptionTimer);
|
||||
}
|
||||
|
||||
public void ServerWriteSpawn(IWriteMessage msg)
|
||||
private void ServerWriteSpawn(IWriteMessage msg)
|
||||
{
|
||||
msg.Write(Prefab.Identifier);
|
||||
msg.Write(Offset.X);
|
||||
msg.Write(Offset.Y);
|
||||
}
|
||||
|
||||
public void ServerWriteBranchGrowth(IWriteMessage msg, BallastFloraBranch branch, int parentId = -1)
|
||||
private void ServerWriteBranchGrowth(IWriteMessage msg, BallastFloraBranch branch, int parentId = -1)
|
||||
{
|
||||
var (x, y) = branch.Position;
|
||||
msg.Write(parentId);
|
||||
@@ -71,30 +82,30 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
msg.Write(branch.ParentBranch == null ? -1 : Branches.IndexOf(branch.ParentBranch));
|
||||
}
|
||||
|
||||
public void ServerWriteBranchDamage(IWriteMessage msg, BallastFloraBranch branch)
|
||||
private void ServerWriteBranchDamage(IWriteMessage msg, BallastFloraBranch branch)
|
||||
{
|
||||
msg.Write((int)branch.ID);
|
||||
msg.Write(branch.Health);
|
||||
}
|
||||
|
||||
public void ServerWriteInfect(IWriteMessage msg, UInt16 itemID, bool infect, BallastFloraBranch infector = null)
|
||||
private void ServerWriteInfect(IWriteMessage msg, UInt16 itemID, InfectEventData.InfectState infect, BallastFloraBranch infector = null)
|
||||
{
|
||||
msg.Write(itemID);
|
||||
msg.Write(infect);
|
||||
if (infect)
|
||||
msg.Write(infect == InfectEventData.InfectState.Yes);
|
||||
if (infect == InfectEventData.InfectState.Yes)
|
||||
{
|
||||
msg.Write(infector?.ID ?? -1);
|
||||
}
|
||||
}
|
||||
|
||||
public void ServerWriteBranchRemove(IWriteMessage msg, BallastFloraBranch branch)
|
||||
private void ServerWriteBranchRemove(IWriteMessage msg, BallastFloraBranch branch)
|
||||
{
|
||||
msg.Write(branch.ID);
|
||||
}
|
||||
|
||||
public void SendNetworkMessage(params object[] extraData)
|
||||
public void SendNetworkMessage(IEventData extraData)
|
||||
{
|
||||
GameMain.Server.CreateEntityEvent(Parent, extraData);
|
||||
GameMain.Server.CreateEntityEvent(Parent, new Hull.BallastFloraEventData(this, extraData));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,20 @@ using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.MapCreatures.Behavior;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class Hull : MapEntity, ISerializableEntity, IServerSerializable, IClientSerializable
|
||||
{
|
||||
private float lastSentVolume, lastSentOxygen, lastSentFireCount;
|
||||
private float sendUpdateTimer;
|
||||
private float lastSentVolume;
|
||||
private float lastSentOxygen;
|
||||
private int lastSentFireCount;
|
||||
|
||||
private float statusUpdateTimer;
|
||||
private float decalUpdateTimer;
|
||||
private float backgroundSectionUpdateTimer;
|
||||
|
||||
private bool decalUpdatePending;
|
||||
|
||||
@@ -33,225 +39,163 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
sendUpdateTimer -= deltaTime;
|
||||
statusUpdateTimer -= deltaTime;
|
||||
decalUpdateTimer -= deltaTime;
|
||||
backgroundSectionUpdateTimer -= deltaTime;
|
||||
|
||||
//update client hulls if the amount of water has changed by >10%
|
||||
//or if oxygen percentage has changed by 5%
|
||||
if (Math.Abs(lastSentVolume - waterVolume) > Volume * 0.1f || Math.Abs(lastSentOxygen - OxygenPercentage) > 5f ||
|
||||
lastSentFireCount != FireSources.Count || FireSources.Count > 0 ||
|
||||
pendingSectionUpdates.Count > 0 ||
|
||||
sendUpdateTimer < -NetConfig.SparseHullUpdateInterval ||
|
||||
decalUpdatePending)
|
||||
{
|
||||
if (sendUpdateTimer < 0.0f)
|
||||
{
|
||||
if (decalUpdatePending)
|
||||
{
|
||||
GameMain.NetworkMember.CreateEntityEvent(this, new object[] { false });
|
||||
}
|
||||
if (pendingSectionUpdates.Count > 0)
|
||||
{
|
||||
foreach (int pendingSectionUpdate in pendingSectionUpdates)
|
||||
{
|
||||
GameMain.NetworkMember.CreateEntityEvent(this, new object[] { true, pendingSectionUpdate } );
|
||||
}
|
||||
pendingSectionUpdates.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.NetworkMember.CreateEntityEvent(this);
|
||||
}
|
||||
bool shouldSendStatusUpdate =
|
||||
(Math.Abs(lastSentVolume - waterVolume) > Volume * 0.1f
|
||||
|| Math.Abs(lastSentOxygen - OxygenPercentage) > 5f
|
||||
|| lastSentFireCount != FireSources.Count)
|
||||
&& statusUpdateTimer <= 0.0f;
|
||||
|
||||
lastSentVolume = waterVolume;
|
||||
lastSentOxygen = OxygenPercentage;
|
||||
lastSentFireCount = FireSources.Count;
|
||||
sendUpdateTimer = NetConfig.HullUpdateInterval;
|
||||
if (shouldSendStatusUpdate)
|
||||
{
|
||||
GameMain.NetworkMember.CreateEntityEvent(this, new StatusEventData());
|
||||
|
||||
lastSentVolume = waterVolume;
|
||||
lastSentOxygen = OxygenPercentage;
|
||||
lastSentFireCount = FireSources.Count;
|
||||
|
||||
statusUpdateTimer = NetConfig.SparseHullUpdateInterval;
|
||||
}
|
||||
if (decalUpdatePending && decalUpdateTimer <= 0.0f)
|
||||
{
|
||||
GameMain.NetworkMember.CreateEntityEvent(this, new DecalEventData());
|
||||
|
||||
decalUpdateTimer = NetConfig.HullUpdateInterval;
|
||||
decalUpdatePending = false;
|
||||
}
|
||||
if (pendingSectionUpdates.Count > 0 && backgroundSectionUpdateTimer <= 0.0f)
|
||||
{
|
||||
foreach (int pendingSectionUpdate in pendingSectionUpdates)
|
||||
{
|
||||
GameMain.NetworkMember.CreateEntityEvent(this, new BackgroundSectionsEventData(pendingSectionUpdate));
|
||||
}
|
||||
|
||||
backgroundSectionUpdateTimer = NetConfig.HullUpdateInterval;
|
||||
pendingSectionUpdates.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void ServerWrite(IWriteMessage message, Client c, object[] extraData = null)
|
||||
public void ServerEventWrite(IWriteMessage msg, Client c, NetEntityEvent.IData extraData = null)
|
||||
{
|
||||
if (extraData != null && extraData.Length >= 2 && extraData[0] is BallastFloraBehavior behavior && extraData[1] is BallastFloraBehavior.NetworkHeader header)
|
||||
if (!(extraData is IEventData eventData)) { throw new Exception($"Malformed hull event: expected {nameof(Hull)}.{nameof(IEventData)}"); }
|
||||
msg.WriteRangedInteger((int)eventData.EventType, (int)EventType.MinValue, (int)EventType.MaxValue);
|
||||
|
||||
switch (eventData)
|
||||
{
|
||||
message.Write(true);
|
||||
message.Write((byte)header);
|
||||
|
||||
switch (header)
|
||||
{
|
||||
case BallastFloraBehavior.NetworkHeader.Spawn:
|
||||
behavior.ServerWriteSpawn(message);
|
||||
break;
|
||||
case BallastFloraBehavior.NetworkHeader.Kill:
|
||||
case BallastFloraBehavior.NetworkHeader.Remove:
|
||||
break;
|
||||
case BallastFloraBehavior.NetworkHeader.BranchCreate when extraData.Length >= 4 && extraData[2] is BallastFloraBranch branch && extraData[3] is int parentId:
|
||||
behavior.ServerWriteBranchGrowth(message, branch, parentId);
|
||||
break;
|
||||
case BallastFloraBehavior.NetworkHeader.BranchDamage when extraData.Length >= 4 && extraData[2] is BallastFloraBranch branch:
|
||||
behavior.ServerWriteBranchDamage(message, branch);
|
||||
break;
|
||||
case BallastFloraBehavior.NetworkHeader.BranchRemove when extraData.Length >= 3 && extraData[2] is BallastFloraBranch branch:
|
||||
behavior.ServerWriteBranchRemove(message, branch);
|
||||
break;
|
||||
case BallastFloraBehavior.NetworkHeader.Infect when extraData.Length >= 4 && extraData[2] is UInt16 itemID && extraData[3] is bool infect:
|
||||
BallastFloraBranch infector = null;
|
||||
if (extraData.Length >= 5 && extraData[4] is BallastFloraBranch b) { infector = b; }
|
||||
behavior.ServerWriteInfect(message, itemID, infect, infector);
|
||||
break;
|
||||
}
|
||||
|
||||
message.Write(behavior.PowerConsumptionTimer);
|
||||
return;
|
||||
}
|
||||
|
||||
message.Write(false); //not a ballast flora update
|
||||
message.WriteRangedSingle(MathHelper.Clamp(waterVolume / Volume, 0.0f, 1.5f), 0.0f, 1.5f, 8);
|
||||
message.WriteRangedSingle(MathHelper.Clamp(OxygenPercentage, 0.0f, 100.0f), 0.0f, 100.0f, 8);
|
||||
|
||||
message.Write(FireSources.Count > 0);
|
||||
if (FireSources.Count > 0)
|
||||
{
|
||||
message.WriteRangedInteger(Math.Min(FireSources.Count, 16), 0, 16);
|
||||
for (int i = 0; i < Math.Min(FireSources.Count, 16); i++)
|
||||
{
|
||||
var fireSource = FireSources[i];
|
||||
Vector2 normalizedPos = new Vector2(
|
||||
(fireSource.Position.X - rect.X) / rect.Width,
|
||||
(fireSource.Position.Y - (rect.Y - rect.Height)) / rect.Height);
|
||||
|
||||
message.WriteRangedSingle(MathHelper.Clamp(normalizedPos.X, 0.0f, 1.0f), 0.0f, 1.0f, 8);
|
||||
message.WriteRangedSingle(MathHelper.Clamp(normalizedPos.Y, 0.0f, 1.0f), 0.0f, 1.0f, 8);
|
||||
message.WriteRangedSingle(MathHelper.Clamp(fireSource.Size.X / rect.Width, 0.0f, 1.0f), 0, 1.0f, 8);
|
||||
}
|
||||
}
|
||||
|
||||
message.Write(extraData != null);
|
||||
if (extraData != null)
|
||||
{
|
||||
message.Write((bool)extraData[0]);
|
||||
|
||||
// Section update
|
||||
if ((bool)extraData[0])
|
||||
{
|
||||
int sectorToUpdate = (int)extraData[1];
|
||||
int start = sectorToUpdate * BackgroundSectionsPerNetworkEvent;
|
||||
int end = Math.Min((sectorToUpdate + 1) * BackgroundSectionsPerNetworkEvent, BackgroundSections.Count - 1);
|
||||
message.WriteRangedInteger(sectorToUpdate, 0, BackgroundSections.Count - 1);
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
message.WriteRangedSingle(BackgroundSections[i].ColorStrength, 0.0f, 1.0f, 8);
|
||||
message.Write(BackgroundSections[i].Color.PackedValue);
|
||||
}
|
||||
}
|
||||
else // Decal update
|
||||
{
|
||||
message.WriteRangedInteger(decals.Count, 0, MaxDecalsPerHull);
|
||||
case StatusEventData statusEventData:
|
||||
msg.WriteRangedSingle(MathHelper.Clamp(OxygenPercentage, 0.0f, 100.0f), 0.0f, 100.0f, 8);
|
||||
SharedStatusWrite(msg);
|
||||
break;
|
||||
case BackgroundSectionsEventData backgroundSectionsEventData:
|
||||
SharedBackgroundSectionsWrite(msg, backgroundSectionsEventData);
|
||||
break;
|
||||
case DecalEventData decalEventData:
|
||||
msg.WriteRangedInteger(decals.Count, 0, MaxDecalsPerHull);
|
||||
foreach (Decal decal in decals)
|
||||
{
|
||||
message.Write(decal.Prefab.UintIdentifier);
|
||||
message.Write((byte)decal.SpriteIndex);
|
||||
msg.Write(decal.Prefab.UintIdentifier);
|
||||
msg.Write((byte)decal.SpriteIndex);
|
||||
float normalizedXPos = MathHelper.Clamp(MathUtils.InverseLerp(0.0f, rect.Width, decal.CenterPosition.X), 0.0f, 1.0f);
|
||||
float normalizedYPos = MathHelper.Clamp(MathUtils.InverseLerp(-rect.Height, 0.0f, decal.CenterPosition.Y), 0.0f, 1.0f);
|
||||
message.WriteRangedSingle(normalizedXPos, 0.0f, 1.0f, 8);
|
||||
message.WriteRangedSingle(normalizedYPos, 0.0f, 1.0f, 8);
|
||||
message.WriteRangedSingle(decal.Scale, 0f, 2f, 12);
|
||||
msg.WriteRangedSingle(normalizedXPos, 0.0f, 1.0f, 8);
|
||||
msg.WriteRangedSingle(normalizedYPos, 0.0f, 1.0f, 8);
|
||||
msg.WriteRangedSingle(decal.Scale, 0f, 2f, 12);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BallastFloraEventData ballastFloraEventData:
|
||||
ballastFloraEventData.Behavior.ServerWrite(msg, ballastFloraEventData.SubEventData);
|
||||
break;
|
||||
default:
|
||||
throw new Exception($"Malformed hull event: did not expect {eventData.GetType().Name}");
|
||||
}
|
||||
}
|
||||
|
||||
//used when clients use the water/fire console commands or section / decal updates are received
|
||||
public void ServerRead(ClientNetObject type, IReadMessage msg, Client c)
|
||||
public void ServerEventRead(IReadMessage msg, Client c)
|
||||
{
|
||||
int messageType = msg.ReadRangedInteger(0, 2);
|
||||
if (messageType == 0)
|
||||
EventType eventType = (EventType)msg.ReadRangedInteger((int)EventType.MinValue, (int)EventType.MaxValue);
|
||||
switch (eventType)
|
||||
{
|
||||
float newWaterVolume = msg.ReadRangedSingle(0.0f, 1.5f, 8) * Volume;
|
||||
case EventType.Status:
|
||||
SharedStatusRead(
|
||||
msg,
|
||||
out float newWaterVolume,
|
||||
out NetworkFireSource[] newFireSources);
|
||||
|
||||
bool hasFireSources = msg.ReadBoolean();
|
||||
int fireSourceCount = 0;
|
||||
List<Vector3> newFireSources = new List<Vector3>();
|
||||
if (hasFireSources)
|
||||
{
|
||||
fireSourceCount = msg.ReadRangedInteger(0, 16);
|
||||
for (int i = 0; i < fireSourceCount; i++)
|
||||
if (!c.HasPermission(ClientPermissions.ConsoleCommands) ||
|
||||
!c.PermittedConsoleCommands.Any(command => command.names.Contains("fire") || command.names.Contains("editfire")))
|
||||
{
|
||||
newFireSources.Add(new Vector3(
|
||||
MathHelper.Clamp(msg.ReadRangedSingle(0.0f, 1.0f, 8), 0.05f, 0.95f),
|
||||
MathHelper.Clamp(msg.ReadRangedSingle(0.0f, 1.0f, 8), 0.05f, 0.95f),
|
||||
msg.ReadRangedSingle(0.0f, 1.0f, 8)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!c.HasPermission(ClientPermissions.ConsoleCommands) ||
|
||||
!c.PermittedConsoleCommands.Any(command => command.names.Contains("fire") || command.names.Contains("editfire")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
WaterVolume = newWaterVolume;
|
||||
|
||||
WaterVolume = newWaterVolume;
|
||||
|
||||
for (int i = 0; i < fireSourceCount; i++)
|
||||
{
|
||||
Vector2 pos = new Vector2(
|
||||
rect.X + rect.Width * newFireSources[i].X,
|
||||
rect.Y - rect.Height + (rect.Height * newFireSources[i].Y));
|
||||
float size = newFireSources[i].Z * rect.Width;
|
||||
|
||||
var newFire = i < FireSources.Count ?
|
||||
FireSources[i] :
|
||||
new FireSource(Submarine == null ? pos : pos + Submarine.Position, null, true);
|
||||
newFire.Position = pos;
|
||||
newFire.Size = new Vector2(size, newFire.Size.Y);
|
||||
|
||||
//ignore if the fire wasn't added to this room (invalid position)?
|
||||
if (!FireSources.Contains(newFire))
|
||||
for (int i = 0; i < newFireSources.Length; i++)
|
||||
{
|
||||
newFire.Remove();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Vector2 pos = newFireSources[i].Position;
|
||||
float size = newFireSources[i].Size;
|
||||
|
||||
for (int i = FireSources.Count - 1; i >= fireSourceCount; i--)
|
||||
{
|
||||
FireSources[i].Remove();
|
||||
if (i < FireSources.Count)
|
||||
var newFire = i < FireSources.Count ?
|
||||
FireSources[i] :
|
||||
new FireSource(Submarine == null ? pos : pos + Submarine.Position, null, true);
|
||||
newFire.Position = pos;
|
||||
newFire.Size = new Vector2(size, newFire.Size.Y);
|
||||
|
||||
//ignore if the fire wasn't added to this room (invalid position)?
|
||||
if (!FireSources.Contains(newFire))
|
||||
{
|
||||
newFire.Remove();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = FireSources.Count - 1; i >= newFireSources.Length; i--)
|
||||
{
|
||||
FireSources.RemoveAt(i);
|
||||
FireSources[i].Remove();
|
||||
if (i < FireSources.Count)
|
||||
{
|
||||
FireSources.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (messageType == 1)
|
||||
{
|
||||
byte decalIndex = msg.ReadByte();
|
||||
float decalAlpha = msg.ReadRangedSingle(0.0f, 1.0f, 255);
|
||||
if (decalIndex < 0 || decalIndex >= decals.Count) { return; }
|
||||
if (c.Character != null && c.Character.AllowInput && c.Character.HeldItems.Any(it => it.GetComponent<Sprayer>() != null))
|
||||
{
|
||||
decals[decalIndex].BaseAlpha = decalAlpha;
|
||||
}
|
||||
decalUpdatePending = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int sectorToUpdate = msg.ReadRangedInteger(0, BackgroundSections.Count - 1);
|
||||
int start = sectorToUpdate * BackgroundSectionsPerNetworkEvent;
|
||||
int end = Math.Min((sectorToUpdate + 1) * BackgroundSectionsPerNetworkEvent, BackgroundSections.Count - 1);
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
float colorStrength = msg.ReadRangedSingle(0.0f, 1.0f, 8);
|
||||
Color color = new Color(msg.ReadUInt32());
|
||||
break;
|
||||
case EventType.BackgroundSections:
|
||||
SharedBackgroundSectionRead(
|
||||
msg,
|
||||
bsnu =>
|
||||
{
|
||||
int i = bsnu.SectionIndex;
|
||||
Color color = bsnu.Color;
|
||||
float colorStrength = bsnu.ColorStrength;
|
||||
|
||||
//TODO: verify the client is close enough to this hull to paint it, that the sprayer is functional and that the color matches
|
||||
#warning TODO: verify the client is close enough to this hull to paint it, that the sprayer is functional and that the color matches
|
||||
if (!(c.Character is { AllowInput: true })) { return; }
|
||||
if (c.Character.HeldItems.All(it => it.GetComponent<Sprayer>() == null)) { return; }
|
||||
|
||||
BackgroundSections[i].SetColorStrength(colorStrength);
|
||||
BackgroundSections[i].SetColor(color);
|
||||
},
|
||||
out int sectorToUpdate);
|
||||
//add to pending updates to notify other clients as well
|
||||
pendingSectionUpdates.Add(sectorToUpdate);
|
||||
break;
|
||||
case EventType.Decal:
|
||||
byte decalIndex = msg.ReadByte();
|
||||
float decalAlpha = msg.ReadRangedSingle(0.0f, 1.0f, 255);
|
||||
if (decalIndex < 0 || decalIndex >= decals.Count) { return; }
|
||||
if (c.Character != null && c.Character.AllowInput && c.Character.HeldItems.Any(it => it.GetComponent<Sprayer>() != null))
|
||||
{
|
||||
BackgroundSections[i].SetColorStrength(colorStrength);
|
||||
BackgroundSections[i].SetColor(color);
|
||||
decals[decalIndex].BaseAlpha = decalAlpha;
|
||||
}
|
||||
}
|
||||
//add to pending updates to notify other clients as well
|
||||
pendingSectionUpdates.Add(sectorToUpdate);
|
||||
}
|
||||
decalUpdatePending = true;
|
||||
break;
|
||||
default:
|
||||
throw new Exception($"Malformed incoming hull event: {eventType} is not a supported event type");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Barotrauma
|
||||
GameMain.Server.KarmaManager.OnStructureHealthChanged(this, attacker, damageAmount);
|
||||
}
|
||||
|
||||
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
|
||||
public void ServerEventWrite(IWriteMessage msg, Client c, NetEntityEvent.IData extraData = null)
|
||||
{
|
||||
msg.Write((byte)Sections.Length);
|
||||
for (int i = 0; i < Sections.Length; i++)
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
using Barotrauma.Networking;
|
||||
using System;
|
||||
using Barotrauma.Networking;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class Submarine
|
||||
{
|
||||
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
|
||||
public void ServerWritePosition(IWriteMessage msg, Client c)
|
||||
{
|
||||
msg.Write(ID);
|
||||
IWriteMessage tempBuffer = new WriteOnlyMessage();
|
||||
subBody.Body.ServerWrite(tempBuffer, c, extraData);
|
||||
subBody.Body.ServerWrite(tempBuffer);
|
||||
msg.Write((byte)tempBuffer.LengthBytes);
|
||||
msg.Write(tempBuffer.Buffer, 0, tempBuffer.LengthBytes);
|
||||
msg.WritePadBits();
|
||||
}
|
||||
|
||||
public void ServerEventWrite(IWriteMessage msg, Client c, NetEntityEvent.IData extraData = null)
|
||||
{
|
||||
throw new Exception($"Error while writing a network event for the submarine \"{Info.Name} ({ID})\". Submarines are not even supposed to send events!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user