Fix palette issues with Oil Derricks and walls (fixes #501).

This commit is contained in:
Paul Chote
2011-01-29 13:21:55 +13:00
parent 9b17bfe697
commit 4b538fd2fe
7 changed files with 56 additions and 28 deletions

View File

@@ -0,0 +1,40 @@
#region Copyright & License Information
/*
* Copyright 2007-2010 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 LICENSE.
*/
#endregion
using System.Drawing;
using OpenRA.Traits;
using System.Collections.Generic;
using OpenRA.FileFormats;
namespace OpenRA.Mods.Cnc
{
class CncWaterPaletteRotationInfo : TraitInfo<CncWaterPaletteRotation> {}
class CncWaterPaletteRotation : ITick, IPaletteModifier
{
float t = 0;
public void Tick(Actor self)
{
t += .25f;
}
public void AdjustPalette(Dictionary<string,Palette> palettes)
{
// Only modify the terrain palette
var pal = palettes["terrain"];
var copy = (uint[])pal.Values.Clone();
var rotate = (int)t % 7;
for (int i = 0; i < 7; i++)
pal.SetColor(0x20 + (rotate + i) % 7, copy[0x20 + i]);
}
}
}

View File

@@ -67,6 +67,7 @@
<Compile Include="WithFire.cs" />
<Compile Include="Activities\HarvesterDockSequence.cs" />
<Compile Include="TiberiumRefinery.cs" />
<Compile Include="CncWaterPaletteRotation.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -15,20 +15,9 @@ using OpenRA.FileFormats;
namespace OpenRA.Mods.RA
{
class WaterPaletteRotationInfo : ITraitInfo
{
public readonly bool CncMode = false;
public object Create(ActorInitializer init) { return new WaterPaletteRotation(CncMode); }
}
class WaterPaletteRotationInfo : TraitInfo<WaterPaletteRotation> {}
class WaterPaletteRotation : ITick, IPaletteModifier
{
bool cncmode = false;
public WaterPaletteRotation(bool cncmode)
{
this.cncmode = cncmode;
}
float t = 0;
public void Tick(Actor self)
{
@@ -46,13 +35,8 @@ namespace OpenRA.Mods.RA
var copy = (uint[])pal.Value.Values.Clone();
var rotate = (int)t % 7;
for (int i = 0; i < 7; i++)
{
if (cncmode)
pal.Value.SetColor(0x20 + (rotate + i) % 7, copy[0x20 + i]);
else
pal.Value.SetColor(0x60 + (rotate + i) % 7, copy[0x60 + i]);
}
}
}
}
}

View File

@@ -257,7 +257,7 @@
Priority: 1
RenderBuildingWall:
HasMakeAnimation: false
Palette: terrain
Palette: staticterrain
GivesExperience:
EditorAppearance:
RelativeToTopLeft: yes
@@ -267,7 +267,7 @@
Tooltip:
Name: Tree
RenderBuilding:
Palette: terrain
Palette: staticterrain
Building:
Footprint: __ x_
Dimensions: 2,2
@@ -281,7 +281,7 @@
Tooltip:
Name: Rock
RenderBuilding:
Palette: terrain
Palette: staticterrain
Building:
Footprint: __ x_
Dimensions: 2,2

View File

@@ -49,14 +49,15 @@ World:
ObserverWidget: OBSERVER_ROOT
ScreenShaker:
NukePaletteEffect:
WaterPaletteRotation:
CncMode: true
CncWaterPaletteRotation:
BuildingInfluence:
UnitInfluence:
BridgeLayer:
Bridges: bridge1, bridge2, bridge3, bridge4
PaletteFromCurrentTileset:
PaletteFromCurrentTileset@terrain:
Name: terrain
PaletteFromCurrentTileset@static:
Name: staticterrain
PaletteFromFile@chrome:
Name: chrome
Filename: temperat.pal
@@ -97,7 +98,7 @@ World:
ResourceLayer:
ResourceType@green-tib:
ResourceType: 1
Palette: terrain
Palette: staticterrain
TerrainType: Tiberium
SpriteNames: ti1,ti2,ti3,ti4,ti5,ti6,ti7,ti8,ti9,ti10,ti11,ti12
ValuePerUnit: 30
@@ -107,7 +108,7 @@ World:
AllowUnderActors: false
ResourceType@blue-tib:
ResourceType: 2
Palette: terrain
Palette: staticterrain
TerrainType: BlueTiberium
SpriteNames: bti1,bti2,bti3,bti4,bti5,bti6,bti7,bti8,bti9,bti10,bti11,bti12
ValuePerUnit: 60

View File

@@ -2,6 +2,7 @@
V19:
Inherits: ^CivBuilding
RenderBuilding:
Palette: staticterrain
CashTrickler:
Building:
Footprint: x
@@ -19,6 +20,7 @@ V19.Husk:
-DeadBuildingState:
-Health:
RenderBuilding:
Palette: staticterrain
WithFire:
Building:
Footprint: x

View File

@@ -1,7 +1,7 @@
SPLIT2:
Inherits: ^Tree
RenderBuilding:
Palette: terrain
Palette: staticterrain
SeedsResource:
ResourceType:Tiberium
Tooltip:
@@ -13,7 +13,7 @@ SPLIT2:
SPLIT3:
Inherits: ^Tree
RenderBuilding:
Palette: terrain
Palette: staticterrain
SeedsResource:
ResourceType:Tiberium
Tooltip: