Check for dead actors when searching for exits.
This commit is contained in:
committed by
abcdefg30
parent
31267aa22d
commit
98b25ddd5e
@@ -35,12 +35,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Exits with larger priorities will be used before lower priorities.")]
|
[Desc("Exits with larger priorities will be used before lower priorities.")]
|
||||||
public readonly int Priority = 1;
|
public readonly int Priority = 1;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new Exit(init, this); }
|
public override object Create(ActorInitializer init) { return new Exit(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Exit : ConditionalTrait<ExitInfo>
|
public class Exit : ConditionalTrait<ExitInfo>
|
||||||
{
|
{
|
||||||
public Exit(ActorInitializer init, ExitInfo info)
|
public Exit(ExitInfo info)
|
||||||
: base(info) { }
|
: base(info) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,6 +62,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public static IEnumerable<Exit> Exits(this Actor actor, string productionType = null)
|
public static IEnumerable<Exit> Exits(this Actor actor, string productionType = null)
|
||||||
{
|
{
|
||||||
|
if (!actor.IsInWorld || actor.Disposed)
|
||||||
|
return Enumerable.Empty<Exit>();
|
||||||
|
|
||||||
var all = actor.TraitsImplementing<Exit>()
|
var all = actor.TraitsImplementing<Exit>()
|
||||||
.Where(Exts.IsTraitEnabled);
|
.Where(Exts.IsTraitEnabled);
|
||||||
|
|
||||||
@@ -73,6 +76,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public static Exit RandomExitOrDefault(this Actor actor, World world, string productionType, Func<Exit, bool> p = null)
|
public static Exit RandomExitOrDefault(this Actor actor, World world, string productionType, Func<Exit, bool> p = null)
|
||||||
{
|
{
|
||||||
|
if (!actor.IsInWorld || actor.Disposed)
|
||||||
|
return null;
|
||||||
|
|
||||||
var allOfType = Exits(actor, productionType);
|
var allOfType = Exits(actor, productionType);
|
||||||
if (!allOfType.Any())
|
if (!allOfType.Any())
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user