diff --git a/Barotrauma/BarotraumaShared/BarotraumaShared.projitems b/Barotrauma/BarotraumaShared/BarotraumaShared.projitems
index a8b61c502..73d4912a1 100644
--- a/Barotrauma/BarotraumaShared/BarotraumaShared.projitems
+++ b/Barotrauma/BarotraumaShared/BarotraumaShared.projitems
@@ -1354,9 +1354,24 @@
PreserveNewest
-
-
-
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ Never
+
+
+ PreserveNewest
+
diff --git a/Barotrauma/BarotraumaShared/Content/Items/Artifacts/artifacts.xml b/Barotrauma/BarotraumaShared/Content/Items/Artifacts/artifacts.xml
index fe4bba8f2..8d5c2c205 100644
--- a/Barotrauma/BarotraumaShared/Content/Items/Artifacts/artifacts.xml
+++ b/Barotrauma/BarotraumaShared/Content/Items/Artifacts/artifacts.xml
@@ -98,9 +98,9 @@
-
-
-
+
+
+
@@ -127,9 +127,9 @@
-
-
-
+
+
+
@@ -201,7 +201,7 @@
-
+
@@ -223,7 +223,7 @@
-
+
diff --git a/Barotrauma/BarotraumaShared/Source/Characters/StatusEffect.cs b/Barotrauma/BarotraumaShared/Source/Characters/StatusEffect.cs
index af6bac60f..1aa8c7857 100644
--- a/Barotrauma/BarotraumaShared/Source/Characters/StatusEffect.cs
+++ b/Barotrauma/BarotraumaShared/Source/Characters/StatusEffect.cs
@@ -32,6 +32,8 @@ namespace Barotrauma
public string[] propertyNames;
private object[] propertyEffects;
+ List> propertyConditionals;
+
private bool setValue;
private bool disableDeltaTime;
@@ -83,7 +85,8 @@ namespace Barotrauma
IEnumerable attributes = element.Attributes();
List propertyAttributes = new List();
-
+ propertyConditionals = new List>();
+
foreach (XAttribute attribute in attributes)
{
switch (attribute.Name.ToString())
@@ -138,7 +141,20 @@ namespace Barotrauma
" - sounds should be defined as child elements of the StatusEffect, not as attributes.");
break;
default:
- propertyAttributes.Add(attribute);
+ object attributeObject = XMLExtensions.GetAttributeObject(attribute);
+ Type type = attributeObject.GetType();
+
+ string op = ((string)attributeObject).Substring(0, 2);
+ if (op != "!=" && op != ">=" && op != "<=" && op != "==" && (op.StartsWith(">") || op.StartsWith("<")))
+ op = op.Substring(0, 1);
+
+ if (op == "!=" || op == ">=" || op == "<=" || op == "==" || op == ">" || op == "<") //Oh shit this is a conditional!
+ {
+ attributeObject = ((string)attributeObject).Substring(op.Length, ((string)attributeObject).Length);
+ propertyConditionals.Add(new Tuple(attribute.Name.ToString().ToLowerInvariant(), op, attributeObject));
+ }
+ else
+ propertyAttributes.Add(attribute);
break;
}
}
@@ -209,6 +225,80 @@ namespace Barotrauma
return true;
}
+ public virtual bool HasRequiredConditions(List targets)
+ {
+ if (!propertyConditionals.Any()) return true;
+ foreach (ISerializableEntity target in targets)
+ {
+ foreach (Tuple con in propertyConditionals)
+ {
+ string name = con.Item1;
+ string op = con.Item2;
+ object value = con.Item3;
+
+ SerializableProperty property;
+
+ if (target == null || target.SerializableProperties == null || !target.SerializableProperties.TryGetValue(name, out property)) continue;
+
+ Type type = value.GetType();
+ float? floatValue = null;
+ if ((type == typeof(float) || type == typeof(int)) && (property.GetValue() is float || property.GetValue() is int))
+ {
+ floatValue = Convert.ToSingle(value);
+ }
+
+ switch (op)
+ {
+ case "==":
+ if (!(property == value))
+ return false;
+ break;
+ case "!=":
+ if (!(property != value))
+ return false;
+ break;
+ case ">":
+ if (floatValue == null)
+ {
+ DebugConsole.ThrowError("Couldn't compare " + value.ToString() + " (" + type + ") to property \"" + property.Name + "\" (" + property.GetValue().GetType() + ")! "
+ + "Make sure the type of the value set in the config files matches the type of the property.");
+ }
+ else if (!((float)property.GetValue() > floatValue))
+ return false;
+ break;
+ case "<":
+ if (floatValue == null)
+ {
+ DebugConsole.ThrowError("Couldn't compare " + value.ToString() + " (" + type + ") to property \"" + property.Name + "\" (" + property.GetValue().GetType() + ")! "
+ + "Make sure the type of the value set in the config files matches the type of the property.");
+ }
+ else if (!((float)property.GetValue() < floatValue))
+ return false;
+ break;
+ case ">=":
+ if (floatValue == null)
+ {
+ DebugConsole.ThrowError("Couldn't compare " + value.ToString() + " (" + type + ") to property \"" + property.Name + "\" (" + property.GetValue().GetType() + ")! "
+ + "Make sure the type of the value set in the config files matches the type of the property.");
+ }
+ else if (!((float)property.GetValue() >= floatValue))
+ return false;
+ break;
+ case "<=":
+ if (floatValue == null)
+ {
+ DebugConsole.ThrowError("Couldn't compare " + value.ToString() + " (" + type + ") to property \"" + property.Name + "\" (" + property.GetValue().GetType() + ")! "
+ + "Make sure the type of the value set in the config files matches the type of the property.");
+ }
+ else if (!((float)property.GetValue() <= floatValue))
+ return false;
+ break;
+ }
+ }
+ }
+ return true;
+ }
+
public virtual void Apply(ActionType type, float deltaTime, Entity entity, ISerializableEntity target)
{
if (this.type != type || !HasRequiredItems(entity)) return;
diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs
index a928a20df..ee5ac9e65 100644
--- a/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs
+++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs
@@ -207,7 +207,8 @@ namespace Barotrauma.Items.Components
{
if (item.Condition <= 0.0f) return true; //For repairing
- return base.HasRequiredItems(character, addMessage);
+ //this is a bit pointless atm because if canBePicked is false it won't allow you to do Pick() anyway, however it's still good for future-proofing.
+ return requiredItems.Any() ? base.HasRequiredItems(character, addMessage) : canBePicked;
}
public override bool Pick(Character picker)
diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs
index 8d265ec58..e47d89d2f 100644
--- a/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs
+++ b/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs
@@ -49,7 +49,7 @@ namespace Barotrauma.Items.Components
private string msg;
- [Serialize(0.0f, false)]
+ [Editable, Serialize(0.0f, false)]
public float PickingTime
{
get;
@@ -105,7 +105,7 @@ namespace Barotrauma.Items.Components
}
}
- [Serialize(false, false)]
+ [Editable, Serialize(false, false)] //Editable for doors to do their magic
public bool CanBePicked
{
get { return canBePicked; }
@@ -171,7 +171,7 @@ namespace Barotrauma.Items.Components
get { return name; }
}
- [Serialize("", false)]
+ [Editable, Serialize("", false)]
public string Msg
{
get { return msg; }