v0.11.0.9

This commit is contained in:
Joonas Rikkonen
2020-12-09 16:34:16 +02:00
parent bbf06f0984
commit f433a7ba10
325 changed files with 13947 additions and 3652 deletions
@@ -31,6 +31,7 @@ namespace Barotrauma.Items.Components
msg.Write(isBroken);
msg.Write(extraData.Length == 3 ? (bool)extraData[2] : false); //forced open
msg.Write(isStuck);
msg.Write(isJammed);
msg.WriteRangedSingle(stuck, 0.0f, 100.0f, 8);
msg.Write(lastUser == null ? (UInt16)0 : lastUser.ID);
}
@@ -25,7 +25,7 @@ namespace Barotrauma.Items.Components
}
if (pumpSpeedLockTimer <= 0.0f)
{
targetLevel = null;
TargetLevel = null;
}
FlowPercentage = newFlowPercentage;
@@ -41,6 +41,16 @@ namespace Barotrauma.Items.Components
//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);
msg.Write(Hijacked);
if (TargetLevel != null)
{
msg.Write(true);
msg.Write(TargetLevel.Value);
}
else
{
msg.Write(false);
}
}
}
}
@@ -5,8 +5,20 @@ namespace Barotrauma.Items.Components
{
partial class Projectile : ItemComponent
{
private float launchRot;
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
{
bool launch = extraData.Length > 2 && (bool)extraData[2];
msg.Write(launch);
if (launch)
{
msg.Write(User.ID);
msg.Write(launchPos.X);
msg.Write(launchPos.Y);
msg.Write(launchRot);
}
bool stuck = StickTarget != null && !item.Removed && !StickTargetRemoved();
msg.Write(stuck);
if (stuck)
@@ -1,4 +1,6 @@
using Barotrauma.Networking;
using System.Collections.Generic;
using System.Linq;
namespace Barotrauma.Items.Components
{
@@ -17,15 +19,70 @@ namespace Barotrauma.Items.Components
GameServer.Log(GameServer.CharacterLogName(c.Character) + " entered \"" + newOutputValue + "\" on " + item.Name,
ServerLog.MessageType.ItemInteraction);
OutputValue = newOutputValue;
ShowOnDisplay(newOutputValue);
item.SendSignal(0, newOutputValue, "signal_out", null);
item.CreateServerEvent(this);
}
}
partial void ShowOnDisplay(string input)
{
messageHistory.Add(input);
while (messageHistory.Count > MaxMessages)
{
messageHistory.RemoveAt(0);
}
}
public void SyncHistory()
{
//split too long messages to multiple parts
foreach (string str in messageHistory)
{
string msgToSend = str;
if (msgToSend.Length > MaxMessageLength)
{
List<string> splitMessage = msgToSend.Split(' ').ToList();
for (int i = 0; i < splitMessage.Count; i++)
{
if (splitMessage[i].Length > MaxMessageLength)
{
string temp = splitMessage[i];
splitMessage[i] = temp.Substring(0, MaxMessageLength);
splitMessage.Insert(i + 1, temp.Substring(MaxMessageLength, temp.Length - MaxMessageLength));
}
}
while (msgToSend.Length > MaxMessageLength)
{
string tempMsg = "";
do
{
tempMsg += splitMessage[0];
splitMessage.RemoveAt(0);
if (!splitMessage.Any()) { break; }
tempMsg += " ";
} while (tempMsg.Length + splitMessage[0].Length < MaxMessageLength);
item.CreateServerEvent(this, new string[] { msgToSend });
msgToSend = msgToSend.Remove(0, tempMsg.Length);
}
}
if (!string.IsNullOrEmpty(msgToSend))
{
item.CreateServerEvent(this, new string[] { msgToSend });
}
}
}
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
{
msg.Write(OutputValue);
if (extraData.Length > 2 && extraData[2] is string str)
{
msg.Write(str);
}
else
{
msg.Write(OutputValue);
}
}
}
}