voices are no longer tied to having Unit; default is to have no voice; defaults.yaml set up appropriately for units that should have one.

This commit is contained in:
Chris Forbes
2010-07-04 14:25:34 +12:00
parent 35b6f5c38b
commit 8e68449af1
4 changed files with 12 additions and 3 deletions

View File

@@ -48,6 +48,11 @@ 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;
@@ -56,14 +61,13 @@ 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 && a.traits.Contains<Unit>()); .FirstOrDefault(a => a.Owner == world.LocalPlayer && HasVoice(a));
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" );
if (voicedActor != null) if (voicedActor != null)
{ {
if(voicedActor.traits.GetOrDefault<IMove>().CanEnterCell(xy.ToInt2())) if(voicedActor.traits.GetOrDefault<IMove>().CanEnterCell(xy.ToInt2()))
Sound.PlayVoice(isAttack ? "Attack" : "Move", voicedActor); Sound.PlayVoice(isAttack ? "Attack" : "Move", voicedActor);

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Traits
{ {
public readonly int Priority = 10; public readonly int Priority = 10;
public readonly int[] Bounds = null; public readonly int[] Bounds = null;
public readonly string Voice = "GenericVoice"; public readonly string Voice = null;
public readonly float Radius = 10; public readonly float Radius = 10;
} }

View File

@@ -59,6 +59,7 @@
TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River
TerrainSpeeds: 90%, 80%, 100%, 0%, 0%, 0%, 0%, 90%, 80%, 0% TerrainSpeeds: 90%, 80%, 100%, 0%, 0%, 0%, 0%, 90%, 80%, 0%
Selectable: Selectable:
Voice: GenericVoice
RenderInfantry: RenderInfantry:
AutoTarget: AutoTarget:
Passenger: Passenger:
@@ -74,6 +75,7 @@
Unit: Unit:
TargetType: Air TargetType: Air
Selectable: Selectable:
Voice: GenericVoice
HiddenUnderFog: HiddenUnderFog:
RevealsShroud: RevealsShroud:
GainsExperience: GainsExperience:

View File

@@ -46,6 +46,7 @@
TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River
TerrainSpeeds: 90%, 80%, 100%, 0%, 0%, 0%, 0%, 100%, 80%, 0% TerrainSpeeds: 90%, 80%, 100%, 0%, 0%, 0%, 0%, 100%, 80%, 0%
Selectable: Selectable:
Voice: GenericVoice
RenderInfantry: RenderInfantry:
AutoTarget: AutoTarget:
Passenger: Passenger:
@@ -62,6 +63,7 @@
TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River
TerrainSpeeds: 0%, 0%, 0%, 0%, 100%, 0%, 0%, 0%, 0%, 0% TerrainSpeeds: 0%, 0%, 0%, 0%, 100%, 0%, 0%, 0%, 0%, 0%
Selectable: Selectable:
Voice: GenericVoice
HiddenUnderFog: HiddenUnderFog:
RevealsShroud: RevealsShroud:
GainsExperience: GainsExperience:
@@ -72,6 +74,7 @@
Unit: Unit:
TargetType: Air TargetType: Air
Selectable: Selectable:
Voice: GenericVoice
HiddenUnderFog: HiddenUnderFog:
RevealsShroud: RevealsShroud:
GainsExperience: GainsExperience: