Remove InitialActivity
This commit is contained in:
@@ -29,9 +29,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Disable production when there are more than this many of this actor on the battlefield. Set to 0 to disable.")]
|
[Desc("Disable production when there are more than this many of this actor on the battlefield. Set to 0 to disable.")]
|
||||||
public readonly int BuildLimit = 0;
|
public readonly int BuildLimit = 0;
|
||||||
|
|
||||||
[Desc("What the unit should start doing. Warning: If this is not a harvester", "it will break if you use FindResources.")]
|
|
||||||
public readonly string InitialActivity = null;
|
|
||||||
|
|
||||||
[Desc("Force a specific race variant, overriding the race of the producing actor.")]
|
[Desc("Force a specific race variant, overriding the race of the producing actor.")]
|
||||||
public readonly string ForceRace = null;
|
public readonly string ForceRace = null;
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,12 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using OpenRA.Activities;
|
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
[Desc("Player recives a unit for free once the building is placed. This also works for structures.",
|
[Desc("Player receives a unit for free once the building is placed. This also works for structures.",
|
||||||
"If you want more than one unit to appear copy this section and assign IDs like FreeActor@2, ...")]
|
"If you want more than one unit to appear copy this section and assign IDs like FreeActor@2, ...")]
|
||||||
public class FreeActorInfo : ITraitInfo
|
public class FreeActorInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
@@ -22,9 +21,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Name of the actor.")]
|
[Desc("Name of the actor.")]
|
||||||
public readonly string Actor = null;
|
public readonly string Actor = null;
|
||||||
|
|
||||||
[Desc("What the unit should start doing. Warning: If this is not a harvester", "it will break if you use FindResources.")]
|
|
||||||
public readonly string InitialActivity = null;
|
|
||||||
|
|
||||||
[Desc("Offset relative to the top-left cell of the building.")]
|
[Desc("Offset relative to the top-left cell of the building.")]
|
||||||
public readonly CVec SpawnOffset = CVec.Zero;
|
public readonly CVec SpawnOffset = CVec.Zero;
|
||||||
|
|
||||||
@@ -43,16 +39,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
init.Self.World.AddFrameEndTask(w =>
|
init.Self.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
var a = w.CreateActor(info.Actor, new TypeDictionary
|
w.CreateActor(info.Actor, new TypeDictionary
|
||||||
{
|
{
|
||||||
new ParentActorInit(init.Self),
|
new ParentActorInit(init.Self),
|
||||||
new LocationInit(init.Self.Location + info.SpawnOffset),
|
new LocationInit(init.Self.Location + info.SpawnOffset),
|
||||||
new OwnerInit(init.Self.Owner),
|
new OwnerInit(init.Self.Owner),
|
||||||
new FacingInit(info.Facing),
|
new FacingInit(info.Facing),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (info.InitialActivity != null)
|
|
||||||
a.QueueActivity(Game.CreateObject<Activity>(info.InitialActivity));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Percentage of maximum speed when fully loaded.")]
|
[Desc("Percentage of maximum speed when fully loaded.")]
|
||||||
public readonly int FullyLoadedSpeed = 85;
|
public readonly int FullyLoadedSpeed = 85;
|
||||||
|
|
||||||
|
[Desc("Automatically scan for resources when created.")]
|
||||||
|
public readonly bool SearchOnCreation = true;
|
||||||
|
|
||||||
[Desc("Initial search radius (in cells) from the refinery that created us.")]
|
[Desc("Initial search radius (in cells) from the refinery that created us.")]
|
||||||
public readonly int SearchFromProcRadius = 24;
|
public readonly int SearchFromProcRadius = 24;
|
||||||
|
|
||||||
@@ -55,8 +58,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class Harvester : IIssueOrder, IResolveOrder, IPips,
|
public class Harvester : IIssueOrder, IResolveOrder, IPips,
|
||||||
IExplodeModifier, IOrderVoice, ISpeedModifier, ISync,
|
IExplodeModifier, IOrderVoice, ISpeedModifier, ISync, INotifyCreated,
|
||||||
INotifyResourceClaimLost, INotifyIdle, INotifyBlockingMove
|
INotifyResourceClaimLost, INotifyIdle, INotifyBlockingMove, INotifyBuildComplete
|
||||||
{
|
{
|
||||||
readonly HarvesterInfo info;
|
readonly HarvesterInfo info;
|
||||||
Dictionary<ResourceTypeInfo, int> contents = new Dictionary<ResourceTypeInfo, int>();
|
Dictionary<ResourceTypeInfo, int> contents = new Dictionary<ResourceTypeInfo, int>();
|
||||||
@@ -76,6 +79,18 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.QueueActivity(new CallFunc(() => ChooseNewProc(self, null)));
|
self.QueueActivity(new CallFunc(() => ChooseNewProc(self, null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Created(Actor self)
|
||||||
|
{
|
||||||
|
if (info.SearchOnCreation)
|
||||||
|
self.QueueActivity(new FindResources());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BuildingComplete(Actor self)
|
||||||
|
{
|
||||||
|
if (info.SearchOnCreation)
|
||||||
|
self.QueueActivity(new FindResources());
|
||||||
|
}
|
||||||
|
|
||||||
public void SetProcLines(Actor proc)
|
public void SetProcLines(Actor proc)
|
||||||
{
|
{
|
||||||
if (proc == null) return;
|
if (proc == null) return;
|
||||||
|
|||||||
@@ -96,9 +96,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
foreach (var notify in notifyOthers)
|
foreach (var notify in notifyOthers)
|
||||||
notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit);
|
notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit);
|
||||||
|
|
||||||
if (bi != null && bi.InitialActivity != null)
|
|
||||||
newUnit.QueueActivity(Game.CreateObject<Activity>(bi.InitialActivity));
|
|
||||||
|
|
||||||
foreach (var t in newUnit.TraitsImplementing<INotifyBuildComplete>())
|
foreach (var t in newUnit.TraitsImplementing<INotifyBuildComplete>())
|
||||||
t.BuildingComplete(newUnit);
|
t.BuildingComplete(newUnit);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -51,19 +51,16 @@ namespace OpenRA.Mods.D2k.Traits
|
|||||||
self = init.Self;
|
self = init.Self;
|
||||||
Info = info;
|
Info = info;
|
||||||
|
|
||||||
DoDelivery(self.Location + info.DeliveryOffset, info.Actor, info.DeliveringActor, info.InitialActivity);
|
DoDelivery(self.Location + info.DeliveryOffset, info.Actor, info.DeliveringActor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DoDelivery(CPos location, string actorName, string carrierActorName, string clientInitialActivity)
|
public void DoDelivery(CPos location, string actorName, string carrierActorName)
|
||||||
{
|
{
|
||||||
Actor cargo;
|
Actor cargo;
|
||||||
Actor carrier;
|
Actor carrier;
|
||||||
|
|
||||||
CreateActors(actorName, carrierActorName, out cargo, out carrier);
|
CreateActors(actorName, carrierActorName, out cargo, out carrier);
|
||||||
|
|
||||||
if (clientInitialActivity != null)
|
|
||||||
cargo.QueueActivity(Game.CreateObject<Activity>(clientInitialActivity));
|
|
||||||
|
|
||||||
var carryable = cargo.Trait<Carryable>();
|
var carryable = cargo.Trait<Carryable>();
|
||||||
carryable.Destination = location;
|
carryable.Destination = location;
|
||||||
carryable.Reserve(carrier);
|
carryable.Reserve(carrier);
|
||||||
|
|||||||
@@ -68,10 +68,6 @@ namespace OpenRA.Mods.D2k.Traits
|
|||||||
foreach (var notify in notifyOthers)
|
foreach (var notify in notifyOthers)
|
||||||
notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit);
|
notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit);
|
||||||
|
|
||||||
var bi = newUnit.Info.Traits.GetOrDefault<BuildableInfo>();
|
|
||||||
if (bi != null && bi.InitialActivity != null)
|
|
||||||
newUnit.QueueActivity(Game.CreateObject<Activity>(bi.InitialActivity));
|
|
||||||
|
|
||||||
foreach (var t in newUnit.TraitsImplementing<INotifyBuildComplete>())
|
foreach (var t in newUnit.TraitsImplementing<INotifyBuildComplete>())
|
||||||
t.BuildingComplete(newUnit);
|
t.BuildingComplete(newUnit);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.D2k.Traits
|
|||||||
var refinery = refineries.First().Actor;
|
var refinery = refineries.First().Actor;
|
||||||
var delivery = refinery.Trait<FreeActorWithDelivery>();
|
var delivery = refinery.Trait<FreeActorWithDelivery>();
|
||||||
delivery.DoDelivery(refinery.Location + delivery.Info.DeliveryOffset, delivery.Info.Actor,
|
delivery.DoDelivery(refinery.Location + delivery.Info.DeliveryOffset, delivery.Info.Actor,
|
||||||
delivery.Info.DeliveringActor, delivery.Info.InitialActivity);
|
delivery.Info.DeliveringActor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,7 +180,6 @@ PROC:
|
|||||||
Value: 500
|
Value: 500
|
||||||
FreeActor:
|
FreeActor:
|
||||||
Actor: HARV
|
Actor: HARV
|
||||||
InitialActivity: FindResources
|
|
||||||
SpawnOffset: 1,2
|
SpawnOffset: 1,2
|
||||||
Facing: 64
|
Facing: 64
|
||||||
WithResources:
|
WithResources:
|
||||||
|
|||||||
@@ -203,7 +203,6 @@ refinery:
|
|||||||
Value: 500
|
Value: 500
|
||||||
FreeActorWithDelivery:
|
FreeActorWithDelivery:
|
||||||
Actor: harvester
|
Actor: harvester
|
||||||
InitialActivity: FindResources
|
|
||||||
DeliveryOffset: 2,2
|
DeliveryOffset: 2,2
|
||||||
DeliveringActor: carryall.reinforce
|
DeliveringActor: carryall.reinforce
|
||||||
Facing: 160
|
Facing: 160
|
||||||
|
|||||||
@@ -972,7 +972,6 @@ PROC:
|
|||||||
Value: 600
|
Value: 600
|
||||||
FreeActor:
|
FreeActor:
|
||||||
Actor: HARV
|
Actor: HARV
|
||||||
InitialActivity: FindResources
|
|
||||||
SpawnOffset: 1,2
|
SpawnOffset: 1,2
|
||||||
Facing: 64
|
Facing: 64
|
||||||
InfiltrateForCash:
|
InfiltrateForCash:
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ PROC:
|
|||||||
Value: 600
|
Value: 600
|
||||||
FreeActor:
|
FreeActor:
|
||||||
Actor: HARV
|
Actor: HARV
|
||||||
InitialActivity: FindResources
|
|
||||||
SpawnOffset: 3,1
|
SpawnOffset: 3,1
|
||||||
Facing: 160
|
Facing: 160
|
||||||
WithIdleOverlay@REDLIGHTS:
|
WithIdleOverlay@REDLIGHTS:
|
||||||
|
|||||||
Reference in New Issue
Block a user