Add ability to grant condition multipile times to GrantExternalConditionCrateAction
This commit is contained in:
committed by
reaperrr
parent
de7706c98f
commit
2bb2d6e9c5
@@ -20,6 +20,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("The condition to apply. Must be included in the target actor's ExternalConditions list.")]
|
[Desc("The condition to apply. Must be included in the target actor's ExternalConditions list.")]
|
||||||
public readonly string Condition = null;
|
public readonly string Condition = null;
|
||||||
|
|
||||||
|
[Desc("How many times to grant the condition.")]
|
||||||
|
public readonly int Levels = 1;
|
||||||
|
|
||||||
[Desc("Duration of the condition (in ticks). Set to 0 for a permanent condition.")]
|
[Desc("Duration of the condition (in ticks). Set to 0 for a permanent condition.")]
|
||||||
public readonly int Duration = 0;
|
public readonly int Duration = 0;
|
||||||
|
|
||||||
@@ -70,12 +73,22 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!a.IsInWorld || a.IsDead)
|
if (!a.IsInWorld || a.IsDead)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var external = a.TraitsImplementing<ExternalCondition>()
|
var externals = a.TraitsImplementing<ExternalCondition>()
|
||||||
.FirstOrDefault(t => t.Info.Condition == info.Condition && t.CanGrantCondition(a, self));
|
.Where(t => t.Info.Condition == info.Condition);
|
||||||
|
|
||||||
|
ExternalCondition external = null;
|
||||||
|
for (var n = 0; n < info.Levels; n++)
|
||||||
|
{
|
||||||
|
if (external == null || !external.CanGrantCondition(a, self))
|
||||||
|
{
|
||||||
|
external = externals.FirstOrDefault(t => t.CanGrantCondition(a, self));
|
||||||
|
if (external == null)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (external != null)
|
|
||||||
external.GrantCondition(a, self, info.Duration);
|
external.GrantCondition(a, self, info.Duration);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
base.Activate(collector);
|
base.Activate(collector);
|
||||||
|
|||||||
Reference in New Issue
Block a user