Play game started audio notifications just as the game starts.
Previously the StartGameNotification and MusicPlaylist traits used the IWorldLoaded interface to play an audio notification and begin music when the game started. However this interface is used by many traits to perform initial loading whilst the load screen was visible, and this loading can take time. Since the traits could run in any order, then audio notification might fire before another trait with a long loading time. This is not ideal as we want the time between the audio notification occurring and the player being able to interact to be as short and reliable as possible. Now, we introduce a new IPostWorldLoaded which runs after all other loading activity, and we switch StartGameNotification and MusicPlaylist to use it. This allows timing sensitive traits that want to run right at the end of loading to fire reliably and with minimal delay. The player perception of hearing the notification and being able to interact is now much snappier.
This commit is contained in:
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public override object Create(ActorInitializer init) { return new MusicPlaylist(init.World, this); }
|
||||
}
|
||||
|
||||
public class MusicPlaylist : INotifyActorDisposing, IGameOver, IWorldLoaded, INotifyGameLoaded
|
||||
public class MusicPlaylist : INotifyActorDisposing, IGameOver, IPostWorldLoaded, INotifyGameLoaded
|
||||
{
|
||||
readonly MusicPlaylistInfo info;
|
||||
readonly World world;
|
||||
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
void IWorldLoaded.WorldLoaded(World world, WorldRenderer wr)
|
||||
void IPostWorldLoaded.PostWorldLoaded(World world, WorldRenderer wr)
|
||||
{
|
||||
// Reset any bogus pre-existing state
|
||||
Game.Sound.DisableWorldSounds = info.DisableWorldSounds;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public override object Create(ActorInitializer init) { return new StartGameNotification(this); }
|
||||
}
|
||||
|
||||
sealed class StartGameNotification : IWorldLoaded, INotifyGameLoaded, INotifyGameSaved
|
||||
sealed class StartGameNotification : IPostWorldLoaded, INotifyGameLoaded, INotifyGameSaved
|
||||
{
|
||||
readonly StartGameNotificationInfo info;
|
||||
public StartGameNotification(StartGameNotificationInfo info)
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
void IWorldLoaded.WorldLoaded(World world, WorldRenderer wr)
|
||||
void IPostWorldLoaded.PostWorldLoaded(World world, WorldRenderer wr)
|
||||
{
|
||||
if (!world.IsLoadingGameSave)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user