Rewrite spawn point assignment logic.

This commit is contained in:
Paul Chote
2020-10-13 19:17:25 +01:00
committed by teinarss
parent b2b639434c
commit a375f0e58a
9 changed files with 101 additions and 72 deletions

View File

@@ -51,19 +51,17 @@ namespace OpenRA.Mods.Common.Traits
var owner = self.Owner;
var map = owner.World.Map;
var aircraftInfo = self.World.Map.Rules.Actors[info.ActorType].TraitInfo<AircraftInfo>();
var mpStart = owner.World.WorldActor.TraitOrDefault<MPStartLocations>();
CPos startPos;
CPos endPos;
WAngle spawnFacing;
if (info.BaselineSpawn && mpStart != null)
if (info.BaselineSpawn)
{
var spawn = mpStart.Start[owner];
var bounds = map.Bounds;
var center = new MPos(bounds.Left + bounds.Width / 2, bounds.Top + bounds.Height / 2).ToCPos(map);
var spawnVec = spawn - center;
startPos = spawn + spawnVec * (Exts.ISqrt((bounds.Height * bounds.Height + bounds.Width * bounds.Width) / (4 * spawnVec.LengthSquared)));
var spawnVec = owner.HomeLocation - center;
startPos = owner.HomeLocation + spawnVec * (Exts.ISqrt((bounds.Height * bounds.Height + bounds.Width * bounds.Width) / (4 * spawnVec.LengthSquared)));
endPos = startPos;
var spawnDirection = new WVec((self.Location - startPos).X, (self.Location - startPos).Y, 0);
spawnFacing = spawnDirection.Yaw;