Add a 'Voice' field to RepairableNearInfo
This commit is contained in:
@@ -63,6 +63,7 @@ namespace OpenRA
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
foreach (var voice in orderSubject.TraitsImplementing<IVoiced>())
|
foreach (var voice in orderSubject.TraitsImplementing<IVoiced>())
|
||||||
|
{
|
||||||
foreach (var v in orderSubject.TraitsImplementing<IOrderVoice>())
|
foreach (var v in orderSubject.TraitsImplementing<IOrderVoice>())
|
||||||
{
|
{
|
||||||
if (voice.PlayVoice(orderSubject, v.VoicePhraseForOrder(orderSubject, o),
|
if (voice.PlayVoice(orderSubject, v.VoicePhraseForOrder(orderSubject, o),
|
||||||
@@ -73,3 +74,4 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,12 +20,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
class RepairableNearInfo : ITraitInfo, Requires<HealthInfo>, Requires<IMoveInfo>
|
class RepairableNearInfo : ITraitInfo, Requires<HealthInfo>, Requires<IMoveInfo>
|
||||||
{
|
{
|
||||||
[ActorReference] public readonly HashSet<string> Buildings = new HashSet<string> { "spen", "syrd" };
|
[ActorReference] public readonly HashSet<string> Buildings = new HashSet<string> { "spen", "syrd" };
|
||||||
public readonly int CloseEnough = 4; /* cells */
|
public readonly int CloseEnough = 4;
|
||||||
|
[VoiceReference] public readonly string Voice = "Action";
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new RepairableNear(init.Self, this); }
|
public object Create(ActorInitializer init) { return new RepairableNear(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class RepairableNear : IIssueOrder, IResolveOrder
|
class RepairableNear : IIssueOrder, IResolveOrder, IOrderVoice
|
||||||
{
|
{
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
readonly RepairableNearInfo info;
|
readonly RepairableNearInfo info;
|
||||||
@@ -65,6 +66,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return self.GetDamageState() > DamageState.Undamaged;
|
return self.GetDamageState() > DamageState.Undamaged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string VoicePhraseForOrder(Actor self, Order order)
|
||||||
|
{
|
||||||
|
return (order.OrderString == "RepairNear" && ShouldRepair()) ? info.Voice : null;
|
||||||
|
}
|
||||||
|
|
||||||
public void ResolveOrder(Actor self, Order order)
|
public void ResolveOrder(Actor self, Order order)
|
||||||
{
|
{
|
||||||
if (order.OrderString == "RepairNear" && CanRepairAt(order.TargetActor) && ShouldRepair())
|
if (order.OrderString == "RepairNear" && CanRepairAt(order.TargetActor) && ShouldRepair())
|
||||||
|
|||||||
Reference in New Issue
Block a user