We get get sprites earlier

This commit is contained in:
Gustas
2025-09-26 16:19:14 +03:00
committed by Gustas Kažukauskas
parent ec7461f09f
commit b340c42ab1
2 changed files with 14 additions and 10 deletions

View File

@@ -158,7 +158,7 @@ namespace OpenRA.Mods.Cnc.Traits
readonly byte maxDensity;
readonly Color veinRadarColor;
ISpriteSequence veinSequence;
readonly ISpriteSequence veinSequence;
PaletteReference veinPalette;
TerrainSpriteLayer spriteLayer;
@@ -177,6 +177,8 @@ namespace OpenRA.Mods.Cnc.Traits
renderIndices = new CellLayer<int[]>(world.Map);
borders = new CellLayer<Adjacency>(world.Map);
veinSequence = self.World.Map.Sequences.GetSequence(info.Image, info.Sequence);
}
void AddDirtyCell(CPos cell, string resourceType)
@@ -194,9 +196,7 @@ namespace OpenRA.Mods.Cnc.Traits
foreach (var a in w.Actors)
ActorAddedToWorld(a);
veinSequence = w.Map.Sequences.GetSequence(info.Image, info.Sequence);
veinPalette = wr.Palette(info.Palette);
var first = veinSequence.GetSprite(0);
var emptySprite = new Sprite(first.Sheet, Rectangle.Empty, TextureChannel.Alpha);
spriteLayer = new TerrainSpriteLayer(w, wr, emptySprite, first.BlendMode, wr.World.Type != WorldType.Editor);

View File

@@ -116,6 +116,15 @@ namespace OpenRA.Mods.Common.Traits
ResourceLayer = self.Trait<IResourceLayer>();
ResourceLayer.CellChanged += AddDirtyCell;
RenderContents = new CellLayer<RendererCellContents>(self.World.Map);
var sequences = self.World.Map.Sequences;
foreach (var kv in Info.ResourceTypes)
{
var resourceInfo = kv.Value;
var resourceVariants = resourceInfo.Sequences
.ToDictionary(v => v, v => sequences.GetSequence(resourceInfo.Image, v));
Variants.Add(kv.Key, resourceVariants);
}
}
void AddDirtyCell(CPos cell, string resourceType)
@@ -126,14 +135,9 @@ namespace OpenRA.Mods.Common.Traits
protected virtual void WorldLoaded(World w, WorldRenderer wr)
{
var sequences = w.Map.Sequences;
foreach (var kv in Info.ResourceTypes)
foreach (var kv in Variants)
{
var resourceInfo = kv.Value;
var resourceVariants = resourceInfo.Sequences
.ToDictionary(v => v, v => sequences.GetSequence(resourceInfo.Image, v));
Variants.Add(kv.Key, resourceVariants);
var resourceVariants = kv.Value;
if (spriteLayer == null)
{
var first = resourceVariants.First().Value.GetSprite(0);