Unstable 0.17.1.0

This commit is contained in:
Markus Isberg
2022-03-17 01:25:04 +09:00
parent 3974067915
commit 6d410cc1b7
302 changed files with 5878 additions and 3317 deletions
@@ -283,9 +283,9 @@ namespace Barotrauma.Items.Components
}
}
public override void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public override void ClientEventRead(IReadMessage msg, float sendingTime)
{
base.ClientRead(type, msg, sendingTime);
base.ClientEventRead(msg, sendingTime);
bool open = msg.ReadBoolean();
bool broken = msg.ReadBoolean();
@@ -54,7 +54,7 @@ namespace Barotrauma.Items.Components
}
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
CurrPowerConsumption = powerConsumption;
charging = true;
@@ -68,7 +68,7 @@ namespace Barotrauma.Items.Components
}
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
Tainted = msg.ReadBoolean();
if (Tainted)
@@ -156,7 +156,7 @@ namespace Barotrauma.Items.Components
private readonly object mutex = new object();
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
Health = msg.ReadRangedSingle(0, MaxHealth, 8);
int startOffset = msg.ReadRangedInteger(-1, MaximumVines);
@@ -2,6 +2,7 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Diagnostics.Tracing;
namespace Barotrauma.Items.Components
{
@@ -58,18 +59,23 @@ namespace Barotrauma.Items.Components
GUI.DrawRectangle(spriteBatch, new Vector2(attachPos.X - 2, -attachPos.Y - 2), Vector2.One * 5, GUIStyle.Red, thickness: 3);
}
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
public override bool ValidateEventData(NetEntityEvent.IData data)
=> TryExtractEventData<EventData>(data, out _);
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
{
if (!attachable || body == null) { return; }
var eventData = ExtractEventData<EventData>(extraData);
Vector2 attachPos = (Vector2)extraData[2];
Vector2 attachPos = eventData.AttachPos;
msg.Write(attachPos.X);
msg.Write(attachPos.Y);
}
public override void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public override void ClientEventRead(IReadMessage msg, float sendingTime)
{
base.ClientRead(type, msg, sendingTime);
base.ClientEventRead(msg, sendingTime);
bool readAttachData = msg.ReadBoolean();
if (!readAttachData) { return; }
@@ -96,7 +96,7 @@ namespace Barotrauma.Items.Components
ContentXElement getElementFromList(List<ContentXElement> list, int index)
=> CharacterInfo.IsValidIndex(index, list)
? list[index]
: characterInfo.GetRandomElement(list);
: null;
var disguisedHairElement = getElementFromList(disguisedHairs, disguisedHairIndex);
var disguisedBeardElement = getElementFromList(disguisedBeards, disguisedBeardIndex);
@@ -566,14 +566,14 @@ namespace Barotrauma.Items.Components
protected virtual void CreateGUI() { }
//Starts a coroutine that will read the correct state of the component from the NetBuffer when correctionTimer reaches zero.
protected void StartDelayedCorrection(ServerNetObject type, IReadMessage buffer, float sendingTime, bool waitForMidRoundSync = false)
protected void StartDelayedCorrection(IReadMessage buffer, float sendingTime, bool waitForMidRoundSync = false)
{
if (delayedCorrectionCoroutine != null) CoroutineManager.StopCoroutines(delayedCorrectionCoroutine);
if (delayedCorrectionCoroutine != null) { CoroutineManager.StopCoroutines(delayedCorrectionCoroutine); }
delayedCorrectionCoroutine = CoroutineManager.StartCoroutine(DoDelayedCorrection(type, buffer, sendingTime, waitForMidRoundSync));
delayedCorrectionCoroutine = CoroutineManager.StartCoroutine(DoDelayedCorrection(buffer, sendingTime, waitForMidRoundSync));
}
private IEnumerable<CoroutineStatus> DoDelayedCorrection(ServerNetObject type, IReadMessage buffer, float sendingTime, bool waitForMidRoundSync)
private IEnumerable<CoroutineStatus> DoDelayedCorrection(IReadMessage buffer, float sendingTime, bool waitForMidRoundSync)
{
while (GameMain.Client != null &&
(correctionTimer > 0.0f || (waitForMidRoundSync && GameMain.Client.MidRoundSyncing)))
@@ -587,7 +587,7 @@ namespace Barotrauma.Items.Components
yield return CoroutineStatus.Success;
}
((IServerSerializable)this).ClientRead(type, buffer, sendingTime);
((IServerSerializable)this).ClientEventRead(buffer, sendingTime);
correctionTimer = 0.0f;
delayedCorrectionCoroutine = null;
@@ -282,7 +282,7 @@ namespace Barotrauma.Items.Components
textBlock.DrawManually(spriteBatch);
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
Text = msg.ReadString();
}
@@ -4,7 +4,7 @@ namespace Barotrauma.Items.Components
{
partial class LevelResource : ItemComponent, IServerSerializable
{
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
deattachTimer = msg.ReadSingle();
if (deattachTimer >= DeattachDuration)
@@ -56,8 +56,9 @@ namespace Barotrauma.Items.Components
}
else
{
Light.Position = item.DrawPosition;
if (item.Submarine != null) { Light.Position -= item.Submarine.DrawPosition; }
Vector2 pos = item.DrawPosition;
if (item.Submarine != null) { pos -= item.Submarine.DrawPosition; }
Light.Position = pos;
}
PhysicsBody body = Light.ParentBody;
if (body != null)
@@ -120,7 +121,7 @@ namespace Barotrauma.Items.Components
yield return CoroutineStatus.Success;
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
IsActive = msg.ReadBoolean();
lastReceivedState = IsActive;
@@ -80,7 +80,7 @@ namespace Barotrauma.Items.Components
}
#endif
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
State = msg.ReadBoolean();
ushort userID = msg.ReadUInt16();
@@ -251,12 +251,12 @@ namespace Barotrauma.Items.Components
return true;
}
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
{
msg.Write(pendingState);
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
ushort userID = msg.ReadUInt16();
Character user = userID == Entity.NullEntityID ? null : Entity.FindEntityByID(userID) as Character;
@@ -156,17 +156,17 @@ namespace Barotrauma.Items.Components
}
}
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
{
//targetForce can only be adjusted at 10% intervals -> no need for more accuracy than this
msg.WriteRangedInteger((int)(targetForce / 10.0f), -10, 10);
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
if (correctionTimer > 0.0f)
{
StartDelayedCorrection(type, msg.ExtractBits(5 + 16), sendingTime);
StartDelayedCorrection(msg.ExtractBits(5 + 16), sendingTime);
return;
}
@@ -705,13 +705,13 @@ namespace Barotrauma.Items.Components
requiredTimeBlock.Text = ToolBox.SecondsToReadableTime(timeUntilReady > 0.0f ? timeUntilReady : requiredTime);
}
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
{
uint recipeHash = pendingFabricatedItem?.RecipeHash ?? 0;
msg.Write(recipeHash);
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
FabricatorState newState = (FabricatorState)msg.ReadByte();
float newTimeUntilReady = msg.ReadSingle();
@@ -216,14 +216,14 @@ namespace Barotrauma.Items.Components
}
}
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
{
//flowpercentage can only be adjusted at 10% intervals -> no need for more accuracy than this
msg.WriteRangedInteger((int)(flowPercentage / 10.0f), -10, 10);
msg.Write(IsActive);
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
int msgStartPos = msg.BitPosition;
@@ -244,7 +244,7 @@ namespace Barotrauma.Items.Components
{
int msgLength = msg.BitPosition - msgStartPos;
msg.BitPosition = msgStartPos;
StartDelayedCorrection(type, msg.ExtractBits(msgLength), sendingTime);
StartDelayedCorrection(msg.ExtractBits(msgLength), sendingTime);
return;
}
@@ -608,9 +608,10 @@ namespace Barotrauma.Items.Components
Vector2 pointerPos = pos - new Vector2(0, 30) * scale;
float scaleMultiplier = 0.95f;
if (optimalRangeNormalized.X == optimalRangeNormalized.Y)
{
sectorSprite.Draw(spriteBatch, pointerPos, GUIStyle.Red, MathHelper.PiOver2, scale);
sectorSprite.Draw(spriteBatch, pointerPos, GUIStyle.Red, MathHelper.PiOver2, scale * scaleMultiplier);
}
else
{
@@ -619,7 +620,6 @@ namespace Barotrauma.Items.Components
spriteBatch.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, GameMain.GraphicsWidth, (int)(pointerPos.Y + (meterSprite.size.Y - meterSprite.Origin.Y) * scale) - 3);
spriteBatch.Begin(SpriteSortMode.Deferred, rasterizerState: GameMain.ScissorTestEnable);
float scaleMultiplier = 0.95f;
sectorSprite.Draw(spriteBatch, pointerPos, optimalRangeColor, MathHelper.PiOver2 + (allowedSectorRad.X + allowedSectorRad.Y) / 2.0f, scale * scaleMultiplier);
sectorSprite.Draw(spriteBatch, pointerPos, offRangeColor, optimalSectorRad.X, scale * scaleMultiplier);
sectorSprite.Draw(spriteBatch, pointerPos, warningColor, allowedSectorRad.X, scale * scaleMultiplier);
@@ -711,7 +711,7 @@ namespace Barotrauma.Items.Components
tempRangeIndicator?.Remove();
}
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
{
msg.Write(autoTemp);
msg.Write(PowerOn);
@@ -721,11 +721,11 @@ namespace Barotrauma.Items.Components
correctionTimer = CorrectionDelay;
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
if (correctionTimer > 0.0f)
{
StartDelayedCorrection(type, msg.ExtractBits(1 + 1 + 8 + 8 + 8 + 8), sendingTime);
StartDelayedCorrection(msg.ExtractBits(1 + 1 + 8 + 8 + 8 + 8), sendingTime);
return;
}
@@ -766,7 +766,7 @@ namespace Barotrauma.Items.Components
if (activePingsCount == 0) { disruptedDirections.Clear(); }
foreach (AITarget t in AITarget.List)
{
if (t.Entity is Character c && c.Params.HideInSonar) { continue; }
if (t.Entity is Character c && !c.IsUnconscious && c.Params.HideInSonar) { continue; }
if (t.SoundRange <= 0.0f || float.IsNaN(t.SoundRange) || float.IsInfinity(t.SoundRange)) { continue; }
float distSqr = Vector2.DistanceSquared(t.WorldPosition, transducerCenter);
@@ -1264,7 +1264,7 @@ namespace Barotrauma.Items.Components
}
foreach (AITarget aiTarget in AITarget.List)
{
float disruption = aiTarget.Entity is Character c ? c.Params.SonarDisruption : aiTarget.SonarDisruption;
float disruption = aiTarget.Entity is Character c && !c.IsUnconscious ? c.Params.SonarDisruption : aiTarget.SonarDisruption;
if (disruption <= 0.0f || aiTarget.InDetectable) { continue; }
float distSqr = Vector2.DistanceSquared(aiTarget.WorldPosition, pingSource);
if (distSqr > worldPingRadiusSqr) { continue; }
@@ -1413,7 +1413,7 @@ namespace Barotrauma.Items.Components
foreach (Character c in Character.CharacterList)
{
if (c.AnimController.CurrentHull != null || !c.Enabled) { continue; }
if (c.Params.HideInSonar) { continue; }
if (!c.IsUnconscious && c.Params.HideInSonar) { continue; }
if (DetectSubmarineWalls && c.AnimController.CurrentHull == null && item.CurrentHull != null) { continue; }
if (c.AnimController.SimplePhysicsEnabled)
@@ -1742,7 +1742,7 @@ namespace Barotrauma.Items.Components
MineralClusters = null;
}
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
{
msg.Write(currentMode == Mode.Active);
if (currentMode == Mode.Active)
@@ -1758,7 +1758,7 @@ namespace Barotrauma.Items.Components
}
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
int msgStartPos = msg.BitPosition;
@@ -1782,7 +1782,7 @@ namespace Barotrauma.Items.Components
{
int msgLength = msg.BitPosition - msgStartPos;
msg.BitPosition = msgStartPos;
StartDelayedCorrection(type, msg.ExtractBits(msgLength), sendingTime);
StartDelayedCorrection(msg.ExtractBits(msgLength), sendingTime);
return;
}
@@ -822,7 +822,7 @@ namespace Barotrauma.Items.Components
Connection dockingConnection = item.Connections?.FirstOrDefault(c => c.Name == "toggle_docking");
if (dockingConnection != null)
{
connectedPorts = item.GetConnectedComponentsRecursive<DockingPort>(dockingConnection, ignoreInactiveRelays: true);
connectedPorts = item.GetConnectedComponentsRecursive<DockingPort>(dockingConnection, ignoreInactiveRelays: true, allowTraversingBackwards: false);
}
checkConnectedPortsTimer = CheckConnectedPortsInterval;
}
@@ -894,7 +894,7 @@ namespace Barotrauma.Items.Components
pathFinder = null;
}
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
{
msg.Write(AutoPilot);
msg.Write(dockingNetworkMessagePending);
@@ -921,7 +921,7 @@ namespace Barotrauma.Items.Components
}
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
int msgStartPos = msg.BitPosition;
@@ -962,7 +962,7 @@ namespace Barotrauma.Items.Components
{
int msgLength = (int)(msg.BitPosition - msgStartPos);
msg.BitPosition = msgStartPos;
StartDelayedCorrection(type, msg.ExtractBits(msgLength), sendingTime);
StartDelayedCorrection(msg.ExtractBits(msgLength), sendingTime);
return;
}
@@ -163,16 +163,16 @@ namespace Barotrauma.Items.Components
indicatorSize * item.Scale, Color.Black, depth: item.SpriteDepth - 0.000015f);
}
public void ClientWrite(IWriteMessage msg, object[] extraData)
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData)
{
msg.WriteRangedInteger((int)(rechargeSpeed / MaxRechargeSpeed * 10), 0, 10);
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
if (correctionTimer > 0.0f)
{
StartDelayedCorrection(type, msg.ExtractBits(4 + 8), sendingTime);
StartDelayedCorrection(msg.ExtractBits(4 + 8), sendingTime);
return;
}
@@ -13,7 +13,7 @@ namespace Barotrauma.Items.Components
{
private readonly List<ParticleEmitter> particleEmitters = new List<ParticleEmitter>();
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
bool launch = msg.ReadBoolean();
if (launch)
@@ -427,7 +427,7 @@ namespace Barotrauma.Items.Components
item.CreateClientEvent(this);
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
deteriorationTimer = msg.ReadSingle();
deteriorateAlwaysResetTimer = msg.ReadSingle();
@@ -446,7 +446,7 @@ namespace Barotrauma.Items.Components
}
}
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
{
msg.WriteRangedInteger((int)requestStartFixAction, 0, 2);
msg.Write(qteSuccess);
@@ -196,7 +196,7 @@ namespace Barotrauma.Items.Components
}
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
snapped = msg.ReadBoolean();
@@ -16,7 +16,7 @@ namespace Barotrauma.Items.Components
}
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
bool wasScanCompletedPreviously = IsScanCompleted;
scanTimer = msg.ReadSingle();
@@ -76,13 +76,14 @@ namespace Barotrauma.Items.Components
UserData = i,
OnClicked = (button, userData) =>
{
int signalIndex = (int)userData;
if (GameMain.IsSingleplayer)
{
SendSignal((int)userData, Character.Controlled);
SendSignal(signalIndex, Character.Controlled);
}
else
{
item.CreateClientEvent(this, new object[] { userData });
item.CreateClientEvent(this, new EventData(signalIndex));
}
return true;
}
@@ -104,12 +105,12 @@ namespace Barotrauma.Items.Components
Container.Inventory.RectTransform = containerHolder.RectTransform;
}
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
{
Write(msg, extraData);
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
SendSignal(msg.ReadRangedInteger(0, Signals.Length - 1), sender: null, isServerMessage: true);
}
@@ -139,7 +139,7 @@ namespace Barotrauma.Items.Components
}
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
if (GameMain.Client.MidRoundSyncing)
{
@@ -161,7 +161,7 @@ namespace Barotrauma.Items.Components
}
int msgLength = (int)(msg.BitPosition - msgStartPos);
msg.BitPosition = (int)msgStartPos;
StartDelayedCorrection(type, msg.ExtractBits(msgLength), sendingTime, waitForMidRoundSync: true);
StartDelayedCorrection(msg.ExtractBits(msgLength), sendingTime, waitForMidRoundSync: true);
}
else
{
@@ -137,13 +137,14 @@ namespace Barotrauma.Items.Components
};
btn.OnClicked += (_, userdata) =>
{
CustomInterfaceElement btnElement = userdata as CustomInterfaceElement;;
if (GameMain.Client == null)
{
ButtonClicked(userdata as CustomInterfaceElement);
ButtonClicked(btnElement);
}
else
{
GameMain.Client.CreateEntityEvent(item, new object[] { NetEntityEvent.Type.ComponentState, item.GetComponentIndex(this), userdata as CustomInterfaceElement });
item.CreateClientEvent(this, new EventData(btnElement));
}
return true;
};
@@ -301,7 +302,7 @@ namespace Barotrauma.Items.Components
}
}
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
{
//extradata contains an array of buttons clicked by the player (or nothing if the player didn't click anything)
for (int i = 0; i < customInterfaceElementList.Count; i++)
@@ -323,12 +324,12 @@ namespace Barotrauma.Items.Components
}
else
{
msg.Write(extraData != null && extraData.Any(d => d as CustomInterfaceElement == customInterfaceElementList[i]));
msg.Write(extraData is Item.ComponentStateEventData { ComponentData: EventData eventData } && eventData.BtnElement == customInterfaceElementList[i]);
}
}
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
for (int i = 0; i < customInterfaceElementList.Count; i++)
{
@@ -4,7 +4,7 @@ namespace Barotrauma.Items.Components
{
partial class MemoryComponent : ItemComponent
{
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
Value = msg.ReadString();
}
@@ -7,6 +7,16 @@ namespace Barotrauma.Items.Components
{
partial class Terminal : ItemComponent, IClientSerializable, IServerSerializable
{
private readonly struct ClientEventData : IEventData
{
public readonly string Text;
public ClientEventData(string text)
{
Text = text;
}
}
private GUIListBox historyBox;
private GUITextBlock fillerBlock;
private GUITextBox inputBox;
@@ -42,7 +52,7 @@ namespace Barotrauma.Items.Components
}
else
{
item.CreateClientEvent(this, new object[] { text });
item.CreateClientEvent(this, new ClientEventData(text));
}
textBox.Text = string.Empty;
return true;
@@ -133,17 +143,15 @@ namespace Barotrauma.Items.Components
}
}
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
{
if (extraData is null) { return; }
if (extraData[2] is string str)
if (TryExtractEventData(extraData, out ClientEventData eventData))
{
msg.Write(str);
msg.Write(eventData.Text);
}
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
SendOutput(msg.ReadString());
}
@@ -21,7 +21,7 @@ namespace Barotrauma.Items.Components
ShapeExtensions.DrawCircle(spriteBatch, pos, range, 32, Color.Cyan * 0.5f, 3);
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
Channel = msg.ReadRangedInteger(MinChannel, MaxChannel);
}
@@ -11,6 +11,16 @@ namespace Barotrauma.Items.Components
{
partial class Wire : ItemComponent, IDrawableComponent, IServerSerializable, IClientSerializable
{
private readonly struct ClientEventData : IEventData
{
public readonly int NodeCount;
public ClientEventData(int nodeCount)
{
NodeCount = nodeCount;
}
}
public static Color higlightColor = Color.LightGreen;
public static Color editorHighlightColor = Color.Yellow;
public static Color editorSelectedColor = Color.Red;
@@ -555,7 +565,7 @@ namespace Barotrauma.Items.Components
return false;
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
int eventIndex = msg.ReadRangedInteger(0, (int)Math.Ceiling(MaxNodeCount / (float)MaxNodesPerNetworkEvent));
int nodeCount = msg.ReadRangedInteger(0, MaxNodesPerNetworkEvent);
@@ -586,9 +596,13 @@ namespace Barotrauma.Items.Components
(item.ParentInventory is CharacterInventory characterInventory && ((characterInventory.Owner as Character)?.HasEquippedItem(item) ?? false));
}
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
public override bool ValidateEventData(NetEntityEvent.IData data)
=> TryExtractEventData<ClientEventData>(data, out _);
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
{
int nodeCount = (int)extraData[2];
var eventData = ExtractEventData<ClientEventData>(extraData);
int nodeCount = eventData.NodeCount;
msg.Write((byte)nodeCount);
if (nodeCount > 0)
{
@@ -4,7 +4,7 @@ namespace Barotrauma.Items.Components
{
partial class TriggerComponent : ItemComponent, IServerSerializable
{
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
CurrentForceFluctuation = msg.ReadRangedSingle(0.0f, 1.0f, 8);
}
@@ -44,7 +44,9 @@ namespace Barotrauma.Items.Components
private readonly Dictionary<string, Widget> widgets = new Dictionary<string, Widget>();
private float prevAngle;
private float currentBarrelSpin = 0f;
private bool flashLowPower;
private bool flashNoAmmo, flashLoaderBroken;
private float flashTimer;
@@ -716,7 +718,7 @@ namespace Barotrauma.Items.Components
}
}
public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
public void ClientEventRead(IReadMessage msg, float sendingTime)
{
UInt16 projectileID = msg.ReadUInt16();
float newTargetRotation = msg.ReadRangedSingle(minRotation, maxRotation, 16);