Initial commit: OpenRA game engine
Some checks failed
Continuous Integration / Linux (.NET 8.0) (push) Has been cancelled
Continuous Integration / Windows (.NET 8.0) (push) Has been cancelled

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:
let5sne.win10
2026-01-10 21:46:54 +08:00
commit 9cf6ebb986
4065 changed files with 635973 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
#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;
using System.Collections.Generic;
using OpenRA.Effects;
using OpenRA.Graphics;
using OpenRA.Mods.Cnc.Graphics;
using OpenRA.Mods.Cnc.Traits;
using OpenRA.Primitives;
namespace OpenRA.Mods.Cnc.Effects
{
sealed class ConyardChronoVortex : IEffect, ISpatiallyPartitionable
{
static readonly Size Size = new(64, 64);
static readonly WVec Offset = new(171, 0, 0);
readonly ChronoVortexRenderer renderer;
readonly WPos center;
readonly Action onCompletion;
WPos pos;
WAngle angle;
int loops = 3;
int frame;
public ConyardChronoVortex(Actor launcher, Action onCompletion)
{
this.onCompletion = onCompletion;
renderer = launcher.World.WorldActor.Trait<ChronoVortexRenderer>();
center = launcher.CenterPosition;
pos = center + Offset.Rotate(WRot.FromYaw(angle));
launcher.World.ScreenMap.Add(this, pos, Size);
}
public void Tick(World world)
{
// First 16 frames are the vortex opening
// Next 16 frames are loopable
// Final 16 frames are the vortex closing
if (++frame == 32 && --loops > 0)
frame = 16;
angle += new WAngle(42);
pos = center + Offset.Rotate(WRot.FromYaw(angle));
world.ScreenMap.Update(this, pos, Size);
if (frame == 48)
world.AddFrameEndTask(w => { w.Remove(this); w.ScreenMap.Remove(this); onCompletion(); });
}
public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
yield return new ChronoVortexRenderable(renderer, pos, frame);
}
}
}

View File

@@ -0,0 +1,119 @@
#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.Generic;
using System.Linq;
using OpenRA.Effects;
using OpenRA.Graphics;
using OpenRA.Mods.Cnc.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Effects
{
sealed class GpsDotEffect : IEffect, IEffectAnnotation
{
readonly Actor actor;
readonly GpsDotInfo info;
readonly Animation anim;
readonly PlayerDictionary<DotState> dotStates;
readonly IVisibilityModifier[] visibilityModifiers;
sealed class DotState
{
public readonly GpsWatcher Watcher;
public readonly bool FrozenActorWithRenderables;
public bool Visible;
public DotState(Actor a, GpsWatcher watcher, FrozenActorLayer frozenLayer)
{
Watcher = watcher;
if (frozenLayer != null)
{
var frozenActor = frozenLayer.FromID(a.ActorID);
FrozenActorWithRenderables = frozenActor != null && frozenActor.HasRenderables;
}
}
}
public GpsDotEffect(Actor actor, GpsDotInfo info)
{
this.actor = actor;
this.info = info;
anim = new Animation(actor.World, info.Image);
anim.PlayRepeating(info.String);
visibilityModifiers = actor.TraitsImplementing<IVisibilityModifier>().ToArray();
dotStates = new PlayerDictionary<DotState>(actor.World,
p => new DotState(actor, p.PlayerActor.Trait<GpsWatcher>(), p.FrozenActorLayer));
}
bool ShouldRender(DotState state, Player toPlayer)
{
// Hide the indicator if a frozen actor portrait is visible
if (state.FrozenActorWithRenderables)
return false;
// Hide the indicator if no watchers are available
if (!state.Watcher.Granted && !state.Watcher.GrantedAllies)
return false;
// Hide the indicator if the unit appears to be owned by an allied player
var owner = actor.EffectiveOwner?.Owner;
if (owner != null && toPlayer.IsAlliedWith(owner))
return false;
// Hide the indicator behind shroud
var visibility = toPlayer.Shroud.GetVisibility(actor.CenterPosition);
if (!visibility.HasFlag(Shroud.CellVisibility.Explored))
return false;
// Hide for visible
if (visibility.HasFlag(Shroud.CellVisibility.Visible))
return false;
// Hide indicator if the actor wouldn't otherwise be visible if there wasn't fog
foreach (var visibilityModifier in visibilityModifiers)
if (!visibilityModifier.IsVisible(actor, toPlayer))
return false;
return true;
}
void IEffect.Tick(World world)
{
for (var playerIndex = 0; playerIndex < dotStates.Count; playerIndex++)
{
var state = dotStates[playerIndex];
state.Visible = ShouldRender(state, world.Players[playerIndex]);
}
}
IEnumerable<IRenderable> IEffect.Render(WorldRenderer wr)
{
return SpriteRenderable.None;
}
IEnumerable<IRenderable> IEffectAnnotation.RenderAnnotation(WorldRenderer wr)
{
if (actor.World.RenderPlayer == null || !dotStates[actor.World.RenderPlayer].Visible)
return SpriteRenderable.None;
var effectiveOwner = actor.EffectiveOwner != null && actor.EffectiveOwner.Owner != null ?
actor.EffectiveOwner.Owner : actor.Owner;
var palette = wr.Palette(info.IndicatorPalettePrefix + effectiveOwner.InternalName);
var screenPos = wr.Viewport.WorldToViewPx(wr.ScreenPxPosition(actor.CenterPosition));
return anim.RenderUI(wr, screenPos, WVec.Zero, 0, palette);
}
}
}

