Merge branch 'master' of git://github.com/beedee/OpenRA
This commit is contained in:
@@ -124,18 +124,37 @@ namespace OpenRa.Game
|
|||||||
soundEngine.Play2D(sound, loop, false, false);
|
soundEngine.Play2D(sound, loop, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int lastTime = Environment.TickCount;
|
||||||
|
public const int timestep = 40;
|
||||||
|
|
||||||
|
public static void ResetTimer()
|
||||||
|
{
|
||||||
|
lastTime = Environment.TickCount;
|
||||||
|
}
|
||||||
|
|
||||||
public static void Tick()
|
public static void Tick()
|
||||||
{
|
{
|
||||||
world.Update();
|
int t = Environment.TickCount;
|
||||||
|
int dt = t - lastTime;
|
||||||
|
if( dt >= timestep )
|
||||||
|
{
|
||||||
|
lastTime += timestep;
|
||||||
|
|
||||||
|
if( controller.orderGenerator != null )
|
||||||
|
controller.orderGenerator.Tick();
|
||||||
|
|
||||||
|
world.Tick();
|
||||||
UnitInfluence.Tick();
|
UnitInfluence.Tick();
|
||||||
foreach( var player in players.Values )
|
foreach( var player in players.Values )
|
||||||
player.Tick();
|
player.Tick();
|
||||||
|
|
||||||
viewport.DrawRegions();
|
|
||||||
|
|
||||||
orderManager.Tick();
|
orderManager.Tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewport.cursor = controller.ChooseCursor();
|
||||||
|
viewport.DrawRegions();
|
||||||
|
}
|
||||||
|
|
||||||
public static bool IsCellBuildable(int2 a, UnitMovementType umt)
|
public static bool IsCellBuildable(int2 a, UnitMovementType umt)
|
||||||
{
|
{
|
||||||
if (BuildingInfluence.GetBuildingAt(a) != null) return false;
|
if (BuildingInfluence.GetBuildingAt(a) != null) return false;
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
ShowCursor(false);
|
ShowCursor(false);
|
||||||
|
|
||||||
Game.world.ResetTimer();
|
Game.ResetTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Run()
|
internal void Run()
|
||||||
@@ -79,9 +79,6 @@ namespace OpenRa.Game
|
|||||||
while (Created && Visible)
|
while (Created && Visible)
|
||||||
{
|
{
|
||||||
Game.Tick();
|
Game.Tick();
|
||||||
Game.viewport.cursor = Game.controller.ChooseCursor();
|
|
||||||
if (Game.controller.orderGenerator != null)
|
|
||||||
Game.controller.orderGenerator.Tick();
|
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ namespace OpenRa.Game
|
|||||||
List<Actor> actors = new List<Actor>();
|
List<Actor> actors = new List<Actor>();
|
||||||
List<IEffect> effects = new List<IEffect>();
|
List<IEffect> effects = new List<IEffect>();
|
||||||
List<Action<World>> frameEndActions = new List<Action<World>>();
|
List<Action<World>> frameEndActions = new List<Action<World>>();
|
||||||
int lastTime = Environment.TickCount;
|
|
||||||
const int timestep = 40;
|
|
||||||
|
|
||||||
public void Add(Actor a) { actors.Add(a); ActorAdded(a); }
|
public void Add(Actor a) { actors.Add(a); ActorAdded(a); }
|
||||||
public void Remove(Actor a) { actors.Remove(a); ActorRemoved(a); }
|
public void Remove(Actor a) { actors.Remove(a); ActorRemoved(a); }
|
||||||
@@ -30,25 +28,13 @@ namespace OpenRa.Game
|
|||||||
nr.Removed(a);
|
nr.Removed(a);
|
||||||
};
|
};
|
||||||
|
|
||||||
public void ResetTimer()
|
public void Tick()
|
||||||
{
|
{
|
||||||
lastTime = Environment.TickCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update()
|
|
||||||
{
|
|
||||||
int t = Environment.TickCount;
|
|
||||||
int dt = t - lastTime;
|
|
||||||
if (dt >= timestep)
|
|
||||||
{
|
|
||||||
lastTime += timestep;
|
|
||||||
|
|
||||||
foreach (var a in actors) a.Tick();
|
foreach (var a in actors) a.Tick();
|
||||||
foreach (var e in effects) e.Tick();
|
foreach (var e in effects) e.Tick();
|
||||||
|
|
||||||
Renderer.waterFrame += 0.00125f * timestep;
|
Renderer.waterFrame += 0.00125f * Game.timestep;
|
||||||
Game.viewport.Tick();
|
Game.viewport.Tick();
|
||||||
}
|
|
||||||
|
|
||||||
foreach (Action<World> a in frameEndActions) a(this);
|
foreach (Action<World> a in frameEndActions) a(this);
|
||||||
frameEndActions.Clear();
|
frameEndActions.Clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user