add audio feedback to stop/scatter/deploy junk
This commit is contained in:
@@ -99,17 +99,9 @@ namespace OpenRA.Widgets
|
|||||||
if (world.OrderGenerator == null) return;
|
if (world.OrderGenerator == null) return;
|
||||||
|
|
||||||
var orders = world.OrderGenerator.Order(world, xy.ToInt2(), mi).ToArray();
|
var orders = world.OrderGenerator.Order(world, xy.ToInt2(), mi).ToArray();
|
||||||
orders.Do( o => world.IssueOrder( o ) );
|
orders.Do( o => world.IssueOrder( o ) );
|
||||||
|
|
||||||
// Find an actor with a phrase to say
|
world.PlayVoiceForOrders(orders);
|
||||||
foreach (var o in orders)
|
|
||||||
{
|
|
||||||
if (o.Subject.Destroyed) continue;
|
|
||||||
foreach (var v in o.Subject.TraitsImplementing<IOrderVoice>())
|
|
||||||
if (Sound.PlayVoice(v.VoicePhraseForOrder(o.Subject, o),
|
|
||||||
o.Subject, o.Subject.Owner.Country.Race))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string GetCursor(int2 pos)
|
public override string GetCursor(int2 pos)
|
||||||
|
|||||||
@@ -124,6 +124,19 @@ namespace OpenRA
|
|||||||
if (!a.Info.Traits.Contains<SelectableInfo>()) return null;
|
if (!a.Info.Traits.Contains<SelectableInfo>()) return null;
|
||||||
var v = a.Info.Traits.Get<SelectableInfo>().Voice;
|
var v = a.Info.Traits.Get<SelectableInfo>().Voice;
|
||||||
return (v == null) ? null : Rules.Voices[v];
|
return (v == null) ? null : Rules.Voices[v];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void PlayVoiceForOrders(this World w, Order[] orders)
|
||||||
|
{
|
||||||
|
// Find an actor with a phrase to say
|
||||||
|
foreach (var o in orders)
|
||||||
|
{
|
||||||
|
if (o.Subject.Destroyed) continue;
|
||||||
|
foreach (var v in o.Subject.TraitsImplementing<IOrderVoice>())
|
||||||
|
if (Sound.PlayVoice(v.VoicePhraseForOrder(o.Subject, o),
|
||||||
|
o.Subject, o.Subject.Owner.Country.Race))
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
public char AttackMoveKey = 'a';
|
public char AttackMoveKey = 'a';
|
||||||
public char StopKey = 's';
|
public char StopKey = 's';
|
||||||
public char ScatterKey = 'x';
|
public char ScatterKey = 'x';
|
||||||
|
public char DeployKey = 'f';
|
||||||
public readonly OrderManager OrderManager;
|
public readonly OrderManager OrderManager;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
@@ -50,11 +51,16 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
|
|
||||||
if (e.KeyChar == ScatterKey)
|
if (e.KeyChar == ScatterKey)
|
||||||
return PerformScatter();
|
return PerformScatter();
|
||||||
|
|
||||||
|
if (e.KeyChar == DeployKey)
|
||||||
|
return PerformDeploy();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: take ALL this garbage and route it through the OrderTargeter stuff.
|
||||||
|
|
||||||
bool PerformAttackMove()
|
bool PerformAttackMove()
|
||||||
{
|
{
|
||||||
World.OrderGenerator = new GenericSelectTarget(World.Selection.Actors, "AttackMove",
|
World.OrderGenerator = new GenericSelectTarget(World.Selection.Actors, "AttackMove",
|
||||||
@@ -63,21 +69,28 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PerformKeyboardOrderOnSelection(Func<Actor, Order> f)
|
||||||
|
{
|
||||||
|
var orders = World.Selection.Actors.Select(f).ToArray();
|
||||||
|
foreach (var o in orders) World.IssueOrder(o);
|
||||||
|
World.PlayVoiceForOrders(orders);
|
||||||
|
}
|
||||||
|
|
||||||
bool PerformStop()
|
bool PerformStop()
|
||||||
{
|
{
|
||||||
/* issue a stop order to everyone. */
|
PerformKeyboardOrderOnSelection(a => new Order("Stop", a, false));
|
||||||
foreach (var a in World.Selection.Actors)
|
|
||||||
World.IssueOrder(new Order("Stop", a, false));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PerformScatter()
|
bool PerformScatter()
|
||||||
{
|
{
|
||||||
/* issue a stop order to everyone. */
|
PerformKeyboardOrderOnSelection(a => new Order("Scatter", a, false));
|
||||||
foreach (var a in World.Selection.Actors)
|
return true;
|
||||||
World.IssueOrder(new Order("Scatter", a, false));
|
}
|
||||||
|
|
||||||
|
bool PerformDeploy()
|
||||||
|
{
|
||||||
|
PerformKeyboardOrderOnSelection(a => new Order("Deploy", a, false));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user