Set the viewport on world load
This commit is contained in:
@@ -153,14 +153,20 @@ namespace OpenRA
|
||||
var manifest = new Manifest(LobbyInfo.GlobalSettings.Mods);
|
||||
Timer.Time( "manifest: {0}" );
|
||||
|
||||
if (!Game.AvailableMaps.ContainsKey(mapName))
|
||||
throw new InvalidDataException("Cannot find map with Uid {0}".F(mapName));
|
||||
|
||||
var map = new Map( Game.AvailableMaps[mapName].Package );
|
||||
|
||||
viewport = new Viewport(clientSize, map.TopLeft, map.BottomRight, renderer);
|
||||
world = null; // trying to access the old world will NRE, rather than silently doing it wrong.
|
||||
ChromeProvider.Initialize(manifest.Chrome);
|
||||
world = new World(manifest,mapName);
|
||||
Timer.Time( "viewport, ChromeProvider: {0}" );
|
||||
world = new World(manifest,map);
|
||||
Timer.Time( "world: {0}" );
|
||||
|
||||
SequenceProvider.Initialize(manifest.Sequences);
|
||||
viewport = new Viewport(clientSize, Game.world.Map.TopLeft, Game.world.Map.BottomRight, renderer);
|
||||
Timer.Time( "ChromeProv, SeqProv, viewport: {0}" );
|
||||
Timer.Time( "ChromeProv, SeqProv: {0}" );
|
||||
|
||||
chrome = new Chrome(renderer, manifest);
|
||||
Timer.Time( "chrome: {0}" );
|
||||
|
||||
@@ -75,15 +75,10 @@ namespace OpenRA
|
||||
public readonly WorldRenderer WorldRenderer;
|
||||
internal readonly Minimap Minimap;
|
||||
|
||||
public World(Manifest manifest, string mapUid)
|
||||
public World(Manifest manifest, Map map)
|
||||
{
|
||||
Timer.Time( "----World.ctor" );
|
||||
|
||||
if (!Game.AvailableMaps.ContainsKey(mapUid))
|
||||
throw new InvalidDataException("Cannot find map with Uid {0}".F(mapUid));
|
||||
|
||||
Map = new Map( Game.AvailableMaps[mapUid].Package );
|
||||
|
||||
Map = map;
|
||||
|
||||
customTerrain = new ICustomTerrain[Map.MapSize.X, Map.MapSize.Y];
|
||||
Timer.Time( "new Map: {0}" );
|
||||
|
||||
@@ -29,16 +29,19 @@ namespace OpenRA.Mods.RA
|
||||
public object Create(Actor self) { return new DefaultShellmapScript(); }
|
||||
}
|
||||
|
||||
class DefaultShellmapScript : ITick
|
||||
class DefaultShellmapScript : ITick, ILoadWorldHook
|
||||
{
|
||||
public void WorldLoaded(World w)
|
||||
{
|
||||
// Set the viewport location
|
||||
Game.MoveViewport(new int2(85,65));
|
||||
}
|
||||
|
||||
// Rude hack around the multiple-creation bug:
|
||||
// wait long enough for the transient copies to die before starting
|
||||
int initialDelay = 20;
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
// Another rude hack
|
||||
Game.MoveViewport(new int2(85,65));
|
||||
|
||||
if (initialDelay > 0 && --initialDelay == 0)
|
||||
Sound.PlayMusic("hell226m.aud");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user