Merge pull request #6917 from reaperrr/common-11
Move palette stuff + nuke effect + Immobile trait to Mods.Common
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
public class CloakPaletteEffectInfo : TraitInfo<CloakPaletteEffect> { }
|
||||
|
||||
public class CloakPaletteEffect : IPaletteModifier, ITick
|
||||
{
|
||||
float t = 0;
|
||||
string paletteName = "cloak";
|
||||
|
||||
Color[] colors = {
|
||||
Color.FromArgb(55, 205, 205, 220),
|
||||
Color.FromArgb(120, 205, 205, 230),
|
||||
Color.FromArgb(192, 180, 180, 255),
|
||||
Color.FromArgb(178, 205, 250, 220),
|
||||
};
|
||||
|
||||
public void AdjustPalette(IReadOnlyDictionary<string, MutablePalette> b)
|
||||
{
|
||||
var i = (int)t;
|
||||
var p = b[paletteName];
|
||||
|
||||
for (var j = 0; j < colors.Length; j++)
|
||||
{
|
||||
var k = (i + j) % 16 + 0xb0;
|
||||
p.SetColor(k, colors[j]);
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
t += 0.25f;
|
||||
if (t >= 256) t = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
public class NukeLaunch : IEffect
|
||||
{
|
||||
readonly Player firedBy;
|
||||
readonly Animation anim;
|
||||
readonly string weapon;
|
||||
|
||||
readonly WPos ascendSource;
|
||||
readonly WPos ascendTarget;
|
||||
readonly WPos descendSource;
|
||||
readonly WPos descendTarget;
|
||||
readonly int delay;
|
||||
readonly int turn;
|
||||
|
||||
WPos pos;
|
||||
int ticks;
|
||||
|
||||
public NukeLaunch(Player firedBy, string weapon, WPos launchPos, WPos targetPos, WRange velocity, int delay, bool skipAscent)
|
||||
{
|
||||
this.firedBy = firedBy;
|
||||
this.weapon = weapon;
|
||||
this.delay = delay;
|
||||
this.turn = delay / 2;
|
||||
|
||||
var offset = new WVec(WRange.Zero, WRange.Zero, velocity * turn);
|
||||
ascendSource = launchPos;
|
||||
ascendTarget = launchPos + offset;
|
||||
descendSource = targetPos + offset;
|
||||
descendTarget = targetPos;
|
||||
|
||||
anim = new Animation(firedBy.World, weapon);
|
||||
anim.PlayRepeating("up");
|
||||
|
||||
pos = launchPos;
|
||||
var weaponRules = firedBy.World.Map.Rules.Weapons[weapon.ToLowerInvariant()];
|
||||
if (weaponRules.Report != null && weaponRules.Report.Any())
|
||||
Sound.Play(weaponRules.Report.Random(firedBy.World.SharedRandom), pos);
|
||||
|
||||
if (skipAscent)
|
||||
ticks = turn;
|
||||
}
|
||||
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
anim.Tick();
|
||||
|
||||
if (ticks == turn)
|
||||
anim.PlayRepeating("down");
|
||||
|
||||
if (ticks <= turn)
|
||||
pos = WPos.LerpQuadratic(ascendSource, ascendTarget, WAngle.Zero, ticks, turn);
|
||||
else
|
||||
pos = WPos.LerpQuadratic(descendSource, descendTarget, WAngle.Zero, ticks - turn, delay - turn);
|
||||
|
||||
if (ticks == delay)
|
||||
Explode(world);
|
||||
|
||||
ticks++;
|
||||
}
|
||||
|
||||
void Explode(World world)
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
var weapon = world.Map.Rules.Weapons[this.weapon.ToLowerInvariant()];
|
||||
weapon.Impact(Target.FromPos(pos), firedBy.PlayerActor, Enumerable.Empty<int>());
|
||||
world.WorldActor.Trait<ScreenShaker>().AddEffect(20, pos, 5);
|
||||
|
||||
foreach (var a in world.ActorsWithTrait<NukePaletteEffect>())
|
||||
a.Trait.Enable();
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
||||
{
|
||||
return anim.Render(pos, wr.Palette("effect"));
|
||||
}
|
||||
|
||||
public float FractionComplete { get { return ticks * 1f / delay; } }
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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 OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class ImmobileInfo : ITraitInfo, IOccupySpaceInfo
|
||||
{
|
||||
public readonly bool OccupiesSpace = true;
|
||||
public object Create(ActorInitializer init) { return new Immobile(init, this); }
|
||||
}
|
||||
|
||||
class Immobile : IOccupySpace, ISync, INotifyAddedToWorld, INotifyRemovedFromWorld
|
||||
{
|
||||
[Sync] readonly CPos location;
|
||||
[Sync] readonly WPos position;
|
||||
readonly IEnumerable<Pair<CPos, SubCell>> occupied;
|
||||
|
||||
public Immobile(ActorInitializer init, ImmobileInfo info)
|
||||
{
|
||||
location = init.Get<LocationInit, CPos>();
|
||||
position = init.world.Map.CenterOfCell(location);
|
||||
|
||||
if (info.OccupiesSpace)
|
||||
occupied = new [] { Pair.New(TopLeft, SubCell.FullCell) };
|
||||
else
|
||||
occupied = new Pair<CPos, SubCell>[0];
|
||||
}
|
||||
|
||||
public CPos TopLeft { get { return location; } }
|
||||
public WPos CenterPosition { get { return position; } }
|
||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { return occupied; }
|
||||
|
||||
public void AddedToWorld(Actor self)
|
||||
{
|
||||
self.World.ActorMap.AddInfluence(self, this);
|
||||
self.World.ActorMap.AddPosition(self, this);
|
||||
self.World.ScreenMap.Add(self);
|
||||
}
|
||||
|
||||
public void RemovedFromWorld(Actor self)
|
||||
{
|
||||
self.World.ActorMap.RemoveInfluence(self, this);
|
||||
self.World.ActorMap.RemovePosition(self, this);
|
||||
self.World.ScreenMap.Remove(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
[Desc("Palette effect used for blinking \"animations\" on actors.")]
|
||||
class LightPaletteRotatorInfo : ITraitInfo
|
||||
{
|
||||
public readonly string[] ExcludePalettes = { };
|
||||
|
||||
public object Create(ActorInitializer init) { return new LightPaletteRotator(this); }
|
||||
}
|
||||
|
||||
class LightPaletteRotator : ITick, IPaletteModifier
|
||||
{
|
||||
float t = 0;
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
t += .5f;
|
||||
}
|
||||
|
||||
readonly LightPaletteRotatorInfo info;
|
||||
|
||||
public LightPaletteRotator(LightPaletteRotatorInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void AdjustPalette(IReadOnlyDictionary<string, MutablePalette> palettes)
|
||||
{
|
||||
foreach (var pal in palettes)
|
||||
{
|
||||
if (info.ExcludePalettes.Contains(pal.Key))
|
||||
continue;
|
||||
|
||||
var rotate = (int)t % 18;
|
||||
if (rotate > 9)
|
||||
rotate = 18 - rotate;
|
||||
|
||||
pal.Value.SetColor(0x67, pal.Value.GetColor(230 + rotate));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
[Desc("Fades the world from/to black at the start/end of the game, and can (optionally) desaturate the world")]
|
||||
public class MenuPaletteEffectInfo : ITraitInfo
|
||||
{
|
||||
[Desc("Time (in ticks) to fade between states")]
|
||||
public readonly int FadeLength = 10;
|
||||
|
||||
[Desc("Effect style to fade to during gameplay. Accepts values of None or Desaturated.")]
|
||||
public readonly MenuPaletteEffect.EffectType Effect = MenuPaletteEffect.EffectType.None;
|
||||
|
||||
[Desc("Effect style to fade to when opening the in-game menu. Accepts values of None, Black or Desaturated.")]
|
||||
public readonly MenuPaletteEffect.EffectType MenuEffect = MenuPaletteEffect.EffectType.None;
|
||||
|
||||
public object Create(ActorInitializer init) { return new MenuPaletteEffect(this); }
|
||||
}
|
||||
|
||||
public class MenuPaletteEffect : IPaletteModifier, ITickRender, IWorldLoaded
|
||||
{
|
||||
public enum EffectType { None, Black, Desaturated }
|
||||
public readonly MenuPaletteEffectInfo Info;
|
||||
|
||||
int remainingFrames;
|
||||
EffectType from = EffectType.Black;
|
||||
EffectType to = EffectType.Black;
|
||||
|
||||
public MenuPaletteEffect(MenuPaletteEffectInfo info) { Info = info; }
|
||||
|
||||
public void Fade(EffectType type)
|
||||
{
|
||||
remainingFrames = Info.FadeLength;
|
||||
from = to;
|
||||
to = type;
|
||||
}
|
||||
|
||||
public void TickRender(WorldRenderer wr, Actor self)
|
||||
{
|
||||
if (remainingFrames > 0)
|
||||
remainingFrames--;
|
||||
}
|
||||
|
||||
static Color ColorForEffect(EffectType t, Color orig)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case EffectType.Black:
|
||||
return Color.FromArgb(orig.A, Color.Black);
|
||||
case EffectType.Desaturated:
|
||||
var lum = (int)(255 * orig.GetBrightness());
|
||||
return Color.FromArgb(orig.A, lum, lum, lum);
|
||||
default:
|
||||
case EffectType.None:
|
||||
return orig;
|
||||
}
|
||||
}
|
||||
|
||||
public void AdjustPalette(IReadOnlyDictionary<string, MutablePalette> palettes)
|
||||
{
|
||||
if (to == EffectType.None && remainingFrames == 0)
|
||||
return;
|
||||
|
||||
foreach (var pal in palettes.Values)
|
||||
{
|
||||
for (var x = 0; x < Palette.Size; x++)
|
||||
{
|
||||
var orig = pal.GetColor(x);
|
||||
var t = ColorForEffect(to, orig);
|
||||
|
||||
if (remainingFrames == 0)
|
||||
pal.SetColor(x, t);
|
||||
else
|
||||
{
|
||||
var f = ColorForEffect(from, orig);
|
||||
pal.SetColor(x, Exts.ColorLerp((float)remainingFrames / Info.FadeLength, t, f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void WorldLoaded(World w, WorldRenderer wr)
|
||||
{
|
||||
Fade(Info.Effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
[Desc("Apply palette full screen rotations during atom bomb explosions. Add this to the world actor.")]
|
||||
class NukePaletteEffectInfo : TraitInfo<NukePaletteEffect> { }
|
||||
|
||||
public class NukePaletteEffect : IPaletteModifier, ITick
|
||||
{
|
||||
const int nukeEffectLength = 20;
|
||||
int remainingFrames;
|
||||
|
||||
public void Enable()
|
||||
{
|
||||
remainingFrames = nukeEffectLength;
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (remainingFrames > 0)
|
||||
remainingFrames--;
|
||||
}
|
||||
|
||||
public void AdjustPalette(IReadOnlyDictionary<string, MutablePalette> palettes)
|
||||
{
|
||||
if (remainingFrames == 0)
|
||||
return;
|
||||
|
||||
var frac = (float)remainingFrames / nukeEffectLength;
|
||||
|
||||
foreach (var pal in palettes)
|
||||
{
|
||||
for (var x = 0; x < Palette.Size; x++)
|
||||
{
|
||||
var orig = pal.Value.GetColor(x);
|
||||
var white = Color.FromArgb(orig.A, 255, 255, 255);
|
||||
pal.Value.SetColor(x, Exts.ColorLerp(frac, orig, white));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,6 @@
|
||||
<Compile Include="GainsExperience.cs" />
|
||||
<Compile Include="Infiltration\InfiltrateForPowerOutage.cs" />
|
||||
<Compile Include="Player\PlaceBeacon.cs" />
|
||||
<Compile Include="MenuPaletteEffect.cs" />
|
||||
<Compile Include="EjectOnDeath.cs" />
|
||||
<Compile Include="Air\FallsToEarth.cs" />
|
||||
<Compile Include="Air\Fly.cs" />
|
||||
@@ -202,7 +201,6 @@
|
||||
<Compile Include="DemoTruck.cs" />
|
||||
<Compile Include="DetectCloaked.cs" />
|
||||
<Compile Include="Effects\GpsDot.cs" />
|
||||
<Compile Include="Effects\NukeLaunch.cs" />
|
||||
<Compile Include="Effects\Parachute.cs" />
|
||||
<Compile Include="Effects\RepairIndicator.cs" />
|
||||
<Compile Include="EmitInfantryOnSell.cs" />
|
||||
@@ -220,7 +218,6 @@
|
||||
<Compile Include="Invulnerable.cs" />
|
||||
<Compile Include="LeavesHusk.cs" />
|
||||
<Compile Include="Captures.cs" />
|
||||
<Compile Include="LightPaletteRotator.cs" />
|
||||
<Compile Include="LimitedAmmo.cs" />
|
||||
<Compile Include="Lint\CheckActorReferences.cs" />
|
||||
<Compile Include="Lint\CheckSyncAnnotations.cs" />
|
||||
@@ -235,14 +232,10 @@
|
||||
<Compile Include="Move\Move.cs" />
|
||||
<Compile Include="Move\PathFinder.cs" />
|
||||
<Compile Include="Move\PathSearch.cs" />
|
||||
<Compile Include="NukePaletteEffect.cs" />
|
||||
<Compile Include="Orders\PlaceBuildingOrderGenerator.cs" />
|
||||
<Compile Include="Orders\PowerDownOrderGenerator.cs" />
|
||||
<Compile Include="Orders\RepairOrderGenerator.cs" />
|
||||
<Compile Include="OreRefinery.cs" />
|
||||
<Compile Include="PlayerPaletteFromCurrentTileset.cs" />
|
||||
<Compile Include="PaletteFromCurrentTileset.cs" />
|
||||
<Compile Include="PaletteFromRGBA.cs" />
|
||||
<Compile Include="ParaDrop.cs" />
|
||||
<Compile Include="Passenger.cs" />
|
||||
<Compile Include="Player\PlayerStatistics.cs" />
|
||||
@@ -324,7 +317,6 @@
|
||||
<Compile Include="Transforms.cs" />
|
||||
<Compile Include="Turreted.cs" />
|
||||
<Compile Include="Valued.cs" />
|
||||
<Compile Include="WaterPaletteRotation.cs" />
|
||||
<Compile Include="Widgets\Logic\KickSpectatorsLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\MissionBrowserLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\IngameMenuLogic.cs" />
|
||||
@@ -360,7 +352,6 @@
|
||||
<Compile Include="Infiltration\InfiltrateForExploration.cs" />
|
||||
<Compile Include="Infiltration\InfiltrateForCash.cs" />
|
||||
<Compile Include="RenderShroudCircle.cs" />
|
||||
<Compile Include="CloakPaletteEffect.cs" />
|
||||
<Compile Include="Infiltration\Infiltrates.cs" />
|
||||
<Compile Include="Armament.cs" />
|
||||
<Compile Include="Buildings\BaseProvider.cs" />
|
||||
@@ -401,7 +392,6 @@
|
||||
<Compile Include="Buildings\Demolishable.cs" />
|
||||
<Compile Include="Activities\FlyFollow.cs" />
|
||||
<Compile Include="Widgets\Logic\GameTimerLogic.cs" />
|
||||
<Compile Include="Immobile.cs" />
|
||||
<Compile Include="Widgets\Logic\ReplayControlBarLogic.cs" />
|
||||
<Compile Include="World\BuildableTerrainLayer.cs" />
|
||||
<Compile Include="Buildings\LaysTerrain.cs" />
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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 OpenRA.FileSystem;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
[Desc("Loads the palette specified in the tileset definition")]
|
||||
class PaletteFromCurrentTilesetInfo : ITraitInfo
|
||||
{
|
||||
[Desc("internal palette name")]
|
||||
public readonly string Name = null;
|
||||
[Desc("Map listed indices to shadow. Ignores previous color.")]
|
||||
public readonly int[] ShadowIndex = { };
|
||||
public readonly bool AllowModifiers = true;
|
||||
|
||||
public object Create(ActorInitializer init) { return new PaletteFromCurrentTileset(init.world, this); }
|
||||
}
|
||||
|
||||
class PaletteFromCurrentTileset : ILoadsPalettes
|
||||
{
|
||||
readonly World world;
|
||||
readonly PaletteFromCurrentTilesetInfo info;
|
||||
|
||||
public PaletteFromCurrentTileset(World world, PaletteFromCurrentTilesetInfo info)
|
||||
{
|
||||
this.world = world;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void LoadPalettes(WorldRenderer wr)
|
||||
{
|
||||
wr.AddPalette(info.Name, new ImmutablePalette(GlobalFileSystem.Open(world.TileSet.Palette), info.ShadowIndex), info.AllowModifiers);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
[Desc("Creates a single color palette without any base palette file.")]
|
||||
class PaletteFromRGBAInfo : ITraitInfo
|
||||
{
|
||||
[Desc("internal palette name")]
|
||||
public readonly string Name = null;
|
||||
[Desc("If defined, load the palette only for this tileset.")]
|
||||
public readonly string Tileset = null;
|
||||
[Desc("red color component")]
|
||||
public readonly int R = 0;
|
||||
[Desc("green color component")]
|
||||
public readonly int G = 0;
|
||||
[Desc("blue color component")]
|
||||
public readonly int B = 0;
|
||||
[Desc("alpha channel (transparency)")]
|
||||
public readonly int A = 255;
|
||||
public readonly bool AllowModifiers = true;
|
||||
|
||||
public object Create(ActorInitializer init) { return new PaletteFromRGBA(init.world, this); }
|
||||
}
|
||||
|
||||
class PaletteFromRGBA : ILoadsPalettes
|
||||
{
|
||||
readonly World world;
|
||||
readonly PaletteFromRGBAInfo info;
|
||||
public PaletteFromRGBA(World world, PaletteFromRGBAInfo info)
|
||||
{
|
||||
this.world = world;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void LoadPalettes(WorldRenderer wr)
|
||||
{
|
||||
// Enable palette only for a specific tileset
|
||||
if (info.Tileset != null && info.Tileset.ToLowerInvariant() != world.Map.Tileset.ToLowerInvariant())
|
||||
return;
|
||||
|
||||
var c = (uint)((info.A << 24) | (info.R << 16) | (info.G << 8) | info.B);
|
||||
wr.AddPalette(info.Name, new ImmutablePalette(Enumerable.Range(0, Palette.Size).Select(i => (i == 0) ? 0 : c)), info.AllowModifiers);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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 OpenRA.FileSystem;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class PlayerPaletteFromCurrentTilesetInfo : ITraitInfo
|
||||
{
|
||||
[Desc("internal palette name")]
|
||||
public readonly string Name = null;
|
||||
[Desc("Map listed indices to shadow.")]
|
||||
public readonly int[] ShadowIndex = { };
|
||||
[Desc("Apply palette rotatotors or not.")]
|
||||
public readonly bool AllowModifiers = true;
|
||||
|
||||
public object Create(ActorInitializer init) { return new PlayerPaletteFromCurrentTileset(init.world, this); }
|
||||
}
|
||||
|
||||
class PlayerPaletteFromCurrentTileset : ILoadsPalettes
|
||||
{
|
||||
readonly World world;
|
||||
readonly PlayerPaletteFromCurrentTilesetInfo info;
|
||||
|
||||
public PlayerPaletteFromCurrentTileset(World world, PlayerPaletteFromCurrentTilesetInfo info)
|
||||
{
|
||||
this.world = world;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void LoadPalettes(WorldRenderer wr)
|
||||
{
|
||||
var filename = world.TileSet.PlayerPalette ?? world.TileSet.Palette;
|
||||
wr.AddPalette(info.Name, new ImmutablePalette(GlobalFileSystem.Open(filename), info.ShadowIndex), info.AllowModifiers);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
[Desc("Palette effect used for sprinkle \"animations\" on terrain tiles.")]
|
||||
class WaterPaletteRotationInfo : ITraitInfo
|
||||
{
|
||||
public readonly string[] ExcludePalettes = { };
|
||||
|
||||
public object Create(ActorInitializer init) { return new WaterPaletteRotation(init.world, this); }
|
||||
}
|
||||
|
||||
class WaterPaletteRotation : ITick, IPaletteModifier
|
||||
{
|
||||
float t = 0;
|
||||
|
||||
readonly WaterPaletteRotationInfo info;
|
||||
readonly World world;
|
||||
|
||||
public WaterPaletteRotation(World world, WaterPaletteRotationInfo info)
|
||||
{
|
||||
this.world = world;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void Tick(Actor self) { t += .25f; }
|
||||
|
||||
uint[] temp = new uint[7]; /* allocating this on the fly actually hurts our profile */
|
||||
|
||||
public void AdjustPalette(IReadOnlyDictionary<string, MutablePalette> palettes)
|
||||
{
|
||||
var rotate = (int)t % 7;
|
||||
if (rotate == 0)
|
||||
return;
|
||||
|
||||
foreach (var kvp in palettes)
|
||||
{
|
||||
if (info.ExcludePalettes.Contains(kvp.Key))
|
||||
continue;
|
||||
|
||||
var palette = kvp.Value;
|
||||
|
||||
for (var i = 0; i < 7; i++)
|
||||
temp[(rotate + i) % 7] = palette[world.TileSet.WaterPaletteRotationBase + i];
|
||||
|
||||
for (var i = 0; i < 7; i++)
|
||||
palette[world.TileSet.WaterPaletteRotationBase + i] = temp[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common;
|
||||
using OpenRA.Mods.RA.Scripting;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using System;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common;
|
||||
using OpenRA.Mods.Common.Widgets;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user