notifications (formerly EVAalerts) centralized and race specific
outsourced into notifications.yaml triggered with PlayNotification(...) (v2: less redundant code for PlayVoice/Notifications) added harvester under attack and battlecontrol terminated
This commit is contained in:
committed by
Chris Forbes
parent
5fee165692
commit
7a578a0679
@@ -246,7 +246,45 @@ namespace OpenRA
|
||||
get { return (video != null) ? video.SeekPosition : 0; }
|
||||
}
|
||||
|
||||
// Returns true if it played a phrase
|
||||
// Returns true if played successfully
|
||||
public static bool PlayPredefined(Player p, Actor voicedUnit, string type, string definition, string variant)
|
||||
{
|
||||
if (definition == null) return false;
|
||||
|
||||
var rules = (voicedUnit != null) ? Rules.Voices[type] : Rules.Notifications[type];
|
||||
|
||||
var ID = (voicedUnit != null) ? voicedUnit.ActorID : 0;
|
||||
|
||||
var clip = (voicedUnit != null) ? rules.VoicePools.Value[definition].GetNext() : rules.NotificationsPools.Value[definition].GetNext();
|
||||
if (clip == null) return false;
|
||||
|
||||
var suffix = rules.DefaultVariant;
|
||||
var prefix = rules.DefaultPrefix;
|
||||
|
||||
if (voicedUnit != null)
|
||||
{
|
||||
if (!rules.VoicePools.Value.ContainsKey("Attack"))
|
||||
rules.VoicePools.Value.Add("Attack", rules.VoicePools.Value["Move"]);
|
||||
|
||||
if (!rules.VoicePools.Value.ContainsKey("AttackMove"))
|
||||
rules.VoicePools.Value.Add("AttackMove", rules.VoicePools.Value["Move"]);
|
||||
}
|
||||
|
||||
if (variant != null)
|
||||
{
|
||||
if (rules.Variants.ContainsKey(variant) && !rules.DisableVariants.Contains(definition))
|
||||
suffix = rules.Variants[variant][ID % rules.Variants[variant].Length];
|
||||
if (rules.Prefixes.ContainsKey(variant) && !rules.DisablePrefixes.Contains(definition))
|
||||
prefix = rules.Prefixes[variant][ID % rules.Prefixes[variant].Length];
|
||||
}
|
||||
|
||||
if (p == null)
|
||||
Play(prefix + clip + suffix);
|
||||
else
|
||||
PlayToPlayer(p, prefix + clip + suffix);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool PlayVoice(string phrase, Actor voicedUnit, string variant)
|
||||
{
|
||||
if (voicedUnit == null) return false;
|
||||
@@ -256,21 +294,17 @@ namespace OpenRA
|
||||
if (mi == null) return false;
|
||||
if (mi.Voice == null) return false;
|
||||
|
||||
var vi = Rules.Voices[mi.Voice.ToLowerInvariant()];
|
||||
var type = mi.Voice.ToLowerInvariant();
|
||||
|
||||
if (!vi.Pools.Value.ContainsKey(phrase))
|
||||
return false;
|
||||
return PlayPredefined(null, voicedUnit, type, phrase, variant);
|
||||
}
|
||||
|
||||
var clip = vi.Pools.Value[phrase].GetNext();
|
||||
if (clip == null)
|
||||
return false;
|
||||
public static bool PlayNotification(Player player, string type, string notification, string variant)
|
||||
{
|
||||
if (type == null) return false;
|
||||
if (notification == null) return false;
|
||||
|
||||
var variantExt = (vi.Variants.ContainsKey(variant) && !vi.DisableVariants.Contains(phrase)) ?
|
||||
vi.Variants[variant][voicedUnit.ActorID % vi.Variants[variant].Length] : vi.DefaultVariant;
|
||||
var prefix = (vi.Prefixes.ContainsKey(variant) && !vi.DisablePrefixes.Contains(phrase)) ?
|
||||
vi.Prefixes[variant][voicedUnit.ActorID % vi.Prefixes[variant].Length] : vi.DefaultPrefix;
|
||||
Play(prefix + clip + variantExt);
|
||||
return true;
|
||||
return PlayPredefined(player, null, type.ToLowerInvariant(), notification, variant);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user