Initial commit: OpenRA game engine
Fork from OpenRA/OpenRA with one-click launch script (start-ra.cmd) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright (c) The OpenRA Developers and Contributors
|
||||
* 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, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
[Desc("Apply palette full screen rotations during chronoshifts. Add this to the world actor.")]
|
||||
public class ChronoshiftPostProcessEffectInfo : TraitInfo
|
||||
{
|
||||
[Desc("Measured in ticks.")]
|
||||
public readonly int ChronoEffectLength = 60;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new ChronoshiftPostProcessEffect(this); }
|
||||
}
|
||||
|
||||
public class ChronoshiftPostProcessEffect : RenderPostProcessPassBase, ITick
|
||||
{
|
||||
readonly ChronoshiftPostProcessEffectInfo info;
|
||||
int remainingFrames;
|
||||
|
||||
public ChronoshiftPostProcessEffect(ChronoshiftPostProcessEffectInfo info)
|
||||
: base("chronoshift", PostProcessPassType.AfterWorld)
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void Enable()
|
||||
{
|
||||
remainingFrames = info.ChronoEffectLength;
|
||||
}
|
||||
|
||||
void ITick.Tick(Actor self)
|
||||
{
|
||||
if (remainingFrames > 0)
|
||||
remainingFrames--;
|
||||
}
|
||||
|
||||
protected override bool Enabled => remainingFrames > 0;
|
||||
protected override void PrepareRender(WorldRenderer wr, IShader shader)
|
||||
{
|
||||
shader.SetVec("Blend", (float)remainingFrames / info.ChronoEffectLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
66
OpenRA.Mods.Cnc/Traits/PaletteEffects/LightPaletteRotator.cs
Normal file
66
OpenRA.Mods.Cnc/Traits/PaletteEffects/LightPaletteRotator.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright (c) The OpenRA Developers and Contributors
|
||||
* 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, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
[Desc("Palette effect used for blinking \"animations\" on actors.")]
|
||||
sealed class LightPaletteRotatorInfo : TraitInfo
|
||||
{
|
||||
[Desc("Palettes this effect should not apply to.")]
|
||||
public readonly FrozenSet<string> ExcludePalettes = FrozenSet<string>.Empty;
|
||||
|
||||
[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 ImmutableArray<int> RotationIndices = [230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 238, 237, 236, 235, 234, 233, 232, 231];
|
||||
|
||||
public override object Create(ActorInitializer init) { return new LightPaletteRotator(this); }
|
||||
}
|
||||
|
||||
sealed class LightPaletteRotator : ITick, IPaletteModifier
|
||||
{
|
||||
readonly LightPaletteRotatorInfo info;
|
||||
float t = 0;
|
||||
|
||||
public LightPaletteRotator(LightPaletteRotatorInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
void ITick.Tick(Actor self)
|
||||
{
|
||||
t += info.TimeStep;
|
||||
}
|
||||
|
||||
void IPaletteModifier.AdjustPalette(IReadOnlyDictionary<string, MutablePalette> palettes)
|
||||
{
|
||||
foreach (var pal in palettes)
|
||||
{
|
||||
if (info.ExcludePalettes.Contains(pal.Key))
|
||||
continue;
|
||||
|
||||
var rotate = (int)t % info.RotationIndices.Length;
|
||||
pal.Value.SetColor(info.ModifyIndex, pal.Value.GetColor(info.RotationIndices[rotate]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user