View File

@@ -0,0 +1,60 @@
#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.Generic;
using OpenRA.Effects;
using OpenRA.Graphics;
using OpenRA.Mods.Cnc.Traits;
namespace OpenRA.Mods.Cnc.Effects
{
sealed class GpsSatellite : IEffect, ISpatiallyPartitionable
{
readonly Player launcher;
readonly Animation anim;
readonly string palette;
readonly int revealDelay;
WPos pos;
int tick;
public GpsSatellite(World world, WPos pos, string image, string sequence, string palette, int revealDelay, Player launcher)
{
this.palette = palette;
this.pos = pos;
this.launcher = launcher;
this.revealDelay = revealDelay;
anim = new Animation(world, image);
anim.PlayRepeating(sequence);
world.ScreenMap.Add(this, pos, anim.Image);
}
public void Tick(World world)
{
anim.Tick();
pos += new WVec(0, 0, 427);
if (++tick > revealDelay)
{
var watcher = launcher.PlayerActor.Trait<GpsWatcher>();
watcher.ReachedOrbit(launcher);
world.AddFrameEndTask(w => { w.Remove(this); w.ScreenMap.Remove(this); });
}
world.ScreenMap.Update(this, pos, anim.Image);
}
public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
return anim.Render(pos, wr.Palette(palette));
}
}
}

View File

@@ -0,0 +1,58 @@
#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.Generic;
using OpenRA.Effects;
using OpenRA.Graphics;
using OpenRA.Mods.Cnc.Traits;
namespace OpenRA.Mods.Cnc.Effects
{
sealed class SatelliteLaunch : IEffect, ISpatiallyPartitionable
{
readonly GpsPowerInfo info;
readonly Actor launcher;
readonly Animation doors;
readonly WPos pos;
int frame = 0;
public SatelliteLaunch(Actor launcher, GpsPowerInfo info)
{
this.info = info;
this.launcher = launcher;
doors = new Animation(launcher.World, info.DoorImage);
doors.PlayThen(info.DoorSequence,
() => launcher.World.AddFrameEndTask(w => { w.Remove(this); w.ScreenMap.Remove(this); }));
pos = launcher.CenterPosition;
launcher.World.ScreenMap.Add(this, pos, doors.Image);
}
public void Tick(World world)
{
doors.Tick();
world.ScreenMap.Update(this, pos, doors.Image);
if (++frame == 19)
{
var palette = info.SatellitePaletteIsPlayerPalette ? info.SatellitePalette + launcher.Owner.InternalName : info.SatellitePalette;
world.AddFrameEndTask(w => w.Add(new GpsSatellite(world, pos, info.SatelliteImage, info.SatelliteSequence, palette, info.RevealDelay, launcher.Owner)));
}
}
public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
var palette = info.DoorPaletteIsPlayerPalette ? info.DoorPalette + launcher.Owner.InternalName : info.DoorPalette;
return doors.Render(pos, wr.Palette(palette));
}
}
}