added Sound.PlayToPlayer. changed existing if(localPlayer) Play() idiom to use it. fixed two places that used Play where PlayToPlayer was correct (mcvUndeploy and "spyplane ready")
This commit is contained in:
@@ -88,10 +88,9 @@ namespace OpenRa
|
|||||||
|
|
||||||
void GiveAdvice(string advice)
|
void GiveAdvice(string advice)
|
||||||
{
|
{
|
||||||
if (this != World.LocalPlayer) return;
|
|
||||||
// todo: store the condition or something.
|
// todo: store the condition or something.
|
||||||
// repeat after Rules.General.SpeakDelay, as long as the condition holds.
|
// repeat after Rules.General.SpeakDelay, as long as the condition holds.
|
||||||
Sound.Play(advice);
|
Sound.PlayToPlayer(this, advice);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GiveCash( int num ) { Cash += num; }
|
public void GiveCash( int num ) { Cash += num; }
|
||||||
@@ -129,22 +128,19 @@ namespace OpenRa
|
|||||||
UpdateOreCapacity();
|
UpdateOreCapacity();
|
||||||
Shroud.Tick( World );
|
Shroud.Tick( World );
|
||||||
|
|
||||||
if (this == World.LocalPlayer)
|
var totalMoney = Cash + Ore;
|
||||||
{
|
|
||||||
var totalMoney = Cash + Ore;
|
|
||||||
|
|
||||||
if (DisplayCash < totalMoney)
|
if (DisplayCash < totalMoney)
|
||||||
{
|
{
|
||||||
DisplayCash += Math.Min(displayCashDeltaPerFrame,
|
DisplayCash += Math.Min(displayCashDeltaPerFrame,
|
||||||
totalMoney - DisplayCash);
|
totalMoney - DisplayCash);
|
||||||
Sound.Play("cashup1.aud");
|
Sound.PlayToPlayer(this, "cashup1.aud");
|
||||||
}
|
}
|
||||||
else if (DisplayCash > totalMoney)
|
else if (DisplayCash > totalMoney)
|
||||||
{
|
{
|
||||||
DisplayCash -= Math.Min(displayCashDeltaPerFrame,
|
DisplayCash -= Math.Min(displayCashDeltaPerFrame,
|
||||||
DisplayCash - totalMoney);
|
DisplayCash - totalMoney);
|
||||||
Sound.Play("cashdn1.aud");
|
Sound.PlayToPlayer(this, "cashdn1.aud");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,12 @@ namespace OpenRa
|
|||||||
soundEngine.Play2D(sound, false);
|
soundEngine.Play2D(sound, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void PlayToPlayer(Player player, string name)
|
||||||
|
{
|
||||||
|
if( player == player.World.LocalPlayer )
|
||||||
|
Play( name );
|
||||||
|
}
|
||||||
|
|
||||||
public static void PlayMusic(string name)
|
public static void PlayMusic(string name)
|
||||||
{
|
{
|
||||||
var sound = sounds[name];
|
var sound = sounds[name];
|
||||||
|
|||||||
@@ -12,11 +12,8 @@ namespace OpenRa.Traits.Activities
|
|||||||
{
|
{
|
||||||
self.Health = 0;
|
self.Health = 0;
|
||||||
self.World.Remove( self );
|
self.World.Remove( self );
|
||||||
if (self.Owner == self.World.LocalPlayer)
|
Sound.PlayToPlayer(self.Owner, "placbldg.aud");
|
||||||
{
|
Sound.PlayToPlayer(self.Owner, "build5.aud");
|
||||||
Sound.Play("placbldg.aud");
|
|
||||||
Sound.Play("build5.aud");
|
|
||||||
}
|
|
||||||
self.World.CreateActor( "fact", self.Location - new int2( 1, 1 ), self.Owner );
|
self.World.CreateActor( "fact", self.Location - new int2( 1, 1 ), self.Owner );
|
||||||
} );
|
} );
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRa.Traits.Activities
|
|||||||
rb.PlayCustomAnimBackwards(self, "make",
|
rb.PlayCustomAnimBackwards(self, "make",
|
||||||
() => self.World.AddFrameEndTask(w => DoUndeploy(w,self)));
|
() => self.World.AddFrameEndTask(w => DoUndeploy(w,self)));
|
||||||
|
|
||||||
Sound.Play("cashturn.aud");
|
Sound.PlayToPlayer(self.Owner, "cashturn.aud");
|
||||||
started = true;
|
started = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,7 @@ namespace OpenRa.Traits
|
|||||||
if (order.OrderString == "PowerDown")
|
if (order.OrderString == "PowerDown")
|
||||||
{
|
{
|
||||||
IsDisabled = !IsDisabled;
|
IsDisabled = !IsDisabled;
|
||||||
if (self.Owner == self.World.LocalPlayer)
|
Sound.PlayToPlayer(self.Owner, IsDisabled ? "bleep12.aud" : "bleep11.aud");
|
||||||
Sound.Play(IsDisabled ? "bleep12.aud" : "bleep11.aud");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ namespace OpenRa.Traits
|
|||||||
class ChronoshiftPower : SupportPower, IResolveOrder
|
class ChronoshiftPower : SupportPower, IResolveOrder
|
||||||
{
|
{
|
||||||
public ChronoshiftPower(Actor self, ChronoshiftPowerInfo info) : base(self, info) { }
|
public ChronoshiftPower(Actor self, ChronoshiftPowerInfo info) : base(self, info) { }
|
||||||
protected override void OnBeginCharging() { if (Owner == Owner.World.LocalPlayer) Sound.Play("chrochr1.aud"); }
|
protected override void OnBeginCharging() { Sound.PlayToPlayer(Owner, "chrochr1.aud"); }
|
||||||
protected override void OnFinishCharging() { if (Owner == Owner.World.LocalPlayer) Sound.Play("chrordy1.aud"); }
|
protected override void OnFinishCharging() { Sound.PlayToPlayer(Owner, "chrordy1.aud"); }
|
||||||
protected override void OnActivate()
|
protected override void OnActivate()
|
||||||
{
|
{
|
||||||
Game.controller.orderGenerator = new SelectTarget();
|
Game.controller.orderGenerator = new SelectTarget();
|
||||||
@@ -36,7 +36,7 @@ namespace OpenRa.Traits
|
|||||||
{
|
{
|
||||||
if (self.Owner == self.World.LocalPlayer)
|
if (self.Owner == self.World.LocalPlayer)
|
||||||
Game.controller.CancelInputMode();
|
Game.controller.CancelInputMode();
|
||||||
|
|
||||||
// Cannot chronoshift into unexplored location
|
// Cannot chronoshift into unexplored location
|
||||||
if (!self.Owner.Shroud.IsExplored(order.TargetLocation))
|
if (!self.Owner.Shroud.IsExplored(order.TargetLocation))
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ namespace OpenRa.Traits
|
|||||||
|
|
||||||
Owner.World.AddFrameEndTask(w =>
|
Owner.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
if (Owner == Owner.World.LocalPlayer)
|
Sound.PlayToPlayer(Owner, "satlnch1.aud");
|
||||||
Sound.Play("satlnch1.aud");
|
|
||||||
|
|
||||||
w.Add(new SatelliteLaunch(launchSite));
|
w.Add(new SatelliteLaunch(launchSite));
|
||||||
w.Add(new DelayedAction((Info as GpsPowerInfo).RevealDelay * 25,
|
w.Add(new DelayedAction((Info as GpsPowerInfo).RevealDelay * 25,
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ namespace OpenRa.Traits
|
|||||||
{
|
{
|
||||||
public IronCurtainPower(Actor self, IronCurtainPowerInfo info) : base(self, info) { }
|
public IronCurtainPower(Actor self, IronCurtainPowerInfo info) : base(self, info) { }
|
||||||
|
|
||||||
protected override void OnBeginCharging() { if (Owner == Owner.World.LocalPlayer) Sound.Play("ironchg1.aud"); }
|
protected override void OnBeginCharging() { Sound.PlayToPlayer(Owner, "ironchg1.aud"); }
|
||||||
protected override void OnFinishCharging() { if (Owner == Owner.World.LocalPlayer) Sound.Play("ironrdy1.aud"); }
|
protected override void OnFinishCharging() { Sound.PlayToPlayer(Owner, "ironrdy1.aud"); }
|
||||||
protected override void OnActivate()
|
protected override void OnActivate()
|
||||||
{
|
{
|
||||||
Game.controller.orderGenerator = new SelectTarget();
|
Game.controller.orderGenerator = new SelectTarget();
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ namespace OpenRa.Traits
|
|||||||
{
|
{
|
||||||
public NukePower(Actor self, NukePowerInfo info) : base(self, info) { }
|
public NukePower(Actor self, NukePowerInfo info) : base(self, info) { }
|
||||||
|
|
||||||
protected override void OnBeginCharging() { if (Owner == Owner.World.LocalPlayer) Sound.Play("aprep1.aud"); }
|
protected override void OnBeginCharging() { Sound.PlayToPlayer(Owner, "aprep1.aud"); }
|
||||||
protected override void OnFinishCharging() { if (Owner == Owner.World.LocalPlayer) Sound.Play("aready1.aud"); }
|
protected override void OnFinishCharging() { Sound.PlayToPlayer(Owner, "aready1.aud"); }
|
||||||
protected override void OnActivate()
|
protected override void OnActivate()
|
||||||
{
|
{
|
||||||
Game.controller.orderGenerator = new SelectTarget();
|
Game.controller.orderGenerator = new SelectTarget();
|
||||||
|
|||||||
@@ -23,11 +23,8 @@ namespace OpenRa.Traits
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
self.World.CreateActor( order.TargetString, order.TargetLocation, order.Player );
|
self.World.CreateActor( order.TargetString, order.TargetLocation, order.Player );
|
||||||
if (order.Player == self.World.LocalPlayer)
|
Sound.PlayToPlayer(order.Player, "placbldg.aud");
|
||||||
{
|
Sound.PlayToPlayer(order.Player, "build5.aud");
|
||||||
Sound.Play("placbldg.aud");
|
|
||||||
Sound.Play("build5.aud");
|
|
||||||
}
|
|
||||||
|
|
||||||
queue.FinishProduction(unit.Category);
|
queue.FinishProduction(unit.Category);
|
||||||
} );
|
} );
|
||||||
|
|||||||
@@ -96,8 +96,7 @@ namespace OpenRa.Traits
|
|||||||
}
|
}
|
||||||
isPrimary = true;
|
isPrimary = true;
|
||||||
|
|
||||||
if (self.Owner == self.World.LocalPlayer)
|
Sound.PlayToPlayer(self.Owner, "pribldg1.aud");
|
||||||
Sound.Play("pribldg1.aud");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,9 +53,9 @@ namespace OpenRa.Traits
|
|||||||
_ =>
|
_ =>
|
||||||
{
|
{
|
||||||
var isBuilding = unit.Traits.Contains<BuildingInfo>();
|
var isBuilding = unit.Traits.Contains<BuildingInfo>();
|
||||||
if( !hasPlayedSound && order.Player == self.World.LocalPlayer )
|
if( !hasPlayedSound )
|
||||||
{
|
{
|
||||||
Sound.Play( isBuilding ? "conscmp1.aud" : "unitrdy1.aud" );
|
Sound.PlayToPlayer( order.Player, isBuilding ? "conscmp1.aud" : "unitrdy1.aud" );
|
||||||
hasPlayedSound = true;
|
hasPlayedSound = true;
|
||||||
}
|
}
|
||||||
if( !isBuilding )
|
if( !isBuilding )
|
||||||
|
|||||||
@@ -95,9 +95,7 @@ namespace OpenRa.Traits
|
|||||||
public void Selling( Actor self )
|
public void Selling( Actor self )
|
||||||
{
|
{
|
||||||
anim.PlayBackwardsThen( "make", null );
|
anim.PlayBackwardsThen( "make", null );
|
||||||
|
Sound.PlayToPlayer(self.Owner, "cashturn.aud");
|
||||||
if (self.Owner == self.World.LocalPlayer)
|
|
||||||
Sound.Play("cashturn.aud");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Sold(Actor self) { DoBib(self, true); }
|
public void Sold(Actor self) { DoBib(self, true); }
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace OpenRa.Traits
|
|||||||
public SonarPulsePower(Actor self, SonarPulsePowerInfo info) : base(self, info) { }
|
public SonarPulsePower(Actor self, SonarPulsePowerInfo info) : base(self, info) { }
|
||||||
|
|
||||||
protected override void OnBeginCharging() { }
|
protected override void OnBeginCharging() { }
|
||||||
protected override void OnFinishCharging() { if (Owner == Owner.World.LocalPlayer) Sound.Play("pulse1.aud"); }
|
protected override void OnFinishCharging() { Sound.PlayToPlayer(Owner, "pulse1.aud"); }
|
||||||
|
|
||||||
protected override void OnActivate()
|
protected override void OnActivate()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace OpenRa.Traits
|
|||||||
{
|
{
|
||||||
public SpyPlanePower(Actor self, SpyPlanePowerInfo info) : base(self, info) { }
|
public SpyPlanePower(Actor self, SpyPlanePowerInfo info) : base(self, info) { }
|
||||||
|
|
||||||
protected override void OnFinishCharging() { Sound.Play("spypln1.aud"); }
|
protected override void OnFinishCharging() { Sound.PlayToPlayer(Owner, "spypln1.aud"); }
|
||||||
protected override void OnActivate()
|
protected override void OnActivate()
|
||||||
{
|
{
|
||||||
Game.controller.orderGenerator = new SelectTarget();
|
Game.controller.orderGenerator = new SelectTarget();
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ namespace OpenRa.Traits
|
|||||||
self.Owner.TakeCash(toSteal);
|
self.Owner.TakeCash(toSteal);
|
||||||
thief.Owner.GiveCash(toSteal);
|
thief.Owner.GiveCash(toSteal);
|
||||||
|
|
||||||
if (self.World.LocalPlayer == thief.Owner)
|
Sound.PlayToPlayer(thief.Owner, "credit1.aud");
|
||||||
Sound.Play("credit1.aud");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<PipType> GetPips(Actor self)
|
public IEnumerable<PipType> GetPips(Actor self)
|
||||||
|
|||||||
@@ -23,9 +23,8 @@ namespace OpenRa.Traits
|
|||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Damaged(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (e.DamageState == DamageState.Dead)
|
if (e.DamageState == DamageState.Dead)
|
||||||
if (self.Owner == self.World.LocalPlayer)
|
Sound.PlayToPlayer(self.Owner,
|
||||||
Sound.Play(self.Info.Traits.Get<OwnedActorInfo>().WaterBound
|
self.Info.Traits.Get<OwnedActorInfo>().WaterBound ? "navylst1.aud" : "unitlst1.aud");
|
||||||
? "navylst1.aud" : "unitlst1.aud");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user