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.")]
|
||||
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.")]
|
||||
public readonly string ForceRace = null;
|
||||
|
||||
|
||||
@@ -8,13 +8,12 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.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, ...")]
|
||||
public class FreeActorInfo : ITraitInfo
|
||||
{
|
||||
@@ -22,9 +21,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Name of the actor.")]
|
||||
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.")]
|
||||
public readonly CVec SpawnOffset = CVec.Zero;
|
||||
|
||||
@@ -43,16 +39,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
init.Self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
var a = w.CreateActor(info.Actor, new TypeDictionary
|
||||
w.CreateActor(info.Actor, new TypeDictionary
|
||||
{
|
||||
new ParentActorInit(init.Self),
|
||||
new LocationInit(init.Self.Location + info.SpawnOffset),
|
||||
new OwnerInit(init.Self.Owner),
|
||||
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.")]
|
||||
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.")]
|
||||
public readonly int SearchFromProcRadius = 24;
|
||||
|
||||
@@ -55,8 +58,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
public class Harvester : IIssueOrder, IResolveOrder, IPips,
|
||||
IExplodeModifier, IOrderVoice, ISpeedModifier, ISync,
|
||||
INotifyResourceClaimLost, INotifyIdle, INotifyBlockingMove
|
||||
IExplodeModifier, IOrderVoice, ISpeedModifier, ISync, INotifyCreated,
|
||||
INotifyResourceClaimLost, INotifyIdle, INotifyBlockingMove, INotifyBuildComplete
|
||||
{
|
||||
readonly HarvesterInfo info;
|
||||
Dictionary<ResourceTypeInfo, int> contents = new Dictionary<ResourceTypeInfo, int>();
|
||||
@@ -76,6 +79,18 @@ namespace OpenRA.Mods.Common.Traits
|
||||
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)
|
||||
{
|
||||
if (proc == null) return;
|
||||
|
||||
@@ -96,9 +96,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var notify in notifyOthers)
|
||||
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>())
|
||||
t.BuildingComplete(newUnit);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user