Locked frame times; SAM, GUN, AGUN work again.
- all frames are 40ms long. (except something in the sidebar, which should really be PlayFetchIndex anyway)
- SAM, GUN, and AGUN no longer crash the game when built. (Turreted used Mobile, which those buildings don't have)
This commit is contained in:
@@ -128,10 +128,10 @@ namespace OpenRa.Game
|
|||||||
traits.Add( new Traits.Tree( treeRenderer.GetImage( tree.Image ) ) );
|
traits.Add( new Traits.Tree( treeRenderer.GetImage( tree.Image ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick( Game game, int dt )
|
public void Tick( Game game )
|
||||||
{
|
{
|
||||||
foreach( var tick in traits.WithInterface<Traits.ITick>() )
|
foreach( var tick in traits.WithInterface<Traits.ITick>() )
|
||||||
tick.Tick( this, game, dt );
|
tick.Tick( this, game );
|
||||||
}
|
}
|
||||||
|
|
||||||
public float2 CenterLocation;
|
public float2 CenterLocation;
|
||||||
|
|||||||
@@ -41,12 +41,12 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
int TotalTime() { return (Dest - Src).Length * BaseBulletSpeed / Weapon.Speed; }
|
int TotalTime() { return (Dest - Src).Length * BaseBulletSpeed / Weapon.Speed; }
|
||||||
|
|
||||||
public void Tick(Game game, int dt)
|
public void Tick(Game game)
|
||||||
{
|
{
|
||||||
if (t == 0)
|
if (t == 0)
|
||||||
game.PlaySound(Weapon.Report + ".aud", false);
|
game.PlaySound(Weapon.Report + ".aud", false);
|
||||||
|
|
||||||
t += dt;
|
t += 40;
|
||||||
|
|
||||||
if (t > TotalTime()) /* remove finished bullets */
|
if (t > TotalTime()) /* remove finished bullets */
|
||||||
game.world.AddFrameEndTask(w => w.Remove(this));
|
game.world.AddFrameEndTask(w => w.Remove(this));
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ namespace OpenRa.Game.Graphics
|
|||||||
int timeUntilNextFrame;
|
int timeUntilNextFrame;
|
||||||
Action tickFunc;
|
Action tickFunc;
|
||||||
|
|
||||||
|
public void Tick()
|
||||||
|
{
|
||||||
|
Tick( 40 ); // tick one frame
|
||||||
|
}
|
||||||
|
|
||||||
public void Tick( int t )
|
public void Tick( int t )
|
||||||
{
|
{
|
||||||
if( tickAlways )
|
if( tickAlways )
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRa.Game
|
|||||||
if (game.LocalPlayer == Unit.Owner)
|
if (game.LocalPlayer == Unit.Owner)
|
||||||
game.PlaySound("ackno.r00", false);
|
game.PlaySound("ackno.r00", false);
|
||||||
var mobile = Unit.traits.Get<Traits.Mobile>();
|
var mobile = Unit.traits.Get<Traits.Mobile>();
|
||||||
mobile.destination = Destination;
|
mobile.destination = Destination;
|
||||||
mobile.desiredFacing = null;
|
mobile.desiredFacing = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace OpenRa.Game.Traits
|
|||||||
self.traits.Get<Turreted>();
|
self.traits.Get<Turreted>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick( Actor self, Game game, int dt )
|
public void Tick( Actor self, Game game )
|
||||||
{
|
{
|
||||||
if( primaryFireDelay > 0 )
|
if( primaryFireDelay > 0 )
|
||||||
--primaryFireDelay;
|
--primaryFireDelay;
|
||||||
@@ -28,7 +28,6 @@ namespace OpenRa.Game.Traits
|
|||||||
if( target == null )
|
if( target == null )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var mobile = self.traits.Get<Mobile>();
|
|
||||||
var turreted = self.traits.Get<Turreted>();
|
var turreted = self.traits.Get<Turreted>();
|
||||||
turreted.desiredFacing = Util.GetFacing( target.CenterLocation - self.CenterLocation, turreted.turretFacing );
|
turreted.desiredFacing = Util.GetFacing( target.CenterLocation - self.CenterLocation, turreted.turretFacing );
|
||||||
if( turreted.desiredFacing != turreted.turretFacing )
|
if( turreted.desiredFacing != turreted.turretFacing )
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace OpenRa.Game.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
public void Tick(Actor self, Game game, int dt)
|
public void Tick(Actor self, Game game)
|
||||||
{
|
{
|
||||||
if (first && self.Owner == game.LocalPlayer)
|
if (first && self.Owner == game.LocalPlayer)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace OpenRa.Game.Traits
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(Actor self, Game game, int dt)
|
public void Tick(Actor self, Game game)
|
||||||
{
|
{
|
||||||
if( self.Location != DeployLocation )
|
if( self.Location != DeployLocation )
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ namespace OpenRa.Game.Traits
|
|||||||
self.CenterLocation = new float2(12, 12) + Game.CellSize * float2.Lerp(fromCell, toCell, fraction);
|
self.CenterLocation = new float2(12, 12) + Game.CellSize * float2.Lerp(fromCell, toCell, fraction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(Actor self, Game game, int dt)
|
public void Tick(Actor self, Game game)
|
||||||
{
|
{
|
||||||
Move(self, game, dt);
|
Move(self, game);
|
||||||
UpdateCenterLocation();
|
UpdateCenterLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Move(Actor self, Game game, int dt)
|
void Move(Actor self, Game game)
|
||||||
{
|
{
|
||||||
if( fromCell != toCell )
|
if( fromCell != toCell )
|
||||||
desiredFacing = Util.GetFacing( toCell - fromCell, facing );
|
desiredFacing = Util.GetFacing( toCell - fromCell, facing );
|
||||||
@@ -48,7 +48,7 @@ namespace OpenRa.Game.Traits
|
|||||||
desiredFacing = null;
|
desiredFacing = null;
|
||||||
|
|
||||||
if( fromCell != toCell )
|
if( fromCell != toCell )
|
||||||
moveFraction += dt * ((UnitInfo.MobileInfo)self.unitInfo).Speed;
|
moveFraction += ((UnitInfo.MobileInfo)self.unitInfo).Speed;
|
||||||
|
|
||||||
if (moveFraction < moveFractionTotal)
|
if (moveFraction < moveFractionTotal)
|
||||||
return;
|
return;
|
||||||
@@ -66,7 +66,7 @@ namespace OpenRa.Game.Traits
|
|||||||
self.Location = res[res.Count - 1];
|
self.Location = res[res.Count - 1];
|
||||||
|
|
||||||
int2 dir = toCell - fromCell;
|
int2 dir = toCell - fromCell;
|
||||||
moveFractionTotal = (dir.X != 0 && dir.Y != 0) ? 2500 : 2000;
|
moveFractionTotal = (dir.X != 0 && dir.Y != 0) ? 70 : 50;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
destination = toCell;
|
destination = toCell;
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ namespace OpenRa.Game.Traits
|
|||||||
return base.Render(self);
|
return base.Render(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Tick(Actor self, Game game, int dt)
|
public override void Tick(Actor self, Game game)
|
||||||
{
|
{
|
||||||
base.Tick(self, game, dt);
|
base.Tick(self, game);
|
||||||
roof.Tick(dt);
|
roof.Tick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
public abstract IEnumerable<Pair<Sprite, float2>> Render(Actor self);
|
public abstract IEnumerable<Pair<Sprite, float2>> Render(Actor self);
|
||||||
|
|
||||||
public virtual void Tick(Actor self, Game game, int dt)
|
public virtual void Tick(Actor self, Game game)
|
||||||
{
|
{
|
||||||
anim.Tick(dt);
|
anim.Tick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ namespace OpenRa.Game.Traits
|
|||||||
yield return Centered(turretAnim.Image, self.CenterLocation);
|
yield return Centered(turretAnim.Image, self.CenterLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Tick(Actor self, Game game, int dt)
|
public override void Tick(Actor self, Game game)
|
||||||
{
|
{
|
||||||
base.Tick(self, game, dt);
|
base.Tick(self, game);
|
||||||
turretAnim.Tick(dt);
|
turretAnim.Tick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using IjwFramework.Types;
|
|||||||
|
|
||||||
namespace OpenRa.Game.Traits
|
namespace OpenRa.Game.Traits
|
||||||
{
|
{
|
||||||
interface ITick { void Tick(Actor self, Game game, int dt); }
|
interface ITick { void Tick(Actor self, Game game); }
|
||||||
interface IRender { IEnumerable<Pair<Sprite, float2>> Render(Actor self); }
|
interface IRender { IEnumerable<Pair<Sprite, float2>> Render(Actor self); }
|
||||||
interface IOrder { Order Order(Actor self, Game game, int2 xy); }
|
interface IOrder { Order Order(Actor self, Game game, int2 xy); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,12 +14,9 @@ namespace OpenRa.Game.Traits
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick( Actor self, Game game, int dt )
|
public void Tick( Actor self, Game game )
|
||||||
{
|
{
|
||||||
// TODO: desiredFacing should follow the base unit's facing only when not in combat.
|
var df = desiredFacing ?? ( self.traits.Contains<Mobile>() ? self.traits.Get<Mobile>().facing : turretFacing );
|
||||||
// also, we want to be able to use this for GUN; avoid referencing Mobile.
|
|
||||||
var df = desiredFacing ?? self.traits.Get<Mobile>().facing;
|
|
||||||
|
|
||||||
Util.TickFacing( ref turretFacing, df, self.unitInfo.ROT );
|
Util.TickFacing( ref turretFacing, df, self.unitInfo.ROT );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ namespace OpenRa.Game
|
|||||||
lastTime += timestep;
|
lastTime += timestep;
|
||||||
|
|
||||||
foreach( var a in actors )
|
foreach( var a in actors )
|
||||||
a.Tick(game, timestep);
|
a.Tick(game);
|
||||||
foreach (var b in bullets)
|
foreach (var b in bullets)
|
||||||
b.Tick(game, timestep);
|
b.Tick(game);
|
||||||
|
|
||||||
Renderer.waterFrame += 0.00125f * timestep;
|
Renderer.waterFrame += 0.00125f * timestep;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user