Skip to content
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

Correct offset for ship spawned aircraft #752

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions OpenRA.Mods.RA2/Traits/BaseSpawnerParent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,17 @@ void INotifyActorDisposing.Disposing(Actor self)
public virtual void SpawnIntoWorld(Actor self, Actor child, WPos centerPosition)
{
var exit = self.RandomExitOrDefault(self.World, null);
SetSpawnedFacing(child, self, exit);
SetSpawnedFacing(child, exit);

self.World.AddFrameEndTask(w =>
{
if (self.IsDead)
return;

var spawnOffset = exit == null ? WVec.Zero : exit.Info.SpawnOffset;
var spawnOffset = WVec.Zero;
if (exit != null)
spawnOffset = exit.Info.SpawnOffset.Rotate(new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(64 - facing.Facing)));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could move this to the Exit trait as that appears to maintain the facing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would indeed be better. Where is the magic 64 - coming from?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that this also works in a 2D plane with only sprites. Just had to change offset from -250 to 250 so the minus sign may be "wrong" compared to Armament LocalOffset from a regular bullet.


child.Trait<IPositionable>().SetVisualPosition(child, centerPosition + spawnOffset);

var location = self.World.Map.CellContaining(centerPosition + spawnOffset);
Expand All @@ -223,7 +226,7 @@ public virtual void SpawnIntoWorld(Actor self, Actor child, WPos centerPosition)
});
}

void SetSpawnedFacing(Actor spawned, Actor spawner, Exit exit)
void SetSpawnedFacing(Actor spawned, Exit exit)
{
var facingOffset = facing == null ? 0 : facing.Facing;

Expand Down