Fix deviator gas blending.

This commit is contained in:
Paul Chote
2015-05-16 21:49:45 +01:00
parent 26fd858fc7
commit 4eb76046f4
5 changed files with 62 additions and 4 deletions

View File

@@ -644,6 +644,7 @@
<Compile Include="Traits\World\EditorResourceLayer.cs" />
<Compile Include="Widgets\EditorViewportControllerWidget.cs" />
<Compile Include="Traits\World\PaletteFromPaletteWithAlpha.cs" />
<Compile Include="Traits\World\PaletteFromPlayerPaletteWithAlpha.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>

View File

@@ -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);
}
}
}

View File

@@ -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:

View File

@@ -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

View File

@@ -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