(bcb06cc5c) Unstable v0.9.9.0
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using Barotrauma.Networking;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
partial class LightComponent : Powered, IServerSerializable
|
||||
{
|
||||
private CoroutineHandle sendStateCoroutine;
|
||||
private bool lastSentState;
|
||||
private float sendStateTimer;
|
||||
|
||||
partial void OnStateChanged()
|
||||
{
|
||||
sendStateTimer = 0.5f;
|
||||
if (sendStateCoroutine == null)
|
||||
{
|
||||
sendStateCoroutine = CoroutineManager.StartCoroutine(SendStateAfterDelay());
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<object> SendStateAfterDelay()
|
||||
{
|
||||
while (sendStateTimer > 0.0f)
|
||||
{
|
||||
sendStateTimer -= CoroutineManager.DeltaTime;
|
||||
yield return CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
if (item.Removed || GameMain.NetworkMember == null)
|
||||
{
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
sendStateCoroutine = null;
|
||||
if (lastSentState != IsActive) { item.CreateServerEvent(this); }
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
|
||||
{
|
||||
msg.Write(IsActive);
|
||||
lastSentState = IsActive;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
|
||||
{
|
||||
msg.Write((byte)State);
|
||||
msg.Write(timeUntilReady);
|
||||
int itemIndex = fabricatedItem == null ? -1 : fabricationRecipes.IndexOf(fabricatedItem);
|
||||
msg.WriteRangedInteger(itemIndex, -1, fabricationRecipes.Count - 1);
|
||||
UInt16 userID = fabricatedItem == null || user == null ? (UInt16)0 : user.ID;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
using Barotrauma.Networking;
|
||||
using System;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
partial class Projectile : ItemComponent
|
||||
{
|
||||
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
|
||||
{
|
||||
msg.Write(StickTarget != null);
|
||||
if (StickTarget != null)
|
||||
{
|
||||
msg.Write(item.body.SimPosition.X);
|
||||
msg.Write(item.body.SimPosition.Y);
|
||||
msg.Write(stickJoint.Axis.X);
|
||||
msg.Write(stickJoint.Axis.Y);
|
||||
if (StickTarget.UserData is Structure structure)
|
||||
{
|
||||
msg.Write(structure.ID);
|
||||
msg.Write((byte)structure.Bodies.IndexOf(StickTarget));
|
||||
}
|
||||
else if (StickTarget.UserData is Entity entity)
|
||||
{
|
||||
msg.Write(entity.ID);
|
||||
}
|
||||
else if (StickTarget.UserData is Limb limb)
|
||||
{
|
||||
msg.Write(limb.character.ID);
|
||||
msg.Write((byte)Array.IndexOf(limb.character.AnimController.Limbs, limb));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException(StickTarget.UserData?.ToString() ?? "null" + " is not a valid projectile stick target.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void ServerRead(ClientNetObject type, IReadMessage msg, Client c)
|
||||
{
|
||||
if (c.Character == null) return;
|
||||
if (c.Character == null) { return; }
|
||||
var requestedFixAction = (FixActions)msg.ReadRangedInteger(0, 2);
|
||||
if (requestedFixAction != FixActions.None)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using Barotrauma.Networking;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
partial class Rope : ItemComponent
|
||||
{
|
||||
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
|
||||
{
|
||||
msg.Write(Snapped);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,9 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (!CheckCharacterSuccess(c.Character))
|
||||
{
|
||||
item.CreateServerEvent(this);
|
||||
c.Character.SelectedItems[0]?.GetComponent<Wire>()?.CreateNetworkEvent();
|
||||
c.Character.SelectedItems[1]?.GetComponent<Wire>()?.CreateNetworkEvent();
|
||||
GameMain.Server?.CreateEntityEvent(item, new object[] { NetEntityEvent.Type.ApplyStatusEffect, ActionType.OnFailure, this, c.Character.ID });
|
||||
return;
|
||||
}
|
||||
|
||||
+19
-3
@@ -10,9 +10,17 @@ namespace Barotrauma.Items.Components
|
||||
public void ServerRead(ClientNetObject type, IReadMessage msg, Client c)
|
||||
{
|
||||
bool[] elementStates = new bool[customInterfaceElementList.Count];
|
||||
string[] elementValues = new string[customInterfaceElementList.Count];
|
||||
for (int i = 0; i < customInterfaceElementList.Count; i++)
|
||||
{
|
||||
elementStates[i] = msg.ReadBoolean();
|
||||
if (!string.IsNullOrEmpty(customInterfaceElementList[i].PropertyName))
|
||||
{
|
||||
elementValues[i] = msg.ReadString();
|
||||
}
|
||||
else
|
||||
{
|
||||
elementStates[i] = msg.ReadBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
CustomInterfaceElement clickedButton = null;
|
||||
@@ -20,7 +28,11 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
for (int i = 0; i < customInterfaceElementList.Count; i++)
|
||||
{
|
||||
if (customInterfaceElementList[i].ContinuousSignal)
|
||||
if (!string.IsNullOrEmpty(customInterfaceElementList[i].PropertyName))
|
||||
{
|
||||
TextChanged(customInterfaceElementList[i], elementValues[i]);
|
||||
}
|
||||
else if (customInterfaceElementList[i].ContinuousSignal)
|
||||
{
|
||||
TickBoxToggled(customInterfaceElementList[i], elementStates[i]);
|
||||
}
|
||||
@@ -48,7 +60,11 @@ namespace Barotrauma.Items.Components
|
||||
//extradata contains an array of buttons clicked by a client (or nothing if nothing was clicked)
|
||||
for (int i = 0; i < customInterfaceElementList.Count; i++)
|
||||
{
|
||||
if (customInterfaceElementList[i].ContinuousSignal)
|
||||
if (!string.IsNullOrEmpty(customInterfaceElementList[i].PropertyName))
|
||||
{
|
||||
msg.Write(customInterfaceElementList[i].Signal);
|
||||
}
|
||||
else if(customInterfaceElementList[i].ContinuousSignal)
|
||||
{
|
||||
msg.Write(customInterfaceElementList[i].State);
|
||||
}
|
||||
|
||||
@@ -17,9 +17,10 @@ namespace Barotrauma.Items.Components
|
||||
GameServer.Log(c.Character.LogName + " entered \"" + newOutputValue + "\" on " + item.Name,
|
||||
ServerLog.MessageType.ItemInteraction);
|
||||
OutputValue = newOutputValue;
|
||||
item.SendSignal(0, newOutputValue, "signal_out", null);
|
||||
item.CreateServerEvent(this);
|
||||
}
|
||||
|
||||
item.CreateServerEvent(this);
|
||||
}
|
||||
|
||||
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
partial class Wire : ItemComponent, IDrawableComponent, IServerSerializable
|
||||
{
|
||||
private void CreateNetworkEvent()
|
||||
public void CreateNetworkEvent()
|
||||
{
|
||||
if (GameMain.Server == null) return;
|
||||
//split into multiple events because one might not be enough to fit all the nodes
|
||||
|
||||
Reference in New Issue
Block a user