Expose some stuff to sub editor, fix alien doors openable with use key, fixed some decon recipes
Beginnings of a Conditional system
This commit is contained in:
@@ -1354,9 +1354,24 @@
|
|||||||
<None Include="$(MSBuildThisFileDirectory)Content\watershader_opengl.xnb">
|
<None Include="$(MSBuildThisFileDirectory)Content\watershader_opengl.xnb">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Include="$(MSBuildThisFileDirectory)Submarines\Nehalennia.sub" />
|
<None Include="$(MSBuildThisFileDirectory)Submarines\Aegir Mark III.sub">
|
||||||
<None Include="$(MSBuildThisFileDirectory)Submarines\TutorialSub.sub" />
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
<None Include="$(MSBuildThisFileDirectory)Submarines\Vellamo.sub" />
|
</None>
|
||||||
|
<None Include="$(MSBuildThisFileDirectory)Submarines\Nehalennia.sub">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="$(MSBuildThisFileDirectory)Submarines\The Blind Carp.sub">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="$(MSBuildThisFileDirectory)Submarines\The Nibbler.sub">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="$(MSBuildThisFileDirectory)Submarines\TutorialSub.sub">
|
||||||
|
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="$(MSBuildThisFileDirectory)Submarines\Vellamo.sub">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Characters\AICharacter.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Source\Characters\AICharacter.cs" />
|
||||||
|
|||||||
@@ -98,9 +98,9 @@
|
|||||||
|
|
||||||
<Deconstruct time="20">
|
<Deconstruct time="20">
|
||||||
<Item name="Steel Bar"/>
|
<Item name="Steel Bar"/>
|
||||||
<Item name="Liquid Oxygenite"/>
|
<Item name="Liquid Oxygenite" mincondition="0.1"/>
|
||||||
<Item name="Liquid Oxygenite"/>
|
<Item name="Liquid Oxygenite" mincondition="0.5"/>
|
||||||
<Item name="Liquid Oxygenite"/>
|
<Item name="Liquid Oxygenite" mincondition="0.9"/>
|
||||||
</Deconstruct>
|
</Deconstruct>
|
||||||
|
|
||||||
<Sprite texture="artifact.png" depth="0.7" sourcerect="119,0,9,32"/>
|
<Sprite texture="artifact.png" depth="0.7" sourcerect="119,0,9,32"/>
|
||||||
@@ -127,9 +127,9 @@
|
|||||||
|
|
||||||
<Deconstruct time="20">
|
<Deconstruct time="20">
|
||||||
<Item name="Steel Bar"/>
|
<Item name="Steel Bar"/>
|
||||||
<Item name="Sulphuric Acid"/>
|
<Item name="Sulphuric Acid" mincondition="0.1"/>
|
||||||
<Item name="Sulphuric Acid"/>
|
<Item name="Sulphuric Acid" mincondition="0.5"/>
|
||||||
<Item name="Sulphuric Acid"/>
|
<Item name="Sulphuric Acid" mincondition="0.9"/>
|
||||||
</Deconstruct>
|
</Deconstruct>
|
||||||
|
|
||||||
<Sprite texture="artifact.png" depth="0.7" sourcerect="119,0,9,32"/>
|
<Sprite texture="artifact.png" depth="0.7" sourcerect="119,0,9,32"/>
|
||||||
@@ -201,7 +201,7 @@
|
|||||||
|
|
||||||
<Sprite texture="Content/Map/ruins.png" sourcerect="747,0,260,95" depth="0.8" origin="0.5,0.5"/>
|
<Sprite texture="Content/Map/ruins.png" sourcerect="747,0,260,95" depth="0.8" origin="0.5,0.5"/>
|
||||||
|
|
||||||
<Door canbeselected="true" horizontal="true">
|
<Door canbepicked="false" canbeselected="true" horizontal="true">
|
||||||
<Sprite texture="Content/Map/ruins.png" sourcerect="0,842,260,54" depth="0.6" origin="0.0,0.5"/>
|
<Sprite texture="Content/Map/ruins.png" sourcerect="0,842,260,54" depth="0.6" origin="0.0,0.5"/>
|
||||||
<sound file="aliendoor.ogg" type="OnUse" range="1000.0"/>
|
<sound file="aliendoor.ogg" type="OnUse" range="1000.0"/>
|
||||||
</Door>
|
</Door>
|
||||||
@@ -223,7 +223,7 @@
|
|||||||
|
|
||||||
<Sprite texture="Content/Map/ruins.png" sourcerect="746,101,93,259" depth="0.8" origin="0.5,0.5"/>
|
<Sprite texture="Content/Map/ruins.png" sourcerect="746,101,93,259" depth="0.8" origin="0.5,0.5"/>
|
||||||
|
|
||||||
<Door canbeselected="true">
|
<Door canbepicked="false" canbeselected="true">
|
||||||
<Sprite texture="Content/Map/ruins.png" sourcerect="842,192,54,259" depth="0.6" origin="0.5,0.0"/>
|
<Sprite texture="Content/Map/ruins.png" sourcerect="842,192,54,259" depth="0.6" origin="0.5,0.0"/>
|
||||||
<sound file="aliendoor.ogg" type="OnUse" range="3000.0"/>
|
<sound file="aliendoor.ogg" type="OnUse" range="3000.0"/>
|
||||||
</Door>
|
</Door>
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ namespace Barotrauma
|
|||||||
public string[] propertyNames;
|
public string[] propertyNames;
|
||||||
private object[] propertyEffects;
|
private object[] propertyEffects;
|
||||||
|
|
||||||
|
List<Tuple<string, string, object>> propertyConditionals;
|
||||||
|
|
||||||
private bool setValue;
|
private bool setValue;
|
||||||
|
|
||||||
private bool disableDeltaTime;
|
private bool disableDeltaTime;
|
||||||
@@ -83,7 +85,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
IEnumerable<XAttribute> attributes = element.Attributes();
|
IEnumerable<XAttribute> attributes = element.Attributes();
|
||||||
List<XAttribute> propertyAttributes = new List<XAttribute>();
|
List<XAttribute> propertyAttributes = new List<XAttribute>();
|
||||||
|
propertyConditionals = new List<Tuple<string, string, object>>();
|
||||||
|
|
||||||
foreach (XAttribute attribute in attributes)
|
foreach (XAttribute attribute in attributes)
|
||||||
{
|
{
|
||||||
switch (attribute.Name.ToString())
|
switch (attribute.Name.ToString())
|
||||||
@@ -138,7 +141,20 @@ namespace Barotrauma
|
|||||||
" - sounds should be defined as child elements of the StatusEffect, not as attributes.");
|
" - sounds should be defined as child elements of the StatusEffect, not as attributes.");
|
||||||
break;
|
break;
|
||||||
default:
|
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<string, string, object>(attribute.Name.ToString().ToLowerInvariant(), op, attributeObject));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
propertyAttributes.Add(attribute);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,6 +225,80 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual bool HasRequiredConditions(List<ISerializableEntity> targets)
|
||||||
|
{
|
||||||
|
if (!propertyConditionals.Any()) return true;
|
||||||
|
foreach (ISerializableEntity target in targets)
|
||||||
|
{
|
||||||
|
foreach (Tuple<string, string, object> 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)
|
public virtual void Apply(ActionType type, float deltaTime, Entity entity, ISerializableEntity target)
|
||||||
{
|
{
|
||||||
if (this.type != type || !HasRequiredItems(entity)) return;
|
if (this.type != type || !HasRequiredItems(entity)) return;
|
||||||
|
|||||||
@@ -207,7 +207,8 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
if (item.Condition <= 0.0f) return true; //For repairing
|
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)
|
public override bool Pick(Character picker)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
private string msg;
|
private string msg;
|
||||||
|
|
||||||
[Serialize(0.0f, false)]
|
[Editable, Serialize(0.0f, false)]
|
||||||
public float PickingTime
|
public float PickingTime
|
||||||
{
|
{
|
||||||
get;
|
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
|
public bool CanBePicked
|
||||||
{
|
{
|
||||||
get { return canBePicked; }
|
get { return canBePicked; }
|
||||||
@@ -171,7 +171,7 @@ namespace Barotrauma.Items.Components
|
|||||||
get { return name; }
|
get { return name; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serialize("", false)]
|
[Editable, Serialize("", false)]
|
||||||
public string Msg
|
public string Msg
|
||||||
{
|
{
|
||||||
get { return msg; }
|
get { return msg; }
|
||||||
|
|||||||
Reference in New Issue
Block a user