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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,69 @@
#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.Activities;
using OpenRA.Mods.Common.Activities;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
// TODO: Add CurleyShuffle (TD, TS), Circle (Generals Gunship-style)
public enum AirAttackType { Default, Hover, Strafe }
public class AttackAircraftInfo : AttackFollowInfo, Requires<AircraftInfo>
{
[Desc("Attack behavior. Currently supported types are:",
"Default: Attack while following the default movement rules.",
"Hover: Hover, even if the Aircraft can't hover while idle.",
"Strafe: Perform a fixed-length attack run on the target.")]
public readonly AirAttackType AttackType = AirAttackType.Default;
[Desc(
"Distance the strafing aircraft makes to a target before turning for another pass. " +
"When set to WDist.Zero this defaults to the maximum armament range.")]
public readonly WDist StrafeRunLength = WDist.Zero;
public override object Create(ActorInitializer init) { return new AttackAircraft(init.Self, this); }
}
public class AttackAircraft : AttackFollow
{
public new readonly AttackAircraftInfo Info;
readonly AircraftInfo aircraftInfo;
public AttackAircraft(Actor self, AttackAircraftInfo info)
: base(self, info)
{
Info = info;
aircraftInfo = self.Info.TraitInfo<AircraftInfo>();
}
public override Activity GetAttackActivity(
Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
{
return new FlyAttack(self, source, newTarget, forceAttack, targetLineColor);
}
protected override bool CanAttack(Actor self, in Target target)
{
// Don't fire while landed or when outside the map.
if (self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length < aircraftInfo.MinAirborneAltitude
|| !self.World.Map.Contains(self.Location))
return false;
if (!base.CanAttack(self, target))
return false;
return TargetInFiringArc(self, target, Info.FacingTolerance);
}
}
}

View File

@@ -0,0 +1,95 @@
#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.Linq;
using OpenRA.Activities;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Trait used for scripted actors or actors spawned by a support power.")]
public class AttackBomberInfo : AttackBaseInfo
{
public override object Create(ActorInitializer init) { return new AttackBomber(init.Self, this); }
}
public class AttackBomber : AttackBase, ITick, ISync, INotifyRemovedFromWorld
{
readonly AttackBomberInfo info;
[VerifySync]
Target target;
[VerifySync]
bool inAttackRange;
[VerifySync]
bool facingTarget = true;
public event Action<Actor> OnRemovedFromWorld = self => { };
public event Action<Actor> OnEnteredAttackRange = self => { };
public event Action<Actor> OnExitedAttackRange = self => { };
public AttackBomber(Actor self, AttackBomberInfo info)
: base(self, info)
{
this.info = info;
}
void ITick.Tick(Actor self)
{
var wasInAttackRange = inAttackRange;
inAttackRange = false;
if (self.IsInWorld)
{
var dat = self.World.Map.DistanceAboveTerrain(target.CenterPosition);
target = Target.FromPos(target.CenterPosition - new WVec(WDist.Zero, WDist.Zero, dat));
var wasFacingTarget = facingTarget;
facingTarget = TargetInFiringArc(self, target, info.FacingTolerance);
foreach (var a in Armaments)
{
if (!target.IsInRange(self.CenterPosition, a.MaxRange()))
continue;
inAttackRange = true;
a.CheckFire(self, facing, target);
}
// Actors without armaments may want to trigger an action when it passes the target
if (!Armaments.Any())
inAttackRange = !wasInAttackRange && !facingTarget && wasFacingTarget;
}
if (inAttackRange && !wasInAttackRange)
OnEnteredAttackRange(self);
if (!inAttackRange && wasInAttackRange)
OnExitedAttackRange(self);
}
public void SetTarget(WPos pos) { target = Target.FromPos(pos); }
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
{
OnRemovedFromWorld(self);
}
public override Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
{
throw new NotImplementedException("AttackBomber requires a scripted target");
}
}
}

View File

@@ -0,0 +1,71 @@
#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.GameRules;
using OpenRA.Mods.Common.Activities;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Causes aircraft husks that are spawned in the air to crash to the ground.")]
public class FallsToEarthInfo : TraitInfo, IRulesetLoaded, Requires<AircraftInfo>
{
[WeaponReference]
[Desc("Explosion weapon that triggers when hitting ground.")]
public readonly string Explosion = "UnitExplode";
[Desc("Limit the maximum spin (in angle units per tick) that can be achieved while crashing.",
"0 disables spinning. Leave undefined for no limit.")]
public readonly WAngle? MaximumSpinSpeed = null;
[Desc("Does the aircraft (husk) move forward at aircraft speed?")]
public readonly bool Moves = false;
[Desc("Velocity (per tick) at which aircraft falls to ground.")]
public readonly WDist Velocity = new(43);
public WeaponInfo ExplosionWeapon { get; private set; }
public override object Create(ActorInitializer init) { return new FallsToEarth(init, this); }
public void RulesetLoaded(Ruleset rules, ActorInfo ai)
{
if (string.IsNullOrEmpty(Explosion))
return;
var weaponToLower = Explosion.ToLowerInvariant();
if (!rules.Weapons.TryGetValue(weaponToLower, out var weapon))
throw new YamlException($"Weapons Ruleset does not contain an entry '{weaponToLower}'");
ExplosionWeapon = weapon;
}
}
public class FallsToEarth : IEffectiveOwner, INotifyCreated
{
readonly FallsToEarthInfo info;
readonly Player effectiveOwner;
public FallsToEarth(ActorInitializer init, FallsToEarthInfo info)
{
this.info = info;
effectiveOwner = init.GetValue<EffectiveOwnerInit, Player>(info, init.Self.Owner);
}
// We return init.Self.Owner if there's no effective owner
bool IEffectiveOwner.Disguised => true;
Player IEffectiveOwner.Owner => effectiveOwner;
void INotifyCreated.Created(Actor self)
{
self.QueueActivity(false, new FallToEarth(self, info));
}
}
}