Faction Test 100.4.0.0
This commit is contained in:
@@ -24,7 +24,8 @@ namespace Barotrauma
|
||||
HasSpecifierTag,
|
||||
Affliction,
|
||||
EntityType,
|
||||
LimbType
|
||||
LimbType,
|
||||
SkillRequirement
|
||||
}
|
||||
|
||||
public enum Comparison
|
||||
@@ -73,6 +74,7 @@ namespace Barotrauma
|
||||
case "targetcontainer":
|
||||
case "targetgrandparent":
|
||||
case "targetcontaineditem":
|
||||
case "skillrequirement":
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
@@ -110,6 +112,11 @@ namespace Barotrauma
|
||||
{
|
||||
Type = ConditionType.Uncertain;
|
||||
}
|
||||
|
||||
if (attribute.Parent.GetAttributeBool("skillrequirement", false))
|
||||
{
|
||||
Type = ConditionType.SkillRequirement;
|
||||
}
|
||||
|
||||
AttributeValue = valueString;
|
||||
SplitAttributeValue = valueString.Split(',');
|
||||
@@ -305,25 +312,20 @@ namespace Barotrauma
|
||||
if (health == null) { return false; }
|
||||
var affliction = health.GetAffliction(AttributeName.ToIdentifier());
|
||||
float afflictionStrength = affliction == null ? 0.0f : affliction.Strength;
|
||||
if (FloatValue.HasValue)
|
||||
{
|
||||
float value = FloatValue.Value;
|
||||
switch (Operator)
|
||||
{
|
||||
case OperatorType.Equals:
|
||||
return afflictionStrength == value;
|
||||
case OperatorType.GreaterThan:
|
||||
return afflictionStrength > value;
|
||||
case OperatorType.GreaterThanEquals:
|
||||
return afflictionStrength >= value;
|
||||
case OperatorType.LessThan:
|
||||
return afflictionStrength < value;
|
||||
case OperatorType.LessThanEquals:
|
||||
return afflictionStrength <= value;
|
||||
case OperatorType.NotEquals:
|
||||
return afflictionStrength != value;
|
||||
}
|
||||
}
|
||||
|
||||
return ValueMatchesRequirement(afflictionStrength);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
case ConditionType.SkillRequirement:
|
||||
{
|
||||
if (target == null) { return Operator == OperatorType.NotEquals; }
|
||||
|
||||
if (target is Character targetChar)
|
||||
{
|
||||
float skillLevel = targetChar.GetSkillLevel(AttributeName.ToIdentifier());
|
||||
|
||||
return ValueMatchesRequirement(skillLevel);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -332,6 +334,30 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private bool ValueMatchesRequirement(float testedValue)
|
||||
{
|
||||
if (FloatValue.HasValue)
|
||||
{
|
||||
float value = FloatValue.Value;
|
||||
switch (Operator)
|
||||
{
|
||||
case OperatorType.Equals:
|
||||
return testedValue == value;
|
||||
case OperatorType.GreaterThan:
|
||||
return testedValue > value;
|
||||
case OperatorType.GreaterThanEquals:
|
||||
return testedValue >= value;
|
||||
case OperatorType.LessThan:
|
||||
return testedValue < value;
|
||||
case OperatorType.LessThanEquals:
|
||||
return testedValue <= value;
|
||||
case OperatorType.NotEquals:
|
||||
return testedValue != value;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool MatchesTagCondition(ISerializableEntity target)
|
||||
{
|
||||
if (!(target is Item item)) { return Operator == OperatorType.NotEquals; }
|
||||
|
||||
Reference in New Issue
Block a user