Skip to content

Commit

Permalink
Add ability to override CannotPlaceNotification per queue.
Browse files Browse the repository at this point in the history
  • Loading branch information
MustaphaTR authored and abcdefg30 committed Mar 12, 2022
1 parent a6cb20a commit b54a724
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ protected virtual IEnumerable<Order> InnerOrder(World world, CPos cell, MouseInp
var owner = Queue.Actor.Owner;
var ai = variants[variant].ActorInfo;
var bi = variants[variant].BuildingInfo;
var notification = Queue.Info.CannotPlaceAudio ?? placeBuildingInfo.CannotPlaceNotification;

if (mi.Button == MouseButton.Left)
{
Expand All @@ -178,7 +179,7 @@ protected virtual IEnumerable<Order> InnerOrder(World world, CPos cell, MouseInp
orderType = "PlacePlug";
if (!AcceptsPlug(topLeft, plugInfo))
{
Game.Sound.PlayNotification(world.Map.Rules, owner, "Speech", placeBuildingInfo.CannotPlaceNotification, owner.Faction.InternalName);
Game.Sound.PlayNotification(world.Map.Rules, owner, "Speech", notification, owner.Faction.InternalName);
yield break;
}
}
Expand All @@ -190,7 +191,7 @@ protected virtual IEnumerable<Order> InnerOrder(World world, CPos cell, MouseInp
foreach (var order in ClearBlockersOrders(world, topLeft))
yield return order;

Game.Sound.PlayNotification(world.Map.Rules, owner, "Speech", placeBuildingInfo.CannotPlaceNotification, owner.Faction.InternalName);
Game.Sound.PlayNotification(world.Map.Rules, owner, "Speech", notification, owner.Faction.InternalName);
yield break;
}

Expand Down
6 changes: 6 additions & 0 deletions OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public class ProductionQueueInfo : TraitInfo
"The filename of the audio is defined per faction in notifications.yaml.")]
public readonly string LimitedAudio = null;

[NotificationReference("Speech")]
[Desc("Notification played when you can't place a building.",
"Overrides PlaceBuilding.CannotPlaceNotification for this queue.",
"The filename of the audio is defined per faction in notifications.yaml.")]
public readonly string CannotPlaceAudio = null;

[NotificationReference("Speech")]
[Desc("Notification played when user clicks on the build palette icon.",
"The filename of the audio is defined per faction in notifications.yaml.")]
Expand Down

0 comments on commit b54a724

Please sign in to comment.