Unstable 0.17.1.0
This commit is contained in:
@@ -30,7 +30,7 @@ namespace Barotrauma
|
||||
|
||||
private float serverUpdateDelay;
|
||||
private float remoteWaterVolume, remoteOxygenPercentage;
|
||||
private List<Vector3> remoteFireSources;
|
||||
private NetworkFireSource[] remoteFireSources = null;
|
||||
private readonly List<BackgroundSection> remoteBackgroundSections = new List<BackgroundSection>();
|
||||
private readonly List<RemoteDecal> remoteDecals = new List<RemoteDecal>();
|
||||
|
||||
@@ -175,15 +175,16 @@ namespace Barotrauma
|
||||
{
|
||||
if (!pendingSectionUpdates.Any() && !pendingDecalUpdates.Any())
|
||||
{
|
||||
GameMain.NetworkMember?.CreateEntityEvent(this);
|
||||
GameMain.NetworkMember?.CreateEntityEvent(this, new StatusEventData());
|
||||
}
|
||||
foreach (Decal decal in pendingDecalUpdates)
|
||||
{
|
||||
GameMain.NetworkMember?.CreateEntityEvent(this, new object[] { decal });
|
||||
GameMain.NetworkMember?.CreateEntityEvent(this, new DecalEventData(decal));
|
||||
}
|
||||
pendingDecalUpdates.Clear();
|
||||
foreach (int pendingSectionUpdate in pendingSectionUpdates)
|
||||
{
|
||||
GameMain.NetworkMember?.CreateEntityEvent(this, new object[] { pendingSectionUpdate });
|
||||
GameMain.NetworkMember?.CreateEntityEvent(this, new BackgroundSectionsEventData(pendingSectionUpdate));
|
||||
}
|
||||
pendingSectionUpdates.Clear();
|
||||
networkUpdatePending = false;
|
||||
@@ -595,132 +596,101 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
|
||||
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
|
||||
{
|
||||
if (extraData == null)
|
||||
{
|
||||
msg.WriteRangedInteger(0, 0, 2);
|
||||
msg.WriteRangedSingle(MathHelper.Clamp(waterVolume / Volume, 0.0f, 1.5f), 0.0f, 1.5f, 8);
|
||||
if (!(extraData is IEventData eventData)) { throw new Exception($"Malformed hull event: expected {nameof(Hull)}.{nameof(IEventData)}"); }
|
||||
|
||||
msg.Write(FireSources.Count > 0);
|
||||
if (FireSources.Count > 0)
|
||||
{
|
||||
msg.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);
|
||||
|
||||
msg.WriteRangedSingle(MathHelper.Clamp(normalizedPos.X, 0.0f, 1.0f), 0.0f, 1.0f, 8);
|
||||
msg.WriteRangedSingle(MathHelper.Clamp(normalizedPos.Y, 0.0f, 1.0f), 0.0f, 1.0f, 8);
|
||||
msg.WriteRangedSingle(MathHelper.Clamp(fireSource.Size.X / rect.Width, 0.0f, 1.0f), 0, 1.0f, 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (extraData[0] is Decal decal)
|
||||
msg.WriteRangedInteger((int)eventData.EventType, (int)EventType.MinValue, (int)EventType.MaxValue);
|
||||
switch (eventData)
|
||||
{
|
||||
msg.WriteRangedInteger(1, 0, 2);
|
||||
int decalIndex = decals.IndexOf(decal);
|
||||
msg.Write((byte)(decalIndex < 0 ? 255 : decalIndex));
|
||||
msg.WriteRangedSingle(decal.BaseAlpha, 0.0f, 1.0f, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.WriteRangedInteger(2, 0, 2);
|
||||
int sectorToUpdate = (int)extraData[0];
|
||||
int start = sectorToUpdate * BackgroundSectionsPerNetworkEvent;
|
||||
int end = Math.Min((sectorToUpdate + 1) * BackgroundSectionsPerNetworkEvent, BackgroundSections.Count - 1);
|
||||
msg.WriteRangedInteger(sectorToUpdate, 0, BackgroundSections.Count - 1);
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
msg.WriteRangedSingle(BackgroundSections[i].ColorStrength, 0.0f, 1.0f, 8);
|
||||
msg.Write(BackgroundSections[i].Color.PackedValue);
|
||||
}
|
||||
case StatusEventData statusEventData:
|
||||
SharedStatusWrite(msg);
|
||||
break;
|
||||
case BackgroundSectionsEventData backgroundSectionsEventData:
|
||||
SharedBackgroundSectionsWrite(msg, backgroundSectionsEventData);
|
||||
break;
|
||||
case DecalEventData decalEventData:
|
||||
var decal = decalEventData.Decal;
|
||||
int decalIndex = decals.IndexOf(decal);
|
||||
msg.Write((byte)(decalIndex < 0 ? 255 : decalIndex));
|
||||
msg.WriteRangedSingle(decal.BaseAlpha, 0.0f, 1.0f, 8);
|
||||
break;
|
||||
default:
|
||||
throw new Exception($"Malformed hull event: did not expect {eventData.GetType().Name}");
|
||||
}
|
||||
}
|
||||
|
||||
public void ClientRead(ServerNetObject type, IReadMessage message, float sendingTime)
|
||||
public void ClientEventRead(IReadMessage msg, float sendingTime)
|
||||
{
|
||||
bool isBallastFloraUpdate = message.ReadBoolean();
|
||||
if (isBallastFloraUpdate)
|
||||
EventType eventType = (EventType)msg.ReadRangedInteger((int)EventType.MinValue, (int)EventType.MaxValue);
|
||||
switch (eventType)
|
||||
{
|
||||
BallastFloraBehavior.NetworkHeader header = (BallastFloraBehavior.NetworkHeader) message.ReadByte();
|
||||
if (header == BallastFloraBehavior.NetworkHeader.Spawn)
|
||||
{
|
||||
Identifier identifier = message.ReadIdentifier();
|
||||
float x = message.ReadSingle();
|
||||
float y = message.ReadSingle();
|
||||
BallastFlora = new BallastFloraBehavior(this, BallastFloraPrefab.Find(identifier), new Vector2(x, y), firstGrowth: true)
|
||||
{
|
||||
PowerConsumptionTimer = message.ReadSingle()
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
BallastFlora?.ClientRead(message, header);
|
||||
}
|
||||
return;
|
||||
}
|
||||
remoteWaterVolume = message.ReadRangedSingle(0.0f, 1.5f, 8) * Volume;
|
||||
remoteOxygenPercentage = message.ReadRangedSingle(0.0f, 100.0f, 8);
|
||||
|
||||
bool hasFireSources = message.ReadBoolean();
|
||||
remoteFireSources = new List<Vector3>();
|
||||
if (hasFireSources)
|
||||
{
|
||||
int fireSourceCount = message.ReadRangedInteger(0, 16);
|
||||
for (int i = 0; i < fireSourceCount; i++)
|
||||
{
|
||||
remoteFireSources.Add(new Vector3(
|
||||
MathHelper.Clamp(message.ReadRangedSingle(0.0f, 1.0f, 8), 0.05f, 0.95f),
|
||||
MathHelper.Clamp(message.ReadRangedSingle(0.0f, 1.0f, 8), 0.05f, 0.95f),
|
||||
message.ReadRangedSingle(0.0f, 1.0f, 8)));
|
||||
}
|
||||
}
|
||||
|
||||
bool hasExtraData = message.ReadBoolean();
|
||||
if (hasExtraData)
|
||||
{
|
||||
bool hasSectionUpdate = message.ReadBoolean();
|
||||
if (hasSectionUpdate)
|
||||
{
|
||||
int sectorToUpdate = message.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 = message.ReadRangedSingle(0.0f, 1.0f, 8);
|
||||
Color color = new Color(message.ReadUInt32());
|
||||
var remoteBackgroundSection = remoteBackgroundSections.Find(s => s.Index == i);
|
||||
if (remoteBackgroundSection != null)
|
||||
case EventType.Status:
|
||||
remoteOxygenPercentage = msg.ReadRangedSingle(0.0f, 100.0f, 8);
|
||||
|
||||
SharedStatusRead(
|
||||
msg,
|
||||
out float newWaterVolume,
|
||||
out NetworkFireSource[] newFireSources);
|
||||
|
||||
remoteWaterVolume = newWaterVolume;
|
||||
remoteFireSources = newFireSources;
|
||||
break;
|
||||
case EventType.BackgroundSections:
|
||||
SharedBackgroundSectionRead(
|
||||
msg,
|
||||
bsnu =>
|
||||
{
|
||||
remoteBackgroundSection.SetColorStrength(colorStrength);
|
||||
remoteBackgroundSection.SetColor(color);
|
||||
}
|
||||
else
|
||||
{
|
||||
remoteBackgroundSections.Add(new BackgroundSection(new Rectangle(0, 0, 1, 1), (ushort)i, colorStrength, color, 0));
|
||||
}
|
||||
}
|
||||
int i = bsnu.SectionIndex;
|
||||
Color color = bsnu.Color;
|
||||
float colorStrength = bsnu.ColorStrength;
|
||||
|
||||
var remoteBackgroundSection = remoteBackgroundSections.Find(s => s.Index == i);
|
||||
if (remoteBackgroundSection != null)
|
||||
{
|
||||
remoteBackgroundSection.SetColorStrength(colorStrength);
|
||||
remoteBackgroundSection.SetColor(color);
|
||||
}
|
||||
else
|
||||
{
|
||||
remoteBackgroundSections.Add(new BackgroundSection(new Rectangle(0, 0, 1, 1), (ushort)i, colorStrength, color, 0));
|
||||
}
|
||||
}, out _);
|
||||
paintAmount = BackgroundSections.Sum(s => s.ColorStrength);
|
||||
}
|
||||
else
|
||||
{
|
||||
int decalCount = message.ReadRangedInteger(0, MaxDecalsPerHull);
|
||||
break;
|
||||
case EventType.Decal:
|
||||
int decalCount = msg.ReadRangedInteger(0, MaxDecalsPerHull);
|
||||
if (decalCount == 0) { decals.Clear(); }
|
||||
remoteDecals.Clear();
|
||||
for (int i = 0; i < decalCount; i++)
|
||||
{
|
||||
UInt32 decalId = message.ReadUInt32();
|
||||
int spriteIndex = message.ReadByte();
|
||||
float normalizedXPos = message.ReadRangedSingle(0.0f, 1.0f, 8);
|
||||
float normalizedYPos = message.ReadRangedSingle(0.0f, 1.0f, 8);
|
||||
float decalScale = message.ReadRangedSingle(0.0f, 2.0f, 12);
|
||||
UInt32 decalId = msg.ReadUInt32();
|
||||
int spriteIndex = msg.ReadByte();
|
||||
float normalizedXPos = msg.ReadRangedSingle(0.0f, 1.0f, 8);
|
||||
float normalizedYPos = msg.ReadRangedSingle(0.0f, 1.0f, 8);
|
||||
float decalScale = msg.ReadRangedSingle(0.0f, 2.0f, 12);
|
||||
remoteDecals.Add(new RemoteDecal(decalId, spriteIndex, new Vector2(normalizedXPos, normalizedYPos), decalScale));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EventType.BallastFlora:
|
||||
BallastFloraBehavior.NetworkHeader header = (BallastFloraBehavior.NetworkHeader) msg.ReadByte();
|
||||
if (header == BallastFloraBehavior.NetworkHeader.Spawn)
|
||||
{
|
||||
Identifier identifier = msg.ReadIdentifier();
|
||||
float x = msg.ReadSingle();
|
||||
float y = msg.ReadSingle();
|
||||
BallastFlora = new BallastFloraBehavior(this, BallastFloraPrefab.Find(identifier), new Vector2(x, y), firstGrowth: true)
|
||||
{
|
||||
PowerConsumptionTimer = msg.ReadSingle()
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
BallastFlora?.ClientRead(msg, header);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Exception($"Malformed incoming hull event: {eventType} is not a supported event type");
|
||||
}
|
||||
|
||||
if (serverUpdateDelay > 0.0f) { return; }
|
||||
@@ -756,17 +726,15 @@ namespace Barotrauma
|
||||
remoteDecals.Clear();
|
||||
}
|
||||
|
||||
if (remoteFireSources == null) { return; }
|
||||
|
||||
if (remoteFireSources is null) { return; }
|
||||
|
||||
WaterVolume = remoteWaterVolume;
|
||||
OxygenPercentage = remoteOxygenPercentage;
|
||||
|
||||
for (int i = 0; i < remoteFireSources.Count; i++)
|
||||
for (int i = 0; i < remoteFireSources.Length; i++)
|
||||
{
|
||||
Vector2 pos = new Vector2(
|
||||
rect.X + rect.Width * remoteFireSources[i].X,
|
||||
rect.Y - rect.Height + (rect.Height * remoteFireSources[i].Y));
|
||||
float size = remoteFireSources[i].Z * rect.Width;
|
||||
Vector2 pos = remoteFireSources[i].Position;
|
||||
float size = remoteFireSources[i].Size;
|
||||
|
||||
var newFire = i < FireSources.Count ?
|
||||
FireSources[i] :
|
||||
@@ -782,7 +750,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = FireSources.Count - 1; i >= remoteFireSources.Count; i--)
|
||||
for (int i = FireSources.Count - 1; i >= remoteFireSources.Length; i--)
|
||||
{
|
||||
FireSources[i].Remove();
|
||||
if (i < FireSources.Count)
|
||||
|
||||
@@ -121,34 +121,42 @@ namespace Barotrauma
|
||||
{
|
||||
renderer?.DrawForeground(spriteBatch, cam, LevelObjectManager);
|
||||
}
|
||||
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
|
||||
public void ClientEventRead(IReadMessage msg, float sendingTime)
|
||||
{
|
||||
bool isGlobalUpdate = msg.ReadBoolean();
|
||||
if (isGlobalUpdate)
|
||||
EventType eventType = (EventType)msg.ReadByte();
|
||||
|
||||
switch (eventType)
|
||||
{
|
||||
foreach (LevelWall levelWall in ExtraWalls)
|
||||
case EventType.GlobalDestructibleWall:
|
||||
{
|
||||
if (levelWall.Body.BodyType == BodyType.Static) { continue; }
|
||||
|
||||
Vector2 bodyPos = new Vector2(
|
||||
msg.ReadSingle(),
|
||||
msg.ReadSingle());
|
||||
levelWall.MoveState = msg.ReadRangedSingle(0.0f, MathHelper.TwoPi, 16);
|
||||
DestructibleLevelWall destructibleWall = levelWall as DestructibleLevelWall;
|
||||
if (Vector2.DistanceSquared(bodyPos, levelWall.Body.Position) > 0.5f && (destructibleWall == null || !destructibleWall.Destroyed))
|
||||
foreach (LevelWall levelWall in ExtraWalls)
|
||||
{
|
||||
levelWall.Body.SetTransformIgnoreContacts(ref bodyPos, levelWall.Body.Rotation);
|
||||
if (levelWall.Body.BodyType == BodyType.Static) { continue; }
|
||||
|
||||
Vector2 bodyPos = new Vector2(
|
||||
msg.ReadSingle(),
|
||||
msg.ReadSingle());
|
||||
levelWall.MoveState = msg.ReadRangedSingle(0.0f, MathHelper.TwoPi, 16);
|
||||
if (Vector2.DistanceSquared(bodyPos, levelWall.Body.Position) > 0.5f
|
||||
&& !(levelWall is DestructibleLevelWall { Destroyed: true }))
|
||||
{
|
||||
levelWall.Body.SetTransformIgnoreContacts(ref bodyPos, levelWall.Body.Rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int index = msg.ReadUInt16();
|
||||
byte damageByte = msg.ReadByte();
|
||||
if (index < ExtraWalls.Count && ExtraWalls[index] is DestructibleLevelWall destructibleWall)
|
||||
break;
|
||||
case EventType.SingleDestructibleWall:
|
||||
{
|
||||
destructibleWall.SetDamage(destructibleWall.MaxHealth * damageByte / 255.0f);
|
||||
int index = msg.ReadUInt16();
|
||||
float damageByte = msg.ReadByte();
|
||||
if (index < ExtraWalls.Count && ExtraWalls[index] is DestructibleLevelWall destructibleWall)
|
||||
{
|
||||
destructibleWall.SetDamage(destructibleWall.MaxHealth * damageByte / 255.0f);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Exception($"Malformed incoming level event: {eventType} is not a supported event type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -229,7 +229,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
|
||||
public void ClientEventRead(IReadMessage msg, float sendingTime)
|
||||
{
|
||||
int objIndex = msg.ReadRangedInteger(0, objects.Count);
|
||||
objects[objIndex].ClientRead(msg);
|
||||
|
||||
@@ -106,7 +106,8 @@ namespace Barotrauma
|
||||
WaterEffect.Parameters["xBlurDistance"].SetValue(BlurAmount / 100.0f);
|
||||
}
|
||||
else
|
||||
{ WaterEffect.CurrentTechnique = WaterEffect.Techniques["WaterShader"];
|
||||
{
|
||||
WaterEffect.CurrentTechnique = WaterEffect.Techniques["WaterShader"];
|
||||
}
|
||||
|
||||
Vector2 offset = WavePos;
|
||||
|
||||
@@ -188,8 +188,10 @@ namespace Barotrauma.Lights
|
||||
if (light.ParentBody != null)
|
||||
{
|
||||
light.ParentBody.UpdateDrawPosition();
|
||||
light.Position = light.ParentBody.DrawPosition;
|
||||
if (light.ParentSub != null) { light.Position -= light.ParentSub.DrawPosition; }
|
||||
|
||||
Vector2 pos = light.ParentBody.DrawPosition;
|
||||
if (light.ParentSub != null) { pos -= light.ParentSub.DrawPosition; }
|
||||
light.Position = pos;
|
||||
}
|
||||
|
||||
float range = light.LightSourceParams.TextureRange;
|
||||
|
||||
@@ -70,6 +70,8 @@ namespace Barotrauma
|
||||
|
||||
private (SubmarineInfo pendingSub, float realWorldCrushDepth) pendingSubInfo;
|
||||
|
||||
private RichString beaconStationActiveText, beaconStationInactiveText;
|
||||
|
||||
/*private (Rectangle targetArea, string tip)? connectionTooltip;
|
||||
private string sanitizedConnectionTooltip;
|
||||
private List<RichTextData> connectionTooltipRichTextData;
|
||||
@@ -153,6 +155,9 @@ namespace Barotrauma
|
||||
DebugConsole.ThrowError($"Could not find campaign map sprites for the biome \"{missingBiome.Identifier}\". Using the sprites of the first biome instead...");
|
||||
}
|
||||
|
||||
beaconStationActiveText = RichString.Rich(TextManager.Get("BeaconStationActiveTooltip"));
|
||||
beaconStationInactiveText = RichString.Rich(TextManager.Get("BeaconStationInactiveTooltip"));
|
||||
|
||||
RemoveFogOfWar(StartLocation);
|
||||
|
||||
GenerateLocationConnectionVisuals();
|
||||
@@ -619,7 +624,7 @@ namespace Barotrauma
|
||||
if (Vector2.Distance(PlayerInput.MousePosition, typeChangeIconPos) < generationParams.TypeChangeIcon.SourceRect.Width * zoom &&
|
||||
(tooltip == null || IsPreferredTooltip(typeChangeIconPos)))
|
||||
{
|
||||
tooltip = (new Rectangle(typeChangeIconPos.ToPoint(), new Point(30)), location.LastTypeChangeMessage);
|
||||
tooltip = (new Rectangle(typeChangeIconPos.ToPoint(), new Point(30)), RichString.Rich(location.LastTypeChangeMessage));
|
||||
}
|
||||
}
|
||||
if (location != CurrentLocation && generationParams.MissionIcon != null)
|
||||
@@ -920,7 +925,7 @@ namespace Barotrauma
|
||||
if (connection.LevelData.HasBeaconStation)
|
||||
{
|
||||
var beaconStationIconStyle = connection.LevelData.IsBeaconActive ? "BeaconStationActive" : "BeaconStationInactive";
|
||||
DrawIcon(beaconStationIconStyle, (int)(28 * zoom), TextManager.Get(connection.LevelData.IsBeaconActive ? "BeaconStationActiveTooltip" : "BeaconStationInactiveTooltip"));
|
||||
DrawIcon(beaconStationIconStyle, (int)(28 * zoom), connection.LevelData.IsBeaconActive ? beaconStationActiveText : beaconStationInactiveText);
|
||||
}
|
||||
|
||||
if (connection.Locked)
|
||||
@@ -942,9 +947,9 @@ namespace Barotrauma
|
||||
|
||||
DrawIcon(
|
||||
"LockedLocationConnection", (int)(28 * zoom),
|
||||
TextManager.GetWithVariables(unlockEvent.UnlockPathTooltip ?? "LockedPathTooltip",
|
||||
RichString.Rich(TextManager.GetWithVariables(unlockEvent.UnlockPathTooltip ?? "LockedPathTooltip",
|
||||
("[requiredreputation]", Reputation.GetFormattedReputationText(MathUtils.InverseLerp(unlockReputation.MinReputation, unlockReputation.MaxReputation, unlockEvent.UnlockPathReputation), unlockEvent.UnlockPathReputation, addColorTags: true)),
|
||||
("[currentreputation]", unlockReputation.GetFormattedReputationText(addColorTags: true))));
|
||||
("[currentreputation]", unlockReputation.GetFormattedReputationText(addColorTags: true)))));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -955,7 +960,7 @@ namespace Barotrauma
|
||||
|
||||
if (connection.LevelData.HasHuntingGrounds)
|
||||
{
|
||||
DrawIcon("HuntingGrounds", (int)(28 * zoom), TextManager.Get("HuntingGroundsTooltip"));
|
||||
DrawIcon("HuntingGrounds", (int)(28 * zoom), RichString.Rich(TextManager.Get("HuntingGroundsTooltip")));
|
||||
}
|
||||
|
||||
if (crushDepthWarningIconStyle != null)
|
||||
@@ -976,7 +981,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
void DrawIcon(string iconStyle, int iconSize, LocalizedString tooltipText)
|
||||
void DrawIcon(string iconStyle, int iconSize, RichString tooltipText)
|
||||
{
|
||||
Vector2 iconPos = (connectionStart.Value + connectionEnd.Value) / 2;
|
||||
Vector2 iconDiff = Vector2.Normalize(connectionEnd.Value - connectionStart.Value) * iconSize;
|
||||
|
||||
@@ -526,22 +526,17 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
|
||||
public void ClientEventRead(IReadMessage msg, float sendingTime)
|
||||
{
|
||||
byte sectionCount = msg.ReadByte();
|
||||
|
||||
bool invalidMessage = false;
|
||||
if (type != ServerNetObject.ENTITY_EVENT && type != ServerNetObject.ENTITY_EVENT_INITIAL)
|
||||
{
|
||||
DebugConsole.NewMessage($"Error while reading a network event for the structure \"{Name} ({ID})\". Invalid event type ({type}).", Color.Red);
|
||||
return;
|
||||
}
|
||||
else if (sectionCount != Sections.Length)
|
||||
if (sectionCount != Sections.Length)
|
||||
{
|
||||
invalidMessage = true;
|
||||
string errorMsg = $"Error while reading a network event for the structure \"{Name} ({ID})\". Section count does not match (server: {sectionCount} client: {Sections.Length})";
|
||||
DebugConsole.NewMessage(errorMsg, Color.Red);
|
||||
GameAnalyticsManager.AddErrorEventOnce("Structure.ClientRead:SectionCountMismatch", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
|
||||
throw new Exception(errorMsg);
|
||||
}
|
||||
|
||||
for (int i = 0; i < sectionCount; i++)
|
||||
|
||||
@@ -15,7 +15,7 @@ using Barotrauma.Items.Components;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class Submarine : Entity, IServerSerializable
|
||||
partial class Submarine : Entity, IServerPositionSync
|
||||
{
|
||||
public static Vector2 MouseToWorldGrid(Camera cam, Submarine sub)
|
||||
{
|
||||
@@ -547,19 +547,50 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
int disabledItemLightCount = 0;
|
||||
foreach (Item item in Item.ItemList)
|
||||
float entityCountWarningThreshold = 0.75f;
|
||||
|
||||
if (Item.ItemList.Count > SubEditorScreen.MaxItems * entityCountWarningThreshold)
|
||||
{
|
||||
if (item.ParentInventory == null) { continue; }
|
||||
disabledItemLightCount += item.GetComponents<Items.Components.LightComponent>().Count();
|
||||
if (!IsWarningSuppressed(SubEditorScreen.WarningType.ItemCount))
|
||||
{
|
||||
errorMsgs.Add(TextManager.Get("subeditor.itemcountwarning").Value);
|
||||
warnings.Add(SubEditorScreen.WarningType.ItemCount);
|
||||
}
|
||||
}
|
||||
int count = GameMain.LightManager.Lights.Count(l => l.CastShadows) - disabledItemLightCount;
|
||||
if (count > 45)
|
||||
|
||||
if ((MapEntity.mapEntityList.Count - Item.ItemList.Count - Hull.HullList.Count - WayPoint.WayPointList.Count - Gap.GapList.Count) > SubEditorScreen.MaxStructures * entityCountWarningThreshold)
|
||||
{
|
||||
if (!IsWarningSuppressed(SubEditorScreen.WarningType.TooManyLights))
|
||||
if (!IsWarningSuppressed(SubEditorScreen.WarningType.StructureCount))
|
||||
{
|
||||
errorMsgs.Add(TextManager.Get("subeditor.structurecountwarning").Value);
|
||||
warnings.Add(SubEditorScreen.WarningType.StructureCount);
|
||||
}
|
||||
}
|
||||
|
||||
if (Structure.WallList.Count > SubEditorScreen.MaxStructures * entityCountWarningThreshold)
|
||||
{
|
||||
if (!IsWarningSuppressed(SubEditorScreen.WarningType.WallCount))
|
||||
{
|
||||
errorMsgs.Add(TextManager.Get("subeditor.wallcountwarning").Value);
|
||||
warnings.Add(SubEditorScreen.WarningType.WallCount);
|
||||
}
|
||||
}
|
||||
|
||||
if (GetLightCount() > SubEditorScreen.MaxLights * entityCountWarningThreshold)
|
||||
{
|
||||
if (!IsWarningSuppressed(SubEditorScreen.WarningType.LightCount))
|
||||
{
|
||||
errorMsgs.Add(TextManager.Get("subeditor.lightcountwarning").Value);
|
||||
warnings.Add(SubEditorScreen.WarningType.LightCount);
|
||||
}
|
||||
}
|
||||
|
||||
if (GetShadowCastingLightCount() > SubEditorScreen.MaxShadowCastingLights * entityCountWarningThreshold)
|
||||
{
|
||||
if (!IsWarningSuppressed(SubEditorScreen.WarningType.ShadowCastingLightCount))
|
||||
{
|
||||
errorMsgs.Add(TextManager.Get("subeditor.shadowcastinglightswarning").Value);
|
||||
warnings.Add(SubEditorScreen.WarningType.TooManyLights);
|
||||
warnings.Add(SubEditorScreen.WarningType.ShadowCastingLightCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -627,14 +658,31 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
|
||||
public static int GetLightCount()
|
||||
{
|
||||
if (type != ServerNetObject.ENTITY_POSITION)
|
||||
int disabledItemLightCount = 0;
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
DebugConsole.NewMessage($"Error while reading a network event for the submarine \"{Info.Name} ({ID})\". Invalid event type ({type}).", Color.Red);
|
||||
if (item.ParentInventory == null) { continue; }
|
||||
disabledItemLightCount += item.GetComponents<Items.Components.LightComponent>().Count();
|
||||
}
|
||||
return GameMain.LightManager.Lights.Count() - disabledItemLightCount;
|
||||
}
|
||||
|
||||
var posInfo = PhysicsBody.ClientRead(type, msg, sendingTime, parentDebugName: Info.Name);
|
||||
public static int GetShadowCastingLightCount()
|
||||
{
|
||||
int disabledItemLightCount = 0;
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
if (item.ParentInventory == null) { continue; }
|
||||
disabledItemLightCount += item.GetComponents<Items.Components.LightComponent>().Count();
|
||||
}
|
||||
return GameMain.LightManager.Lights.Count(l => l.CastShadows) - disabledItemLightCount;
|
||||
}
|
||||
|
||||
public void ClientReadPosition(IReadMessage msg, float sendingTime)
|
||||
{
|
||||
var posInfo = PhysicsBody.ClientRead(msg, sendingTime, parentDebugName: Info.Name);
|
||||
msg.ReadPadBits();
|
||||
|
||||
if (posInfo != null)
|
||||
@@ -648,5 +696,10 @@ namespace Barotrauma
|
||||
subBody.PositionBuffer.Insert(index, posInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClientEventRead(IReadMessage msg, float sendingTime)
|
||||
{
|
||||
throw new Exception($"Error while reading a network event for the submarine \"{Info.Name} ({ID})\". Submarines are not even supposed to receive events!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user