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="UpdateRules\Rules\20180923\RemovedDemolishLocking.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\CloakRequiresConditionToPause.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 Barrel[] Barrels;
|
||||
@@ -369,8 +369,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -127,7 +127,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
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;
|
||||
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 class Harvester : IIssueOrder, IResolveOrder, IPips, IExplodeModifier, IOrderVoice,
|
||||
public class Harvester : IIssueOrder, IResolveOrder, IPips, IOrderVoice,
|
||||
ISpeedModifier, ISync, INotifyCreated, INotifyIdle, INotifyBlockingMove
|
||||
{
|
||||
public readonly HarvesterInfo Info;
|
||||
@@ -470,8 +470,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
yield return GetPipAt(i);
|
||||
}
|
||||
|
||||
bool IExplodeModifier.ShouldExplode(Actor self) { return !IsEmpty; }
|
||||
|
||||
int ISpeedModifier.GetSpeedModifier()
|
||||
{
|
||||
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); }
|
||||
}
|
||||
|
||||
class StoresResources : IPips, INotifyOwnerChanged, INotifyCapture, IExplodeModifier, IStoreResources, ISync, INotifyKilled
|
||||
class StoresResources : IPips, INotifyOwnerChanged, INotifyCapture, IStoreResources, ISync, INotifyKilled
|
||||
{
|
||||
readonly StoresResourcesInfo info;
|
||||
PlayerResources player;
|
||||
@@ -70,7 +70,5 @@ namespace OpenRA.Mods.Common.Traits
|
||||
player.Resources * info.PipCount > i * player.ResourceCapacity
|
||||
? 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 ICruiseAltitudeInfo : ITraitInfo { WDist GetCruiseAltitude(); }
|
||||
|
||||
public interface IExplodeModifier { bool ShouldExplode(Actor self); }
|
||||
public interface IHuskModifier { string HuskActor(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 AddHarvesterBotModule(),
|
||||
new RemoveNegativeDamageFullHealthCheck(),
|
||||
new RemoveResourceExplodeModifier(),
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user