Merge pull request #10104 from pchote/fix-d2k-tags
Fix the D2K building selection decorations
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
@@ -59,19 +60,24 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Should this be visible to enemy players?")]
|
[Desc("Should this be visible to enemy players?")]
|
||||||
public readonly bool ShowToEnemies = false;
|
public readonly bool ShowToEnemies = false;
|
||||||
|
|
||||||
|
[Desc("Should this be visible only when selected?")]
|
||||||
|
public readonly bool SelectionDecoration = false;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new WithDecoration(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new WithDecoration(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WithDecoration : UpgradableTrait<WithDecorationInfo>, IRender
|
public class WithDecoration : UpgradableTrait<WithDecorationInfo>, IRender, IPostRenderSelection
|
||||||
{
|
{
|
||||||
readonly WithDecorationInfo info;
|
readonly WithDecorationInfo info;
|
||||||
readonly string image;
|
readonly string image;
|
||||||
readonly Animation anim;
|
readonly Animation anim;
|
||||||
|
readonly Actor self;
|
||||||
|
|
||||||
public WithDecoration(Actor self, WithDecorationInfo info)
|
public WithDecoration(Actor self, WithDecorationInfo info)
|
||||||
: base(info)
|
: base(info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
|
this.self = self;
|
||||||
image = info.Image ?? self.Info.Name;
|
image = info.Image ?? self.Info.Name;
|
||||||
anim = new Animation(self.World, image);
|
anim = new Animation(self.World, image);
|
||||||
anim.Paused = () => self.World.Paused;
|
anim.Paused = () => self.World.Paused;
|
||||||
@@ -86,6 +92,16 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public virtual bool ShouldRender(Actor self) { return true; }
|
public virtual bool ShouldRender(Actor self) { return true; }
|
||||||
|
|
||||||
public IEnumerable<IRenderable> Render(Actor self, WorldRenderer wr)
|
public IEnumerable<IRenderable> Render(Actor self, WorldRenderer wr)
|
||||||
|
{
|
||||||
|
return !info.SelectionDecoration ? RenderInner(self, wr, self.Bounds) : Enumerable.Empty<IRenderable>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<IRenderable> RenderAfterWorld(WorldRenderer wr)
|
||||||
|
{
|
||||||
|
return info.SelectionDecoration ? RenderInner(self, wr, self.VisualBounds) : Enumerable.Empty<IRenderable>();
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerable<IRenderable> RenderInner(Actor self, WorldRenderer wr, Rectangle actorBounds)
|
||||||
{
|
{
|
||||||
if (IsTraitDisabled)
|
if (IsTraitDisabled)
|
||||||
return Enumerable.Empty<IRenderable>();
|
return Enumerable.Empty<IRenderable>();
|
||||||
@@ -111,7 +127,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return Enumerable.Empty<IRenderable>();
|
return Enumerable.Empty<IRenderable>();
|
||||||
|
|
||||||
var pxPos = wr.ScreenPxPosition(self.CenterPosition);
|
var pxPos = wr.ScreenPxPosition(self.CenterPosition);
|
||||||
var actorBounds = self.Bounds;
|
|
||||||
actorBounds.Offset(pxPos.X, pxPos.Y);
|
actorBounds.Offset(pxPos.X, pxPos.Y);
|
||||||
|
|
||||||
var img = anim.Image;
|
var img = anim.Image;
|
||||||
|
|||||||
BIN
mods/d2k/bits/primary.shp
Normal file
BIN
mods/d2k/bits/primary.shp
Normal file
Binary file not shown.
@@ -84,4 +84,5 @@ Player:
|
|||||||
Prerequisites: techlevel.low, techlevel.medium, techlevel.high, techlevel.superweapons
|
Prerequisites: techlevel.low, techlevel.medium, techlevel.high, techlevel.superweapons
|
||||||
EnemyWatcher:
|
EnemyWatcher:
|
||||||
HarvesterInsurance:
|
HarvesterInsurance:
|
||||||
|
GlobalUpgradeManager:
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,17 @@ construction_yard:
|
|||||||
Palette: d2k
|
Palette: d2k
|
||||||
PrimaryBuilding:
|
PrimaryBuilding:
|
||||||
ProvidesPrerequisite@buildingname:
|
ProvidesPrerequisite@buildingname:
|
||||||
|
GlobalUpgradable:
|
||||||
|
Prerequisites: upgrade.conyard
|
||||||
|
Upgrades: stardecoration
|
||||||
|
WithDecoration@upgraded:
|
||||||
|
SelectionDecoration: true
|
||||||
|
Image: pips
|
||||||
|
Sequence: tag-upgraded
|
||||||
|
ReferencePoint: Top, Right
|
||||||
|
ZOffset: 256
|
||||||
|
UpgradeTypes: stardecoration
|
||||||
|
UpgradeMinEnabledLevel: 1
|
||||||
|
|
||||||
wind_trap:
|
wind_trap:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
@@ -176,6 +187,17 @@ barracks:
|
|||||||
atreides: barracks.atreides
|
atreides: barracks.atreides
|
||||||
ordos: barracks.ordos
|
ordos: barracks.ordos
|
||||||
ProvidesPrerequisite@buildingname:
|
ProvidesPrerequisite@buildingname:
|
||||||
|
GlobalUpgradable:
|
||||||
|
Prerequisites: upgrade.barracks
|
||||||
|
Upgrades: stardecoration
|
||||||
|
WithDecoration@upgraded:
|
||||||
|
SelectionDecoration: true
|
||||||
|
Image: pips
|
||||||
|
Sequence: tag-upgraded
|
||||||
|
ReferencePoint: Top, Right
|
||||||
|
ZOffset: 256
|
||||||
|
UpgradeTypes: stardecoration
|
||||||
|
UpgradeMinEnabledLevel: 1
|
||||||
|
|
||||||
refinery:
|
refinery:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
@@ -333,6 +355,17 @@ light_factory:
|
|||||||
Sequence: idle-top
|
Sequence: idle-top
|
||||||
Power:
|
Power:
|
||||||
Amount: -125
|
Amount: -125
|
||||||
|
GlobalUpgradable:
|
||||||
|
Prerequisites: upgrade.light
|
||||||
|
Upgrades: stardecoration
|
||||||
|
WithDecoration@upgraded:
|
||||||
|
SelectionDecoration: true
|
||||||
|
Image: pips
|
||||||
|
Sequence: tag-upgraded
|
||||||
|
ReferencePoint: Top, Right
|
||||||
|
ZOffset: 256
|
||||||
|
UpgradeTypes: stardecoration
|
||||||
|
UpgradeMinEnabledLevel: 1
|
||||||
|
|
||||||
heavy_factory:
|
heavy_factory:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
@@ -395,6 +428,17 @@ heavy_factory:
|
|||||||
ProvidesPrerequisite@buildingname:
|
ProvidesPrerequisite@buildingname:
|
||||||
SelectionDecorations:
|
SelectionDecorations:
|
||||||
VisualBounds: 96,96
|
VisualBounds: 96,96
|
||||||
|
GlobalUpgradable:
|
||||||
|
Prerequisites: upgrade.heavy
|
||||||
|
Upgrades: stardecoration
|
||||||
|
WithDecoration@upgraded:
|
||||||
|
SelectionDecoration: true
|
||||||
|
Image: pips
|
||||||
|
Sequence: tag-upgraded
|
||||||
|
ReferencePoint: Top, Right
|
||||||
|
ZOffset: 256
|
||||||
|
UpgradeTypes: stardecoration
|
||||||
|
UpgradeMinEnabledLevel: 1
|
||||||
|
|
||||||
outpost:
|
outpost:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
@@ -734,6 +778,17 @@ high_tech_factory:
|
|||||||
Amount: -75
|
Amount: -75
|
||||||
SelectionDecorations:
|
SelectionDecorations:
|
||||||
VisualBounds: 96,96
|
VisualBounds: 96,96
|
||||||
|
GlobalUpgradable:
|
||||||
|
Prerequisites: upgrade.hightech
|
||||||
|
Upgrades: stardecoration
|
||||||
|
WithDecoration@upgraded:
|
||||||
|
SelectionDecoration: true
|
||||||
|
Image: pips
|
||||||
|
Sequence: tag-upgraded
|
||||||
|
ReferencePoint: Top, Right
|
||||||
|
ZOffset: 256
|
||||||
|
UpgradeTypes: stardecoration
|
||||||
|
UpgradeMinEnabledLevel: 1
|
||||||
|
|
||||||
research_centre:
|
research_centre:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
@@ -106,12 +106,14 @@ pips:
|
|||||||
Length: 10
|
Length: 10
|
||||||
pickup-indicator: DATA.R8
|
pickup-indicator: DATA.R8
|
||||||
Start: 112
|
Start: 112
|
||||||
tag-primary: DATA.R8
|
tag-primary: primary.shp
|
||||||
Start: 110
|
|
||||||
pip-empty: DATA.R8
|
pip-empty: DATA.R8
|
||||||
Start: 15
|
Start: 15
|
||||||
pip-green: DATA.R8
|
pip-green: DATA.R8
|
||||||
Start: 16
|
Start: 16
|
||||||
|
tag-upgraded: DATA.R8
|
||||||
|
Start: 110
|
||||||
|
Offset: -8,-8
|
||||||
|
|
||||||
clock:
|
clock:
|
||||||
idle: clock.shp
|
idle: clock.shp
|
||||||
|
|||||||
Reference in New Issue
Block a user