Convert Parachutable to conditions.
This commit is contained in:
@@ -17,7 +17,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
public class Parachute : Activity
|
public class Parachute : Activity
|
||||||
{
|
{
|
||||||
readonly UpgradeManager um;
|
|
||||||
readonly IPositionable pos;
|
readonly IPositionable pos;
|
||||||
readonly ParachutableInfo para;
|
readonly ParachutableInfo para;
|
||||||
readonly WVec fallVector;
|
readonly WVec fallVector;
|
||||||
@@ -29,7 +28,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public Parachute(Actor self, WPos dropPosition, Actor ignoreActor = null)
|
public Parachute(Actor self, WPos dropPosition, Actor ignoreActor = null)
|
||||||
{
|
{
|
||||||
um = self.TraitOrDefault<UpgradeManager>();
|
|
||||||
pos = self.TraitOrDefault<IPositionable>();
|
pos = self.TraitOrDefault<IPositionable>();
|
||||||
ignore = ignoreActor;
|
ignore = ignoreActor;
|
||||||
|
|
||||||
@@ -44,9 +42,8 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
triggered = true;
|
triggered = true;
|
||||||
|
|
||||||
if (um != null)
|
foreach (var np in self.TraitsImplementing<INotifyParachute>())
|
||||||
foreach (var u in para.ParachuteUpgrade)
|
np.OnParachute(self);
|
||||||
um.GrantUpgrade(self, u, this);
|
|
||||||
|
|
||||||
// Place the actor and retrieve its visual position (CenterPosition)
|
// Place the actor and retrieve its visual position (CenterPosition)
|
||||||
pos.SetPosition(self, dropPosition);
|
pos.SetPosition(self, dropPosition);
|
||||||
@@ -60,12 +57,8 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
var dat = self.World.Map.DistanceAboveTerrain(currentPosition);
|
var dat = self.World.Map.DistanceAboveTerrain(currentPosition);
|
||||||
pos.SetPosition(self, currentPosition - new WVec(WDist.Zero, WDist.Zero, dat));
|
pos.SetPosition(self, currentPosition - new WVec(WDist.Zero, WDist.Zero, dat));
|
||||||
|
|
||||||
if (um != null)
|
foreach (var np in self.TraitsImplementing<INotifyParachute>())
|
||||||
foreach (var u in para.ParachuteUpgrade)
|
np.OnLanded(self, ignore);
|
||||||
um.RevokeUpgrade(self, u, this);
|
|
||||||
|
|
||||||
foreach (var npl in self.TraitsImplementing<INotifyParachuteLanded>())
|
|
||||||
npl.OnLanded(ignore);
|
|
||||||
|
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Crate : ITick, IPositionable, ICrushable, ISync,
|
class Crate : ITick, IPositionable, ICrushable, ISync,
|
||||||
INotifyParachuteLanded, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyCrushed
|
INotifyParachute, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyCrushed
|
||||||
{
|
{
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
readonly CrateInfo info;
|
readonly CrateInfo info;
|
||||||
@@ -70,7 +70,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
OnCrushInner(crusher);
|
OnCrushInner(crusher);
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyParachuteLanded.OnLanded(Actor ignore)
|
void INotifyParachute.OnParachute(Actor self) { }
|
||||||
|
void INotifyParachute.OnLanded(Actor self, Actor ignore)
|
||||||
{
|
{
|
||||||
// Check whether the crate landed on anything
|
// Check whether the crate landed on anything
|
||||||
var landedOn = self.World.ActorMap.GetActorsAt(self.Location)
|
var landedOn = self.World.ActorMap.GetActorsAt(self.Location)
|
||||||
|
|||||||
@@ -39,27 +39,42 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public readonly int FallRate = 13;
|
public readonly int FallRate = 13;
|
||||||
|
|
||||||
[UpgradeGrantedReference]
|
[UpgradeGrantedReference]
|
||||||
[Desc("Upgrade to grant to this actor when parachuting. Normally used to render the parachute using the WithParachute trait.")]
|
[Desc("The condition to grant to self while parachuting.")]
|
||||||
public readonly string[] ParachuteUpgrade = { "parachute" };
|
public readonly string ParachutingCondition = null;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new Parachutable(init, this); }
|
public object Create(ActorInitializer init) { return new Parachutable(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class Parachutable : INotifyParachuteLanded
|
class Parachutable : INotifyCreated, INotifyParachute
|
||||||
{
|
{
|
||||||
readonly Actor self;
|
|
||||||
readonly ParachutableInfo info;
|
readonly ParachutableInfo info;
|
||||||
readonly IPositionable positionable;
|
readonly IPositionable positionable;
|
||||||
|
|
||||||
public Parachutable(ActorInitializer init, ParachutableInfo info)
|
UpgradeManager um;
|
||||||
|
int parachutingToken = UpgradeManager.InvalidConditionToken;
|
||||||
|
|
||||||
|
public Parachutable(Actor self, ParachutableInfo info)
|
||||||
{
|
{
|
||||||
self = init.Self;
|
|
||||||
this.info = info;
|
this.info = info;
|
||||||
positionable = self.Trait<IPositionable>();
|
positionable = self.Trait<IPositionable>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyParachuteLanded.OnLanded(Actor ignore)
|
void INotifyCreated.Created(Actor self)
|
||||||
{
|
{
|
||||||
|
um = self.TraitOrDefault<UpgradeManager>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void INotifyParachute.OnParachute(Actor self)
|
||||||
|
{
|
||||||
|
if (um != null && parachutingToken == UpgradeManager.InvalidConditionToken && !string.IsNullOrEmpty(info.ParachutingCondition))
|
||||||
|
parachutingToken = um.GrantCondition(self, info.ParachutingCondition);
|
||||||
|
}
|
||||||
|
|
||||||
|
void INotifyParachute.OnLanded(Actor self, Actor ignore)
|
||||||
|
{
|
||||||
|
if (parachutingToken != UpgradeManager.InvalidConditionToken)
|
||||||
|
parachutingToken = um.RevokeCondition(self, parachutingToken);
|
||||||
|
|
||||||
if (!info.KilledOnImpassableTerrain)
|
if (!info.KilledOnImpassableTerrain)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WithCrateBody : INotifyParachuteLanded, INotifyAddedToWorld
|
class WithCrateBody : INotifyParachute, INotifyAddedToWorld
|
||||||
{
|
{
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
readonly Animation anim;
|
readonly Animation anim;
|
||||||
@@ -70,7 +70,9 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
PlaySequence();
|
PlaySequence();
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyParachuteLanded.OnLanded(Actor ignore)
|
void INotifyParachute.OnParachute(Actor self) { }
|
||||||
|
|
||||||
|
void INotifyParachute.OnLanded(Actor self, Actor ignore)
|
||||||
{
|
{
|
||||||
PlaySequence();
|
PlaySequence();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public interface INotifyOtherProduction { void UnitProducedByOther(Actor self, Actor producer, Actor produced); }
|
public interface INotifyOtherProduction { void UnitProducedByOther(Actor self, Actor producer, Actor produced); }
|
||||||
public interface INotifyDelivery { void IncomingDelivery(Actor self); void Delivered(Actor self); }
|
public interface INotifyDelivery { void IncomingDelivery(Actor self); void Delivered(Actor self); }
|
||||||
public interface INotifyDocking { void Docked(Actor self, Actor harvester); void Undocked(Actor self, Actor harvester); }
|
public interface INotifyDocking { void Docked(Actor self, Actor harvester); void Undocked(Actor self, Actor harvester); }
|
||||||
public interface INotifyParachuteLanded { void OnLanded(Actor ignore); }
|
public interface INotifyParachute { void OnParachute(Actor self); void OnLanded(Actor self, Actor ignore); }
|
||||||
public interface INotifyCapture { void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner); }
|
public interface INotifyCapture { void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner); }
|
||||||
public interface INotifyDiscovered { void OnDiscovered(Actor self, Player discoverer, bool playNotification); }
|
public interface INotifyDiscovered { void OnDiscovered(Actor self, Player discoverer, bool playNotification); }
|
||||||
public interface IRenderActorPreviewInfo : ITraitInfo { IEnumerable<IActorPreview> RenderPreview(ActorPreviewInitializer init); }
|
public interface IRenderActorPreviewInfo : ITraitInfo { IEnumerable<IActorPreview> RenderPreview(ActorPreviewInitializer init); }
|
||||||
|
|||||||
@@ -603,6 +603,13 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
if (!node.Value.Nodes.Any(n => n.Key == "DisguisedCondition"))
|
if (!node.Value.Nodes.Any(n => n.Key == "DisguisedCondition"))
|
||||||
node.Value.Nodes.Add(new MiniYamlNode("DisguisedCondition", "disguise"));
|
node.Value.Nodes.Add(new MiniYamlNode("DisguisedCondition", "disguise"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (node.Key == "Parachutable")
|
||||||
|
{
|
||||||
|
ConvertUpgradesToCondition(parent, node, "ParachuteUpgrade", "ParachutingCondition");
|
||||||
|
if (!node.Value.Nodes.Any(n => n.Key == "ParachutingCondition"))
|
||||||
|
node.Value.Nodes.Add(new MiniYamlNode("ParachutingCondition", "parachute"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||||
|
|||||||
@@ -191,6 +191,7 @@
|
|||||||
GroundCorpsePalette:
|
GroundCorpsePalette:
|
||||||
WaterCorpseSequence:
|
WaterCorpseSequence:
|
||||||
WaterCorpsePalette:
|
WaterCorpsePalette:
|
||||||
|
ParachutingCondition: parachute
|
||||||
Explodes:
|
Explodes:
|
||||||
Weapon: UnitExplodeSmall
|
Weapon: UnitExplodeSmall
|
||||||
EmptyWeapon: UnitExplodeSmall
|
EmptyWeapon: UnitExplodeSmall
|
||||||
@@ -307,6 +308,7 @@
|
|||||||
GroundImpactSound: squishy2.aud
|
GroundImpactSound: squishy2.aud
|
||||||
WaterImpactSound: splash9.aud
|
WaterImpactSound: splash9.aud
|
||||||
WaterCorpseSequence: small_splash
|
WaterCorpseSequence: small_splash
|
||||||
|
ParachutingCondition: parachute
|
||||||
Cloneable:
|
Cloneable:
|
||||||
Types: Infantry
|
Types: Infantry
|
||||||
Voiced:
|
Voiced:
|
||||||
@@ -884,6 +886,7 @@
|
|||||||
Parachutable:
|
Parachutable:
|
||||||
FallRate: 26
|
FallRate: 26
|
||||||
KilledOnImpassableTerrain: false
|
KilledOnImpassableTerrain: false
|
||||||
|
ParachutingCondition: parachute
|
||||||
Passenger:
|
Passenger:
|
||||||
WithParachute:
|
WithParachute:
|
||||||
Image: parach
|
Image: parach
|
||||||
|
|||||||
Reference in New Issue
Block a user