Unstable 1.8.4.0
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
@@ -13,10 +14,18 @@ namespace Barotrauma.Items.Components
|
||||
msg.WriteBoolean(writeAttachData);
|
||||
if (!writeAttachData) { return; }
|
||||
|
||||
UInt16 attacherId = Entity.NullEntityID;
|
||||
if (TryExtractEventData(extraData, out AttachEventData attachEventData) &&
|
||||
attachEventData.Attacher != null)
|
||||
{
|
||||
attacherId = attachEventData.Attacher.ID;
|
||||
}
|
||||
|
||||
msg.WriteBoolean(Attached);
|
||||
msg.WriteSingle(body.SimPosition.X);
|
||||
msg.WriteSingle(body.SimPosition.Y);
|
||||
msg.WriteUInt16(item.Submarine?.ID ?? Entity.NullEntityID);
|
||||
msg.WriteUInt16(attacherId);
|
||||
}
|
||||
|
||||
public void ServerEventRead(IReadMessage msg, Client c)
|
||||
@@ -34,7 +43,7 @@ namespace Barotrauma.Items.Components
|
||||
AttachToWall();
|
||||
OnUsed.Invoke(new ItemUseInfo(item, c.Character));
|
||||
|
||||
item.CreateServerEvent(this);
|
||||
item.CreateServerEvent(this, new AttachEventData(simPosition, c.Character));
|
||||
c.Character.Inventory?.CreateNetworkEvent();
|
||||
|
||||
GameServer.Log(GameServer.CharacterLogName(c.Character) + " attached " + item.Name + " to a wall", ServerLog.MessageType.ItemInteraction);
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Barotrauma.Items.Components
|
||||
private string lastSentText;
|
||||
private float sendStateTimer;
|
||||
|
||||
[Serialize("", IsPropertySaveable.Yes, description: "The text to display on the label.", alwaysUseInstanceValues: true), Editable(100)]
|
||||
[Serialize("", IsPropertySaveable.Yes, description: "The text to display on the label.", alwaysUseInstanceValues: true), Editable(MaxLength = 100)]
|
||||
public string Text
|
||||
{
|
||||
get;
|
||||
|
||||
@@ -14,11 +14,15 @@ namespace Barotrauma.Items.Components
|
||||
DockingButtonClicked = dockingButtonClicked;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: an enumeration would be much cleaner
|
||||
public bool MaintainPos;
|
||||
public bool LevelStartSelected;
|
||||
public bool LevelEndSelected;
|
||||
|
||||
[Serialize(defaultValue: false, isSaveable: IsPropertySaveable.Yes, AlwaysUseInstanceValues = true)]
|
||||
public bool MaintainPos { get; set; }
|
||||
|
||||
[Serialize(defaultValue: false, isSaveable: IsPropertySaveable.Yes, AlwaysUseInstanceValues = true)]
|
||||
public bool LevelStartSelected { get; set; }
|
||||
|
||||
[Serialize(defaultValue: false, isSaveable: IsPropertySaveable.Yes, AlwaysUseInstanceValues = true)]
|
||||
public bool LevelEndSelected { get; set; }
|
||||
|
||||
public bool UnsentChanges
|
||||
{
|
||||
@@ -74,7 +78,7 @@ namespace Barotrauma.Items.Components
|
||||
if (!AutoPilot)
|
||||
{
|
||||
steeringInput = newSteeringInput;
|
||||
steeringAdjustSpeed = MathHelper.Lerp(0.2f, 1.0f, c.Character.GetSkillLevel("helm") / 100.0f);
|
||||
steeringAdjustSpeed = MathHelper.Lerp(0.2f, 1.0f, c.Character.GetSkillLevel(Tags.HelmSkill) / 100.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#nullable enable
|
||||
#nullable enable
|
||||
|
||||
using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
@@ -310,7 +310,13 @@ namespace Barotrauma.Items.Components
|
||||
return wire.BackingWire.TryUnwrap(out var backingWire) ? backingWire.Name : "a wire";
|
||||
}
|
||||
|
||||
bool CanAccessAndUnlocked(Client client) => item.CanClientAccess(client) && !Locked;
|
||||
bool CanAccessAndUnlocked(Client client) =>
|
||||
!IsLocked() &&
|
||||
item.CanClientAccess(client) &&
|
||||
ClientHasRequiredItems(client);
|
||||
|
||||
bool ClientHasRequiredItems(Client client) =>
|
||||
client.Character is { } chara && HasRequiredItems(chara, addMessage: false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+39
-34
@@ -11,13 +11,17 @@ namespace Barotrauma.Items.Components
|
||||
string[] elementValues = new string[customInterfaceElementList.Count];
|
||||
for (int i = 0; i < customInterfaceElementList.Count; i++)
|
||||
{
|
||||
if (customInterfaceElementList[i].HasPropertyName)
|
||||
var element = customInterfaceElementList[i];
|
||||
switch (element.InputType)
|
||||
{
|
||||
elementValues[i] = msg.ReadString();
|
||||
}
|
||||
else
|
||||
{
|
||||
elementStates[i] = msg.ReadBoolean();
|
||||
case CustomInterfaceElement.InputTypeOption.Number:
|
||||
case CustomInterfaceElement.InputTypeOption.Text:
|
||||
elementValues[i] = msg.ReadString();
|
||||
break;
|
||||
case CustomInterfaceElement.InputTypeOption.Button:
|
||||
case CustomInterfaceElement.InputTypeOption.TickBox:
|
||||
elementStates[i] = msg.ReadBoolean();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,15 +30,10 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
for (int i = 0; i < customInterfaceElementList.Count; i++)
|
||||
{
|
||||
var element = customInterfaceElementList[i];
|
||||
if (element.HasPropertyName)
|
||||
var element = customInterfaceElementList[i];
|
||||
switch (element.InputType)
|
||||
{
|
||||
if (!element.IsNumberInput)
|
||||
{
|
||||
TextChanged(element, elementValues[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
case CustomInterfaceElement.InputTypeOption.Number:
|
||||
switch (element.NumberType)
|
||||
{
|
||||
case NumberType.Int when int.TryParse(elementValues[i], out int value):
|
||||
@@ -44,16 +43,20 @@ namespace Barotrauma.Items.Components
|
||||
ValueChanged(element, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (element.ContinuousSignal)
|
||||
{
|
||||
TickBoxToggled(element, elementStates[i]);
|
||||
}
|
||||
else if (elementStates[i])
|
||||
{
|
||||
clickedButton = element;
|
||||
ButtonClicked(element);
|
||||
break;
|
||||
case CustomInterfaceElement.InputTypeOption.Text:
|
||||
TextChanged(element, elementValues[i]);
|
||||
break;
|
||||
case CustomInterfaceElement.InputTypeOption.TickBox:
|
||||
TickBoxToggled(element, elementStates[i]);
|
||||
break;
|
||||
case CustomInterfaceElement.InputTypeOption.Button:
|
||||
if (elementStates[i])
|
||||
{
|
||||
clickedButton = element;
|
||||
ButtonClicked(element);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,17 +73,19 @@ namespace Barotrauma.Items.Components
|
||||
for (int i = 0; i < customInterfaceElementList.Count; i++)
|
||||
{
|
||||
var element = customInterfaceElementList[i];
|
||||
if (element.HasPropertyName)
|
||||
|
||||
switch (element.InputType)
|
||||
{
|
||||
msg.WriteString(element.Signal);
|
||||
}
|
||||
else if(element.ContinuousSignal)
|
||||
{
|
||||
msg.WriteBoolean(element.State);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.WriteBoolean(extraData is Item.ComponentStateEventData { ComponentData: EventData eventData } && eventData.BtnElement == customInterfaceElementList[i]);
|
||||
case CustomInterfaceElement.InputTypeOption.Number:
|
||||
case CustomInterfaceElement.InputTypeOption.Text:
|
||||
msg.WriteString(element.Signal);
|
||||
break;
|
||||
case CustomInterfaceElement.InputTypeOption.TickBox:
|
||||
msg.WriteBoolean(element.State);
|
||||
break;
|
||||
case CustomInterfaceElement.InputTypeOption.Button:
|
||||
msg.WriteBoolean(extraData is Item.ComponentStateEventData { ComponentData: EventData eventData } && eventData.BtnElement == customInterfaceElementList[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,15 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
public void ServerEventWrite(IWriteMessage msg, Client c, NetEntityEvent.IData extraData = null)
|
||||
{
|
||||
msg.WriteRangedInteger(Channel, MinChannel, MaxChannel);
|
||||
SharedEventWrite(msg);
|
||||
}
|
||||
|
||||
public void ServerEventRead(IReadMessage msg, Client c)
|
||||
{
|
||||
SharedEventRead(msg);
|
||||
|
||||
// Create an event to notify other clients about the changes
|
||||
item.CreateServerEvent(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user