Add a function to World for setting just the local pause state, and add a lock variable to prevent further pause state changes
This commit is contained in:
@@ -46,7 +46,7 @@ namespace OpenRA
|
|||||||
public bool ObserveAfterWinOrLose;
|
public bool ObserveAfterWinOrLose;
|
||||||
public Player RenderPlayer
|
public Player RenderPlayer
|
||||||
{
|
{
|
||||||
get { return renderPlayer == null || (ObserveAfterWinOrLose && renderPlayer.WinState != WinState.Undefined)? null : renderPlayer; }
|
get { return renderPlayer == null || (ObserveAfterWinOrLose && renderPlayer.WinState != WinState.Undefined) ? null : renderPlayer; }
|
||||||
set { renderPlayer = value; }
|
set { renderPlayer = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ namespace OpenRA
|
|||||||
get { return orderGenerator_; }
|
get { return orderGenerator_; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
Sync.AssertUnsynced( "The current order generator may not be changed from synced code" );
|
Sync.AssertUnsynced("The current order generator may not be changed from synced code");
|
||||||
orderGenerator_ = value;
|
orderGenerator_ = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,16 +145,16 @@ namespace OpenRA
|
|||||||
wlh.WorldLoaded(this, wr);
|
wlh.WorldLoaded(this, wr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Actor CreateActor( string name, TypeDictionary initDict )
|
public Actor CreateActor(string name, TypeDictionary initDict)
|
||||||
{
|
{
|
||||||
return CreateActor( true, name, initDict );
|
return CreateActor(true, name, initDict);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Actor CreateActor( bool addToWorld, string name, TypeDictionary initDict )
|
public Actor CreateActor(bool addToWorld, string name, TypeDictionary initDict)
|
||||||
{
|
{
|
||||||
var a = new Actor( this, name, initDict );
|
var a = new Actor(this, name, initDict);
|
||||||
if( addToWorld )
|
if (addToWorld)
|
||||||
Add( a );
|
Add(a);
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,14 +188,23 @@ namespace OpenRA
|
|||||||
|
|
||||||
public bool Paused { get; internal set; }
|
public bool Paused { get; internal set; }
|
||||||
public bool PredictedPaused { get; internal set; }
|
public bool PredictedPaused { get; internal set; }
|
||||||
|
public bool PauseStateLocked { get; set; }
|
||||||
public bool IsShellmap = false;
|
public bool IsShellmap = false;
|
||||||
|
|
||||||
public void SetPauseState(bool paused)
|
public void SetPauseState(bool paused)
|
||||||
{
|
{
|
||||||
|
if (PauseStateLocked)
|
||||||
|
return;
|
||||||
|
|
||||||
IssueOrder(Order.PauseGame(paused));
|
IssueOrder(Order.PauseGame(paused));
|
||||||
PredictedPaused = paused;
|
PredictedPaused = paused;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetLocalPauseState(bool paused)
|
||||||
|
{
|
||||||
|
Paused = PredictedPaused = paused;
|
||||||
|
}
|
||||||
|
|
||||||
public void Tick()
|
public void Tick()
|
||||||
{
|
{
|
||||||
if (!Paused && (!IsShellmap || Game.Settings.Game.ShowShellmap))
|
if (!Paused && (!IsShellmap || Game.Settings.Game.ShowShellmap))
|
||||||
@@ -206,7 +215,7 @@ namespace OpenRA
|
|||||||
ni.Trait.TickIdle(ni.Actor);
|
ni.Trait.TickIdle(ni.Actor);
|
||||||
|
|
||||||
using (new PerfSample("tick_activities"))
|
using (new PerfSample("tick_activities"))
|
||||||
foreach(var a in actors)
|
foreach (var a in actors)
|
||||||
a.Tick();
|
a.Tick();
|
||||||
|
|
||||||
ActorsWithTrait<ITick>().DoTimed(x => x.Trait.Tick(x.Actor),
|
ActorsWithTrait<ITick>().DoTimed(x => x.Trait.Tick(x.Actor),
|
||||||
@@ -246,11 +255,11 @@ namespace OpenRA
|
|||||||
|
|
||||||
// hash all the actors
|
// hash all the actors
|
||||||
foreach (var a in Actors)
|
foreach (var a in Actors)
|
||||||
ret += n++ * (int)(1+a.ActorID) * Sync.CalculateSyncHash(a);
|
ret += n++ * (int)(1 + a.ActorID) * Sync.CalculateSyncHash(a);
|
||||||
|
|
||||||
// hash all the traits that tick
|
// hash all the traits that tick
|
||||||
foreach (var x in traitDict.ActorsWithTraitMultiple<ISync>(this))
|
foreach (var x in traitDict.ActorsWithTraitMultiple<ISync>(this))
|
||||||
ret += n++ * (int)(1+x.Actor.ActorID) * Sync.CalculateSyncHash(x.Trait);
|
ret += n++ * (int)(1 + x.Actor.ActorID) * Sync.CalculateSyncHash(x.Trait);
|
||||||
|
|
||||||
// TODO: don't go over all effects
|
// TODO: don't go over all effects
|
||||||
foreach (var e in Effects)
|
foreach (var e in Effects)
|
||||||
@@ -280,7 +289,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return "{0}->{1}".F( Actor.Info.Name, Trait.GetType().Name );
|
return "{0}->{1}".F(Actor.Info.Name, Trait.GetType().Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user