Remove IExplodeModifier interface.
This commit is contained in:
committed by
Oliver Brakmann
parent
80842fd4b8
commit
807a40c209
@@ -596,6 +596,7 @@
|
|||||||
<Compile Include="Traits\ActorSpawner.cs" />
|
<Compile Include="Traits\ActorSpawner.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\20180923\RemovedDemolishLocking.cs" />
|
<Compile Include="UpdateRules\Rules\20180923\RemovedDemolishLocking.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\20180923\RemoveNegativeDamageFullHealthCheck.cs" />
|
<Compile Include="UpdateRules\Rules\20180923\RemoveNegativeDamageFullHealthCheck.cs" />
|
||||||
|
<Compile Include="UpdateRules\Rules\20180923\RemoveResourceExplodeModifier.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\20180923\RenameCrateActionNotification.cs" />
|
<Compile Include="UpdateRules\Rules\20180923\RenameCrateActionNotification.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\20180923\CloakRequiresConditionToPause.cs" />
|
<Compile Include="UpdateRules\Rules\20180923\CloakRequiresConditionToPause.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\20180923\MergeCaptureTraits.cs" />
|
<Compile Include="UpdateRules\Rules\20180923\MergeCaptureTraits.cs" />
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Armament : PausableConditionalTrait<ArmamentInfo>, ITick, IExplodeModifier
|
public class Armament : PausableConditionalTrait<ArmamentInfo>, ITick
|
||||||
{
|
{
|
||||||
public readonly WeaponInfo Weapon;
|
public readonly WeaponInfo Weapon;
|
||||||
public readonly Barrel[] Barrels;
|
public readonly Barrel[] Barrels;
|
||||||
@@ -369,8 +369,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool IsReloading { get { return FireDelay > 0 || IsTraitDisabled; } }
|
public virtual bool IsReloading { get { return FireDelay > 0 || IsTraitDisabled; } }
|
||||||
public virtual bool AllowExplode { get { return !IsReloading; } }
|
|
||||||
bool IExplodeModifier.ShouldExplode(Actor self) { return AllowExplode; }
|
|
||||||
|
|
||||||
public WVec MuzzleOffset(Actor self, Barrel b)
|
public WVec MuzzleOffset(Actor self, Barrel b)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -127,7 +127,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
WeaponInfo ChooseWeaponForExplosion(Actor self)
|
WeaponInfo ChooseWeaponForExplosion(Actor self)
|
||||||
{
|
{
|
||||||
var shouldExplode = self.TraitsImplementing<IExplodeModifier>().All(a => a.ShouldExplode(self));
|
var armaments = self.TraitsImplementing<Armament>();
|
||||||
|
if (!armaments.Any())
|
||||||
|
return Info.WeaponInfo;
|
||||||
|
|
||||||
|
// TODO: EmptyWeapon should be removed in favour of conditions
|
||||||
|
var shouldExplode = !armaments.All(a => a.IsReloading);
|
||||||
var useFullExplosion = self.World.SharedRandom.Next(100) <= Info.LoadedChance;
|
var useFullExplosion = self.World.SharedRandom.Next(100) <= Info.LoadedChance;
|
||||||
return (shouldExplode && useFullExplosion) ? Info.WeaponInfo : Info.EmptyWeaponInfo;
|
return (shouldExplode && useFullExplosion) ? Info.WeaponInfo : Info.EmptyWeaponInfo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public object Create(ActorInitializer init) { return new Harvester(init.Self, this); }
|
public object Create(ActorInitializer init) { return new Harvester(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Harvester : IIssueOrder, IResolveOrder, IPips, IExplodeModifier, IOrderVoice,
|
public class Harvester : IIssueOrder, IResolveOrder, IPips, IOrderVoice,
|
||||||
ISpeedModifier, ISync, INotifyCreated, INotifyIdle, INotifyBlockingMove
|
ISpeedModifier, ISync, INotifyCreated, INotifyIdle, INotifyBlockingMove
|
||||||
{
|
{
|
||||||
public readonly HarvesterInfo Info;
|
public readonly HarvesterInfo Info;
|
||||||
@@ -470,8 +470,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
yield return GetPipAt(i);
|
yield return GetPipAt(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IExplodeModifier.ShouldExplode(Actor self) { return !IsEmpty; }
|
|
||||||
|
|
||||||
int ISpeedModifier.GetSpeedModifier()
|
int ISpeedModifier.GetSpeedModifier()
|
||||||
{
|
{
|
||||||
return 100 - (100 - Info.FullyLoadedSpeed) * contents.Values.Sum() / Info.Capacity;
|
return 100 - (100 - Info.FullyLoadedSpeed) * contents.Values.Sum() / Info.Capacity;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public object Create(ActorInitializer init) { return new StoresResources(init.Self, this); }
|
public object Create(ActorInitializer init) { return new StoresResources(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class StoresResources : IPips, INotifyOwnerChanged, INotifyCapture, IExplodeModifier, IStoreResources, ISync, INotifyKilled
|
class StoresResources : IPips, INotifyOwnerChanged, INotifyCapture, IStoreResources, ISync, INotifyKilled
|
||||||
{
|
{
|
||||||
readonly StoresResourcesInfo info;
|
readonly StoresResourcesInfo info;
|
||||||
PlayerResources player;
|
PlayerResources player;
|
||||||
@@ -70,7 +70,5 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
player.Resources * info.PipCount > i * player.ResourceCapacity
|
player.Resources * info.PipCount > i * player.ResourceCapacity
|
||||||
? info.PipColor : PipType.Transparent);
|
? info.PipColor : PipType.Transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IExplodeModifier.ShouldExplode(Actor self) { return Stored > 0; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,7 +142,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public interface IRenderActorPreviewInfo : ITraitInfo { IEnumerable<IActorPreview> RenderPreview(ActorPreviewInitializer init); }
|
public interface IRenderActorPreviewInfo : ITraitInfo { IEnumerable<IActorPreview> RenderPreview(ActorPreviewInitializer init); }
|
||||||
public interface ICruiseAltitudeInfo : ITraitInfo { WDist GetCruiseAltitude(); }
|
public interface ICruiseAltitudeInfo : ITraitInfo { WDist GetCruiseAltitude(); }
|
||||||
|
|
||||||
public interface IExplodeModifier { bool ShouldExplode(Actor self); }
|
|
||||||
public interface IHuskModifier { string HuskActor(Actor self); }
|
public interface IHuskModifier { string HuskActor(Actor self); }
|
||||||
|
|
||||||
public interface ISeedableResource { void Seed(Actor self); }
|
public interface ISeedableResource { void Seed(Actor self); }
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2018 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, 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;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||||
|
{
|
||||||
|
public class RemoveResourceExplodeModifier : UpdateRule
|
||||||
|
{
|
||||||
|
public override string Name { get { return "Harvester and StoresResources traits no longer force Explodes.EmptyWeapon"; } }
|
||||||
|
public override string Description
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "The hardcoded behaviour forcing Explodes to use EmptyWeapon when the harvester/player has no\n" +
|
||||||
|
"resources has been removed. Affected actors are listed so that conditions may be manually defined.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly List<string> locations = new List<string>();
|
||||||
|
|
||||||
|
public override IEnumerable<string> AfterUpdate(ModData modData)
|
||||||
|
{
|
||||||
|
if (locations.Any())
|
||||||
|
yield return "Review the following definitions and, if the actor uses Harvester or StoresResources,\n" +
|
||||||
|
"define a new Explodes trait with the previous EmptyWeapon, enabled by Harvester.EmptyCondition or\n" +
|
||||||
|
"GrantConditionOnPlayerResources.Condition (negated):\n" + UpdateUtils.FormatMessageList(locations);
|
||||||
|
|
||||||
|
locations.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
||||||
|
{
|
||||||
|
if (actorNode.LastChildMatching("Explodes") != null)
|
||||||
|
locations.Add("{0} ({1})".F(actorNode.Key, actorNode.Location.Filename));
|
||||||
|
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -108,6 +108,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
|||||||
new AddBotOrderManager(),
|
new AddBotOrderManager(),
|
||||||
new AddHarvesterBotModule(),
|
new AddHarvesterBotModule(),
|
||||||
new RemoveNegativeDamageFullHealthCheck(),
|
new RemoveNegativeDamageFullHealthCheck(),
|
||||||
|
new RemoveResourceExplodeModifier(),
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ HARV:
|
|||||||
BaleUnloadDelay: 6
|
BaleUnloadDelay: 6
|
||||||
SearchFromProcRadius: 25
|
SearchFromProcRadius: 25
|
||||||
SearchFromOrderRadius: 15
|
SearchFromOrderRadius: 15
|
||||||
|
EmptyCondition: no-tiberium
|
||||||
Mobile:
|
Mobile:
|
||||||
Speed: 85
|
Speed: 85
|
||||||
Health:
|
Health:
|
||||||
@@ -83,6 +84,7 @@ HARV:
|
|||||||
WithHarvestAnimation:
|
WithHarvestAnimation:
|
||||||
WithDockingAnimation:
|
WithDockingAnimation:
|
||||||
Explodes:
|
Explodes:
|
||||||
|
RequiresCondition: !no-tiberium
|
||||||
Weapon: TiberiumExplosion
|
Weapon: TiberiumExplosion
|
||||||
SelectionDecorations:
|
SelectionDecorations:
|
||||||
|
|
||||||
|
|||||||
@@ -301,6 +301,7 @@ HARV:
|
|||||||
BaleUnloadDelay: 1
|
BaleUnloadDelay: 1
|
||||||
SearchFromProcRadius: 30
|
SearchFromProcRadius: 30
|
||||||
SearchFromOrderRadius: 11
|
SearchFromOrderRadius: 11
|
||||||
|
EmptyCondition: no-ore
|
||||||
Health:
|
Health:
|
||||||
HP: 60000
|
HP: 60000
|
||||||
Armor:
|
Armor:
|
||||||
@@ -328,6 +329,7 @@ HARV:
|
|||||||
HealIfBelow: 50
|
HealIfBelow: 50
|
||||||
DamageCooldown: 500
|
DamageCooldown: 500
|
||||||
Explodes:
|
Explodes:
|
||||||
|
RequiresCondition: !no-ore
|
||||||
Weapon: OreExplosion
|
Weapon: OreExplosion
|
||||||
|
|
||||||
MCV:
|
MCV:
|
||||||
|
|||||||
@@ -123,7 +123,10 @@ PROC:
|
|||||||
FactionImages:
|
FactionImages:
|
||||||
gdi: proc.gdi
|
gdi: proc.gdi
|
||||||
nod: proc.nod
|
nod: proc.nod
|
||||||
|
GrantConditionOnPlayerResources:
|
||||||
|
Condition: contains-tiberium
|
||||||
Explodes:
|
Explodes:
|
||||||
|
RequiresCondition: contains-tiberium
|
||||||
Weapon: TiberiumExplosion
|
Weapon: TiberiumExplosion
|
||||||
|
|
||||||
GASILO:
|
GASILO:
|
||||||
@@ -172,7 +175,10 @@ GASILO:
|
|||||||
Power:
|
Power:
|
||||||
Amount: -10
|
Amount: -10
|
||||||
SelectionDecorations:
|
SelectionDecorations:
|
||||||
|
GrantConditionOnPlayerResources:
|
||||||
|
Condition: contains-tiberium
|
||||||
Explodes:
|
Explodes:
|
||||||
|
RequiresCondition: contains-tiberium
|
||||||
Weapon: TiberiumExplosion
|
Weapon: TiberiumExplosion
|
||||||
|
|
||||||
ANYPOWER:
|
ANYPOWER:
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ HARV:
|
|||||||
SearchFromOrderRadius: 18
|
SearchFromOrderRadius: 18
|
||||||
HarvestVoice: Attack
|
HarvestVoice: Attack
|
||||||
DeliverVoice: Move
|
DeliverVoice: Move
|
||||||
|
EmptyCondition: no-tiberium
|
||||||
Mobile:
|
Mobile:
|
||||||
Speed: 71
|
Speed: 71
|
||||||
Health:
|
Health:
|
||||||
@@ -85,6 +86,7 @@ HARV:
|
|||||||
-WithVoxelBody:
|
-WithVoxelBody:
|
||||||
WithVoxelUnloadBody:
|
WithVoxelUnloadBody:
|
||||||
Explodes:
|
Explodes:
|
||||||
|
RequiresCondition: !no-tiberium
|
||||||
Weapon: TiberiumExplosion
|
Weapon: TiberiumExplosion
|
||||||
WithHarvestOverlay:
|
WithHarvestOverlay:
|
||||||
LocalOffset: 543,0,0
|
LocalOffset: 543,0,0
|
||||||
|
|||||||
Reference in New Issue
Block a user