Merge pull request #10532 from abcdefg30/polish

Apply some general polish to the code/yaml
This commit is contained in:
Oliver Brakmann
2016-01-21 20:18:57 +01:00
5 changed files with 70 additions and 112 deletions

View File

@@ -249,66 +249,61 @@ namespace OpenRA.Mods.Common.Traits
switch (order.OrderString) switch (order.OrderString)
{ {
case "StartProduction": case "StartProduction":
var unit = rules.Actors[order.TargetString];
var bi = unit.TraitInfo<BuildableInfo>();
// Not built by this queue
if (!bi.Queue.Contains(Info.Type))
return;
var cost = unit.HasTraitInfo<ValuedInfo>() ? unit.TraitInfo<ValuedInfo>().Cost : 0;
var time = GetBuildTime(order.TargetString);
// You can't build that
if (BuildableItems().All(b => b.Name != order.TargetString))
return;
// Check if the player is trying to build more units that they are allowed
var fromLimit = int.MaxValue;
if (!developerMode.AllTech && bi.BuildLimit > 0)
{ {
var unit = rules.Actors[order.TargetString]; var inQueue = queue.Count(pi => pi.Item == order.TargetString);
var bi = unit.TraitInfo<BuildableInfo>(); var owned = self.Owner.World.ActorsHavingTrait<Buildable>().Count(a => a.Info.Name == order.TargetString && a.Owner == self.Owner);
if (!bi.Queue.Contains(Info.Type)) fromLimit = bi.BuildLimit - (inQueue + owned);
return; /* Not built by this queue */
var cost = unit.HasTraitInfo<ValuedInfo>() ? unit.TraitInfo<ValuedInfo>().Cost : 0; if (fromLimit <= 0)
var time = GetBuildTime(order.TargetString); return;
}
if (BuildableItems().All(b => b.Name != order.TargetString)) var amountToBuild = Math.Min(fromLimit, order.ExtraData);
return; /* you can't build that!! */ for (var n = 0; n < amountToBuild; n++)
{
// Check if the player is trying to build more units that they are allowed var hasPlayedSound = false;
var fromLimit = int.MaxValue; BeginProduction(new ProductionItem(this, order.TargetString, cost, playerPower, () => self.World.AddFrameEndTask(_ =>
if (!developerMode.AllTech && bi.BuildLimit > 0)
{ {
var inQueue = queue.Count(pi => pi.Item == order.TargetString); var isBuilding = unit.HasTraitInfo<BuildingInfo>();
var owned = self.Owner.World.ActorsHavingTrait<Buildable>().Count(a => a.Info.Name == order.TargetString && a.Owner == self.Owner);
fromLimit = bi.BuildLimit - (inQueue + owned);
if (fromLimit <= 0) if (isBuilding && !hasPlayedSound)
return; hasPlayedSound = Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Faction.InternalName);
} else if (!isBuilding)
var amountToBuild = Math.Min(fromLimit, order.ExtraData);
for (var n = 0; n < amountToBuild; n++)
{
var hasPlayedSound = false;
BeginProduction(new ProductionItem(this, order.TargetString, cost, playerPower, () => self.World.AddFrameEndTask(_ =>
{ {
var isBuilding = unit.HasTraitInfo<BuildingInfo>(); if (BuildUnit(order.TargetString))
Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Faction.InternalName);
if (isBuilding && !hasPlayedSound) else if (!hasPlayedSound && time > 0)
hasPlayedSound = Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Faction.InternalName); hasPlayedSound = Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.BlockedAudio, self.Owner.Faction.InternalName);
else if (!isBuilding) }
{ })));
if (BuildUnit(order.TargetString))
Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Faction.InternalName);
else if (!hasPlayedSound && time > 0)
hasPlayedSound = Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.BlockedAudio, self.Owner.Faction.InternalName);
}
})));
}
break;
} }
break;
case "PauseProduction": case "PauseProduction":
{ if (queue.Count > 0 && queue[0].Item == order.TargetString)
if (queue.Count > 0 && queue[0].Item == order.TargetString) queue[0].Pause(order.ExtraData != 0);
queue[0].Pause(order.ExtraData != 0);
break;
}
break;
case "CancelProduction": case "CancelProduction":
{ CancelProduction(order.TargetString, order.ExtraData);
CancelProduction(order.TargetString, order.ExtraData); break;
break;
}
} }
} }

View File

@@ -1899,7 +1899,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
// Rename *CrateAction.ValidRaces // Rename *CrateAction.ValidRaces
if (depth == 2 && node.Key == "ValidRaces" if (depth == 2 && node.Key == "ValidRaces"
&& (parentKey == "DuplicateUnitCrateAction" || parentKey == "GiveUnitCrateAction")) && (parentKey == "DuplicateUnitCrateAction" || parentKey == "GiveUnitCrateAction"))
node.Key = "ValidFactions"; node.Key = "ValidFactions";
} }

View File

@@ -418,17 +418,17 @@ namespace OpenRA.Mods.Common.Widgets
} }
else if (first.Paused) else if (first.Paused)
overlayFont.DrawTextWithContrast(HoldText, overlayFont.DrawTextWithContrast(HoldText,
icon.Pos + holdOffset, icon.Pos + holdOffset,
Color.White, Color.Black, 1); Color.White, Color.Black, 1);
else if (!waiting) else if (!waiting)
overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(first.RemainingTimeActual, World.Timestep), overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(first.RemainingTimeActual, World.Timestep),
icon.Pos + timeOffset, icon.Pos + timeOffset,
Color.White, Color.Black, 1); Color.White, Color.Black, 1);
if (total > 1 || waiting) if (total > 1 || waiting)
overlayFont.DrawTextWithContrast(total.ToString(), overlayFont.DrawTextWithContrast(total.ToString(),
icon.Pos + queuedOffset, icon.Pos + queuedOffset,
Color.White, Color.Black, 1); Color.White, Color.Black, 1);
} }
} }
} }

View File

@@ -88,11 +88,11 @@ v2:
ZOffset: 1023 ZOffset: 1023
rallypoint: rallypoint:
flag:flagfly flag: flagfly
Length: * Length: *
Offset: 11,-5 Offset: 11,-5
ZOffset: 2535 ZOffset: 2535
circles:fpls circles: fpls
Length: * Length: *
ZOffset: 2047 ZOffset: 2047

View File

