Implement "Game Saved" / "Game Loaded" notifications in RA and D2k.

This commit is contained in:
Paul Chote
2019-04-20 10:35:20 +00:00
committed by reaperrr
parent 492b5aec82
commit d5588c51ed
5 changed files with 27 additions and 4 deletions

View File

@@ -19,10 +19,16 @@ namespace OpenRA.Mods.Common.Traits
[NotificationReference("Speech")]
public readonly string Notification = "StartGame";
[NotificationReference("Speech")]
public readonly string LoadedNotification = "GameLoaded";
[NotificationReference("Speech")]
public readonly string SavedNotification = "GameSaved";
public object Create(ActorInitializer init) { return new StartGameNotification(this); }
}
class StartGameNotification : IWorldLoaded
class StartGameNotification : IWorldLoaded, INotifyGameLoaded, INotifyGameSaved
{
StartGameNotificationInfo info;
public StartGameNotification(StartGameNotificationInfo info)
@@ -35,5 +41,17 @@ namespace OpenRA.Mods.Common.Traits
if (!world.IsLoadingGameSave)
Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.Notification, world.RenderPlayer == null ? null : world.RenderPlayer.Faction.InternalName);
}
void INotifyGameLoaded.GameLoaded(World world)
{
if (!world.IsReplay)
Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.LoadedNotification, world.RenderPlayer == null ? null : world.RenderPlayer.Faction.InternalName);
}
void INotifyGameSaved.GameSaved(World world)
{
if (!world.IsReplay)
Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.SavedNotification, world.RenderPlayer == null ? null : world.RenderPlayer.Faction.InternalName);
}
}
}