From 80a4f3373023826e8f4dabb72ea2b6d4d4ea5aa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 8 Jun 2014 11:12:05 +0200 Subject: [PATCH 1/4] document MoveIntoWorld --- OpenRA.Mods.RA/Production.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenRA.Mods.RA/Production.cs b/OpenRA.Mods.RA/Production.cs index 3ea49c4685..031e808668 100755 --- a/OpenRA.Mods.RA/Production.cs +++ b/OpenRA.Mods.RA/Production.cs @@ -35,6 +35,8 @@ namespace OpenRA.Mods.RA [Desc("Cell offset where the exiting actor enters the ActorMap")] public readonly CVec ExitCell = CVec.Zero; public readonly int Facing = -1; + + [Desc("AttackMove to a RallyPoint or stay where you are spawned.")] public readonly bool MoveIntoWorld = true; } From a35d84bf5a73f183e61a17854df67cb15187954b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 8 Jun 2014 11:17:10 +0200 Subject: [PATCH 2/4] don't remove and add a trait at the same time --- mods/ra/rules/defaults.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 7f23b3980e..950d309d75 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -410,7 +410,6 @@ Name: Field -TargetableBuilding: -Demolishable: - -ProximityCaptor: ProximityCaptor: Types: CivilianField From 799966d376505a846111138f5405201e07205fbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 8 Jun 2014 11:18:14 +0200 Subject: [PATCH 3/4] don't target or demolish oil derrick husks --- mods/ra/rules/civilian.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mods/ra/rules/civilian.yaml b/mods/ra/rules/civilian.yaml index 88037a5d03..089afed54b 100644 --- a/mods/ra/rules/civilian.yaml +++ b/mods/ra/rules/civilian.yaml @@ -256,6 +256,8 @@ V19.Husk: WithFire: -Health: -Selectable: + -TargetableBuilding: + -Demolishable: BARL: Inherits: ^TechBuilding From ee0df9c1cb5eb483606639dfcaf57386e7422bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 8 Jun 2014 11:19:24 +0200 Subject: [PATCH 4/4] make C4 Demolition frozen actor aware --- OpenRA.Game/Traits/TraitsInterfaces.cs | 3 +++ OpenRA.Mods.RA/BridgeHut.cs | 6 ++++-- OpenRA.Mods.RA/Buildings/Demolishable.cs | 9 +++++++-- OpenRA.Mods.RA/C4Demolition.cs | 16 +++++----------- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index cfa990b7e0..ac9898a133 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -83,11 +83,14 @@ namespace OpenRA.Traits public interface ISeedableResource { void Seed(Actor self); } public interface IAcceptInfiltrator { void OnInfiltrate(Actor self, Actor infiltrator); } + + public interface IDemolishableInfo { bool IsValidTarget(ActorInfo actorInfo, Actor saboteur); } public interface IDemolishable { void Demolish(Actor self, Actor saboteur); bool IsValidTarget(Actor self, Actor saboteur); } + public interface IStoreOre { int Capacity { get; } } public interface INotifyDocking { void Docked(Actor self, Actor harvester); void Undocked(Actor self, Actor harvester); } public interface IEffectiveOwner diff --git a/OpenRA.Mods.RA/BridgeHut.cs b/OpenRA.Mods.RA/BridgeHut.cs index 1a51e44472..b26434f0ad 100644 --- a/OpenRA.Mods.RA/BridgeHut.cs +++ b/OpenRA.Mods.RA/BridgeHut.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) * 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. For more information, @@ -12,8 +12,10 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class BridgeHutInfo : ITraitInfo + class BridgeHutInfo : IDemolishableInfo, ITraitInfo { + public bool IsValidTarget(ActorInfo actorInfo, Actor saboteur) { return false; } // TODO: bridges don't support frozen under fog + public object Create(ActorInitializer init) { return new BridgeHut(init); } } diff --git a/OpenRA.Mods.RA/Buildings/Demolishable.cs b/OpenRA.Mods.RA/Buildings/Demolishable.cs index 194298a755..7afa32ca47 100644 --- a/OpenRA.Mods.RA/Buildings/Demolishable.cs +++ b/OpenRA.Mods.RA/Buildings/Demolishable.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2013 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) * 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. For more information, @@ -14,7 +14,12 @@ using OpenRA.FileFormats; namespace OpenRA.Mods.RA { [Desc("Handle demolitions from C4 explosives.")] - public class DemolishableInfo : TraitInfo { } + public class DemolishableInfo : IDemolishableInfo, ITraitInfo + { + public bool IsValidTarget(ActorInfo actorInfo, Actor saboteur) { return true; } + + public object Create(ActorInitializer init) { return new Demolishable(); } + } public class Demolishable : IDemolishable { diff --git a/OpenRA.Mods.RA/C4Demolition.cs b/OpenRA.Mods.RA/C4Demolition.cs index ab395bde72..8824e75eda 100644 --- a/OpenRA.Mods.RA/C4Demolition.cs +++ b/OpenRA.Mods.RA/C4Demolition.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) * 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. For more information, @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Drawing; +using System.Linq; using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Orders; using OpenRA.Traits; @@ -19,6 +20,7 @@ namespace OpenRA.Mods.RA class C4DemolitionInfo : ITraitInfo { public readonly int C4Delay = 45; // 1.8 seconds + public object Create(ActorInitializer init) { return new C4Demolition(this); } } @@ -83,20 +85,12 @@ namespace OpenRA.Mods.RA if (modifiers.HasModifier(TargetModifiers.ForceMove)) return false; - var demolishable = target.TraitOrDefault(); - if (demolishable == null || !demolishable.IsValidTarget(target, self)) - return false; - - return true; + return target.TraitsImplementing().Any(i => i.IsValidTarget(target, self)); } public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor) { - // TODO: Bridges don't yet support FrozenUnderFog. - if (target.Actor != null && target.Actor.HasTrait()) - return false; - - return true; + return target.Info.Traits.WithInterface().Any(i => i.IsValidTarget(target.Info, self)); } } }