Merge pull request #11479 from reaperrr/improve-shadow
Improve WithShadow
This commit is contained in:
@@ -16,31 +16,44 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits.Render
|
namespace OpenRA.Mods.Common.Traits.Render
|
||||||
{
|
{
|
||||||
[Desc("Clones the aircraft sprite with another palette below it.")]
|
[Desc("Clones the actor sprite with another palette below it.")]
|
||||||
class WithShadowInfo : ITraitInfo
|
public class WithShadowInfo : UpgradableTraitInfo
|
||||||
{
|
{
|
||||||
[PaletteReference] public readonly string Palette = "shadow";
|
[PaletteReference] public readonly string Palette = "shadow";
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new WithShadow(this); }
|
[Desc("Shadow position offset relative to actor position (ground level).")]
|
||||||
|
public readonly WVec Offset = WVec.Zero;
|
||||||
|
|
||||||
|
[Desc("Shadow Z offset relative to actor sprite.")]
|
||||||
|
public readonly int ZOffset = -5;
|
||||||
|
|
||||||
|
public override object Create(ActorInitializer init) { return new WithShadow(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class WithShadow : IRenderModifier
|
public class WithShadow : UpgradableTrait<WithShadowInfo>, IRenderModifier
|
||||||
{
|
{
|
||||||
WithShadowInfo info;
|
readonly WithShadowInfo info;
|
||||||
|
|
||||||
public WithShadow(WithShadowInfo info)
|
public WithShadow(WithShadowInfo info)
|
||||||
|
: base(info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IRenderable> ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
|
public IEnumerable<IRenderable> ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
|
||||||
{
|
{
|
||||||
|
if (IsTraitDisabled)
|
||||||
|
return Enumerable.Empty<IRenderable>();
|
||||||
|
|
||||||
|
if (self.IsDead || !self.IsInWorld)
|
||||||
|
return Enumerable.Empty<IRenderable>();
|
||||||
|
|
||||||
// Contrails shouldn't cast shadows
|
// Contrails shouldn't cast shadows
|
||||||
var height = self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length;
|
var height = self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length;
|
||||||
var shadowSprites = r.Where(s => !s.IsDecoration)
|
var shadowSprites = r.Where(s => !s.IsDecoration)
|
||||||
.Select(a => a.WithPalette(wr.Palette(info.Palette))
|
.Select(a => a.WithPalette(wr.Palette(info.Palette))
|
||||||
.OffsetBy(new WVec(0, 0, -height))
|
.OffsetBy(info.Offset - new WVec(0, 0, height))
|
||||||
.WithZOffset(a.ZOffset + height)
|
.WithZOffset(a.ZOffset + (height + info.ZOffset))
|
||||||
.AsDecoration());
|
.AsDecoration());
|
||||||
|
|
||||||
return shadowSprites.Concat(r);
|
return shadowSprites.Concat(r);
|
||||||
|
|||||||
@@ -153,6 +153,8 @@
|
|||||||
GenericName: Helicopter
|
GenericName: Helicopter
|
||||||
WithFacingSpriteBody:
|
WithFacingSpriteBody:
|
||||||
WithShadow:
|
WithShadow:
|
||||||
|
Offset: 43, 128, 0
|
||||||
|
ZOffset: -129
|
||||||
Hovers@CRUISING:
|
Hovers@CRUISING:
|
||||||
UpgradeTypes: cruising
|
UpgradeTypes: cruising
|
||||||
UpgradeMinEnabledLevel: 1
|
UpgradeMinEnabledLevel: 1
|
||||||
@@ -427,6 +429,8 @@
|
|||||||
ActorLostNotification:
|
ActorLostNotification:
|
||||||
AttackMove:
|
AttackMove:
|
||||||
WithShadow:
|
WithShadow:
|
||||||
|
Offset: 43, 128, 0
|
||||||
|
ZOffset: -129
|
||||||
WithFacingSpriteBody:
|
WithFacingSpriteBody:
|
||||||
FlyAwayOnIdle:
|
FlyAwayOnIdle:
|
||||||
RejectsOrders:
|
RejectsOrders:
|
||||||
@@ -746,6 +750,8 @@
|
|||||||
^HelicopterHusk:
|
^HelicopterHusk:
|
||||||
Inherits: ^CommonHuskDefaults
|
Inherits: ^CommonHuskDefaults
|
||||||
WithShadow:
|
WithShadow:
|
||||||
|
Offset: 43, 128, 0
|
||||||
|
ZOffset: -129
|
||||||
Aircraft:
|
Aircraft:
|
||||||
AirborneUpgrades: airborne
|
AirborneUpgrades: airborne
|
||||||
CanHover: True
|
CanHover: True
|
||||||
|
|||||||
@@ -386,6 +386,8 @@
|
|||||||
Tooltip:
|
Tooltip:
|
||||||
GenericName: Plane
|
GenericName: Plane
|
||||||
WithShadow:
|
WithShadow:
|
||||||
|
Offset: 43, 128, 0
|
||||||
|
ZOffset: -129
|
||||||
WithFacingSpriteBody:
|
WithFacingSpriteBody:
|
||||||
MustBeDestroyed:
|
MustBeDestroyed:
|
||||||
Voiced:
|
Voiced:
|
||||||
@@ -690,6 +692,8 @@
|
|||||||
^PlaneHusk:
|
^PlaneHusk:
|
||||||
Inherits: ^BasicHusk
|
Inherits: ^BasicHusk
|
||||||
WithShadow:
|
WithShadow:
|
||||||
|
Offset: 43, 128, 0
|
||||||
|
ZOffset: -129
|
||||||
Tooltip:
|
Tooltip:
|
||||||
GenericName: Destroyed Plane
|
GenericName: Destroyed Plane
|
||||||
Aircraft:
|
Aircraft:
|
||||||
@@ -703,6 +707,8 @@
|
|||||||
^HelicopterHusk:
|
^HelicopterHusk:
|
||||||
Inherits: ^BasicHusk
|
Inherits: ^BasicHusk
|
||||||
WithShadow:
|
WithShadow:
|
||||||
|
Offset: 43, 128, 0
|
||||||
|
ZOffset: -129
|
||||||
Tooltip:
|
Tooltip:
|
||||||
GenericName: Destroyed Helicopter
|
GenericName: Destroyed Helicopter
|
||||||
Aircraft:
|
Aircraft:
|
||||||
|
|||||||
Reference in New Issue
Block a user