merged pchote/master

This commit is contained in:
Chris Forbes
2010-01-15 17:30:37 +13:00
10 changed files with 175 additions and 54 deletions

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRa.FileFormats;
using OpenRa.Game.Support;
using OpenRa.Game.Traits;
namespace OpenRa.Game.Traits
{
class GeneratesGapInfo : ITraitInfo
{
public readonly int Range = 10;
public object Create(Actor self) { return new GeneratesGap(self); }
}
class GeneratesGap
{
Actor self;
public GeneratesGap(Actor self)
{
this.self = self;
}
public IEnumerable<int2> GetShroudedTiles()
{
int range = self.Info.Traits.Get<GeneratesGapInfo>().Range;
// Gap Generator building; powered down
if (self.traits.Contains<Building>() && self.traits.Get<Building>().Disabled)
yield break;
foreach (var t in Game.FindTilesInCircle(self.Location, range))
yield return t;
}
}
}

View File

@@ -0,0 +1,25 @@
using System.Drawing;
namespace OpenRa.Game.Traits
{
class LightPaletteRotatorInfo : StatelessTraitInfo<LightPaletteRotator> { }
class LightPaletteRotator : ITick, IPaletteModifier
{
float t = 0;
public void Tick(Actor self)
{
t += .5f;
}
public void AdjustPalette(Bitmap b)
{
var rotate = (int)t % 18;
if (rotate > 9)
rotate = 18 - rotate;
using (var bitmapCopy = new Bitmap(b))
for (int j = 0; j < 16; j++)
b.SetPixel(0x67, j, b.GetPixel(230+rotate, j));
}
}
}