diff --git a/OpenRA.Editor/ActorTemplate.cs b/OpenRA.Editor/ActorTemplate.cs
index 54b33ffb30..98947f4785 100644
--- a/OpenRA.Editor/ActorTemplate.cs
+++ b/OpenRA.Editor/ActorTemplate.cs
@@ -18,7 +18,7 @@ namespace OpenRA.Editor
{
public Bitmap Bitmap;
public ActorInfo Info;
- public bool Centered;
+ public EditorAppearanceInfo Appearance;
}
class BrushTemplate
diff --git a/OpenRA.Editor/OpenRA.Editor.csproj b/OpenRA.Editor/OpenRA.Editor.csproj
index 0b2befb264..a6b94efb4b 100644
--- a/OpenRA.Editor/OpenRA.Editor.csproj
+++ b/OpenRA.Editor/OpenRA.Editor.csproj
@@ -145,10 +145,6 @@
{0DFB103F-2962-400F-8C6D-E2C28CCBA633}
OpenRA.Game
-
- {4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}
- OpenRA.Mods.RA
-
diff --git a/OpenRA.Editor/RenderUtils.cs b/OpenRA.Editor/RenderUtils.cs
index 5c9b84b70e..cf1737342d 100644
--- a/OpenRA.Editor/RenderUtils.cs
+++ b/OpenRA.Editor/RenderUtils.cs
@@ -13,7 +13,6 @@ using System.Drawing;
using System.Drawing.Imaging;
using OpenRA.FileFormats;
using OpenRA.Traits;
-using OpenRA.Mods.RA.Buildings;
namespace OpenRA.Editor
{
@@ -122,7 +121,12 @@ namespace OpenRA.Editor
}
catch { }
- return new ActorTemplate { Bitmap = bitmap, Info = info, Centered = !info.Traits.Contains() };
+ return new ActorTemplate
+ {
+ Bitmap = bitmap,
+ Info = info,
+ Appearance = info.Traits.GetOrDefault()
+ };
}
}
diff --git a/OpenRA.Editor/Surface.cs b/OpenRA.Editor/Surface.cs
index 184ca8bce7..c9c26ee454 100755
--- a/OpenRA.Editor/Surface.cs
+++ b/OpenRA.Editor/Surface.cs
@@ -413,10 +413,12 @@ namespace OpenRA.Editor
void DrawActor(System.Drawing.Graphics g, int2 p, ActorTemplate t, ColorPalette cp)
{
- float OffsetX = t.Centered ? t.Bitmap.Width / 2 - TileSet.TileSize / 2 : 0;
+ var centered = t.Appearance == null || !t.Appearance.RelativeToTopLeft;
+
+ float OffsetX = centered ? t.Bitmap.Width / 2 - TileSet.TileSize / 2 : 0;
float DrawX = TileSet.TileSize * p.X * Zoom + Offset.X - OffsetX;
- float OffsetY = t.Centered ? t.Bitmap.Height / 2 - TileSet.TileSize / 2 : 0;
+ float OffsetY = centered ? t.Bitmap.Height / 2 - TileSet.TileSize / 2 : 0;
float DrawY = TileSet.TileSize * p.Y * Zoom + Offset.Y - OffsetY;
float width = t.Bitmap.Width * Zoom;
@@ -447,10 +449,12 @@ namespace OpenRA.Editor
void DrawActorBorder(System.Drawing.Graphics g, int2 p, ActorTemplate t)
{
- float OffsetX = t.Centered ? t.Bitmap.Width / 2 - TileSet.TileSize / 2 : 0;
+ var centered = t.Appearance == null || !t.Appearance.RelativeToTopLeft;
+
+ float OffsetX = centered ? t.Bitmap.Width / 2 - TileSet.TileSize / 2 : 0;
float DrawX = TileSet.TileSize * p.X * Zoom + Offset.X - OffsetX;
- float OffsetY = t.Centered ? t.Bitmap.Height / 2 - TileSet.TileSize / 2 : 0;
+ float OffsetY = centered ? t.Bitmap.Height / 2 - TileSet.TileSize / 2 : 0;
float DrawY = TileSet.TileSize * p.Y * Zoom + Offset.Y - OffsetY;
g.DrawRectangle(CordonPen,
diff --git a/OpenRA.Game/GameRules/ActorInfo.cs b/OpenRA.Game/GameRules/ActorInfo.cs
index 420f99acd1..7a5a584cf2 100644
--- a/OpenRA.Game/GameRules/ActorInfo.cs
+++ b/OpenRA.Game/GameRules/ActorInfo.cs
@@ -66,21 +66,21 @@ namespace OpenRA
var ret = new List();
var t = Traits.WithInterface().ToList();
int index = 0;
- while( t.Count != 0 )
+ while (t.Count != 0)
{
- if( index >= t.Count )
- throw new InvalidOperationException( "Trait prerequisites not satisfied (or prerequisite loop) Actor={0} Unresolved={1}".F(
- Name, string.Join( ",", t.Select( x => x.GetType().Name ).ToArray())));
-
- var prereqs = PrerequisitesOf( t[ index ] );
- if( prereqs.Count == 0 || prereqs.All( n => ret.Any( x => x.GetType() == n || x.GetType().IsSubclassOf( n ) ) ) )
+ var prereqs = PrerequisitesOf(t[index]);
+ var unsatisfied = prereqs.Where(n => !ret.Any(x => x.GetType() == n || x.GetType().IsSubclassOf(n)));
+ if (!unsatisfied.Any())
{
- ret.Add( t[ index ] );
- t.RemoveAt( index );
+ ret.Add(t[index]);
+ t.RemoveAt(index);
index = 0;
}
- else
- ++index;
+ else if (++index >= t.Count)
+ throw new InvalidOperationException("Trait prerequisites not satisfied (or prerequisite loop) Actor={0} Unresolved={1} Missing={2}".F(
+ Name,
+ string.Join(",", t.Select(x => x.GetType().Name).ToArray()),
+ string.Join(",", unsatisfied.Select(x => x.Name).ToArray())));
}
return ret;
diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj
index 32e3f0ec5b..dbe245d211 100755
--- a/OpenRA.Game/OpenRA.Game.csproj
+++ b/OpenRA.Game/OpenRA.Game.csproj
@@ -211,6 +211,7 @@
+
diff --git a/OpenRA.Game/Traits/EditorAppearance.cs b/OpenRA.Game/Traits/EditorAppearance.cs
new file mode 100644
index 0000000000..3b4cce38e3
--- /dev/null
+++ b/OpenRA.Game/Traits/EditorAppearance.cs
@@ -0,0 +1,19 @@
+#region Copyright & License Information
+/*
+ * Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
+ * This file is part of OpenRA, which is free software. It is made
+ * available to you under the terms of the GNU General Public License
+ * as published by the Free Software Foundation. For more information,
+ * see LICENSE.
+ */
+#endregion
+
+namespace OpenRA.Traits
+{
+ public class EditorAppearanceInfo : TraitInfo
+ {
+ public readonly bool RelativeToTopLeft = false;
+ }
+
+ public class EditorAppearance { }
+}
diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml
index a62f258483..4bd571fcd6 100644
--- a/mods/cnc/rules/defaults.yaml
+++ b/mods/cnc/rules/defaults.yaml
@@ -205,6 +205,8 @@
Notification: nodcapt1.aud
ActorLostNotification:
Notification: strclost.aud
+ EditorAppearance:
+ RelativeToTopLeft: yes
^CivBuilding:
Inherits: ^Building
@@ -254,6 +256,8 @@
HasMakeAnimation: false
Palette: terrain
GivesExperience:
+ EditorAppearance:
+ RelativeToTopLeft: yes
^Tree:
Tooltip:
diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml
index 7a274d03cb..4467347a5c 100644
--- a/mods/ra/rules/defaults.yaml
+++ b/mods/ra/rules/defaults.yaml
@@ -139,6 +139,8 @@
FrozenUnderFog:
CaptureNotification:
Notification: strucap1.aud
+ EditorAppearance:
+ RelativeToTopLeft: yes
^Wall:
AppearsOnRadar:
@@ -163,6 +165,8 @@
HasMakeAnimation: false
Palette: terrain
GivesExperience:
+ EditorAppearance:
+ RelativeToTopLeft: yes
^CivBuilding:
Inherits: ^Building