Replace projectile, WithShadow, WithParachute shadows with tint effects.
This commit is contained in:
@@ -50,9 +50,8 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
[Desc("Does this projectile have a shadow?")]
|
||||
public readonly bool Shadow = false;
|
||||
|
||||
[PaletteReference]
|
||||
[Desc("Palette to use for this projectile's shadow if Shadow is true.")]
|
||||
public readonly string ShadowPalette = "shadow";
|
||||
[Desc("Color to draw shadow if Shadow is true.")]
|
||||
public readonly Color ShadowColor = Color.FromArgb(140, 0, 0, 0);
|
||||
|
||||
[Desc("Trail animation.")]
|
||||
public readonly string TrailImage = null;
|
||||
@@ -122,6 +121,9 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
readonly WDist speed;
|
||||
readonly string trailPalette;
|
||||
|
||||
readonly float3 shadowColor;
|
||||
readonly float shadowAlpha;
|
||||
|
||||
ContrailRenderable contrail;
|
||||
|
||||
[Sync]
|
||||
@@ -181,6 +183,9 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
|
||||
smokeTicks = info.TrailDelay;
|
||||
remainingBounces = info.BounceCount;
|
||||
|
||||
shadowColor = new float3(info.ShadowColor.R, info.ShadowColor.G, info.ShadowColor.B) / 255f;
|
||||
shadowAlpha = info.ShadowColor.A;
|
||||
}
|
||||
|
||||
WAngle GetEffectiveFacing()
|
||||
@@ -286,8 +291,10 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
{
|
||||
var dat = world.Map.DistanceAboveTerrain(pos);
|
||||
var shadowPos = pos - new WVec(0, 0, dat.Length);
|
||||
foreach (var r in anim.Render(shadowPos, wr.Palette(info.ShadowPalette)))
|
||||
yield return r;
|
||||
foreach (var r in anim.Render(shadowPos, wr.Palette(info.Palette)))
|
||||
yield return ((IModifyableRenderable)r)
|
||||
.WithTint(shadowColor, ((IModifyableRenderable)r).TintModifiers | TintModifiers.ReplaceColor)
|
||||
.WithAlpha(shadowAlpha);
|
||||
}
|
||||
|
||||
var palette = wr.Palette(info.Palette + (info.IsPlayerPalette ? args.SourceActor.Owner.InternalName : ""));
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Projectiles
|
||||
@@ -35,10 +36,11 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
[Desc("Palette is a player palette BaseName")]
|
||||
public readonly bool IsPlayerPalette = false;
|
||||
|
||||
[Desc("Does this projectile have a shadow?")]
|
||||
public readonly bool Shadow = false;
|
||||
|
||||
[PaletteReference]
|
||||
public readonly string ShadowPalette = "shadow";
|
||||
[Desc("Color to draw shadow if Shadow is true.")]
|
||||
public readonly Color ShadowColor = Color.FromArgb(140, 0, 0, 0);
|
||||
|
||||
[Desc("Projectile movement vector per tick (forward, right, up), use negative values for opposite directions.")]
|
||||
public readonly WVec Velocity = WVec.Zero;
|
||||
@@ -55,6 +57,10 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
readonly Animation anim;
|
||||
readonly ProjectileArgs args;
|
||||
readonly WVec acceleration;
|
||||
|
||||
readonly float3 shadowColor;
|
||||
readonly float shadowAlpha;
|
||||
|
||||
WVec velocity;
|
||||
|
||||
[Sync]
|
||||
@@ -78,6 +84,9 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
else
|
||||
anim.PlayRepeating(info.Sequences.Random(args.SourceActor.World.SharedRandom));
|
||||
}
|
||||
|
||||
shadowColor = new float3(info.ShadowColor.R, info.ShadowColor.G, info.ShadowColor.B) / 255f;
|
||||
shadowAlpha = info.ShadowColor.A;
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
@@ -115,8 +124,10 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
{
|
||||
var dat = world.Map.DistanceAboveTerrain(pos);
|
||||
var shadowPos = pos - new WVec(0, 0, dat.Length);
|
||||
foreach (var r in anim.Render(shadowPos, wr.Palette(info.ShadowPalette)))
|
||||
yield return r;
|
||||
foreach (var r in anim.Render(shadowPos, wr.Palette(info.Palette)))
|
||||
yield return ((IModifyableRenderable)r)
|
||||
.WithTint(shadowColor, ((IModifyableRenderable)r).TintModifiers | TintModifiers.ReplaceColor)
|
||||
.WithAlpha(shadowAlpha);
|
||||
}
|
||||
|
||||
var palette = wr.Palette(info.Palette + (info.IsPlayerPalette ? args.SourceActor.Owner.InternalName : ""));
|
||||
|
||||
@@ -37,9 +37,12 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
[Desc("Palette is a player palette BaseName")]
|
||||
public readonly bool IsPlayerPalette = false;
|
||||
|
||||
[Desc("Should the projectile's shadow be rendered?")]
|
||||
[Desc("Does this projectile have a shadow?")]
|
||||
public readonly bool Shadow = false;
|
||||
|
||||
[Desc("Color to draw shadow if Shadow is true.")]
|
||||
public readonly Color ShadowColor = Color.FromArgb(140, 0, 0, 0);
|
||||
|
||||
[Desc("Minimum vertical launch angle (pitch).")]
|
||||
public readonly WAngle MinimumLaunchAngle = new WAngle(-64);
|
||||
|
||||
@@ -180,6 +183,9 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
readonly WAngle minLaunchAngle;
|
||||
readonly WAngle maxLaunchAngle;
|
||||
|
||||
readonly float3 shadowColor;
|
||||
readonly float shadowAlpha;
|
||||
|
||||
int ticks;
|
||||
|
||||
int ticksToNextSmoke;
|
||||
@@ -264,6 +270,9 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
trailPalette = info.TrailPalette;
|
||||
if (info.TrailUsePlayerPalette)
|
||||
trailPalette += args.SourceActor.Owner.InternalName;
|
||||
|
||||
shadowColor = new float3(info.ShadowColor.R, info.ShadowColor.G, info.ShadowColor.B) / 255f;
|
||||
shadowAlpha = info.ShadowColor.A;
|
||||
}
|
||||
|
||||
static int LoopRadius(int speed, int rot)
|
||||
@@ -916,8 +925,10 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
{
|
||||
var dat = world.Map.DistanceAboveTerrain(pos);
|
||||
var shadowPos = pos - new WVec(0, 0, dat.Length);
|
||||
foreach (var r in anim.Render(shadowPos, wr.Palette("shadow")))
|
||||
yield return r;
|
||||
foreach (var r in anim.Render(shadowPos, wr.Palette(info.Palette)))
|
||||
yield return ((IModifyableRenderable)r)
|
||||
.WithTint(shadowColor, ((IModifyableRenderable)r).TintModifiers | TintModifiers.ReplaceColor)
|
||||
.WithAlpha(shadowAlpha);
|
||||
}
|
||||
|
||||
var palette = wr.Palette(info.Palette + (info.IsPlayerPalette ? args.SourceActor.Owner.InternalName : ""));
|
||||
|
||||
Reference in New Issue
Block a user