diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index a7ddefc2a4..e08b12b742 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -644,6 +644,7 @@ + diff --git a/OpenRA.Mods.Common/Traits/World/PaletteFromPlayerPaletteWithAlpha.cs b/OpenRA.Mods.Common/Traits/World/PaletteFromPlayerPaletteWithAlpha.cs new file mode 100644 index 0000000000..908c22f44d --- /dev/null +++ b/OpenRA.Mods.Common/Traits/World/PaletteFromPlayerPaletteWithAlpha.cs @@ -0,0 +1,53 @@ +#region Copyright & License Information +/* + * Copyright 2007-2015 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. For more information, + * see COPYING. + */ +#endregion + +using System.Collections.Generic; +using System.Drawing; +using OpenRA.Graphics; +using OpenRA.Mods.Common.Traits; +using OpenRA.Traits; + +namespace OpenRA.Mods.D2k.Traits +{ + [Desc("Create player palettes by applying alpha transparency to another player palette.")] + class PaletteFromPlayerPaletteWithAlphaInfo : ITraitInfo + { + [Desc("The prefix for the resulting player palettes")] + public readonly string BaseName = null; + + [Desc("The name of the player palette to base off.")] + public readonly string BasePalette = null; + + [Desc("Allow palette modifiers to change the palette.")] + public readonly bool AllowModifiers = true; + + [Desc("Alpha component that is applied to the base palette.")] + public readonly float Alpha = 1.0f; + + [Desc("Premultiply color by the alpha component.")] + public readonly bool Premultiply = true; + + public object Create(ActorInitializer init) { return new PaletteFromPlayerPaletteWithAlpha(this); } + } + + class PaletteFromPlayerPaletteWithAlpha : ILoadsPlayerPalettes + { + readonly PaletteFromPlayerPaletteWithAlphaInfo info; + + public PaletteFromPlayerPaletteWithAlpha(PaletteFromPlayerPaletteWithAlphaInfo info) { this.info = info; } + + public void LoadPlayerPalettes(WorldRenderer wr, string playerName, HSLColor color, bool replaceExisting) + { + var remap = new AlphaPaletteRemap(info.Alpha, info.Premultiply); + var pal = new ImmutablePalette(wr.Palette(info.BasePalette + playerName).Palette, remap); + wr.AddPalette(info.BaseName + playerName, pal, info.AllowModifiers, replaceExisting); + } + } +} diff --git a/mods/d2k/rules/palettes.yaml b/mods/d2k/rules/palettes.yaml index c6b67f8d35..6f4d7c1fbf 100644 --- a/mods/d2k/rules/palettes.yaml +++ b/mods/d2k/rules/palettes.yaml @@ -80,5 +80,10 @@ PlayerColorPalette: BasePalette: d2k RemapIndex: 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240 + PaletteFromPlayerPaletteWithAlpha@deviatorgas: + BaseName: deviatorgas + BasePalette: player + Alpha: 0.68 + Premultiply: false PlayerHighlightPalette: diff --git a/mods/d2k/sequences/misc.yaml b/mods/d2k/sequences/misc.yaml index 7952651246..d09b2fb122 100644 --- a/mods/d2k/sequences/misc.yaml +++ b/mods/d2k/sequences/misc.yaml @@ -52,7 +52,7 @@ explosion: deviator: DATA.R8 Start: 3512 Length: 23 - BlendMode: SoftAdditive + BlendMode: Alpha Tick: 80 corpse: DATA.R8 Start: 430 @@ -95,7 +95,6 @@ deviator_trail: Start: 3535 Length: 5 Tick: 80 - BlendMode: SoftAdditive laserfire: idle: DATA.R8 diff --git a/mods/d2k/weapons.yaml b/mods/d2k/weapons.yaml index 107f3f76d8..a661f46b4e 100644 --- a/mods/d2k/weapons.yaml +++ b/mods/d2k/weapons.yaml @@ -396,7 +396,7 @@ NerveGasMissile: Inaccuracy: 1c96 Image: MISSILE Trail: deviator_trail - TrailPalette: player + TrailPalette: deviatorgas TrailUsePlayerPalette: true TrailInterval: 1 Warhead@1Dam: SpreadDamage @@ -411,7 +411,7 @@ NerveGasMissile: SmudgeType: SandCrater, RockCrater Warhead@3Eff: CreateEffect Explosion: deviator - ExplosionPalette: player + ExplosionPalette: deviatorgas UsePlayerPalette: true ImpactSound: EXPLSML2.WAV Warhead@4OwnerChange: ChangeOwner