@@ -77,9 +77,21 @@
UpgradeTypes: notmobile UpgradeTypes: notmobile
UpgradeMaxEnabledLevel: 0 UpgradeMaxEnabledLevel: 0
^Cloakable:
Cloak@CLOAKGENERATOR:
UpgradeTypes: cloakgenerator
UpgradeMinEnabledLevel: 1
InitialDelay: 0
CloakDelay: 90
IsPlayerPalette: true
CloakSound: cloak5.aud
UncloakSound: cloak5.aud
UncloakOn: Attack, Unload, Infiltrate, Demolish, Damage
^BasicBuilding: ^BasicBuilding:
Inherits@1: ^ExistsInWorld Inherits@1: ^ExistsInWorld
Inherits@2: ^SpriteActor Inherits@2: ^SpriteActor
Inherits@3: ^Cloakable
SelectionDecorations: SelectionDecorations:
Palette: pips Palette: pips
Selectable: Selectable:
@@ -105,15 +117,6 @@
Guardable: Guardable:
Range: 3c0 Range: 3c0
Demolishable: Demolishable:
Cloak@CLOAKGENERATOR:
UpgradeTypes: cloakgenerator
UpgradeMinEnabledLevel: 1
InitialDelay: 0
CloakDelay: 90
IsPlayerPalette: true
CloakSound: cloak5.aud
UncloakSound: cloak5.aud
UncloakOn: Attack, Unload, Infiltrate, Demolish, Damage
^Building: ^Building:
Inherits@1: ^BasicBuilding Inherits@1: ^BasicBuilding
@@ -184,6 +187,7 @@
^Wall: ^Wall:
Inherits@1: ^SpriteActor Inherits@1: ^SpriteActor
Inherits@2: ^Cloakable
CombatDebugOverlay: CombatDebugOverlay:
HiddenUnderShroud: HiddenUnderShroud:
AppearsOnRadar: AppearsOnRadar:
@@ -213,15 +217,6 @@
Demolishable: Demolishable:
ScriptTriggers: ScriptTriggers:
UpgradeManager: UpgradeManager:
Cloak@CLOAKGENERATOR:
UpgradeTypes: cloakgenerator
UpgradeMinEnabledLevel: 1
InitialDelay: 0
CloakDelay: 90
IsPlayerPalette: true
CloakSound: cloak5.aud
UncloakSound: cloak5.aud
UncloakOn: Attack, Unload, Infiltrate, Demolish, Damage
Health: Health:
Shape: Circle Shape: Circle
Radius: 363 Radius: 363
@@ -238,6 +233,7 @@
Inherits@1: ^GainsExperience Inherits@1: ^GainsExperience
Inherits@2: ^ExistsInWorld Inherits@2: ^ExistsInWorld
Inherits@3: ^SpriteActor Inherits@3: ^SpriteActor
Inherits@4: ^Cloakable
DrawLineToTarget: DrawLineToTarget:
Health: Health:
HP: 50 HP: 50
@@ -319,15 +315,6 @@
DeathSounds@ZAPPED: DeathSounds@ZAPPED:
Voice: Zapped Voice: Zapped
DeathTypes: EnergyDeath DeathTypes: EnergyDeath
Cloak@CLOAKGENERATOR:
UpgradeTypes: cloakgenerator
UpgradeMinEnabledLevel: 1
InitialDelay: 0
CloakDelay: 90
IsPlayerPalette: true
CloakSound: cloak5.aud
UncloakSound: cloak5.aud
UncloakOn: Attack, Unload, Infiltrate, Demolish, Damage
^Soldier: ^Soldier:
Inherits: ^Infantry Inherits: ^Infantry
@@ -379,6 +366,7 @@
Inherits@1: ^GainsExperience Inherits@1: ^GainsExperience
Inherits@2: ^ExistsInWorld Inherits@2: ^ExistsInWorld
Inherits@3: ^EmpDisableMobile Inherits@3: ^EmpDisableMobile
Inherits@4: ^Cloakable
DrawLineToTarget: DrawLineToTarget:
Mobile: Mobile:
Crushes: crate Crushes: crate
@@ -423,15 +411,6 @@
Explodes: Explodes:
Weapon: UnitExplodeSmall Weapon: UnitExplodeSmall
EmptyWeapon: UnitExplodeSmall EmptyWeapon: UnitExplodeSmall
Cloak@CLOAKGENERATOR:
UpgradeTypes: cloakgenerator
UpgradeMinEnabledLevel: 1
InitialDelay: 0
CloakDelay: 90
IsPlayerPalette: true
CloakSound: cloak5.aud
UncloakSound: cloak5.aud
UncloakOn: Attack, Unload, Infiltrate, Demolish, Damage
MustBeDestroyed: MustBeDestroyed:
RenderSprites: RenderSprites:
ThrowsShrapnel: ThrowsShrapnel:
@@ -474,6 +453,7 @@
^Aircraft: ^Aircraft:
Inherits@1: ^GainsExperience Inherits@1: ^GainsExperience
Inherits@2: ^ExistsInWorld Inherits@2: ^ExistsInWorld
Inherits@3: ^Cloakable
DrawLineToTarget: DrawLineToTarget:
AppearsOnRadar: AppearsOnRadar:
UseLocation: yes UseLocation: yes
@@ -512,15 +492,6 @@
MustBeDestroyed: MustBeDestroyed:
RenderVoxels: RenderVoxels:
WithVoxelBody: WithVoxelBody:
Cloak@CLOAKGENERATOR:
UpgradeTypes: cloakgenerator
UpgradeMinEnabledLevel: 1
InitialDelay: 0
CloakDelay: 90
IsPlayerPalette: true
CloakSound: cloak5.aud
UncloakSound: cloak5.aud
UncloakOn: Attack, Unload, Infiltrate, Demolish, Damage
^Helicopter: ^Helicopter:
Inherits: ^Aircraft Inherits: ^Aircraft
@@ -715,6 +686,7 @@
^Train: ^Train:
Inherits@1: ^EmpDisableMobile Inherits@1: ^EmpDisableMobile
Inherits@2: ^ExistsInWorld Inherits@2: ^ExistsInWorld
Inherits@3: ^Cloakable
RenderVoxels: RenderVoxels:
RenderSprites: RenderSprites:
WithVoxelBody: WithVoxelBody:
@@ -753,15 +725,6 @@
Explodes: Explodes:
Weapon: UnitExplodeSmall Weapon: UnitExplodeSmall
EmptyWeapon: UnitExplodeSmall EmptyWeapon: UnitExplodeSmall
Cloak@CLOAKGENERATOR:
UpgradeTypes: cloakgenerator
UpgradeMinEnabledLevel: 1
InitialDelay: 0
CloakDelay: 90
IsPlayerPalette: true
CloakSound: cloak5.aud
UncloakSound: cloak5.aud
UncloakOn: Attack, Unload, Infiltrate, Demolish, Damage
ThrowsShrapnel: ThrowsShrapnel:
Weapons: SmallDebris Weapons: SmallDebris
Pieces: 3, 7 Pieces: 3, 7