Merge pull request #13161 from reaperrr/mods-cnc-tweak
Unhardcode LightPaletteRotator properties
This commit is contained in:
@@ -72,7 +72,7 @@
|
|||||||
<Compile Include="Traits\Render\WithReloadingSpriteTurret.cs" />
|
<Compile Include="Traits\Render\WithReloadingSpriteTurret.cs" />
|
||||||
<Compile Include="Traits\Render\WithRoof.cs" />
|
<Compile Include="Traits\Render\WithRoof.cs" />
|
||||||
<Compile Include="Traits\SupportPowers\IonCannonPower.cs" />
|
<Compile Include="Traits\SupportPowers\IonCannonPower.cs" />
|
||||||
<Compile Include="ImportTiberianDawnLegacyMapCommand.cs" />
|
<Compile Include="UtilityCommands\ImportTiberianDawnLegacyMapCommand.cs" />
|
||||||
<Compile Include="Projectiles\IonCannon.cs" />
|
<Compile Include="Projectiles\IonCannon.cs" />
|
||||||
<Compile Include="Activities\VoxelHarvesterDockSequence.cs" />
|
<Compile Include="Activities\VoxelHarvesterDockSequence.cs" />
|
||||||
<Compile Include="SpriteLoaders\TmpTSLoader.cs" />
|
<Compile Include="SpriteLoaders\TmpTSLoader.cs" />
|
||||||
@@ -130,7 +130,7 @@
|
|||||||
<Compile Include="Traits\GpsWatcher.cs" />
|
<Compile Include="Traits\GpsWatcher.cs" />
|
||||||
<Compile Include="Scripting\Properties\ChronosphereProperties.cs" />
|
<Compile Include="Scripting\Properties\ChronosphereProperties.cs" />
|
||||||
<Compile Include="Traits\Render\WithDisguisingInfantryBody.cs" />
|
<Compile Include="Traits\Render\WithDisguisingInfantryBody.cs" />
|
||||||
<Compile Include="ImportRedAlertLegacyMapCommand.cs" />
|
<Compile Include="UtilityCommands\ImportRedAlertLegacyMapCommand.cs" />
|
||||||
<Compile Include="Traits\Infiltration\InfiltrateForDecoration.cs" />
|
<Compile Include="Traits\Infiltration\InfiltrateForDecoration.cs" />
|
||||||
<Compile Include="TraitsInterfaces.cs" />
|
<Compile Include="TraitsInterfaces.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -18,8 +18,18 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
[Desc("Palette effect used for blinking \"animations\" on actors.")]
|
[Desc("Palette effect used for blinking \"animations\" on actors.")]
|
||||||
class LightPaletteRotatorInfo : ITraitInfo
|
class LightPaletteRotatorInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
|
[Desc("Palettes this effect should not apply to.")]
|
||||||
public readonly HashSet<string> ExcludePalettes = new HashSet<string>();
|
public readonly HashSet<string> ExcludePalettes = new HashSet<string>();
|
||||||
|
|
||||||
|
[Desc("'Speed' at which the effect cycles through palette indices.")]
|
||||||
|
public readonly float TimeStep = .5f;
|
||||||
|
|
||||||
|
[Desc("Palette index to map to rotating color indices.")]
|
||||||
|
public readonly int ModifyIndex = 103;
|
||||||
|
|
||||||
|
[Desc("Palette indices to rotate through.")]
|
||||||
|
public readonly int[] RotationIndices = { 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 238, 237, 236, 235, 234, 233, 232, 231 };
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new LightPaletteRotator(this); }
|
public object Create(ActorInitializer init) { return new LightPaletteRotator(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,23 +43,20 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
this.info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(Actor self)
|
void ITick.Tick(Actor self)
|
||||||
{
|
{
|
||||||
t += .5f;
|
t += info.TimeStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AdjustPalette(IReadOnlyDictionary<string, MutablePalette> palettes)
|
void IPaletteModifier.AdjustPalette(IReadOnlyDictionary<string, MutablePalette> palettes)
|
||||||
{
|
{
|
||||||
foreach (var pal in palettes)
|
foreach (var pal in palettes)
|
||||||
{
|
{
|
||||||
if (info.ExcludePalettes.Contains(pal.Key))
|
if (info.ExcludePalettes.Contains(pal.Key))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var rotate = (int)t % 18;
|
var rotate = (int)t % info.RotationIndices.Length;
|
||||||
if (rotate > 9)
|
pal.Value.SetColor(info.ModifyIndex, pal.Value.GetColor(info.RotationIndices[rotate]));
|
||||||
rotate = 18 - rotate;
|
|
||||||
|
|
||||||
pal.Value.SetColor(0x67, pal.Value.GetColor(230 + rotate));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user