v0.10.5.1

This commit is contained in:
Juan Pablo Arce
2020-09-22 11:31:56 -03:00
parent 44032d0ae0
commit 0002ad2c50
343 changed files with 12276 additions and 5023 deletions
@@ -0,0 +1,22 @@
using Barotrauma.Networking;
using System;
namespace Barotrauma.Items.Components
{
partial class DockingPort : ItemComponent, IDrawableComponent, IServerSerializable
{
private UInt16 originalDockingTargetID;
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
{
msg.Write(docked);
if (docked)
{
msg.Write(originalDockingTargetID);
msg.Write(hulls != null && hulls[0] != null && hulls[1] != null && gap != null);
}
}
}
}
@@ -30,6 +30,7 @@ namespace Barotrauma.Items.Components
msg.Write(isOpen);
msg.Write(isBroken);
msg.Write(extraData.Length == 3 ? (bool)extraData[2] : false); //forced open
msg.Write(isStuck);
msg.WriteRangedSingle(stuck, 0.0f, 100.0f, 8);
msg.Write(lastUser == null ? (UInt16)0 : lastUser.ID);
}
@@ -0,0 +1,52 @@
using System;
using System.ComponentModel;
using System.Linq;
using System.Xml.Linq;
using Barotrauma.Networking;
namespace Barotrauma.Items.Components
{
internal partial class Growable
{
partial void LoadVines(XElement element)
{
foreach (XElement subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
{
case "flowersprite":
flowerVariants++;
break;
case "leafsprite":
leafVariants++;
break;
}
}
}
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
{
msg.WriteRangedSingle(Health, 0f, (float) MaxHealth, 8);
if (extraData != null && extraData.Length >= 3 && extraData[2] is int offset)
{
int amountToSend = Math.Min(Vines.Count - offset, VineChunkSize);
msg.WriteRangedInteger(offset, -1, MaximumVines);
msg.WriteRangedInteger(amountToSend, 0, VineChunkSize);
for (int i = offset; i < offset + amountToSend; i++)
{
VineTile vine = Vines[i];
var (x, y) = vine.Position;
msg.WriteRangedInteger((byte) vine.Type, 0b0000, 0b1111);
msg.WriteRangedInteger(vine.FlowerConfig.Serialize(), 0, 0xFFF);
msg.WriteRangedInteger(vine.LeafConfig.Serialize(), 0, 0xFFF);
msg.Write((byte) (x / VineTile.Size));
msg.Write((byte) (y / VineTile.Size));
}
}
else
{
msg.WriteRangedInteger(-1, -1, MaximumVines);
}
}
}
}
@@ -31,6 +31,8 @@ namespace Barotrauma.Items.Components
AttachToWall();
item.CreateServerEvent(this);
c.Character.Inventory?.CreateNetworkEvent();
GameServer.Log(GameServer.CharacterLogName(c.Character) + " attached " + item.Name + " to a wall", ServerLog.MessageType.ItemInteraction);
}
}
@@ -17,6 +17,8 @@ namespace Barotrauma.Items.Components
}
return true; //element processed
}
public virtual void ServerAppendExtraData(ref object[] extraData) { }
}
}
@@ -1,10 +1,16 @@
using Microsoft.Xna.Framework;
using Barotrauma.Networking;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.Xml.Linq;
namespace Barotrauma.Items.Components
{
partial class ItemLabel : ItemComponent, IDrawableComponent
{
private CoroutineHandle sendStateCoroutine;
private string lastSentText;
private float sendStateTimer;
[Serialize("", true, description: "The text to display on the label.", alwaysUseInstanceValues: true), Editable(100)]
public string Text
{
@@ -35,5 +41,38 @@ namespace Barotrauma.Items.Components
: base(item, element)
{
}
partial void OnStateChanged()
{
sendStateTimer = 0.1f;
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 (lastSentText != Text) { item.CreateServerEvent(this); }
yield return CoroutineStatus.Success;
}
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
{
msg.Write(Text);
lastSentText = Text;
}
}
}
@@ -9,6 +9,7 @@ namespace Barotrauma.Items.Components
{
//force can only be adjusted at 10% intervals -> no need for more accuracy than this
msg.WriteRangedInteger((int)(targetForce / 10.0f), -10, 10);
msg.Write(User == null ? Entity.NullEntityID : User.ID);
}
public void ServerRead(ClientNetObject type, IReadMessage msg, Client c)
@@ -23,6 +24,7 @@ namespace Barotrauma.Items.Components
}
targetForce = newTargetForce;
User = c.Character;
}
//notify all clients of the changed state
@@ -31,9 +31,22 @@ namespace Barotrauma.Items.Components
}
}
private ulong serverEventId = 0;
public override void ServerAppendExtraData(ref object[] extraData)
{
//ensuring the uniqueness of this event is
//required for the fabricator to sync correctly;
//otherwise, the event manager would incorrectly
//assume that the client actually has the latest state
Array.Resize(ref extraData, 4);
extraData[2] = serverEventId;
extraData[3] = State;
}
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
{
msg.Write((byte)State);
FabricatorState stateAtEvent = (FabricatorState)extraData[3];
msg.Write((byte)stateAtEvent);
msg.Write(timeUntilReady);
int itemIndex = fabricatedItem == null ? -1 : fabricationRecipes.IndexOf(fabricatedItem);
msg.WriteRangedInteger(itemIndex, -1, fabricationRecipes.Count - 1);
@@ -23,6 +23,10 @@ namespace Barotrauma.Items.Components
{
GameServer.Log(GameServer.CharacterLogName(c.Character) + (newIsActive ? " turned on " : " turned off ") + item.Name, ServerLog.MessageType.ItemInteraction);
}
if (pumpSpeedLockTimer <= 0.0f)
{
targetLevel = null;
}
FlowPercentage = newFlowPercentage;
IsActive = newIsActive;
@@ -22,13 +22,12 @@ namespace Barotrauma.Items.Components
bool autoPilot = msg.ReadBoolean();
bool dockingButtonClicked = msg.ReadBoolean();
Vector2 newSteeringInput = targetVelocity;
bool maintainPos = false;
Vector2? newPosToMaintain = null;
bool headingToStart = false;
if (autoPilot)
{
maintainPos = msg.ReadBoolean();
bool maintainPos = msg.ReadBoolean();
if (maintainPos)
{
newPosToMaintain = new Vector2(
@@ -0,0 +1,45 @@
using Barotrauma.Networking;
using System.Collections.Generic;
namespace Barotrauma.Items.Components
{
partial class MemoryComponent : ItemComponent
{
private CoroutineHandle sendStateCoroutine;
private string lastSentValue;
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 (lastSentValue != Value) { item.CreateServerEvent(this); }
yield return CoroutineStatus.Success;
}
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
{
msg.Write(Value);
lastSentValue = Value;
}
}
}