internal override void JoinAsEscort(IMyCubeGrid escortApplicant, UnitType unitType, MyPlanet marsPlanet) { var applicantPosition = escortApplicant.GetPosition(); var gravity = marsPlanet.GetGravityAtPoint(applicantPosition); var closestDistSq = double.MaxValue; EscortPosition?closestPosition = null; foreach (var escortPosition in GetPotentialEscortPositions(unitType)) { if (!escortDic.ContainsKey(escortPosition)) { var suggestedPosition = GetEscortPositionVector(leader, gravity, escortPosition, GetAdditionalHeightModifier()); var distSq = Vector3D.DistanceSquared(applicantPosition, suggestedPosition); if (distSq < closestDistSq) { closestDistSq = distSq; closestPosition = escortPosition; } } } if (closestPosition.HasValue) { escortDic.Add(closestPosition.Value, escortApplicant); //TODO: Update the new recruit on our current state and have them act appropriately? } }
public void Draw() { MatrixD origin = MyAPIGateway.Session.Camera.WorldMatrix; //playerEntity.WorldMatrix; origin.Up = -Vector3D.Normalize(planet.GetGravityAtPoint(playerEntity.GetPosition())); origin.Translation = origin.Translation + 2 * origin.Up; foreach (var dustCloud in DustClouds) { dustCloud.Draw(origin); } }
private void SpawnHelperPatrol(IMyPlayer player) { var playerPos = player.GetPosition(); var playerNaturalGravity = marsPlanet.GetGravityAtPoint(playerPos); var perpendicularDistance = MyUtils.GetRandomPerpendicularVector(ref playerNaturalGravity) * 400; //4km away NOTE: since mars NG is not 1.0, it's NOT 4km var locationToSpawnPatrol = playerPos + perpendicularDistance + playerNaturalGravity * -200f; // 2km up var naturalGravityAtSpawn = marsPlanet.GetGravityAtPoint(locationToSpawnPatrol); var spawnLocation = MyAPIGateway.Entities.FindFreePlace(locationToSpawnPatrol, 10, 20, 5, 10); // ModLog.Info("Spawning helper patrol. perpD=" + perpendicularDistance.ToString("N2")); if (spawnLocation.HasValue) { PrefabGrid backup = PrefabGrid.GetBackup(heatSystem.GenerateBackupShipSize()); DuckUtils.SpawnInGravity(spawnLocation.Value, naturalGravityAtSpawn, RemoteControl.OwnerId, backup.PrefabName, backup.InitialBeaconName); } else { ModLog.DebugError("Couldn't spawn backup!", locationToSpawnPatrol); } }
private void SpawnHelperPatrol(IMyPlayer player) { var playerPos = player.GetPosition(); var playerNaturalGravity = marsPlanet.GetGravityAtPoint(playerPos); //TODO does perpendicularDistance maybe need to be normalised? // TODO: use faction info from faction definition. var perpendicularDistance = MyUtils.GetRandomPerpendicularVector(ref playerNaturalGravity) * 400; //4km away var locationToSpawnPatrol = playerPos + perpendicularDistance + playerNaturalGravity * -200f; // 2km up var naturalGravityAtSpawn = marsPlanet.GetGravityAtPoint(locationToSpawnPatrol); var spawnLocation = MyAPIGateway.Entities.FindFreePlace(locationToSpawnPatrol, 10, 20, 5, 10); if (spawnLocation.HasValue) { PrefabGrid backup = faction.Ships.GetBackupShip(); DuckUtils.SpawnInGravity(spawnLocation.Value, naturalGravityAtSpawn, RemoteControl.OwnerId, // TODO: use faction info from faction definition. backup.PrefabName, backup.InitialBeaconName); } else { ModLog.DebugError("Couldn't spawn backup!", locationToSpawnPatrol); } }
public void SpawnConvoyEscorts(IMyCubeGrid convoyLeaderGrid, UnitType unitType, MyPlanet planet) { var gravity = planet.GetGravityAtPoint(convoyLeaderGrid.GetPosition()); var escortsNeededToSpawn = heatSystem.GenerateEscortSpecs(); if (unitType == UnitType.Air) { SpawnAirEscorts(escortsNeededToSpawn, gravity, convoyLeaderGrid); } else { SpawnLandEscorts(escortsNeededToSpawn, gravity, convoyLeaderGrid); SpawnAirEscorts(escortsNeededToSpawn, gravity, convoyLeaderGrid); } }