fix crash on selecting husks (and other things with Unit but Selectable.Voice = null)
This commit is contained in:
@@ -48,11 +48,6 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool HasVoice(Actor a)
|
|
||||||
{
|
|
||||||
return a.Info.Traits.Contains<SelectableInfo>() && a.Info.Traits.Get<SelectableInfo>().Voice != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ApplyOrders(World world, float2 xy, MouseInput mi)
|
void ApplyOrders(World world, float2 xy, MouseInput mi)
|
||||||
{
|
{
|
||||||
if (orderGenerator == null) return;
|
if (orderGenerator == null) return;
|
||||||
@@ -61,7 +56,7 @@ namespace OpenRA
|
|||||||
Game.orderManager.IssueOrders( orders );
|
Game.orderManager.IssueOrders( orders );
|
||||||
|
|
||||||
var voicedActor = orders.Select(o => o.Subject)
|
var voicedActor = orders.Select(o => o.Subject)
|
||||||
.FirstOrDefault(a => a.Owner == world.LocalPlayer && HasVoice(a));
|
.FirstOrDefault(a => a.Owner == world.LocalPlayer && a.HasVoice());
|
||||||
|
|
||||||
var isMove = orders.Any(o => o.OrderString == "Move");
|
var isMove = orders.Any(o => o.OrderString == "Move");
|
||||||
var isAttack = orders.Any( o => o.OrderString == "Attack" );
|
var isAttack = orders.Any( o => o.OrderString == "Attack" );
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace OpenRA
|
|||||||
else
|
else
|
||||||
actors = (isCombine ? oldSelection.Union(newSelection) : newSelection).ToList();
|
actors = (isCombine ? oldSelection.Union(newSelection) : newSelection).ToList();
|
||||||
|
|
||||||
var voicedUnit = actors.FirstOrDefault(a => a.traits.Contains<Unit>() && a.Owner == world.LocalPlayer);
|
var voicedUnit = actors.FirstOrDefault(a => a.Owner == world.LocalPlayer && a.HasVoice());
|
||||||
Sound.PlayVoice("Select", voicedUnit);
|
Sound.PlayVoice("Select", voicedUnit);
|
||||||
|
|
||||||
foreach (var ns in world.WorldActor.traits.WithInterface<INotifySelection>())
|
foreach (var ns in world.WorldActor.traits.WithInterface<INotifySelection>())
|
||||||
|
|||||||
@@ -222,5 +222,10 @@ namespace OpenRA
|
|||||||
|
|
||||||
return "{0:D2}:{1:D2}".F(minutes, seconds % 60);
|
return "{0:D2}:{1:D2}".F(minutes, seconds % 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool HasVoice(this Actor a)
|
||||||
|
{
|
||||||
|
return a.Info.Traits.Contains<SelectableInfo>() && a.Info.Traits.Get<SelectableInfo>().Voice != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user