Remove editor-specific resource rendering.
Mods must manually move their *ResourceRenderer definitions from World onto BaseWorld to restore resource rendering in the editor.
This commit is contained in:
@@ -1,107 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2020 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.Linq;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
|
||||
namespace OpenRA.Mods.D2k.Traits
|
||||
{
|
||||
using ClearSides = D2kResourceRenderer.ClearSides;
|
||||
|
||||
[Desc("Used to render spice with round borders.")]
|
||||
public class D2kEditorResourceLayerInfo : EditorResourceLayerInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new D2kEditorResourceLayer(init.Self); }
|
||||
}
|
||||
|
||||
public class D2kEditorResourceLayer : EditorResourceLayer
|
||||
{
|
||||
public D2kEditorResourceLayer(Actor self)
|
||||
: base(self) { }
|
||||
|
||||
public override EditorCellContents UpdateDirtyTile(CPos c)
|
||||
{
|
||||
var t = Tiles[c];
|
||||
|
||||
// Empty tile
|
||||
if (t.Type == null)
|
||||
{
|
||||
t.Sequence = null;
|
||||
return t;
|
||||
}
|
||||
|
||||
NetWorth -= t.Density * t.Type.Info.ValuePerUnit;
|
||||
|
||||
t.Density = ResourceDensityAt(c);
|
||||
|
||||
NetWorth += t.Density * t.Type.Info.ValuePerUnit;
|
||||
|
||||
int index;
|
||||
var clear = FindClearSides(t.Type, c);
|
||||
if (clear == ClearSides.None)
|
||||
{
|
||||
var sprites = D2kResourceRenderer.Variants[t.Variant];
|
||||
var frame = t.Density > t.Type.Info.MaxDensity / 2 ? 1 : 0;
|
||||
t.Sequence = t.Type.Variants.First().Value;
|
||||
t.Frame = sprites[frame];
|
||||
}
|
||||
else if (D2kResourceRenderer.SpriteMap.TryGetValue(clear, out index))
|
||||
{
|
||||
t.Sequence = t.Type.Variants.First().Value;
|
||||
t.Frame = index;
|
||||
}
|
||||
else
|
||||
t.Sequence = null;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
protected override string ChooseRandomVariant(ResourceType t)
|
||||
{
|
||||
return D2kResourceRenderer.Variants.Keys.Random(Game.CosmeticRandom);
|
||||
}
|
||||
|
||||
bool CellContains(CPos c, ResourceType t)
|
||||
{
|
||||
return Tiles.Contains(c) && Tiles[c].Type == t;
|
||||
}
|
||||
|
||||
ClearSides FindClearSides(ResourceType t, CPos p)
|
||||
{
|
||||
var ret = ClearSides.None;
|
||||
if (!CellContains(p + new CVec(0, -1), t))
|
||||
ret |= ClearSides.Top | ClearSides.TopLeft | ClearSides.TopRight;
|
||||
|
||||
if (!CellContains(p + new CVec(-1, 0), t))
|
||||
ret |= ClearSides.Left | ClearSides.TopLeft | ClearSides.BottomLeft;
|
||||
|
||||
if (!CellContains(p + new CVec(1, 0), t))
|
||||
ret |= ClearSides.Right | ClearSides.TopRight | ClearSides.BottomRight;
|
||||
|
||||
if (!CellContains(p + new CVec(0, 1), t))
|
||||
ret |= ClearSides.Bottom | ClearSides.BottomLeft | ClearSides.BottomRight;
|
||||
|
||||
if (!CellContains(p + new CVec(-1, -1), t))
|
||||
ret |= ClearSides.TopLeft;
|
||||
|
||||
if (!CellContains(p + new CVec(1, -1), t))
|
||||
ret |= ClearSides.TopRight;
|
||||
|
||||
if (!CellContains(p + new CVec(-1, 1), t))
|
||||
ret |= ClearSides.BottomLeft;
|
||||
|
||||
if (!CellContains(p + new CVec(1, 1), t))
|
||||
ret |= ClearSides.BottomRight;
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
if (clear == ClearSides.None)
|
||||
{
|
||||
var sprites = Variants[content.Variant];
|
||||
var frame = density > ResourceLayer.GetMaxResourceDensity(cell) / 2 ? 1 : 0;
|
||||
var frame = density > renderType.Info.MaxDensity / 2 ? 1 : 0;
|
||||
|
||||
UpdateSpriteLayers(cell, renderType.Variants.First().Value, sprites[frame], renderType.Palette);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user