Remove legacy bounds code.
This commit is contained in:
@@ -327,8 +327,6 @@
|
||||
<Compile Include="Traits\Crates\SupportPowerCrateAction.cs" />
|
||||
<Compile Include="Traits\Crushable.cs" />
|
||||
<Compile Include="Traits\CustomSellValue.cs" />
|
||||
<Compile Include="Traits\CustomSelectionSize.cs" />
|
||||
<Compile Include="Traits\Render\CustomRenderSize.cs" />
|
||||
<Compile Include="Traits\DamagedByTerrain.cs" />
|
||||
<Compile Include="Traits\DeliversCash.cs" />
|
||||
<Compile Include="Traits\DeliversExperience.cs" />
|
||||
@@ -417,8 +415,6 @@
|
||||
<Compile Include="Traits\ProximityCapturable.cs" />
|
||||
<Compile Include="Traits\BodyOrientation.cs" />
|
||||
<Compile Include="Traits\QuantizeFacingsFromSequence.cs" />
|
||||
<Compile Include="Traits\Render\AutoSelectionSize.cs" />
|
||||
<Compile Include="Traits\Render\AutoRenderSize.cs" />
|
||||
<Compile Include="Traits\Render\CashTricklerBar.cs" />
|
||||
<Compile Include="Traits\Render\CustomTerrainDebugOverlay.cs" />
|
||||
<Compile Include="Traits\Render\Hovers.cs" />
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2017 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, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Special case trait for actors that need to define targetable area and screen map bounds manually.")]
|
||||
public class CustomSelectionSizeInfo : ITraitInfo, IAutoSelectionSizeInfo
|
||||
{
|
||||
[FieldLoader.Require]
|
||||
public readonly int[] CustomBounds = null;
|
||||
|
||||
public object Create(ActorInitializer init) { return new CustomSelectionSize(this); }
|
||||
}
|
||||
|
||||
public class CustomSelectionSize : IAutoSelectionSize
|
||||
{
|
||||
readonly CustomSelectionSizeInfo info;
|
||||
public CustomSelectionSize(CustomSelectionSizeInfo info) { this.info = info; }
|
||||
|
||||
public int2 SelectionSize(Actor self)
|
||||
{
|
||||
return new int2(info.CustomBounds[0], info.CustomBounds[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,17 +19,11 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("This actor will remain visible (but not updated visually) under fog, once discovered.")]
|
||||
public class FrozenUnderFogInfo : ITraitInfo, Requires<BuildingInfo>, IDefaultVisibilityInfo, IRulesetLoaded
|
||||
public class FrozenUnderFogInfo : ITraitInfo, Requires<BuildingInfo>, IDefaultVisibilityInfo
|
||||
{
|
||||
[Desc("Players with these stances can always see the actor.")]
|
||||
public readonly Stance AlwaysVisibleStances = Stance.Ally;
|
||||
|
||||
void IRulesetLoaded<ActorInfo>.RulesetLoaded(Ruleset rules, ActorInfo info)
|
||||
{
|
||||
if (!info.HasTraitInfo<SelectableInfo>() && !info.HasTraitInfo<IAutoSelectionSizeInfo>())
|
||||
throw new YamlException("Cannot create a frozen actor for actor type '{0}' with empty bounds (no selection size given).".F(info.Name));
|
||||
}
|
||||
|
||||
public object Create(ActorInitializer init) { return new FrozenUnderFog(init, this); }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2017 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, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits.Render
|
||||
{
|
||||
[Desc("Automatically calculates the screen map boundaries from the sprite size.")]
|
||||
public class AutoRenderSizeInfo : ITraitInfo, Requires<RenderSpritesInfo>, IAutoRenderSizeInfo, IDecorationBoundsInfo
|
||||
{
|
||||
public object Create(ActorInitializer init) { return new AutoRenderSize(init.Self); }
|
||||
}
|
||||
|
||||
public class AutoRenderSize : IAutoRenderSize, IMouseBounds, IDecorationBounds
|
||||
{
|
||||
readonly RenderSprites rs;
|
||||
|
||||
public AutoRenderSize(Actor self)
|
||||
{
|
||||
rs = self.Trait<RenderSprites>();
|
||||
}
|
||||
|
||||
public int2 RenderSize(Actor self)
|
||||
{
|
||||
return rs.AutoRenderSize(self);
|
||||
}
|
||||
|
||||
Rectangle Bounds(Actor self, WorldRenderer wr)
|
||||
{
|
||||
return self.TraitsImplementing<IAutoMouseBounds>()
|
||||
.Select(s => s.AutoMouseoverBounds(self, wr))
|
||||
.FirstOrDefault(r => !r.IsEmpty);
|
||||
}
|
||||
|
||||
Rectangle IMouseBounds.MouseoverBounds(Actor self, WorldRenderer wr)
|
||||
{
|
||||
return Bounds(self, wr);
|
||||
}
|
||||
|
||||
Rectangle IDecorationBounds.DecorationBounds(Actor self, WorldRenderer wr)
|
||||
{
|
||||
return Bounds(self, wr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2017 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, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits.Render
|
||||
{
|
||||
[Desc("Automatically calculates the targetable area and screen map boundaries from the sprite size.")]
|
||||
public class AutoSelectionSizeInfo : ITraitInfo, Requires<RenderSpritesInfo>, IAutoSelectionSizeInfo
|
||||
{
|
||||
public object Create(ActorInitializer init) { return new AutoSelectionSize(this); }
|
||||
}
|
||||
|
||||
public class AutoSelectionSize : IAutoSelectionSize
|
||||
{
|
||||
public AutoSelectionSize(AutoSelectionSizeInfo info) { }
|
||||
|
||||
public int2 SelectionSize(Actor self)
|
||||
{
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
return rs.AutoSelectionSize(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2017 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, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Drawing;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Special case trait for actors that need to define targetable area and screen map bounds manually.")]
|
||||
public class CustomRenderSizeInfo : ITraitInfo, IAutoRenderSizeInfo, IDecorationBoundsInfo
|
||||
{
|
||||
[FieldLoader.Require]
|
||||
public readonly int[] CustomBounds = null;
|
||||
|
||||
[Desc("Defines a custom rectangle for Decorations.",
|
||||
"If null, CustomBounds will be used instead")]
|
||||
public readonly int[] DecorationBounds = null;
|
||||
|
||||
public object Create(ActorInitializer init) { return new CustomRenderSize(this); }
|
||||
}
|
||||
|
||||
public class CustomRenderSize : IAutoRenderSize, IMouseBounds, IDecorationBounds
|
||||
{
|
||||
readonly CustomRenderSizeInfo info;
|
||||
public CustomRenderSize(CustomRenderSizeInfo info) { this.info = info; }
|
||||
|
||||
public int2 RenderSize(Actor self)
|
||||
{
|
||||
return new int2(info.CustomBounds[0], info.CustomBounds[1]);
|
||||
}
|
||||
|
||||
Rectangle IMouseBounds.MouseoverBounds(Actor self, WorldRenderer wr)
|
||||
{
|
||||
if (info.CustomBounds == null)
|
||||
return Rectangle.Empty;
|
||||
|
||||
var size = new int2(info.CustomBounds[0], info.CustomBounds[1]);
|
||||
|
||||
var offset = -size / 2;
|
||||
if (info.CustomBounds.Length > 2)
|
||||
offset += new int2(info.CustomBounds[2], info.CustomBounds[3]);
|
||||
|
||||
var xy = wr.ScreenPxPosition(self.CenterPosition);
|
||||
return new Rectangle(xy.X, xy.Y, size.X, size.Y);
|
||||
}
|
||||
|
||||
Rectangle IDecorationBounds.DecorationBounds(Actor self, WorldRenderer wr)
|
||||
{
|
||||
var bounds = info.DecorationBounds ?? info.CustomBounds;
|
||||
if (bounds == null)
|
||||
return Rectangle.Empty;
|
||||
|
||||
var size = new int2(bounds[0], bounds[1]);
|
||||
|
||||
var offset = -size / 2;
|
||||
if (bounds.Length > 2)
|
||||
offset += new int2(bounds[2], bounds[3]);
|
||||
|
||||
var xy = wr.ScreenPxPosition(self.CenterPosition);
|
||||
return new Rectangle(xy.X, xy.Y, size.X, size.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,15 +18,10 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits.Render
|
||||
{
|
||||
public class SelectionDecorationsInfo : ITraitInfo, ISelectionDecorationsInfo, Requires<IDecorationBoundsInfo>
|
||||
public class SelectionDecorationsInfo : ITraitInfo, Requires<IDecorationBoundsInfo>
|
||||
{
|
||||
[PaletteReference] public readonly string Palette = "chrome";
|
||||
|
||||
[Desc("Bounds for visual selection box. If null, it uses AutoSelectionSize.",
|
||||
"The first two values define the bounds' size, the optional third and fourth",
|
||||
"values specify the position relative to the actors' center. Defaults to selectable bounds.")]
|
||||
public readonly int[] VisualBounds = null;
|
||||
|
||||
[Desc("Health bar, production progress bar etc.")]
|
||||
public readonly bool RenderSelectionBars = true;
|
||||
|
||||
@@ -37,8 +32,6 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
public readonly string Image = "pips";
|
||||
|
||||
public object Create(ActorInitializer init) { return new SelectionDecorations(init.Self, this); }
|
||||
|
||||
public int[] SelectionBoxBounds { get { return VisualBounds; } }
|
||||
}
|
||||
|
||||
public class SelectionDecorations : IRenderAboveShroud, INotifyCreated, ITick
|
||||
|
||||
@@ -20,7 +20,7 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits.Render
|
||||
{
|
||||
[Desc("Also returns a default selection size that is calculated automatically from the voxel dimensions.")]
|
||||
public class WithVoxelBodyInfo : ConditionalTraitInfo, IRenderActorPreviewVoxelsInfo, Requires<RenderVoxelsInfo>, IAutoSelectionSizeInfo, IAutoRenderSizeInfo
|
||||
public class WithVoxelBodyInfo : ConditionalTraitInfo, IRenderActorPreviewVoxelsInfo, Requires<RenderVoxelsInfo>
|
||||
{
|
||||
public readonly string Sequence = "idle";
|
||||
|
||||
@@ -40,9 +40,8 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
}
|
||||
}
|
||||
|
||||
public class WithVoxelBody : ConditionalTrait<WithVoxelBodyInfo>, IAutoSelectionSize, IAutoRenderSize, IAutoMouseBounds
|
||||
public class WithVoxelBody : ConditionalTrait<WithVoxelBodyInfo>, IAutoMouseBounds
|
||||
{
|
||||
readonly int2 size;
|
||||
readonly ModelAnimation modelAnimation;
|
||||
readonly RenderVoxels rv;
|
||||
|
||||
@@ -58,15 +57,8 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
() => IsTraitDisabled, () => 0, info.ShowShadow);
|
||||
|
||||
rv.Add(modelAnimation);
|
||||
// Selection size
|
||||
var rvi = self.Info.TraitInfo<RenderVoxelsInfo>();
|
||||
var s = (int)(rvi.Scale * model.Size.Aggregate(Math.Max));
|
||||
size = new int2(s, s);
|
||||
}
|
||||
|
||||
public int2 SelectionSize(Actor self) { return size; }
|
||||
public int2 RenderSize(Actor self) { return size; }
|
||||
|
||||
Rectangle IAutoMouseBounds.AutoMouseoverBounds(Actor self, WorldRenderer wr)
|
||||
{
|
||||
return modelAnimation.ScreenBounds(self.CenterPosition, wr, rv.Info.Scale);
|
||||
|
||||
@@ -13,7 +13,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public abstract class TooltipInfoBase : ConditionalTraitInfo
|
||||
public abstract class TooltipInfoBase : ConditionalTraitInfo, Requires<IMouseBoundsInfo>
|
||||
{
|
||||
[Translate] public readonly string Name = "";
|
||||
}
|
||||
|
||||
@@ -1253,6 +1253,48 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
}
|
||||
}
|
||||
|
||||
if (engineVersion < 20171208)
|
||||
{
|
||||
// Move SelectionDecorations.VisualBounds to Selectable.Bounds
|
||||
if (node.Key.StartsWith("AutoRenderSize", StringComparison.Ordinal))
|
||||
RenameNodeKey(node, "Interactable");
|
||||
|
||||
if (node.Key.StartsWith("CustomRenderSize", StringComparison.Ordinal))
|
||||
{
|
||||
RenameNodeKey(node, "Interactable");
|
||||
var boundsNode = node.Value.Nodes.FirstOrDefault(n => n.Key == "CustomBounds");
|
||||
if (boundsNode != null)
|
||||
RenameNodeKey(boundsNode, "Bounds");
|
||||
}
|
||||
|
||||
if (node.Key.StartsWith("SelectionDecorations", StringComparison.Ordinal))
|
||||
{
|
||||
var boundsNode = node.Value.Nodes.FirstOrDefault(n => n.Key == "VisualBounds");
|
||||
if (boundsNode != null)
|
||||
{
|
||||
RenameNodeKey(boundsNode, "DecorationBounds");
|
||||
node.Value.Nodes.Remove(boundsNode);
|
||||
var selectable = parent.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("Selectable", StringComparison.Ordinal));
|
||||
if (selectable == null)
|
||||
{
|
||||
selectable = new MiniYamlNode("Selectable", new MiniYaml(""));
|
||||
addNodes.Add(selectable);
|
||||
}
|
||||
|
||||
selectable.Value.Nodes.Add(boundsNode);
|
||||
}
|
||||
}
|
||||
|
||||
if (node.Key == "-Selectable")
|
||||
addNodes.Add(new MiniYamlNode("Interactable", new MiniYaml("")));
|
||||
|
||||
if (depth == 0)
|
||||
{
|
||||
node.Value.Nodes.RemoveAll(n => n.Key.StartsWith("CustomSelectionSize", StringComparison.Ordinal));
|
||||
node.Value.Nodes.RemoveAll(n => n.Key.StartsWith("AutoSelectionSize", StringComparison.Ordinal));
|
||||
}
|
||||
}
|
||||
|
||||
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user