Remove unused parameters.
This commit is contained in:
committed by
abcdefg30
parent
ea243b8558
commit
0e7ad43425
@@ -141,6 +141,9 @@ dotnet_diagnostic.IDE0040.severity = warning
|
||||
# Make field readonly.
|
||||
dotnet_diagnostic.IDE0044.severity = warning
|
||||
|
||||
# Unused parameter.
|
||||
dotnet_diagnostic.IDE0060.severity = warning
|
||||
|
||||
# Naming rule violation.
|
||||
dotnet_diagnostic.IDE1006.severity = warning
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace OpenRA
|
||||
filterNode: n => n.Key.StartsWith(ActorInfo.AbstractActorPrefix, StringComparison.Ordinal));
|
||||
|
||||
var weapons = MergeOrDefault("Manifest,Weapons", fs, m.Weapons, null, null,
|
||||
k => new WeaponInfo(k.Key.ToLowerInvariant(), k.Value));
|
||||
k => new WeaponInfo(k.Value));
|
||||
|
||||
var voices = MergeOrDefault("Manifest,Voices", fs, m.Voices, null, null,
|
||||
k => new SoundInfo(k.Value));
|
||||
@@ -190,7 +190,7 @@ namespace OpenRA
|
||||
filterNode: n => n.Key.StartsWith(ActorInfo.AbstractActorPrefix, StringComparison.Ordinal));
|
||||
|
||||
var weapons = MergeOrDefault("Weapons", fileSystem, m.Weapons, mapWeapons, dr.Weapons,
|
||||
k => new WeaponInfo(k.Key.ToLowerInvariant(), k.Value));
|
||||
k => new WeaponInfo(k.Value));
|
||||
|
||||
var voices = MergeOrDefault("Voices", fileSystem, m.Voices, mapVoices, dr.Voices,
|
||||
k => new SoundInfo(k.Value));
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace OpenRA.GameRules
|
||||
[FieldLoader.LoadUsing(nameof(LoadWarheads))]
|
||||
public readonly List<IWarhead> Warheads = new List<IWarhead>();
|
||||
|
||||
public WeaponInfo(string name, MiniYaml content)
|
||||
public WeaponInfo(MiniYaml content)
|
||||
{
|
||||
// Resolve any weapon-level yaml inheritance or removals
|
||||
// HACK: The "Defaults" sequence syntax prevents us from doing this generally during yaml parsing
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace OpenRA.Graphics
|
||||
ZOffset = zOffset;
|
||||
}
|
||||
|
||||
public IRenderable[] Render(Actor self, WorldRenderer wr, PaletteReference pal)
|
||||
public IRenderable[] Render(Actor self, PaletteReference pal)
|
||||
{
|
||||
var center = self.CenterPosition;
|
||||
var offset = OffsetFunc?.Invoke() ?? WVec.Zero;
|
||||
|
||||
@@ -84,6 +84,7 @@ namespace OpenRA.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "IDE0060:Remove unused parameter", Justification = "Load game API")]
|
||||
public PlaceholderModelSequenceLoader(ModData modData) { }
|
||||
|
||||
public IModelCache CacheModels(IReadOnlyFileSystem fileSystem, ModData modData, IReadOnlyDictionary<string, MiniYamlNode> modelDefinitions)
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace OpenRA.Graphics
|
||||
shader.SetTexture("Palette", palette);
|
||||
}
|
||||
|
||||
public void SetViewportParams(Size screen, int2 scroll)
|
||||
public void SetViewportParams()
|
||||
{
|
||||
var a = 2f / renderer.SheetSize;
|
||||
var view = new[]
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace OpenRA.Graphics
|
||||
return new Vertex(xyz, cr, cg, cb, ca, 0, 0);
|
||||
}
|
||||
|
||||
public void FillEllipse(in float3 tl, in float3 br, Color color, int vertices = 32, BlendMode blendMode = BlendMode.Alpha)
|
||||
public void FillEllipse(in float3 tl, in float3 br, Color color, BlendMode blendMode = BlendMode.Alpha)
|
||||
{
|
||||
// TODO: Create an ellipse polygon instead
|
||||
var a = (br.X - tl.X) / 2;
|
||||
|
||||
@@ -56,14 +56,14 @@ namespace OpenRA.Graphics
|
||||
foreach (var b in waypoints.Skip(1).Select(pos => wr.Viewport.WorldToViewPx(wr.Screen3DPosition(pos))))
|
||||
{
|
||||
Game.Renderer.RgbaColorRenderer.DrawLine(a, b, width, color);
|
||||
DrawTargetMarker(wr, color, b, markerSize);
|
||||
DrawTargetMarker(color, b, markerSize);
|
||||
a = b;
|
||||
}
|
||||
|
||||
DrawTargetMarker(wr, color, first);
|
||||
DrawTargetMarker(color, first);
|
||||
}
|
||||
|
||||
public static void DrawTargetMarker(WorldRenderer wr, Color color, int2 screenPos, int size = 1)
|
||||
public static void DrawTargetMarker(Color color, int2 screenPos, int size = 1)
|
||||
{
|
||||
var offset = new int2(size, size);
|
||||
var tl = screenPos - offset;
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace OpenRA
|
||||
|
||||
var sequenceFormat = Manifest.Get<SpriteSequenceFormat>();
|
||||
var sequenceLoader = ObjectCreator.FindType(sequenceFormat.Type + "Loader");
|
||||
var sequenceCtor = sequenceLoader != null ? sequenceLoader.GetConstructor(new[] { typeof(ModData) }) : null;
|
||||
var sequenceCtor = sequenceLoader?.GetConstructor(new[] { typeof(ModData) });
|
||||
if (sequenceLoader == null || !sequenceLoader.GetInterfaces().Contains(typeof(ISpriteSequenceLoader)) || sequenceCtor == null)
|
||||
throw new InvalidOperationException($"Unable to find a sequence loader for type '{sequenceFormat.Type}'.");
|
||||
|
||||
|
||||
@@ -44,9 +44,8 @@ namespace OpenRA.Orders
|
||||
public virtual IEnumerable<Order> Order(World world, CPos cell, int2 worldPixel, MouseInput mi)
|
||||
{
|
||||
var target = TargetForInput(world, cell, worldPixel, mi);
|
||||
var actorsAt = world.ActorMap.GetActorsAt(cell).ToList();
|
||||
var orders = world.Selection.Actors
|
||||
.Select(a => OrderForUnit(a, target, actorsAt, cell, mi))
|
||||
.Select(a => OrderForUnit(a, target, cell, mi))
|
||||
.Where(o => o != null)
|
||||
.ToList();
|
||||
|
||||
@@ -70,7 +69,6 @@ namespace OpenRA.Orders
|
||||
public virtual string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi)
|
||||
{
|
||||
var target = TargetForInput(world, cell, worldPixel, mi);
|
||||
var actorsAt = world.ActorMap.GetActorsAt(cell).ToList();
|
||||
|
||||
bool useSelect;
|
||||
if (Game.Settings.Game.UseClassicMouseStyle && !InputOverridesSelection(world, worldPixel, mi))
|
||||
@@ -78,7 +76,7 @@ namespace OpenRA.Orders
|
||||
else
|
||||
{
|
||||
var ordersWithCursor = world.Selection.Actors
|
||||
.Select(a => OrderForUnit(a, target, actorsAt, cell, mi))
|
||||
.Select(a => OrderForUnit(a, target, cell, mi))
|
||||
.Where(o => o != null && o.Cursor != null);
|
||||
|
||||
var cursorOrder = ordersWithCursor.MaxByOrDefault(o => o.Order.OrderPriority);
|
||||
@@ -120,7 +118,7 @@ namespace OpenRA.Orders
|
||||
|
||||
foreach (var a in world.Selection.Actors)
|
||||
{
|
||||
var o = OrderForUnit(a, target, actorsAt, cell, mi);
|
||||
var o = OrderForUnit(a, target, cell, mi);
|
||||
if (o != null && o.Order.TargetOverridesSelection(a, target, actorsAt, cell, modifiers))
|
||||
return true;
|
||||
}
|
||||
@@ -135,7 +133,7 @@ namespace OpenRA.Orders
|
||||
/// First priority is given to orders that interact with the given actors.
|
||||
/// Second priority is given to actors in the given cell.
|
||||
/// </summary>
|
||||
static UnitOrderResult OrderForUnit(Actor self, Target target, List<Actor> actorsAt, CPos xy, MouseInput mi)
|
||||
static UnitOrderResult OrderForUnit(Actor self, Target target, CPos xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button != Game.Settings.Game.MouseButtonPreference.Action)
|
||||
return null;
|
||||
@@ -174,7 +172,7 @@ namespace OpenRA.Orders
|
||||
{
|
||||
var localModifiers = modifiers;
|
||||
string cursor = null;
|
||||
if (o.Order.CanTarget(self, target, actorsAt, ref localModifiers, ref cursor))
|
||||
if (o.Order.CanTarget(self, target, ref localModifiers, ref cursor))
|
||||
return new UnitOrderResult(self, o.Order, o.Trait, cursor, target);
|
||||
}
|
||||
|
||||
|
||||
@@ -254,7 +254,7 @@ namespace OpenRA
|
||||
if (lastWorldViewport != worldViewport)
|
||||
{
|
||||
WorldSpriteRenderer.SetViewportParams(worldSheet.Size, worldDownscaleFactor, depthMargin, worldViewport.Location);
|
||||
WorldModelRenderer.SetViewportParams(worldSheet.Size, worldViewport.Location);
|
||||
WorldModelRenderer.SetViewportParams();
|
||||
|
||||
lastWorldViewport = worldViewport;
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ namespace OpenRA.Scripting
|
||||
worldLoaded.Call().Dispose();
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
public void Tick()
|
||||
{
|
||||
if (FatalErrorOccurred || disposed)
|
||||
return;
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace OpenRA.Scripting
|
||||
throw new LuaException($"The property '{Member.Name}' is write-only");
|
||||
}
|
||||
|
||||
public void Set(LuaRuntime runtime, LuaValue value)
|
||||
public void Set(LuaValue value)
|
||||
{
|
||||
if (IsSetProperty)
|
||||
{
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace OpenRA.Scripting
|
||||
if (!members.TryGetValue(name, out var wrapper))
|
||||
throw new LuaException(MemberNotFoundError(name));
|
||||
|
||||
wrapper.Set(runtime, value);
|
||||
wrapper.Set(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1032,7 +1032,7 @@ namespace OpenRA.Server
|
||||
}
|
||||
}
|
||||
|
||||
public void ReceivePing(Connection conn, int[] pingHistory, byte queueLength)
|
||||
public void ReceivePing(Connection conn, int[] pingHistory)
|
||||
{
|
||||
// Levels set relative to the default order lag of 3 net ticks (360ms)
|
||||
// TODO: Adjust this once dynamic lag is implemented
|
||||
@@ -1389,7 +1389,7 @@ namespace OpenRA.Server
|
||||
|
||||
void IServerEvent.Invoke(Server server)
|
||||
{
|
||||
server.ReceivePing(connection, pingHistory, queueLength);
|
||||
server.ReceivePing(connection, pingHistory);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ namespace OpenRA.Traits
|
||||
flashAlpha = null;
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
||||
public IEnumerable<IRenderable> Render()
|
||||
{
|
||||
if (Shrouded)
|
||||
return NoRenderables;
|
||||
@@ -323,7 +323,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
return world.ScreenMap.RenderableFrozenActorsInBox(owner, wr.Viewport.TopLeft, wr.Viewport.BottomRight)
|
||||
.Where(f => f.Visible)
|
||||
.SelectMany(ff => ff.Render(wr));
|
||||
.SelectMany(ff => ff.Render());
|
||||
}
|
||||
|
||||
public IEnumerable<Rectangle> ScreenBounds(Actor self, WorldRenderer wr)
|
||||
|
||||
@@ -299,7 +299,7 @@ namespace OpenRA.Traits
|
||||
sources.Remove(key);
|
||||
}
|
||||
|
||||
public void ExploreProjectedCells(World world, IEnumerable<PPos> cells)
|
||||
public void ExploreProjectedCells(IEnumerable<PPos> cells)
|
||||
{
|
||||
foreach (var puv in cells)
|
||||
{
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
string OrderID { get; }
|
||||
int OrderPriority { get; }
|
||||
bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor);
|
||||
bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor);
|
||||
bool IsQueued { get; }
|
||||
bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenRA
|
||||
return self.TraitsImplementing<IVoiced>().Any(x => x.HasVoice(self, voice));
|
||||
}
|
||||
|
||||
public static void PlayVoiceForOrders(this World w, Order[] orders)
|
||||
public static void PlayVoiceForOrders(this Order[] orders)
|
||||
{
|
||||
// Find the first actor with a phrase to say
|
||||
foreach (var o in orders)
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
int ticks = 0;
|
||||
WPos targetPosition;
|
||||
|
||||
public Leap(Actor self, in Target target, Mobile mobile, Mobile targetMobile, int speed, AttackLeap attack, EdibleByLeap edible)
|
||||
public Leap(in Target target, Mobile mobile, Mobile targetMobile, int speed, AttackLeap attack, EdibleByLeap edible)
|
||||
{
|
||||
this.mobile = mobile;
|
||||
this.targetMobile = targetMobile;
|
||||
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
|
||||
// Update movement which results in movementType set to MovementType.None.
|
||||
// This is needed to prevent the move animation from playing.
|
||||
mobile.UpdateMovement(self);
|
||||
mobile.UpdateMovement();
|
||||
|
||||
// Revoke the condition before attacking, as it is usually used to pause the attack trait
|
||||
attack.RevokeLeapCondition(self);
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
return false;
|
||||
}
|
||||
|
||||
QueueChild(new Leap(self, target, mobile, targetMobile, info.Speed.Length, attack, edible));
|
||||
QueueChild(new Leap(target, mobile, targetMobile, info.Speed.Length, attack, edible));
|
||||
|
||||
// Re-queue the child activities to kill the target if it didn't die in one go
|
||||
return false;
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace OpenRA.Mods.Cnc.Graphics
|
||||
{
|
||||
public Action<string> OnMissingModelError { get; set; }
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "IDE0060:Remove unused parameter", Justification = "Load game API")]
|
||||
public VoxelModelSequenceLoader(ModData modData) { }
|
||||
|
||||
public IModelCache CacheModels(IReadOnlyFileSystem fileSystem, ModData modData, IReadOnlyDictionary<string, MiniYamlNode> modelSequences)
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
|
||||
public override Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
|
||||
{
|
||||
return new AttackTDGunboatTurretedActivity(self, newTarget, allowMove, forceAttack, targetLineColor);
|
||||
return new AttackTDGunboatTurretedActivity(self, newTarget, forceAttack, targetLineColor);
|
||||
}
|
||||
|
||||
class AttackTDGunboatTurretedActivity : Activity
|
||||
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
readonly Color? targetLineColor;
|
||||
bool hasTicked;
|
||||
|
||||
public AttackTDGunboatTurretedActivity(Actor self, in Target target, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||
public AttackTDGunboatTurretedActivity(Actor self, in Target target, bool forceAttack, Color? targetLineColor = null)
|
||||
{
|
||||
attack = self.Trait<AttackTDGunboatTurreted>();
|
||||
this.target = target;
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
if (hasTicked && attack.RequestedTarget.Type == TargetType.Invalid)
|
||||
return true;
|
||||
|
||||
attack.SetRequestedTarget(self, target);
|
||||
attack.SetRequestedTarget(target);
|
||||
hasTicked = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,14 +26,14 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
[Desc("Damage is divided by this number when converting damage to drain ticks.")]
|
||||
public readonly int DamageDivisor = 600;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new DrainPrerequisitePowerOnDamage(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new DrainPrerequisitePowerOnDamage(this); }
|
||||
}
|
||||
|
||||
public class DrainPrerequisitePowerOnDamage : ConditionalTrait<DrainPrerequisitePowerOnDamageInfo>, INotifyOwnerChanged, IDamageModifier
|
||||
{
|
||||
SupportPowerManager spm;
|
||||
|
||||
public DrainPrerequisitePowerOnDamage(Actor self, DrainPrerequisitePowerOnDamageInfo info)
|
||||
public DrainPrerequisitePowerOnDamage(DrainPrerequisitePowerOnDamageInfo info)
|
||||
: base(info) { }
|
||||
|
||||
protected override void Created(Actor self)
|
||||
|
||||
@@ -30,14 +30,14 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
[Desc("Sound the perpetrator will hear after successful infiltration.")]
|
||||
public readonly string InfiltrationNotification = null;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new InfiltrateForExploration(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new InfiltrateForExploration(this); }
|
||||
}
|
||||
|
||||
class InfiltrateForExploration : INotifyInfiltrated
|
||||
{
|
||||
readonly InfiltrateForExplorationInfo info;
|
||||
|
||||
public InfiltrateForExploration(Actor self, InfiltrateForExplorationInfo info)
|
||||
public InfiltrateForExploration(InfiltrateForExplorationInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
return new Order(order.OrderID, self, target, queued);
|
||||
}
|
||||
|
||||
bool IsValidOrder(Actor self, Order order)
|
||||
bool IsValidOrder(Order order)
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
return false;
|
||||
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
|
||||
public string VoicePhraseForOrder(Actor self, Order order)
|
||||
{
|
||||
return order.OrderString == "Infiltrate" && IsValidOrder(self, order)
|
||||
return order.OrderString == "Infiltrate" && IsValidOrder(order)
|
||||
? Info.Voice : null;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString != "Infiltrate" || !IsValidOrder(self, order) || IsTraitDisabled)
|
||||
if (order.OrderString != "Infiltrate" || !IsValidOrder(order) || IsTraitDisabled)
|
||||
return;
|
||||
|
||||
if (!CanInfiltrateTarget(self, order.Target))
|
||||
|
||||
@@ -360,7 +360,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
|
||||
public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
|
||||
|
||||
public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
||||
public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
if (target.Type != TargetType.Terrain)
|
||||
return false;
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
public bool IsQueued { get; protected set; }
|
||||
public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
|
||||
|
||||
public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
||||
public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
if (modifiers.HasModifier(TargetModifiers.ForceMove))
|
||||
{
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
|
||||
|
||||
IEnumerable<IRenderable> IRender.Render(Actor self, WorldRenderer wr)
|
||||
{
|
||||
var bodyOrientation = body.QuantizeOrientation(self, self.Orientation);
|
||||
var bodyOrientation = body.QuantizeOrientation(self.Orientation);
|
||||
var pos = self.CenterPosition;
|
||||
var i = 0;
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
|
||||
.FirstOrDefault(t => t.EnabledByDefault);
|
||||
if (renderSprites != null && infantryBody != null)
|
||||
{
|
||||
disguiseImage = renderSprites.GetImage(disguiseActor, self.World.Map.Rules.Sequences, disguisePlayer.Faction.InternalName);
|
||||
disguiseImage = renderSprites.GetImage(disguiseActor, disguisePlayer.Faction.InternalName);
|
||||
disguiseInfantryBody = infantryBody;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
|
||||
overlay.Play(info.Sequence);
|
||||
|
||||
WithOffset = new AnimationWithOffset(overlay,
|
||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self.Orientation))),
|
||||
() => !Visible || IsTraitDisabled);
|
||||
|
||||
rs.Add(WithOffset, info.Palette, info.IsPlayerPalette);
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
|
||||
|
||||
var idleModel = self.World.ModelCache.GetModelSequence(rv.Image, info.IdleSequence);
|
||||
modelAnimation = new ModelAnimation(idleModel, () => WVec.Zero,
|
||||
() => body.QuantizeOrientation(self, self.Orientation),
|
||||
() => body.QuantizeOrientation(self.Orientation),
|
||||
() => Docked,
|
||||
() => 0, info.ShowShadow);
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
|
||||
|
||||
var unloadModel = self.World.ModelCache.GetModelSequence(rv.Image, info.UnloadSequence);
|
||||
rv.Add(new ModelAnimation(unloadModel, () => WVec.Zero,
|
||||
() => body.QuantizeOrientation(self, self.Orientation),
|
||||
() => body.QuantizeOrientation(self.Orientation),
|
||||
() => !Docked,
|
||||
() => 0, info.ShowShadow));
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
|
||||
var model = self.World.ModelCache.GetModelSequence(rv.Image, info.Sequence);
|
||||
frames = model.Frames;
|
||||
modelAnimation = new ModelAnimation(model, () => WVec.Zero,
|
||||
() => body.QuantizeOrientation(self, self.Orientation),
|
||||
() => body.QuantizeOrientation(self.Orientation),
|
||||
() => IsTraitDisabled, () => frame, info.ShowShadow);
|
||||
|
||||
rv.Add(modelAnimation);
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
[Desc("How often the cash ticks can appear.")]
|
||||
public readonly int TickRate = 10;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new ResourcePurifier(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new ResourcePurifier(this); }
|
||||
}
|
||||
|
||||
public class ResourcePurifier : ConditionalTrait<ResourcePurifierInfo>, INotifyResourceAccepted, ITick, INotifyOwnerChanged
|
||||
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
int currentDisplayTick;
|
||||
int currentDisplayValue;
|
||||
|
||||
public ResourcePurifier(Actor self, ResourcePurifierInfo info)
|
||||
public ResourcePurifier(ResourcePurifierInfo info)
|
||||
: base(info)
|
||||
{
|
||||
modifier = new int[] { Info.Modifier };
|
||||
|
||||
@@ -70,13 +70,13 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
return new DischargeableSupportPowerInstance(key, info, manager);
|
||||
}
|
||||
|
||||
public void Activate(Actor self, SupportPowerInstance instance)
|
||||
public void Activate(Actor self)
|
||||
{
|
||||
active = true;
|
||||
techTree.ActorChanged(self);
|
||||
}
|
||||
|
||||
public void Deactivate(Actor self, SupportPowerInstance instance)
|
||||
public void Deactivate(Actor self)
|
||||
{
|
||||
active = false;
|
||||
techTree.ActorChanged(self);
|
||||
@@ -119,7 +119,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
available = false;
|
||||
|
||||
foreach (var p in Instances)
|
||||
((GrantPrerequisiteChargeDrainPower)p).Deactivate(p.Self, this);
|
||||
((GrantPrerequisiteChargeDrainPower)p).Deactivate(p.Self);
|
||||
}
|
||||
|
||||
public override void Tick()
|
||||
@@ -178,7 +178,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
power.PlayLaunchSounds();
|
||||
|
||||
foreach (var p in Instances)
|
||||
((GrantPrerequisiteChargeDrainPower)p).Activate(p.Self, this);
|
||||
((GrantPrerequisiteChargeDrainPower)p).Activate(p.Self);
|
||||
}
|
||||
|
||||
public override string IconOverlayTextOverride()
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
return;
|
||||
|
||||
var external = toActor.TraitsImplementing<ExternalCondition>()
|
||||
.FirstOrDefault(t => t.Info.Condition == info.Condition && t.CanGrantCondition(toActor, this));
|
||||
.FirstOrDefault(t => t.Info.Condition == info.Condition && t.CanGrantCondition(this));
|
||||
|
||||
external?.GrantCondition(toActor, this, duration, remaining);
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
public override void ReadActors(IniFile file)
|
||||
{
|
||||
base.ReadActors(file);
|
||||
LoadActors(file, "SHIPS", Players, MapSize, Map);
|
||||
LoadActors(file, "SHIPS", Players, Map);
|
||||
}
|
||||
|
||||
public override void SaveWaypoint(int waypointNumber, ActorReference waypointReference)
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return false;
|
||||
|
||||
target = target.Recalculate(self.Owner, out var targetIsHiddenActor);
|
||||
attackAircraft.SetRequestedTarget(self, target, forceAttack);
|
||||
attackAircraft.SetRequestedTarget(target, forceAttack);
|
||||
hasTicked = true;
|
||||
|
||||
if (!targetIsHiddenActor && target.Type == TargetType.Actor)
|
||||
@@ -171,9 +171,9 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
// The aircraft must keep moving forward even if it is already in an ideal position.
|
||||
else if (attackAircraft.Info.AttackType == AirAttackType.Strafe)
|
||||
QueueChild(new StrafeAttackRun(self, attackAircraft, aircraft, target, strafeDistance != WDist.Zero ? strafeDistance : lastVisibleMaximumRange));
|
||||
QueueChild(new StrafeAttackRun(attackAircraft, aircraft, target, strafeDistance != WDist.Zero ? strafeDistance : lastVisibleMaximumRange));
|
||||
else if (attackAircraft.Info.AttackType == AirAttackType.Default && !aircraft.Info.CanHover)
|
||||
QueueChild(new FlyAttackRun(self, target, lastVisibleMaximumRange, attackAircraft));
|
||||
QueueChild(new FlyAttackRun(target, lastVisibleMaximumRange, attackAircraft));
|
||||
|
||||
// Turn to face the target if required.
|
||||
else if (!attackAircraft.TargetInFiringArc(self, target, attackAircraft.Info.FacingTolerance))
|
||||
@@ -220,7 +220,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
Target target;
|
||||
bool targetIsVisibleActor;
|
||||
|
||||
public FlyAttackRun(Actor self, in Target t, WDist exitRange, AttackAircraft attack)
|
||||
public FlyAttackRun(in Target t, WDist exitRange, AttackAircraft attack)
|
||||
{
|
||||
ChildHasPriority = false;
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
Target target;
|
||||
|
||||
public StrafeAttackRun(Actor self, AttackAircraft attackAircraft, Aircraft aircraft, in Target t, WDist exitRange)
|
||||
public StrafeAttackRun(AttackAircraft attackAircraft, Aircraft aircraft, in Target t, WDist exitRange)
|
||||
{
|
||||
ChildHasPriority = false;
|
||||
|
||||
@@ -304,7 +304,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// Update the position if we seen the target move; keep the previous one if it dies or disappears
|
||||
target = target.Recalculate(self.Owner, out var targetIsHiddenActor);
|
||||
if (!targetIsHiddenActor && target.Type == TargetType.Actor)
|
||||
attackAircraft.SetRequestedTarget(self, Target.FromTargetPositions(target), true);
|
||||
attackAircraft.SetRequestedTarget(Target.FromTargetPositions(target), true);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
protected override void OnFirstRun(Actor self)
|
||||
{
|
||||
if (targetActor != null && targetActor.IsInWorld)
|
||||
harv.LinkProc(self, targetActor);
|
||||
harv.LinkProc(targetActor);
|
||||
}
|
||||
|
||||
public override bool Tick(Actor self)
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
self.Trait<Aircraft>().RemoveInfluence();
|
||||
|
||||
var localOffset = carryall.CarryableOffset.Rotate(body.QuantizeOrientation(self, self.Orientation));
|
||||
var localOffset = carryall.CarryableOffset.Rotate(body.QuantizeOrientation(self.Orientation));
|
||||
var targetPosition = self.CenterPosition + body.LocalToWorld(localOffset);
|
||||
var targetLocation = self.World.Map.CellContaining(targetPosition);
|
||||
carryall.Carryable.Trait<IPositionable>().SetPosition(carryall.Carryable, targetLocation, SubCell.FullCell);
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (IsCanceling || (deploy.DeployState != DeployState.Deployed && moving))
|
||||
return true;
|
||||
|
||||
QueueChild(new DeployInner(self, deploy));
|
||||
QueueChild(new DeployInner(deploy));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
readonly GrantConditionOnDeploy deployment;
|
||||
bool initiated;
|
||||
|
||||
public DeployInner(Actor self, GrantConditionOnDeploy deployment)
|
||||
public DeployInner(GrantConditionOnDeploy deployment)
|
||||
{
|
||||
this.deployment = deployment;
|
||||
|
||||
|
||||
@@ -159,19 +159,19 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// Harvesters should respect an explicit harvest order instead of harvesting the current cell.
|
||||
if (orderLocation == null)
|
||||
{
|
||||
if (harv.CanHarvestCell(self, self.Location) && claimLayer.CanClaimCell(self, self.Location))
|
||||
if (harv.CanHarvestCell(self.Location) && claimLayer.CanClaimCell(self, self.Location))
|
||||
return self.Location;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (harv.CanHarvestCell(self, orderLocation.Value) && claimLayer.CanClaimCell(self, orderLocation.Value))
|
||||
if (harv.CanHarvestCell(orderLocation.Value) && claimLayer.CanClaimCell(self, orderLocation.Value))
|
||||
return orderLocation;
|
||||
|
||||
orderLocation = null;
|
||||
}
|
||||
|
||||
// Determine where to search from and how far to search:
|
||||
var procLoc = GetSearchFromProcLocation(self);
|
||||
var procLoc = GetSearchFromProcLocation();
|
||||
var searchFromLoc = lastHarvestedCell ?? procLoc ?? self.Location;
|
||||
var searchRadius = lastHarvestedCell.HasValue ? harvInfo.SearchFromHarvesterRadius : harvInfo.SearchFromProcRadius;
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
using (var search = PathSearch.ToTargetCellByPredicate(
|
||||
self.World, mobile.Locomotor, self, new[] { searchFromLoc, self.Location },
|
||||
loc =>
|
||||
harv.CanHarvestCell(self, loc) &&
|
||||
harv.CanHarvestCell(loc) &&
|
||||
claimLayer.CanClaimCell(self, loc),
|
||||
BlockedByActor.Stationary,
|
||||
loc =>
|
||||
@@ -196,7 +196,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
// Add a cost modifier to harvestable cells to prefer resources that are closer to the refinery.
|
||||
// This reduces the tendency for harvesters to move in straight lines
|
||||
if (procPos.HasValue && harvInfo.ResourceRefineryDirectionPenalty > 0 && harv.CanHarvestCell(self, loc))
|
||||
if (procPos.HasValue && harvInfo.ResourceRefineryDirectionPenalty > 0 && harv.CanHarvestCell(loc))
|
||||
{
|
||||
var pos = map.CenterOfCell(loc);
|
||||
|
||||
@@ -244,7 +244,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
yield return new TargetLineNode(Target.FromActor(deliverActor), harvInfo.DeliverLineColor);
|
||||
}
|
||||
|
||||
CPos? GetSearchFromProcLocation(Actor self)
|
||||
CPos? GetSearchFromProcLocation()
|
||||
{
|
||||
if (harv.LastLinkedProc != null && !harv.LastLinkedProc.IsDead && harv.LastLinkedProc.IsInWorld)
|
||||
return harv.LastLinkedProc.Location + harv.LastLinkedProc.Trait<IAcceptResources>().DeliveryOffset;
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!harv.CanHarvestCell(self, self.Location))
|
||||
if (!harv.CanHarvestCell(self.Location))
|
||||
return true;
|
||||
|
||||
// Turn to one of the harvestable facings
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
case DockingState.Complete:
|
||||
Harv.LastLinkedProc = Harv.LinkedProc;
|
||||
Harv.LinkProc(self, null);
|
||||
Harv.LinkProc(null);
|
||||
if (IsDragRequired)
|
||||
QueueChild(new Drag(self, EndDrag, StartDrag, DragLength));
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
}
|
||||
|
||||
// Can complete the move in this step
|
||||
var speed = mobile.MovementSpeedForCell(self, self.Location);
|
||||
var speed = mobile.MovementSpeedForCell(self.Location);
|
||||
if (delta.LengthSquared <= speed * speed)
|
||||
{
|
||||
mobile.SetCenterPosition(self, targetPos);
|
||||
|
||||
@@ -415,7 +415,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// Only move by a full speed step if we didn't already move this tick.
|
||||
// If we did, we limit the move to any carried-over leftover progress.
|
||||
if (Move.lastMovePartCompletedTick < self.World.WorldTick)
|
||||
progress += mobile.MovementSpeedForCell(self, mobile.ToCell);
|
||||
progress += mobile.MovementSpeedForCell(mobile.ToCell);
|
||||
|
||||
if (progress >= Distance)
|
||||
{
|
||||
@@ -448,13 +448,13 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
var currentCellOrientation = self.World.Map.TerrainOrientation(mobile.FromCell);
|
||||
var orientation = WRot.SLerp(FromTerrainOrientation.Value, currentCellOrientation, progress, terrainOrientationMargin);
|
||||
mobile.SetTerrainRampOrientation(self, orientation);
|
||||
mobile.SetTerrainRampOrientation(orientation);
|
||||
}
|
||||
else if (ToTerrainOrientation.HasValue && Distance - progress < terrainOrientationMargin)
|
||||
{
|
||||
var currentCellOrientation = self.World.Map.TerrainOrientation(mobile.FromCell);
|
||||
var orientation = WRot.SLerp(ToTerrainOrientation.Value, currentCellOrientation, Distance - progress, terrainOrientationMargin);
|
||||
mobile.SetTerrainRampOrientation(self, orientation);
|
||||
mobile.SetTerrainRampOrientation(orientation);
|
||||
}
|
||||
|
||||
mobile.Facing = WAngle.Lerp(FromFacing, ToFacing, progress, Distance);
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// Pickup position and facing are now known - swap the fly/wait activity with Land
|
||||
ChildActivity.Cancel(self);
|
||||
|
||||
var localOffset = carryall.OffsetForCarryable(self, cargo).Rotate(carryableBody.QuantizeOrientation(self, cargo.Orientation));
|
||||
var localOffset = carryall.OffsetForCarryable(self, cargo).Rotate(carryableBody.QuantizeOrientation(cargo.Orientation));
|
||||
QueueChild(new Land(self, Target.FromActor(cargo), -carryableBody.LocalToWorld(localOffset), carryableFacing.Facing));
|
||||
|
||||
// Pause briefly before attachment for visual effect
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
if (mi.Modifiers.HasModifier(Modifiers.Shift))
|
||||
{
|
||||
FloodFillWithBrush(cell, isMoving);
|
||||
FloodFillWithBrush(cell);
|
||||
painting = false;
|
||||
}
|
||||
else
|
||||
@@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
editorActionManager.Add(new PaintTileEditorAction(Template, world.Map, cell));
|
||||
}
|
||||
|
||||
void FloodFillWithBrush(CPos cell, bool isMoving)
|
||||
void FloodFillWithBrush(CPos cell)
|
||||
{
|
||||
var map = world.Map;
|
||||
var mapTiles = map.Tiles;
|
||||
|
||||
@@ -113,10 +113,10 @@ namespace OpenRA.Mods.Common.Effects
|
||||
if (targetLineNodes.Count == 0)
|
||||
return SpriteRenderable.None;
|
||||
|
||||
return RenderInner(wr);
|
||||
return RenderInner();
|
||||
}
|
||||
|
||||
IEnumerable<IRenderable> RenderInner(WorldRenderer wr)
|
||||
IEnumerable<IRenderable> RenderInner()
|
||||
{
|
||||
var prev = targetLineNodes[0];
|
||||
foreach (var pos in targetLineNodes.Skip(1))
|
||||
|
||||
@@ -59,9 +59,9 @@ namespace OpenRA.Mods.Common.FileFormats
|
||||
3, 4, 5, 6, 7, 8
|
||||
};
|
||||
|
||||
static readonly Huffman LitCode = new Huffman(LitLen, LitLen.Length, 256);
|
||||
static readonly Huffman LenCode = new Huffman(LenLen, LenLen.Length, 16);
|
||||
static readonly Huffman DistCode = new Huffman(DistLen, DistLen.Length, 64);
|
||||
static readonly Huffman LitCode = new Huffman(LitLen, 256);
|
||||
static readonly Huffman LenCode = new Huffman(LenLen, 16);
|
||||
static readonly Huffman DistCode = new Huffman(DistLen, 64);
|
||||
|
||||
/// <summary>PKWare Compression Library stream.</summary>
|
||||
/// <param name="input">Compressed input stream.</param>
|
||||
@@ -247,7 +247,7 @@ namespace OpenRA.Mods.Common.FileFormats
|
||||
public short[] Count; // number of symbols of each length
|
||||
public short[] Symbol; // canonically ordered symbols
|
||||
|
||||
public Huffman(byte[] rep, int n, short symbolCount)
|
||||
public Huffman(byte[] rep, short symbolCount)
|
||||
{
|
||||
var length = new short[256]; // code lengths
|
||||
var s = 0; // current symbol
|
||||
@@ -262,7 +262,7 @@ namespace OpenRA.Mods.Common.FileFormats
|
||||
while (--num > 0);
|
||||
}
|
||||
|
||||
n = s;
|
||||
var n = s;
|
||||
|
||||
// count number of codes of each length
|
||||
Count = new short[Blast.MAXBITS + 1];
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
|
||||
public class DefaultSpriteSequenceLoader : ISpriteSequenceLoader
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "IDE0060:Remove unused parameter", Justification = "Load game API")]
|
||||
public DefaultSpriteSequenceLoader(ModData modData) { }
|
||||
|
||||
public virtual ISpriteSequence CreateSequence(ModData modData, string tileSet, SpriteCache cache, string sequence, string animation, MiniYaml info)
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
public IRenderable OffsetBy(in WVec vec) { return new SelectionBarsAnnotationRenderable(pos + vec, actor, decorationBounds); }
|
||||
public IRenderable AsDecoration() { return this; }
|
||||
|
||||
void DrawExtraBars(WorldRenderer wr, float2 start, float2 end)
|
||||
void DrawExtraBars(float2 start, float2 end)
|
||||
{
|
||||
foreach (var extraBar in actor.TraitsImplementing<ISelectionBar>())
|
||||
{
|
||||
@@ -58,12 +58,12 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
var offset = new float2(0, 4);
|
||||
start += offset;
|
||||
end += offset;
|
||||
DrawSelectionBar(wr, start, end, extraBar.GetValue(), extraBar.GetColor());
|
||||
DrawSelectionBar(start, end, extraBar.GetValue(), extraBar.GetColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawSelectionBar(WorldRenderer wr, float2 start, float2 end, float value, Color barColor)
|
||||
void DrawSelectionBar(float2 start, float2 end, float value, Color barColor)
|
||||
{
|
||||
var c = Color.FromArgb(128, 30, 30, 30);
|
||||
var c2 = Color.FromArgb(128, 10, 10, 10);
|
||||
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
health.DamageState == DamageState.Heavy ? Color.Yellow : Color.LimeGreen;
|
||||
}
|
||||
|
||||
void DrawHealthBar(WorldRenderer wr, IHealth health, float2 start, float2 end)
|
||||
void DrawHealthBar(IHealth health, float2 start, float2 end)
|
||||
{
|
||||
if (health == null || health.IsDead)
|
||||
return;
|
||||
@@ -149,10 +149,10 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
var end = wr.Viewport.WorldToViewPx(new float2(decorationBounds.Right - 1, decorationBounds.Top));
|
||||
|
||||
if (DisplayHealth)
|
||||
DrawHealthBar(wr, health, start, end);
|
||||
DrawHealthBar(health, start, end);
|
||||
|
||||
if (DisplayExtra)
|
||||
DrawExtraBars(wr, start, end);
|
||||
DrawExtraBars(start, end);
|
||||
}
|
||||
|
||||
public void RenderDebugGeometry(WorldRenderer wr) { }
|
||||
|
||||
@@ -59,12 +59,12 @@ namespace OpenRA.Mods.Common.Lint
|
||||
foreach (var filename in modData.Manifest.ChromeLayout)
|
||||
{
|
||||
var yaml = MiniYaml.FromStream(modData.DefaultFileSystem.Open(filename), filename);
|
||||
CheckInner(modData, namedKeys, checkWidgetFields, customLintMethods, yaml, filename, null, emitError, emitWarning);
|
||||
CheckInner(modData, namedKeys, checkWidgetFields, customLintMethods, yaml, filename, null, emitError);
|
||||
}
|
||||
}
|
||||
|
||||
void CheckInner(ModData modData, string[] namedKeys, (string Widget, string Field)[] checkWidgetFields, Dictionary<string, List<string>> customLintMethods,
|
||||
List<MiniYamlNode> nodes, string filename, MiniYamlNode parent, Action<string> emitError, Action<string> emitWarning)
|
||||
List<MiniYamlNode> nodes, string filename, MiniYamlNode parent, Action<string> emitError)
|
||||
{
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
if (customLintMethods.TryGetValue(widgetType, out var checkMethods))
|
||||
{
|
||||
var type = modData.ObjectCreator.FindType(widgetType + "Widget");
|
||||
var keyNames = checkMethods.SelectMany(m => (IEnumerable<string>)type.GetMethod(m).Invoke(null, new object[] { node, emitError, emitWarning }));
|
||||
var keyNames = checkMethods.SelectMany(m => (IEnumerable<string>)type.GetMethod(m).Invoke(null, new object[] { node, emitError }));
|
||||
|
||||
foreach (var name in keyNames)
|
||||
if (!namedKeys.Contains(name) && !Hotkey.TryParse(name, out var unused))
|
||||
@@ -114,7 +114,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
}
|
||||
|
||||
if (node.Value.Nodes != null)
|
||||
CheckInner(modData, namedKeys, checkWidgetFields, customLintMethods, node.Value.Nodes, filename, node, emitError, emitWarning);
|
||||
CheckInner(modData, namedKeys, checkWidgetFields, customLintMethods, node.Value.Nodes, filename, node, emitError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,14 +51,14 @@ namespace OpenRA.Mods.Common.Lint
|
||||
if (string.IsNullOrEmpty(locomotor))
|
||||
continue;
|
||||
|
||||
CheckLocomotors(actorInfo.Value, emitError, rules, locomotorInfos, locomotor);
|
||||
CheckLocomotors(actorInfo.Value, emitError, locomotorInfos, locomotor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CheckLocomotors(ActorInfo actorInfo, Action<string> emitError, Ruleset rules, LocomotorInfo[] locomotorInfos, string locomotor)
|
||||
void CheckLocomotors(ActorInfo actorInfo, Action<string> emitError, LocomotorInfo[] locomotorInfos, string locomotor)
|
||||
{
|
||||
if (!locomotorInfos.Any(l => l.Name == locomotor))
|
||||
emitError($"Actor {actorInfo.Name} defines Locomotor {locomotor} not found on World actor.");
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
{
|
||||
var palettes = new List<string>();
|
||||
var playerPalettes = new List<string>();
|
||||
GetPalettes(emitError, rules, palettes, playerPalettes);
|
||||
GetPalettes(rules, palettes, playerPalettes);
|
||||
|
||||
foreach (var actorInfo in rules.Actors)
|
||||
{
|
||||
@@ -121,7 +121,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
}
|
||||
}
|
||||
|
||||
void GetPalettes(Action<string> emitError, Ruleset rules, List<string> palettes, List<string> playerPalettes)
|
||||
void GetPalettes(Ruleset rules, List<string> palettes, List<string> playerPalettes)
|
||||
{
|
||||
foreach (var actorInfo in rules.Actors)
|
||||
{
|
||||
|
||||
@@ -47,12 +47,12 @@ namespace OpenRA.Mods.Common.Lint
|
||||
|
||||
var images = new HashSet<string>()
|
||||
{
|
||||
renderInfo.GetImage(actorInfo.Value, sequences, null).ToLowerInvariant()
|
||||
renderInfo.GetImage(actorInfo.Value, null).ToLowerInvariant()
|
||||
};
|
||||
|
||||
// Some actors define faction-specific artwork
|
||||
foreach (var faction in factions)
|
||||
images.Add(renderInfo.GetImage(actorInfo.Value, sequences, faction).ToLowerInvariant());
|
||||
images.Add(renderInfo.GetImage(actorInfo.Value, faction).ToLowerInvariant());
|
||||
|
||||
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Orders
|
||||
public int OrderPriority { get; private set; }
|
||||
public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
|
||||
|
||||
public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
||||
public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
if (target.Type != TargetType.Actor)
|
||||
return false;
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace OpenRA.Mods.Common.Orders
|
||||
{
|
||||
foreach (var a in world.ActorMap.GetActorsAt(cell))
|
||||
foreach (var p in a.TraitsImplementing<Pluggable>())
|
||||
if (p.AcceptsPlug(a, plug.Type))
|
||||
if (p.AcceptsPlug(plug.Type))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Orders
|
||||
public abstract bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor);
|
||||
public abstract bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor);
|
||||
|
||||
public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
||||
public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
var type = target.Type;
|
||||
if (type != TargetType.Actor && type != TargetType.FrozenActor)
|
||||
|
||||
@@ -302,7 +302,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
if ((sbyte)vFacing < 0)
|
||||
speed = minSpeed;
|
||||
else if (!WillClimbWithinDistance(vFacing, loopRadius, predClfDist, diffClfMslHgt)
|
||||
&& !WillClimbAroundInclineTop(vFacing, loopRadius, predClfDist, diffClfMslHgt, speed))
|
||||
&& !WillClimbAroundInclineTop(vFacing, loopRadius, predClfDist, diffClfMslHgt))
|
||||
{
|
||||
// Find highest speed greater than the above minimum that allows the missile
|
||||
// to surmount the incline
|
||||
@@ -311,7 +311,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
{
|
||||
var lpRds = LoopRadius(spd, info.VerticalRateOfTurn.Facing);
|
||||
return WillClimbWithinDistance(vFac, lpRds, predClfDist, diffClfMslHgt)
|
||||
|| WillClimbAroundInclineTop(vFac, lpRds, predClfDist, diffClfMslHgt, spd);
|
||||
|| WillClimbAroundInclineTop(vFac, lpRds, predClfDist, diffClfMslHgt);
|
||||
});
|
||||
}
|
||||
else
|
||||
@@ -401,7 +401,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
// Will missile climb around incline top if bringing vertical facing
|
||||
// down to zero on an arc of radius loopRadius
|
||||
// Calling this function only makes sense when IsNearInclineTop returns true
|
||||
static bool WillClimbAroundInclineTop(int vFacing, int loopRadius, int predClfDist, int diffClfMslHgt, int speed)
|
||||
static bool WillClimbAroundInclineTop(int vFacing, int loopRadius, int predClfDist, int diffClfMslHgt)
|
||||
{
|
||||
// Vector from missile's current position pointing to the loop's center
|
||||
var radius = new WVec(loopRadius, 0, 0)
|
||||
@@ -523,7 +523,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
// Missile will climb around incline top if bringing vertical facing
|
||||
// down to zero on an arc of radius loopRadius
|
||||
else if (IsNearInclineTop(vFacing, loopRadius, predClfDist)
|
||||
&& WillClimbAroundInclineTop(vFacing, loopRadius, predClfDist, diffClfMslHgt, speed))
|
||||
&& WillClimbAroundInclineTop(vFacing, loopRadius, predClfDist, diffClfMslHgt))
|
||||
desiredVFacing = 0;
|
||||
|
||||
// Missile will not climb terrAltDiff w-units within hHeightChange w-units
|
||||
@@ -537,7 +537,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
for (var vFac = System.Math.Min(vFacing + info.VerticalRateOfTurn.Facing - 1, 63); vFac >= vFacing; vFac--)
|
||||
if (!WillClimbWithinDistance(vFac, loopRadius, predClfDist, diffClfMslHgt)
|
||||
&& !(predClfDist <= loopRadius * (1024 - WAngle.FromFacing(vFac).Sin()) / 1024
|
||||
&& WillClimbAroundInclineTop(vFac, loopRadius, predClfDist, diffClfMslHgt, speed)))
|
||||
&& WillClimbAroundInclineTop(vFac, loopRadius, predClfDist, diffClfMslHgt)))
|
||||
{
|
||||
desiredVFacing = vFac + 1;
|
||||
break;
|
||||
@@ -568,7 +568,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
}
|
||||
|
||||
int HomingInnerTick(int predClfDist, int diffClfMslHgt, int relTarHorDist, int lastHtChg, int lastHt,
|
||||
int nxtRelTarHorDist, int relTarHgt, int vFacing, bool targetPassedBy)
|
||||
int relTarHgt, int vFacing, bool targetPassedBy)
|
||||
{
|
||||
int desiredVFacing = vFacing;
|
||||
|
||||
@@ -772,7 +772,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
targetPassedBy = false;
|
||||
|
||||
var desiredVFacing = HomingInnerTick(predClfDist, diffClfMslHgt, relTarHorDist, lastHtChg, lastHt,
|
||||
nxtRelTarHorDist, relTarHgt, vFacing, targetPassedBy);
|
||||
relTarHgt, vFacing, targetPassedBy);
|
||||
|
||||
// The target has been passed by
|
||||
if (tarDistVec.HorizontalLength < speed * WAngle.FromFacing(vFacing).Cos() / 1024)
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
|
||||
void ITick.Tick(Actor self)
|
||||
{
|
||||
context.Tick(self);
|
||||
context.Tick();
|
||||
}
|
||||
|
||||
void INotifyActorDisposing.Disposing(Actor self)
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
public int GrantCondition(string condition, int duration = 0)
|
||||
{
|
||||
var external = externalConditions
|
||||
.FirstOrDefault(t => t.Info.Condition == condition && t.CanGrantCondition(Self, this));
|
||||
.FirstOrDefault(t => t.Info.Condition == condition && t.CanGrantCondition(this));
|
||||
|
||||
if (external == null)
|
||||
throw new LuaException($"Condition `{condition}` has not been listed on an enabled ExternalCondition trait");
|
||||
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
public bool AcceptsCondition(string condition)
|
||||
{
|
||||
return externalConditions
|
||||
.Any(t => t.Info.Condition == condition && t.CanGrantCondition(Self, this));
|
||||
.Any(t => t.Info.Condition == condition && t.CanGrantCondition(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
public int GrantCondition(string condition, int duration = 0)
|
||||
{
|
||||
var external = externalConditions
|
||||
.FirstOrDefault(t => t.Info.Condition == condition && t.CanGrantCondition(Player.PlayerActor, this));
|
||||
.FirstOrDefault(t => t.Info.Condition == condition && t.CanGrantCondition(this));
|
||||
|
||||
if (external == null)
|
||||
throw new LuaException($"Condition `{condition}` has not been listed on an enabled ExternalCondition trait");
|
||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
public bool AcceptsCondition(string condition)
|
||||
{
|
||||
return externalConditions
|
||||
.Any(t => t.Info.Condition == condition && t.CanGrantCondition(Player.PlayerActor, this));
|
||||
.Any(t => t.Info.Condition == condition && t.CanGrantCondition(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace OpenRA.Mods.Common.Terrain
|
||||
{
|
||||
public class DefaultTerrainLoader : ITerrainLoader
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "IDE0060:Remove unused parameter", Justification = "Load game API")]
|
||||
public DefaultTerrainLoader(ModData modData) { }
|
||||
|
||||
public ITerrainInfo ParseTerrain(IReadOnlyFileSystem fileSystem, string path)
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Player relationships the owner of the delivering actor needs.")]
|
||||
public readonly PlayerRelationship ValidRelationships = PlayerRelationship.Ally;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new AcceptsDeliveredExperience(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new AcceptsDeliveredExperience(); }
|
||||
}
|
||||
|
||||
public class AcceptsDeliveredExperience
|
||||
{
|
||||
public AcceptsDeliveredExperience(Actor self, AcceptsDeliveredExperienceInfo info) { }
|
||||
public AcceptsDeliveredExperience() { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1286,7 +1286,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return modifiers.HasModifier(TargetModifiers.ForceMove);
|
||||
}
|
||||
|
||||
public virtual bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
||||
public virtual bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
if (target.Type != TargetType.Terrain || (aircraft.requireForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove)))
|
||||
return false;
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
OnExitedAttackRange(self);
|
||||
}
|
||||
|
||||
public void SetTarget(World w, WPos pos) { target = Target.FromPos(pos); }
|
||||
public void SetTarget(WPos pos) { target = Target.FromPos(pos); }
|
||||
|
||||
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("The condition to grant to self for each ammo point in this pool.")]
|
||||
public readonly string AmmoCondition = null;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new AmmoPool(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new AmmoPool(this); }
|
||||
}
|
||||
|
||||
public class AmmoPool : INotifyCreated, INotifyAttack, ISync
|
||||
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public bool HasAmmo => CurrentAmmoCount > 0;
|
||||
public bool HasFullAmmo => CurrentAmmoCount == Info.Ammo;
|
||||
|
||||
public AmmoPool(Actor self, AmmoPoolInfo info)
|
||||
public AmmoPool(AmmoPoolInfo info)
|
||||
{
|
||||
Info = info;
|
||||
CurrentAmmoCount = Info.InitialAmmo < Info.Ammo && Info.InitialAmmo >= 0 ? Info.InitialAmmo : Info.Ammo;
|
||||
|
||||
@@ -380,7 +380,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var localOffset = b.Offset + new WVec(-Recoil, WDist.Zero, WDist.Zero);
|
||||
|
||||
// Turret coordinates to body coordinates
|
||||
var bodyOrientation = coords.QuantizeOrientation(self, self.Orientation);
|
||||
var bodyOrientation = coords.QuantizeOrientation(self.Orientation);
|
||||
if (turret != null)
|
||||
localOffset = localOffset.Rotate(turret.WorldOrientation) + turret.Offset.Rotate(bodyOrientation);
|
||||
else
|
||||
|
||||
@@ -19,12 +19,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public readonly string Type = null;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new Armor(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new Armor(this); }
|
||||
}
|
||||
|
||||
public class Armor : ConditionalTrait<ArmorInfo>
|
||||
{
|
||||
public Armor(Actor self, ArmorInfo info)
|
||||
public Armor(ArmorInfo info)
|
||||
: base(info) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,7 +474,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CanTargetLocation(Actor self, CPos location, List<Actor> actorsAtLocation, TargetModifiers modifiers, ref string cursor)
|
||||
bool CanTargetLocation(Actor self, CPos location, TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
if (!self.World.Map.Contains(location))
|
||||
return false;
|
||||
@@ -505,7 +505,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
||||
public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
switch (target.Type)
|
||||
{
|
||||
@@ -513,7 +513,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
case TargetType.FrozenActor:
|
||||
return CanTargetActor(self, target, ref modifiers, ref cursor);
|
||||
case TargetType.Terrain:
|
||||
return CanTargetLocation(self, self.World.Map.CellContaining(target.CenterPosition), othersAtTarget, modifiers, ref cursor);
|
||||
return CanTargetLocation(self, self.World.Map.CellContaining(target.CenterPosition), modifiers, ref cursor);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
bool opportunityForceAttack;
|
||||
bool opportunityTargetIsPersistentTarget;
|
||||
|
||||
public void SetRequestedTarget(Actor self, in Target target, bool isForceAttack = false)
|
||||
public void SetRequestedTarget(in Target target, bool isForceAttack = false)
|
||||
{
|
||||
RequestedTarget = target;
|
||||
requestedForceAttack = isForceAttack;
|
||||
@@ -274,7 +274,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return false;
|
||||
|
||||
target = target.Recalculate(self.Owner, out var targetIsHiddenActor);
|
||||
attack.SetRequestedTarget(self, target, forceAttack);
|
||||
attack.SetRequestedTarget(target, forceAttack);
|
||||
hasTicked = true;
|
||||
|
||||
if (!targetIsHiddenActor && target.Type == TargetType.Actor)
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
WVec PortOffset(Actor self, FirePort p)
|
||||
{
|
||||
var bodyOrientation = coords.Value.QuantizeOrientation(self, self.Orientation);
|
||||
var bodyOrientation = coords.Value.QuantizeOrientation(self.Orientation);
|
||||
return coords.Value.LocalToWorld(p.Offset.Rotate(bodyOrientation));
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Display muzzle flashes
|
||||
foreach (var m in muzzles)
|
||||
foreach (var r in m.Render(self, wr, pal))
|
||||
foreach (var r in m.Render(self, pal))
|
||||
yield return r;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,15 +19,15 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Required distance away from destination before requesting a pickup. Default is 6 cells.")]
|
||||
public readonly WDist MinDistance = WDist.FromCells(6);
|
||||
|
||||
public override object Create(ActorInitializer init) { return new AutoCarryable(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new AutoCarryable(this); }
|
||||
}
|
||||
|
||||
public class AutoCarryable : Carryable, ICallForTransport
|
||||
{
|
||||
readonly AutoCarryableInfo info;
|
||||
|
||||
public AutoCarryable(Actor self, AutoCarryableInfo info)
|
||||
: base(self, info)
|
||||
public AutoCarryable(AutoCarryableInfo info)
|
||||
: base(info)
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
@@ -35,10 +35,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public WDist MinimumDistance => info.MinDistance;
|
||||
|
||||
// No longer want to be carried
|
||||
void ICallForTransport.MovementCancelled(Actor self) { MovementCancelled(self); }
|
||||
void ICallForTransport.MovementCancelled(Actor self) { MovementCancelled(); }
|
||||
void ICallForTransport.RequestTransport(Actor self, CPos destination) { RequestTransport(self, destination); }
|
||||
|
||||
void MovementCancelled(Actor self)
|
||||
void MovementCancelled()
|
||||
{
|
||||
if (state == State.Locked)
|
||||
return;
|
||||
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (delta.HorizontalLengthSquared < info.MinDistance.LengthSquared)
|
||||
{
|
||||
// Cancel pickup
|
||||
MovementCancelled(self);
|
||||
MovementCancelled();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (delta.HorizontalLengthSquared < info.MinDistance.LengthSquared)
|
||||
{
|
||||
// Cancel pickup
|
||||
MovementCancelled(self);
|
||||
MovementCancelled();
|
||||
return LockResponse.Failed;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsBestAutoCarryallForCargo(Actor self, Actor candidateCargo)
|
||||
static bool IsBestAutoCarryallForCargo(Actor self, Actor candidateCargo)
|
||||
{
|
||||
// Find carriers
|
||||
var carriers = self.World.ActorsHavingTrait<AutoCarryall>(c => !c.busy)
|
||||
|
||||
@@ -257,7 +257,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
Aggressor = attacker;
|
||||
|
||||
Attack(self, Target.FromActor(Aggressor), allowMove);
|
||||
Attack(Target.FromActor(Aggressor), allowMove);
|
||||
}
|
||||
|
||||
void INotifyIdle.TickIdle(Actor self)
|
||||
@@ -309,10 +309,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var target = ScanForTarget(self, allowMove, allowTurn);
|
||||
if (target.Type != TargetType.Invalid)
|
||||
Attack(self, target, allowMove);
|
||||
Attack(target, allowMove);
|
||||
}
|
||||
|
||||
void Attack(Actor self, in Target target, bool allowMove)
|
||||
void Attack(in Target target, bool allowMove)
|
||||
{
|
||||
foreach (var ab in ActiveAttackBases)
|
||||
ab.AttackTarget(target, AttackSource.AutoTarget, false, allowMove);
|
||||
|
||||
@@ -22,12 +22,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Determines what projectiles to block based on their allegiance to the wall owner.")]
|
||||
public readonly PlayerRelationship ValidRelationships = PlayerRelationship.Ally | PlayerRelationship.Neutral | PlayerRelationship.Enemy;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new BlocksProjectiles(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new BlocksProjectiles(this); }
|
||||
}
|
||||
|
||||
public class BlocksProjectiles : ConditionalTrait<BlocksProjectilesInfo>, IBlocksProjectiles
|
||||
{
|
||||
public BlocksProjectiles(Actor self, BlocksProjectilesInfo info)
|
||||
public BlocksProjectiles(BlocksProjectilesInfo info)
|
||||
: base(info) { }
|
||||
|
||||
WDist IBlocksProjectiles.BlockingHeight => Info.Height;
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return info.LocalToWorld(vec);
|
||||
}
|
||||
|
||||
public WRot QuantizeOrientation(Actor self, in WRot orientation)
|
||||
public WRot QuantizeOrientation(in WRot orientation)
|
||||
{
|
||||
return info.QuantizeOrientation(orientation, quantizedFacings.Value);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (plugInfo != null)
|
||||
{
|
||||
var possibleBuilding = world.ActorsWithTrait<Pluggable>().FirstOrDefault(a =>
|
||||
a.Actor.Owner == player && a.Trait.AcceptsPlug(a.Actor, plugInfo.Type));
|
||||
a.Actor.Owner == player && a.Trait.AcceptsPlug(plugInfo.Type));
|
||||
|
||||
if (possibleBuilding.Actor != null)
|
||||
{
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// IsValid check filters out Frozen Actors that have not initialized their Owner
|
||||
foreach (var scrutinized in checkFrozen)
|
||||
answer += consideration.GetAttractiveness(scrutinized, firedBy.RelationshipWith(scrutinized.Owner), firedBy);
|
||||
answer += consideration.GetAttractiveness(scrutinized, firedBy.RelationshipWith(scrutinized.Owner));
|
||||
}
|
||||
|
||||
return answer;
|
||||
@@ -105,7 +105,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var consideration in Considerations)
|
||||
foreach (var scrutinized in frozenActors)
|
||||
if (scrutinized.IsValid && scrutinized.Visible)
|
||||
answer += consideration.GetAttractiveness(scrutinized, firedBy.RelationshipWith(scrutinized.Owner), firedBy);
|
||||
answer += consideration.GetAttractiveness(scrutinized, firedBy.RelationshipWith(scrutinized.Owner));
|
||||
|
||||
return answer;
|
||||
}
|
||||
@@ -174,7 +174,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int GetAttractiveness(FrozenActor fa, PlayerRelationship stance, Player firedBy)
|
||||
public int GetAttractiveness(FrozenActor fa, PlayerRelationship stance)
|
||||
{
|
||||
if (stance != Against)
|
||||
return 0;
|
||||
|
||||
@@ -16,12 +16,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Manages AI repairing base buildings.")]
|
||||
public class BuildingRepairBotModuleInfo : ConditionalTraitInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new BuildingRepairBotModule(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new BuildingRepairBotModule(this); }
|
||||
}
|
||||
|
||||
public class BuildingRepairBotModule : ConditionalTrait<BuildingRepairBotModuleInfo>, IBotRespondToAttack
|
||||
{
|
||||
public BuildingRepairBotModule(Actor self, BuildingRepairBotModuleInfo info)
|
||||
public BuildingRepairBotModule(BuildingRepairBotModuleInfo info)
|
||||
: base(info) { }
|
||||
|
||||
void IBotRespondToAttack.RespondToAttack(IBot bot, Actor self, AttackInfo e)
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Target FindNextResource(Actor actor, HarvesterTraitWrapper harv)
|
||||
{
|
||||
Func<CPos, bool> isValidResource = cell =>
|
||||
harv.Harvester.CanHarvestCell(actor, cell) &&
|
||||
harv.Harvester.CanHarvestCell(cell) &&
|
||||
claimLayer.CanClaimCell(actor, cell);
|
||||
|
||||
List<CPos> path;
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly IActorPreview[] preview;
|
||||
|
||||
public ActorPreviewPlaceBuildingPreviewPreview(WorldRenderer wr, ActorInfo ai, ActorPreviewPlaceBuildingPreviewInfo info, TypeDictionary init)
|
||||
: base(wr, ai, info, init)
|
||||
: base(wr, ai, info)
|
||||
{
|
||||
this.info = info;
|
||||
var previewInit = new ActorPreviewInitializer(ActorInfo, wr, init);
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return buildRadiusEnabled && (self.Owner == self.World.RenderPlayer || (allyBuildEnabled && self.Owner.IsAlliedWith(self.World.RenderPlayer)));
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> RangeCircleRenderables(WorldRenderer wr)
|
||||
public IEnumerable<IRenderable> RangeCircleRenderables()
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
yield break;
|
||||
@@ -108,7 +108,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
IEnumerable<IRenderable> IRenderAnnotationsWhenSelected.RenderAnnotations(Actor self, WorldRenderer wr)
|
||||
{
|
||||
return RangeCircleRenderables(wr);
|
||||
return RangeCircleRenderables();
|
||||
}
|
||||
|
||||
bool IRenderAnnotationsWhenSelected.SpatiallyPartitionable => false;
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return terrainInfo.GetTerrainInfo(new TerrainTile(template, (byte)index));
|
||||
}
|
||||
|
||||
public void LinkNeighbouringBridges(World world, LegacyBridgeLayer bridges)
|
||||
public void LinkNeighbouringBridges(LegacyBridgeLayer bridges)
|
||||
{
|
||||
for (var d = 0; d <= 1; d++)
|
||||
{
|
||||
|
||||
@@ -259,7 +259,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!RequiresBaseProvider)
|
||||
return SpriteRenderable.None;
|
||||
|
||||
return w.ActorsWithTrait<BaseProvider>().SelectMany(a => a.Trait.RangeCircleRenderables(wr));
|
||||
return w.ActorsWithTrait<BaseProvider>().SelectMany(a => a.Trait.RangeCircleRenderables());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
protected virtual IPlaceBuildingPreview CreatePreview(WorldRenderer wr, ActorInfo ai, TypeDictionary init)
|
||||
{
|
||||
return new FootprintPlaceBuildingPreviewPreview(wr, ai, this, init);
|
||||
return new FootprintPlaceBuildingPreviewPreview(wr, ai, this);
|
||||
}
|
||||
|
||||
IPlaceBuildingPreview IPlaceBuildingPreviewGeneratorInfo.CreatePreview(WorldRenderer wr, ActorInfo ai, TypeDictionary init)
|
||||
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly Sprite validTile, blockedTile;
|
||||
readonly float validAlpha, blockedAlpha;
|
||||
|
||||
public FootprintPlaceBuildingPreviewPreview(WorldRenderer wr, ActorInfo ai, FootprintPlaceBuildingPreviewInfo info, TypeDictionary init)
|
||||
public FootprintPlaceBuildingPreviewPreview(WorldRenderer wr, ActorInfo ai, FootprintPlaceBuildingPreviewInfo info)
|
||||
{
|
||||
ActorInfo = ai;
|
||||
this.info = info;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public bool IsValidTarget(ActorInfo actorInfo, Actor saboteur) { return false; } // TODO: bridges don't support frozen under fog
|
||||
|
||||
public override object Create(ActorInitializer init) { return new LegacyBridgeHut(init, this); }
|
||||
public override object Create(ActorInitializer init) { return new LegacyBridgeHut(init); }
|
||||
}
|
||||
|
||||
class LegacyBridgeHut : IDemolishable
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public bool Repairing => repairDirections > 0;
|
||||
int repairDirections = 0;
|
||||
|
||||
public LegacyBridgeHut(ActorInitializer init, LegacyBridgeHutInfo info)
|
||||
public LegacyBridgeHut(ActorInitializer init)
|
||||
{
|
||||
var bridge = init.Get<ParentActorInit>().Value;
|
||||
init.World.AddFrameEndTask(_ =>
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public bool ForceSet { get; private set; }
|
||||
public bool IsQueued { get; protected set; }
|
||||
|
||||
public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
||||
public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
if (target.Type != TargetType.Terrain)
|
||||
return false;
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return count;
|
||||
}
|
||||
|
||||
void CancelDock(Actor self)
|
||||
void CancelDock()
|
||||
{
|
||||
preventDock = true;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void INotifyActorDisposing.Disposing(Actor self)
|
||||
{
|
||||
CancelDock(self);
|
||||
CancelDock();
|
||||
foreach (var harv in GetLinkedHarvesters())
|
||||
harv.Trait.UnlinkProc(harv.Actor, self);
|
||||
}
|
||||
@@ -193,11 +193,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
dockedHarv.ChangeOwner(newOwner);
|
||||
|
||||
// Relink to this refinery
|
||||
dockedHarv.Trait<Harvester>().LinkProc(dockedHarv, self);
|
||||
dockedHarv.Trait<Harvester>().LinkProc(self);
|
||||
}
|
||||
}
|
||||
|
||||
void INotifySold.Selling(Actor self) { CancelDock(self); }
|
||||
void INotifySold.Selling(Actor self) { CancelDock(); }
|
||||
void INotifySold.Sold(Actor self)
|
||||
{
|
||||
foreach (var harv in GetLinkedHarvesters())
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly PaletteReference palette;
|
||||
|
||||
public SequencePlaceBuildingPreviewPreview(WorldRenderer wr, ActorInfo ai, SequencePlaceBuildingPreviewInfo info, TypeDictionary init)
|
||||
: base(wr, ai, info, init)
|
||||
: base(wr, ai, info)
|
||||
{
|
||||
this.info = info;
|
||||
var ownerName = init.Get<OwnerInit>().InternalName;
|
||||
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var rsi = ai.TraitInfo<RenderSpritesInfo>();
|
||||
palette = wr.Palette(rsi.Palette ?? rsi.PlayerPalette + ownerName);
|
||||
preview = new Animation(wr.World, rsi.GetImage(ai, wr.World.Map.Rules.Sequences, faction));
|
||||
preview = new Animation(wr.World, rsi.GetImage(ai, faction));
|
||||
preview.PlayRepeating(info.Sequence);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
AircraftCanEnter,
|
||||
target => Reservable.IsAvailableFor(target, self));
|
||||
|
||||
yield return new AircraftMoveOrderTargeter(self, this);
|
||||
yield return new AircraftMoveOrderTargeter(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return modifiers.HasModifier(TargetModifiers.ForceMove);
|
||||
}
|
||||
|
||||
public AircraftMoveOrderTargeter(Actor self, TransformsIntoAircraft aircraft)
|
||||
public AircraftMoveOrderTargeter(TransformsIntoAircraft aircraft)
|
||||
{
|
||||
this.aircraft = aircraft;
|
||||
}
|
||||
@@ -200,7 +200,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public int OrderPriority => 4;
|
||||
public bool IsQueued { get; protected set; }
|
||||
|
||||
public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
||||
public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
if (target.Type != TargetType.Terrain || (aircraft.Info.RequiresForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove)))
|
||||
return false;
|
||||
|
||||
@@ -189,7 +189,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public int OrderPriority => 4;
|
||||
public bool IsQueued { get; protected set; }
|
||||
|
||||
public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
||||
public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
if (rejectMove || target.Type != TargetType.Terrain || (mobile.Info.RequiresForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove)))
|
||||
return false;
|
||||
|
||||
@@ -20,12 +20,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[VoiceReference]
|
||||
public readonly string Voice = "Action";
|
||||
|
||||
public override object Create(ActorInitializer init) { return new TransformsIntoTransforms(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new TransformsIntoTransforms(this); }
|
||||
}
|
||||
|
||||
public class TransformsIntoTransforms : ConditionalTrait<TransformsIntoTransformsInfo>, IResolveOrder, IOrderVoice, IIssueDeployOrder
|
||||
{
|
||||
public TransformsIntoTransforms(Actor self, TransformsIntoTransformsInfo info)
|
||||
public TransformsIntoTransforms(TransformsIntoTransformsInfo info)
|
||||
: base(info) { }
|
||||
|
||||
void IResolveOrder.ResolveOrder(Actor self, Order order)
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
self.CancelActivity();
|
||||
}
|
||||
|
||||
protected override void TraitEnabled(Actor self) { captureManager.RefreshCapturable(self); }
|
||||
protected override void TraitDisabled(Actor self) { captureManager.RefreshCapturable(self); }
|
||||
protected override void TraitEnabled(Actor self) { captureManager.RefreshCapturable(); }
|
||||
protected override void TraitDisabled(Actor self) { captureManager.RefreshCapturable(); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public readonly Color Color = Color.Orange;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new CapturableProgressBar(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new CapturableProgressBar(this); }
|
||||
}
|
||||
|
||||
class CapturableProgressBar : ConditionalTrait<CapturableProgressBarInfo>, ISelectionBar, ICaptureProgressWatcher
|
||||
{
|
||||
readonly Dictionary<Actor, (int Current, int Total)> progress = new Dictionary<Actor, (int, int)>();
|
||||
|
||||
public CapturableProgressBar(Actor self, CapturableProgressBarInfo info)
|
||||
public CapturableProgressBar(CapturableProgressBarInfo info)
|
||||
: base(info) { }
|
||||
|
||||
void ICaptureProgressWatcher.Update(Actor self, Actor captor, Actor target, int current, int total)
|
||||
|
||||
@@ -99,11 +99,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
.ToArray()
|
||||
.Where(Exts.IsTraitEnabled);
|
||||
|
||||
RefreshCaptures(self);
|
||||
RefreshCapturable(self);
|
||||
RefreshCaptures();
|
||||
RefreshCapturable();
|
||||
}
|
||||
|
||||
public void RefreshCapturable(Actor self)
|
||||
public void RefreshCapturable()
|
||||
{
|
||||
allyCapturableTypes = neutralCapturableTypes = enemyCapturableTypes = default(BitSet<CaptureType>);
|
||||
foreach (var c in enabledCapturable)
|
||||
@@ -119,7 +119,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshCaptures(Actor self)
|
||||
public void RefreshCaptures()
|
||||
{
|
||||
capturesTypes = enabledCaptures.Aggregate(
|
||||
default(BitSet<CaptureType>),
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public readonly Color Color = Color.Orange;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new CaptureProgressBar(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new CaptureProgressBar(this); }
|
||||
}
|
||||
|
||||
class CaptureProgressBar : ConditionalTrait<CaptureProgressBarInfo>, ISelectionBar, ICaptureProgressWatcher
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
int current;
|
||||
int total;
|
||||
|
||||
public CaptureProgressBar(Actor self, CaptureProgressBarInfo info)
|
||||
public CaptureProgressBar(CaptureProgressBarInfo info)
|
||||
: base(info) { }
|
||||
|
||||
void ICaptureProgressWatcher.Update(Actor self, Actor captor, Actor target, int current, int total)
|
||||
|
||||
@@ -110,8 +110,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
self.ShowTargetLines();
|
||||
}
|
||||
|
||||
protected override void TraitEnabled(Actor self) { captureManager.RefreshCaptures(self); }
|
||||
protected override void TraitDisabled(Actor self) { captureManager.RefreshCaptures(self); }
|
||||
protected override void TraitEnabled(Actor self) { captureManager.RefreshCaptures(); }
|
||||
protected override void TraitDisabled(Actor self) { captureManager.RefreshCaptures(); }
|
||||
|
||||
class CaptureOrderTargeter : UnitOrderTargeter
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Carryall attachment point relative to body.")]
|
||||
public readonly WVec LocalOffset = WVec.Zero;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new Carryable(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new Carryable(this); }
|
||||
}
|
||||
|
||||
public enum LockResponse { Success, Pending, Failed }
|
||||
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
protected State state = State.Free;
|
||||
protected bool attached;
|
||||
|
||||
public Carryable(Actor self, CarryableInfo info)
|
||||
public Carryable(CarryableInfo info)
|
||||
: base(info) { }
|
||||
|
||||
protected override void Created(Actor self)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user