Moved SellSounds from Building to Sellable & added upgrade to rules.

This commit is contained in:
atlimit8
2014-08-29 12:55:19 -05:00
parent f9255ecc49
commit cc9c253419
8 changed files with 51 additions and 10 deletions

View File

@@ -34,7 +34,6 @@ namespace OpenRA.Mods.RA.Buildings
public readonly bool AllowInvalidPlacement = false;
public readonly string[] BuildSounds = { "placbldg.aud", "build5.aud" };
public readonly string[] SellSounds = { "cashturn.aud" };
public readonly string[] UndeploySounds = { "cashturn.aud" };
public object Create(ActorInitializer init) { return new Building(init, this); }
@@ -176,9 +175,6 @@ namespace OpenRA.Mods.RA.Buildings
public void Selling(Actor self)
{
foreach (var s in Info.SellSounds)
Sound.PlayToPlayer(self.Owner, s, self.CenterPosition);
BuildComplete = false;
}

View File

@@ -8,6 +8,7 @@
*/
#endregion
using System.Linq;
using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Render;
@@ -15,14 +16,22 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
[Desc("Building can be sold")]
public class SellableInfo : TraitInfo<Sellable>
[Desc("Actor can be sold")]
public class SellableInfo : ITraitInfo
{
public readonly int RefundPercent = 50;
public readonly string[] SellSounds = { };
public object Create(ActorInitializer init) { return new Sellable(this); }
}
public class Sellable : IResolveOrder
{
readonly SellableInfo info;
public Sellable(SellableInfo info) { this.info = info; }
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Sell")
@@ -37,6 +46,9 @@ namespace OpenRA.Mods.RA
self.CancelActivity();
foreach (var s in info.SellSounds)
Sound.PlayToPlayer(self.Owner, s, self.CenterPosition);
foreach (var ns in self.TraitsImplementing<INotifySold>())
ns.Selling(self);

View File

@@ -488,6 +488,33 @@ namespace OpenRA.Utility
node.Key = "DeathType";
}
// SellSounds from Building was moved into Sellable
if (engineVersion < 20140904)
{
if (depth == 0)
{
var actorTraits = node.Value.Nodes;
var building = actorTraits.FirstOrDefault(t => t.Key == "Building");
if (building != null)
{
var buildingFields = building.Value.Nodes;
var sellSounds = buildingFields.FirstOrDefault(n => n.Key == "SellSounds");
if (sellSounds != null)
{
buildingFields.Remove(sellSounds);
var sellable = actorTraits.FirstOrDefault(t => t.Key == "Sellable");
if (sellable != null)
sellable.Value.Nodes.Add(sellSounds);
else
{
Console.WriteLine("Warning: Adding Sellable trait to {0} in {1}".F(node.Key, node.Location.Filename));
actorTraits.Add(new MiniYamlNode("Sellable", new MiniYaml("", new List<MiniYamlNode> { sellSounds })));
}
}
}
}
}
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
}
}

View File

@@ -334,7 +334,6 @@
Dimensions: 1,1
Footprint: x
BuildSounds: constru2.aud, hvydoor1.aud
SellSounds: cashturn.aud
TerrainTypes: Clear,Road
SoundOnDamageTransition:
DamagedSound: xplos.aud
@@ -374,6 +373,7 @@
GivesBuildableArea:
EngineerRepairable:
Sellable:
SellSounds: cashturn.aud
Capturable:
^CivBuilding:
@@ -473,6 +473,7 @@
RelativeToTopLeft: yes
AutoTargetIgnore:
Sellable:
SellSounds: cashturn.aud
Guardable:
BodyOrientation:
FrozenUnderFog:

View File

@@ -243,7 +243,6 @@
Footprint: x
TerrainTypes: Rock, Concrete
BuildSounds: BUILD1.WAV
SellSounds: BUILD1.WAV
Adjacent: 3
GivesBuildableArea:
ExternalCapturable:
@@ -268,6 +267,7 @@
ProximityCaptor:
Types: Building
Sellable:
SellSounds: BUILD1.WAV
GivesBounty:
CombatDebugOverlay:
Guardable:

View File

@@ -3,7 +3,6 @@
Adjacent: 4
TerrainTypes: Rock
BuildSounds: CHUNG.WAV
SellSounds: CHUNG.WAV
AllowInvalidPlacement: true
LaysTerrain:
Template: 88
@@ -412,7 +411,6 @@ CONCRETEB:
AppearsOnRadar:
Building:
BuildSounds: CHUNG.WAV
SellSounds: CHUNG.WAV
Adjacent: 7
TerrainTypes: Rock, Concrete
Health:
@@ -436,6 +434,7 @@ CONCRETEB:
ProximityCaptor:
Types: Wall
Sellable:
SellSounds: CHUNG.WAV
Guardable:
BodyOrientation:
ThrowsShrapnel:
@@ -462,6 +461,7 @@ WALL:
Building:
Adjacent: 4
BuildSounds: CHUNG.WAV
Sellable:
SellSounds: CHUNG.WAV
Selectable:
Bounds: 32,40,0,-8
@@ -514,6 +514,7 @@ WALL:
Building:
Adjacent: 4
BuildSounds: CHUNG.WAV
Sellable:
SellSounds: CHUNG.WAV
Selectable:
Bounds: 32,40,0,-8

View File

@@ -298,6 +298,7 @@
ProximityCaptor:
Types: Building
Sellable:
SellSounds: cashturn.aud
AcceptsSupplies:
GivesBounty:
UpdatesPlayerStatistics:
@@ -348,6 +349,7 @@
ProximityCaptor:
Types: Wall
Sellable:
SellSounds: cashturn.aud
Guardable:
BodyOrientation:
FrozenUnderFog:

View File

@@ -29,6 +29,7 @@
ProximityCaptor:
Types: Building
Sellable:
SellSounds: cashturn.aud
AcceptsSupplies:
GivesBounty:
UpdatesPlayerStatistics:
@@ -75,6 +76,7 @@
ProximityCaptor:
Types: Wall
Sellable:
SellSounds: cashturn.aud
UpdatesPlayerStatistics:
BodyOrientation:
LuaScriptEvents: