v0.10.5.1
This commit is contained in:
+23
-6
@@ -1,14 +1,24 @@
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Networking;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
class MemoryComponent : ItemComponent
|
||||
partial class MemoryComponent : ItemComponent, IServerSerializable
|
||||
{
|
||||
const int MaxValueLength = 256;
|
||||
|
||||
|
||||
private string value;
|
||||
|
||||
[InGameEditable, Serialize("", true, description: "The currently stored signal the item outputs.", alwaysUseInstanceValues: true)]
|
||||
public string Value
|
||||
{
|
||||
get;
|
||||
set;
|
||||
get { return value; }
|
||||
set
|
||||
{
|
||||
if (value == null) { return; }
|
||||
this.value = value.Length <= MaxValueLength ? value : value.Substring(0, MaxValueLength);
|
||||
}
|
||||
}
|
||||
|
||||
protected bool writeable = true;
|
||||
@@ -24,15 +34,22 @@ namespace Barotrauma.Items.Components
|
||||
item.SendSignal(0, Value, "signal_out", null);
|
||||
}
|
||||
|
||||
partial void OnStateChanged();
|
||||
|
||||
public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power = 0.0f, float signalStrength = 1.0f)
|
||||
{
|
||||
switch (connection.Name)
|
||||
{
|
||||
case "signal_in":
|
||||
if (writeable) { Value = signal; }
|
||||
if (writeable)
|
||||
{
|
||||
if (Value == signal) { return; }
|
||||
Value = signal;
|
||||
OnStateChanged();
|
||||
}
|
||||
break;
|
||||
case "signal_store":
|
||||
writeable = (signal == "1");
|
||||
writeable = signal == "1";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user