(f0d812055) v0.9.9.0
This commit is contained in:
@@ -30,7 +30,7 @@ namespace Barotrauma.Items.Components
|
||||
AttachToWall();
|
||||
|
||||
item.CreateServerEvent(this);
|
||||
GameServer.Log(c.Character.LogName + " attached " + item.Name + " to a wall", ServerLog.MessageType.ItemInteraction);
|
||||
GameServer.Log(GameServer.CharacterLogName(c.Character) + " attached " + item.Name + " to a wall", ServerLog.MessageType.ItemInteraction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (Math.Abs(newTargetForce - targetForce) > 0.01f)
|
||||
{
|
||||
GameServer.Log(c.Character.LogName + " set the force of " + item.Name + " to " + (int)(newTargetForce) + " %", ServerLog.MessageType.ItemInteraction);
|
||||
GameServer.Log(GameServer.CharacterLogName(c.Character) + " set the force of " + item.Name + " to " + (int)(newTargetForce) + " %", ServerLog.MessageType.ItemInteraction);
|
||||
}
|
||||
|
||||
targetForce = newTargetForce;
|
||||
|
||||
@@ -17,11 +17,11 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (newFlowPercentage != FlowPercentage)
|
||||
{
|
||||
GameServer.Log(c.Character.LogName + " set the pumping speed of " + item.Name + " to " + (int)(newFlowPercentage) + " %", ServerLog.MessageType.ItemInteraction);
|
||||
GameServer.Log(GameServer.CharacterLogName(c.Character) + " set the pumping speed of " + item.Name + " to " + (int)(newFlowPercentage) + " %", ServerLog.MessageType.ItemInteraction);
|
||||
}
|
||||
if (newIsActive != IsActive)
|
||||
{
|
||||
GameServer.Log(c.Character.LogName + (newIsActive ? " turned on " : " turned off ") + item.Name, ServerLog.MessageType.ItemInteraction);
|
||||
GameServer.Log(GameServer.CharacterLogName(c.Character) + (newIsActive ? " turned on " : " turned off ") + item.Name, ServerLog.MessageType.ItemInteraction);
|
||||
}
|
||||
|
||||
FlowPercentage = newFlowPercentage;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Barotrauma.Items.Components
|
||||
if (item.CanClientAccess(c))
|
||||
{
|
||||
RechargeSpeed = newRechargeSpeed;
|
||||
GameServer.Log(c.Character.LogName + " set the recharge speed of " + item.Name + " to " + (int)((rechargeSpeed / maxRechargeSpeed) * 100.0f) + " %", ServerLog.MessageType.ItemInteraction);
|
||||
GameServer.Log(GameServer.CharacterLogName(c.Character) + " set the recharge speed of " + item.Name + " to " + (int)((rechargeSpeed / maxRechargeSpeed) * 100.0f) + " %", ServerLog.MessageType.ItemInteraction);
|
||||
}
|
||||
|
||||
item.CreateServerEvent(this);
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
using Barotrauma.Networking;
|
||||
using System;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
partial class Projectile : ItemComponent
|
||||
{
|
||||
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
|
||||
{
|
||||
bool stuck = StickTarget != null && !item.Removed && !StickTargetRemoved();
|
||||
msg.Write(stuck);
|
||||
if (stuck)
|
||||
{
|
||||
msg.Write(item.Submarine?.ID ?? Entity.NullEntityID);
|
||||
msg.Write(item.CurrentHull?.ID ?? Entity.NullEntityID);
|
||||
msg.Write(item.SimPosition.X);
|
||||
msg.Write(item.SimPosition.Y);
|
||||
msg.Write(stickJoint.Axis.X);
|
||||
msg.Write(stickJoint.Axis.Y);
|
||||
if (StickTarget.UserData is Structure structure)
|
||||
{
|
||||
msg.Write(structure.ID);
|
||||
int bodyIndex = structure.Bodies.IndexOf(StickTarget);
|
||||
msg.Write((byte)(bodyIndex == -1 ? 0 : bodyIndex));
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-7
@@ -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;
|
||||
}
|
||||
@@ -85,7 +88,7 @@ namespace Barotrauma.Items.Components
|
||||
if (existingWire.Locked)
|
||||
{
|
||||
//this should not be possible unless the client is running a modified version of the game
|
||||
GameServer.Log(c.Character.LogName + " attempted to disconnect a locked wire from " +
|
||||
GameServer.Log(GameServer.CharacterLogName(c.Character) + " attempted to disconnect a locked wire from " +
|
||||
Connections[i].Item.Name + " (" + Connections[i].Name + ")", ServerLog.MessageType.Error);
|
||||
continue;
|
||||
}
|
||||
@@ -103,7 +106,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (existingWire.Connections[0] == null && existingWire.Connections[1] == null)
|
||||
{
|
||||
GameServer.Log(c.Character.LogName + " disconnected a wire from " +
|
||||
GameServer.Log(GameServer.CharacterLogName(c.Character) + " disconnected a wire from " +
|
||||
Connections[i].Item.Name + " (" + Connections[i].Name + ")", ServerLog.MessageType.Wiring);
|
||||
|
||||
if (existingWire.Item.ParentInventory != null)
|
||||
@@ -119,7 +122,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
else if (existingWire.Connections[0] != null)
|
||||
{
|
||||
GameServer.Log(c.Character.LogName + " disconnected a wire from " +
|
||||
GameServer.Log(GameServer.CharacterLogName(c.Character) + " disconnected a wire from " +
|
||||
Connections[i].Item.Name + " (" + Connections[i].Name + ") to " + existingWire.Connections[0].Item.Name + " (" + existingWire.Connections[0].Name + ")", ServerLog.MessageType.Wiring);
|
||||
|
||||
//wires that are not in anyone's inventory (i.e. not currently being rewired)
|
||||
@@ -134,7 +137,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
else if (existingWire.Connections[1] != null)
|
||||
{
|
||||
GameServer.Log(c.Character.LogName + " disconnected a wire from " +
|
||||
GameServer.Log(GameServer.CharacterLogName(c.Character) + " disconnected a wire from " +
|
||||
Connections[i].Item.Name + " (" + Connections[i].Name + ") to " + existingWire.Connections[1].Item.Name + " (" + existingWire.Connections[1].Name + ")", ServerLog.MessageType.Wiring);
|
||||
|
||||
/*if (existingWire.Item.ParentInventory == null && !wires.Any(w => w.Contains(existingWire)))
|
||||
@@ -158,7 +161,7 @@ namespace Barotrauma.Items.Components
|
||||
disconnectedWire.Item.ParentInventory == null)
|
||||
{
|
||||
disconnectedWire.Item.Drop(c.Character);
|
||||
GameServer.Log(c.Character.LogName + " dropped " + disconnectedWire.Name, ServerLog.MessageType.Inventory);
|
||||
GameServer.Log(GameServer.CharacterLogName(c.Character) + " dropped " + disconnectedWire.Name, ServerLog.MessageType.Inventory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,13 +180,13 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (otherConnection == null)
|
||||
{
|
||||
GameServer.Log(c.Character.LogName + " connected a wire to " +
|
||||
GameServer.Log(GameServer.CharacterLogName(c.Character) + " connected a wire to " +
|
||||
Connections[i].Item.Name + " (" + Connections[i].Name + ")",
|
||||
ServerLog.MessageType.Wiring);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameServer.Log(c.Character.LogName + " connected a wire from " +
|
||||
GameServer.Log(GameServer.CharacterLogName(c.Character) + " connected a wire from " +
|
||||
Connections[i].Item.Name + " (" + Connections[i].Name + ") to " +
|
||||
(otherConnection == null ? "none" : otherConnection.Item.Name + " (" + (otherConnection.Name) + ")"),
|
||||
ServerLog.MessageType.Wiring);
|
||||
|
||||
+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);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
newOutputValue = newOutputValue.Substring(0, MaxMessageLength);
|
||||
}
|
||||
GameServer.Log(c.Character.LogName + " entered \"" + newOutputValue + "\" on " + item.Name,
|
||||
GameServer.Log(GameServer.CharacterLogName(c.Character) + " entered \"" + newOutputValue + "\" on " + item.Name,
|
||||
ServerLog.MessageType.ItemInteraction);
|
||||
OutputValue = newOutputValue;
|
||||
item.SendSignal(0, newOutputValue, "signal_out", 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