Merge pull request #9124 from penev92/bleed_deployToUpgrade
Make use of DeployToUpgrade
This commit is contained in:
@@ -142,6 +142,9 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
|
if (IsCanceled)
|
||||||
|
return NextActivity;
|
||||||
|
|
||||||
if (moveDisablers.Any(d => d.MoveDisabled(self)))
|
if (moveDisablers.Any(d => d.MoveDisabled(self)))
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ using OpenRA.Traits;
|
|||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
[Desc("Also returns a default selection size that is calculated automatically from the voxel dimensions.")]
|
[Desc("Also returns a default selection size that is calculated automatically from the voxel dimensions.")]
|
||||||
public class WithVoxelBodyInfo : ITraitInfo, IRenderActorPreviewVoxelsInfo, Requires<RenderVoxelsInfo>
|
public class WithVoxelBodyInfo : UpgradableTraitInfo, IRenderActorPreviewVoxelsInfo, Requires<RenderVoxelsInfo>
|
||||||
{
|
{
|
||||||
public readonly string Sequence = "idle";
|
public readonly string Sequence = "idle";
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new WithVoxelBody(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new WithVoxelBody(init.Self, this); }
|
||||||
|
|
||||||
public IEnumerable<VoxelAnimation> RenderPreviewVoxels(ActorPreviewInitializer init, RenderVoxelsInfo rv, string image, WRot orientation, int facings, PaletteReference p)
|
public IEnumerable<VoxelAnimation> RenderPreviewVoxels(ActorPreviewInitializer init, RenderVoxelsInfo rv, string image, WRot orientation, int facings, PaletteReference p)
|
||||||
{
|
{
|
||||||
@@ -35,11 +35,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WithVoxelBody : IAutoSelectionSize
|
public class WithVoxelBody : UpgradableTrait<WithVoxelBodyInfo>, IAutoSelectionSize
|
||||||
{
|
{
|
||||||
readonly int2 size;
|
readonly int2 size;
|
||||||
|
|
||||||
public WithVoxelBody(Actor self, WithVoxelBodyInfo info)
|
public WithVoxelBody(Actor self, WithVoxelBodyInfo info)
|
||||||
|
: base(info)
|
||||||
{
|
{
|
||||||
var body = self.Trait<IBodyOrientation>();
|
var body = self.Trait<IBodyOrientation>();
|
||||||
var rv = self.Trait<RenderVoxels>();
|
var rv = self.Trait<RenderVoxels>();
|
||||||
@@ -47,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
var voxel = VoxelProvider.GetVoxel(rv.Image, info.Sequence);
|
var voxel = VoxelProvider.GetVoxel(rv.Image, info.Sequence);
|
||||||
rv.Add(new VoxelAnimation(voxel, () => WVec.Zero,
|
rv.Add(new VoxelAnimation(voxel, () => WVec.Zero,
|
||||||
() => new[] { body.QuantizeOrientation(self, self.Orientation) },
|
() => new[] { body.QuantizeOrientation(self, self.Orientation) },
|
||||||
() => false, () => 0));
|
() => IsTraitDisabled, () => 0));
|
||||||
|
|
||||||
// Selection size
|
// Selection size
|
||||||
var rvi = self.Info.Traits.Get<RenderVoxelsInfo>();
|
var rvi = self.Info.Traits.Get<RenderVoxelsInfo>();
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using OpenRA.Activities;
|
||||||
|
using OpenRA.Mods.Common.Activities;
|
||||||
using OpenRA.Mods.Common.Orders;
|
using OpenRA.Mods.Common.Orders;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
@@ -32,6 +34,18 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Cursor to display when unable to (un)deploy the actor.")]
|
[Desc("Cursor to display when unable to (un)deploy the actor.")]
|
||||||
public readonly string DeployBlockedCursor = "deploy-blocked";
|
public readonly string DeployBlockedCursor = "deploy-blocked";
|
||||||
|
|
||||||
|
[SequenceReference, Desc("Animation to play for deploying/undeploying.")]
|
||||||
|
public readonly string DeployAnimation = null;
|
||||||
|
|
||||||
|
[Desc("Facing that the actor must face before deploying. Set to -1 to deploy regardless of facing.")]
|
||||||
|
public readonly int Facing = -1;
|
||||||
|
|
||||||
|
[Desc("Sound to play when deploying.")]
|
||||||
|
public readonly string DeploySound = null;
|
||||||
|
|
||||||
|
[Desc("Sound to play when undeploying.")]
|
||||||
|
public readonly string UndeploySound = null;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new DeployToUpgrade(init.Self, this); }
|
public object Create(ActorInitializer init) { return new DeployToUpgrade(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,6 +55,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
readonly DeployToUpgradeInfo info;
|
readonly DeployToUpgradeInfo info;
|
||||||
readonly UpgradeManager manager;
|
readonly UpgradeManager manager;
|
||||||
readonly bool checkTerrainType;
|
readonly bool checkTerrainType;
|
||||||
|
readonly bool canTurn;
|
||||||
|
readonly Lazy<ISpriteBody> body;
|
||||||
|
|
||||||
bool isUpgraded;
|
bool isUpgraded;
|
||||||
|
|
||||||
@@ -50,6 +66,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
this.info = info;
|
this.info = info;
|
||||||
manager = self.Trait<UpgradeManager>();
|
manager = self.Trait<UpgradeManager>();
|
||||||
checkTerrainType = info.AllowedTerrainTypes.Length > 0;
|
checkTerrainType = info.AllowedTerrainTypes.Length > 0;
|
||||||
|
canTurn = self.Info.Traits.WithInterface<IFacingInfo>().Any();
|
||||||
|
body = Exts.Lazy(self.TraitOrDefault<ISpriteBody>);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IOrderTargeter> Orders
|
public IEnumerable<IOrderTargeter> Orders
|
||||||
@@ -75,11 +93,50 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (isUpgraded)
|
if (isUpgraded)
|
||||||
foreach (var up in info.Upgrades)
|
{
|
||||||
manager.RevokeUpgrade(self, up, this);
|
// Play undeploy animation and after that revoke the upgrades
|
||||||
|
self.QueueActivity(false, new CallFunc(() =>
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(info.UndeploySound))
|
||||||
|
Sound.Play(info.UndeploySound, self.CenterPosition);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(info.DeployAnimation))
|
||||||
|
{
|
||||||
|
RevokeUpgrades();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body.Value != null)
|
||||||
|
body.Value.PlayCustomAnimationBackwards(self, info.DeployAnimation, RevokeUpgrades);
|
||||||
|
else
|
||||||
|
RevokeUpgrades();
|
||||||
|
}));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
foreach (var up in info.Upgrades)
|
{
|
||||||
manager.GrantUpgrade(self, up, this);
|
self.CancelActivity();
|
||||||
|
|
||||||
|
// Turn
|
||||||
|
if (info.Facing != -1 && canTurn)
|
||||||
|
self.QueueActivity(new Turn(self, info.Facing));
|
||||||
|
|
||||||
|
// Grant the upgrade
|
||||||
|
self.QueueActivity(new CallFunc(GrantUpgrades));
|
||||||
|
|
||||||
|
// Play deploy sound and animation
|
||||||
|
self.QueueActivity(new CallFunc(() =>
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(info.DeploySound))
|
||||||
|
Sound.Play(info.DeploySound, self.CenterPosition);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(info.DeployAnimation))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (body.Value != null)
|
||||||
|
body.Value.PlayCustomAnimation(self, info.DeployAnimation,
|
||||||
|
() => body.Value.PlayCustomAnimationRepeating(self, "idle"));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
isUpgraded = !isUpgraded;
|
isUpgraded = !isUpgraded;
|
||||||
}
|
}
|
||||||
@@ -98,5 +155,17 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
return info.AllowedTerrainTypes.Contains(terrainType);
|
return info.AllowedTerrainTypes.Contains(terrainType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GrantUpgrades()
|
||||||
|
{
|
||||||
|
foreach (var up in info.Upgrades)
|
||||||
|
manager.GrantUpgrade(self, up, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RevokeUpgrades()
|
||||||
|
{
|
||||||
|
foreach (var up in info.Upgrades)
|
||||||
|
manager.RevokeUpgrade(self, up, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,13 +8,11 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using OpenRA.GameRules;
|
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
|
[Desc("Disable the actor when this trait is enabled by an upgrade.")]
|
||||||
public class DisableUpgradeInfo : UpgradableTraitInfo
|
public class DisableUpgradeInfo : UpgradableTraitInfo
|
||||||
{
|
{
|
||||||
public override object Create(ActorInitializer init) { return new DisableUpgrade(this); }
|
public override object Create(ActorInitializer init) { return new DisableUpgrade(this); }
|
||||||
@@ -25,7 +23,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public DisableUpgrade(DisableUpgradeInfo info)
|
public DisableUpgrade(DisableUpgradeInfo info)
|
||||||
: base(info) { }
|
: base(info) { }
|
||||||
|
|
||||||
// Disable the actor when this trait is enabled.
|
|
||||||
public bool Disabled { get { return !IsTraitDisabled; } }
|
public bool Disabled { get { return !IsTraitDisabled; } }
|
||||||
public bool MoveDisabled(Actor self) { return !IsTraitDisabled; }
|
public bool MoveDisabled(Actor self) { return !IsTraitDisabled; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,35 +100,54 @@ HARV:
|
|||||||
|
|
||||||
LPST:
|
LPST:
|
||||||
Inherits: ^VoxelVehicle
|
Inherits: ^VoxelVehicle
|
||||||
|
-AppearsOnRadar:
|
||||||
|
-GainsExperience:
|
||||||
|
Buildable:
|
||||||
|
Queue: Vehicle
|
||||||
|
BuildPaletteOrder: 100
|
||||||
|
Prerequisites: ~factory, radar
|
||||||
Valued:
|
Valued:
|
||||||
Cost: 950
|
Cost: 950
|
||||||
Tooltip:
|
Tooltip:
|
||||||
Name: Mobile Sensor Array
|
Name: Mobile Sensor Array
|
||||||
Description: Can detect cloaked and subterranean\nunits when deployed.\n Unarmed
|
Description: Can detect cloaked and subterranean\nunits when deployed.\n Unarmed
|
||||||
Buildable:
|
|
||||||
Queue: Vehicle
|
|
||||||
BuildPaletteOrder: 100
|
|
||||||
Prerequisites: ~factory, radar
|
|
||||||
Health:
|
Health:
|
||||||
HP: 600
|
HP: 600
|
||||||
Armor:
|
Armor:
|
||||||
Type: Light
|
Type: Wood
|
||||||
Mobile:
|
Mobile:
|
||||||
Speed: 85
|
Speed: 85
|
||||||
ROT: 5
|
ROT: 5
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 10c0
|
Range: 7c0
|
||||||
Transforms:
|
|
||||||
IntoActor: gadpsa
|
|
||||||
Facing: 159
|
|
||||||
TransformSounds:
|
|
||||||
NoTransformSounds:
|
|
||||||
Voice: Move
|
|
||||||
RenderSprites:
|
RenderSprites:
|
||||||
Image: lpst.gdi
|
Image: lpst.gdi
|
||||||
FactionImages:
|
FactionImages:
|
||||||
gdi: lpst.gdi
|
gdi: lpst.gdi
|
||||||
nod: lpst.nod
|
nod: lpst.nod
|
||||||
|
DeployToUpgrade:
|
||||||
|
Upgrades: deployed
|
||||||
|
DeployAnimation: make
|
||||||
|
Facing: 160
|
||||||
|
AllowedTerrainTypes: Clear, Road, DirtRoad, Rough
|
||||||
|
DeploySound: place2.aud
|
||||||
|
UndeploySound: clicky1.aud
|
||||||
|
WithVoxelBody:
|
||||||
|
Image: lpst
|
||||||
|
UpgradeTypes: deployed
|
||||||
|
UpgradeMaxEnabledLevel: 0
|
||||||
|
WithSpriteBody@deployed:
|
||||||
|
StartSequence: make
|
||||||
|
UpgradeTypes: deployed
|
||||||
|
UpgradeMinEnabledLevel: 1
|
||||||
|
DisableUpgrade:
|
||||||
|
UpgradeTypes: deployed
|
||||||
|
UpgradeMinEnabledLevel: 1
|
||||||
|
DetectCloaked:
|
||||||
|
UpgradeTypes: deployed
|
||||||
|
UpgradeMinEnabledLevel: 1
|
||||||
|
Range: 18
|
||||||
|
RenderDetectionCircle:
|
||||||
|
|
||||||
GGHUNT:
|
GGHUNT:
|
||||||
Inherits: ^Vehicle
|
Inherits: ^Vehicle
|
||||||
|
|||||||
@@ -26,9 +26,23 @@ hvr:
|
|||||||
|
|
||||||
lpst.gdi:
|
lpst.gdi:
|
||||||
icon: sidec01.mix:lpsticon
|
icon: sidec01.mix:lpsticon
|
||||||
|
idle: gadpsa
|
||||||
|
Offset: 0, -12
|
||||||
|
ShadowStart: 3
|
||||||
|
make: gadpsamk
|
||||||
|
Offset: 0, -12
|
||||||
|
Length: 36
|
||||||
|
ShadowStart: 36
|
||||||
|
|
||||||
lpst.nod:
|
lpst.nod:
|
||||||
icon: sidec02.mix:lpsticon
|
icon: sidec02.mix:lpsticon
|
||||||
|
idle: gadpsa
|
||||||
|
Offset: 0, -12
|
||||||
|
ShadowStart: 3
|
||||||
|
make: gadpsamk
|
||||||
|
Offset: 0, -12
|
||||||
|
Length: 36
|
||||||
|
ShadowStart: 36
|
||||||
|
|
||||||
repair:
|
repair:
|
||||||
icon: rboticon
|
icon: rboticon
|
||||||
|
|||||||
Reference in New Issue
Block a user