-
Notifications
You must be signed in to change notification settings - Fork 174
Added more landing pads to the Airforce Command Center #735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#region Copyright & License Information | ||
/* | ||
* Copyright 2007-2020 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 OpenRA.Mods.Common.Traits; | ||
using OpenRA.Primitives; | ||
using OpenRA.Traits; | ||
|
||
namespace OpenRA.Mods.RA2.Traits | ||
{ | ||
[Desc("This actor places other actors around itself, which keep connected as in they get removed when the parent is sold or destroyed.")] | ||
public class SpawnNeighboringActorsInfo : ITraitInfo | ||
{ | ||
[FieldLoader.Require] | ||
[ActorReference] | ||
[Desc("Types of actors to place. If multiple are defined, a random one will be selected for each actor spawned.")] | ||
public readonly HashSet<string> ActorTypes = new HashSet<string>(); | ||
|
||
[FieldLoader.Require] | ||
[Desc("Locations to spawn the actors relative to the origin (top-left for buildings) of this actor.")] | ||
public readonly CVec[] Locations = { }; | ||
|
||
public object Create(ActorInitializer init) { return new SpawnNeighboringActors(this, init.Self); } | ||
} | ||
|
||
public class SpawnNeighboringActors : INotifyKilled, INotifyOwnerChanged, INotifyActorDisposing, INotifyAddedToWorld, INotifySold | ||
{ | ||
readonly SpawnNeighboringActorsInfo info; | ||
readonly List<Actor> actors = new List<Actor>(); | ||
Mailaender marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public SpawnNeighboringActors(SpawnNeighboringActorsInfo info, Actor self) | ||
{ | ||
this.info = info; | ||
} | ||
|
||
void INotifyAddedToWorld.AddedToWorld(Actor self) | ||
{ | ||
SpawnActors(self); | ||
Mailaender marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
public void SpawnActors(Actor self) | ||
{ | ||
foreach (var offset in info.Locations) | ||
{ | ||
self.World.AddFrameEndTask(w => | ||
{ | ||
Mailaender marked this conversation as resolved.
Show resolved
Hide resolved
|
||
var actorType = info.ActorTypes.Random(self.World.SharedRandom).ToLowerInvariant(); | ||
var cell = self.Location + offset; | ||
|
||
var actor = w.CreateActor(true, actorType, new TypeDictionary | ||
{ | ||
new OwnerInit(self.Owner), | ||
new LocationInit(cell) | ||
}); | ||
|
||
actors.Add(actor); | ||
}); | ||
} | ||
} | ||
|
||
public void RemoveActors() | ||
Mailaender marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
foreach (var actor in actors) | ||
actor.Dispose(); | ||
|
||
actors.Clear(); | ||
} | ||
|
||
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see this documented at all and this seems to be a very specific behavior unrelated to spawning nearby actors. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a note to the trait description. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that in reference to the "which keep connected?" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Owner changing is still undocumented. |
||
{ | ||
foreach (var actor in actors) | ||
Mailaender marked this conversation as resolved.
Show resolved
Hide resolved
|
||
actor.ChangeOwnerSync(newOwner); | ||
} | ||
|
||
void INotifyKilled.Killed(Actor self, AttackInfo e) | ||
Mailaender marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
RemoveActors(); | ||
} | ||
|
||
void INotifyActorDisposing.Disposing(Actor self) | ||
{ | ||
RemoveActors(); | ||
} | ||
|
||
void INotifySold.Selling(Actor self) { } | ||
void INotifySold.Sold(Actor self) | ||
Mailaender marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
RemoveActors(); | ||
} | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.