/// <summary> /// Returns a string containing the mass of a star in Solar /// Mass units. /// </summary> public static string GetMassRel(StellarBody star, bool showUnits = true) { var mass = String.Format("{0:0.00}", star.Mass); var units = showUnits ? " Solar Masses" : ""; return(mass + units); }
/// <summary> /// Returns a string containing the luminosity of a star as a /// percentage of Sol's luminosity /// </summary> public static string GetLuminosityPercent(StellarBody star, bool showUnits = true) { var lum = String.Format("{0:0.}", star.Luminosity * 100); var units = showUnits ? "% Sol" : ""; return(lum + units); }
/// <summary> /// Returns a string containing the luminosity of a star in Solar /// Luminosity units. /// </summary> public static string GetLuminosityRel(StellarBody star, bool showUnits = true) { var lum = String.Format("{0:0.00}", star.Luminosity); var units = showUnits ? " Solar Luminosity" : ""; return(lum + units); }
/// <summary> /// Returns a string containing the age of a star in years, displayed /// using scientific notation. public static string GetAgeStringYearsSciN(StellarBody star, bool showUnits = true) { var age = String.Format("{0:E2}", star.Age); var units = showUnits ? " Years" : ""; return(age + units); }
/// <summary> /// Returns a string containing the mass of a star as a /// percentage of Sol's mass. /// </summary> public static string GetMassPercent(StellarBody star, bool showUnits = true) { var mass = String.Format("{0:0.}", star.Mass * 100); var units = showUnits ? "% Sol" : ""; return(mass + units); }
public AttackPlanetObjective(StellarBody planet) { this.m_ObjectiveType = ObjectiveType.ATTACK_TARGET; this.m_Planet = planet; this.m_TaskGroups = new List <TaskGroup>(); this.m_RequestTaskGroup = false; }
private void ThinkTrack() { if (this.m_Target == null) { if (this.m_Target != this.m_LocustNest) { this.m_State = LocustFighterStates.SEEK; } else { this.m_State = LocustFighterStates.IDLE; } } else { if (!(this.m_Target is StellarBody)) { return; } StellarBody target = this.m_Target as StellarBody; float num = target.Parameters.Radius + this.m_LocustFighter.ShipSphere.radius; if ((double)(target.Parameters.Position - this.m_LocustFighter.Position).LengthSquared >= (double)num * (double)num) { return; } this.m_State = LocustFighterStates.ASSAULT; if (this.m_LocustNest == null) { return; } this.m_LocustNest.NotifyFighterHasLanded(); } }
protected Vector3 GetFlyByPosition( Vector3 currentPos, Vector3 flybyCenter, float offsetDist, float deviationAngle = 0.0f) { Vector3 forward = flybyCenter - currentPos; if ((double)forward.LengthSquared <= 9.99999997475243E-07) { return(currentPos); } forward.Y = 0.0f; double num1 = (double)forward.Normalize(); Vector3 position = flybyCenter + forward * offsetDist; StellarBody containingPosition = this.m_CommanderAI.GetPlanetContainingPosition(position); if (containingPosition == null) { return(position); } Matrix matrix = Matrix.CreateRotationYPR(MathHelper.DegreesToRadians(deviationAngle), 0.0f, 0.0f) * Matrix.CreateWorld(flybyCenter, forward, Vector3.UnitZ); Matrix mat = Matrix.Inverse(matrix); Vector3 vec = Vector3.Transform(containingPosition.Parameters.Position, mat); vec.X += (float)(((double)vec.X < 0.0 ? 1.0 : -1.0) * ((double)containingPosition.Parameters.Radius + 750.0 + 500.0)); vec = Vector3.Transform(vec, matrix); forward = vec - flybyCenter; forward.Y = 0.0f; double num2 = (double)forward.Normalize(); return(flybyCenter + forward * offsetDist); }
public float GetAddedFlyByAngle( Matrix currentAttackMatrix, Vector3 attackCenter, float offsetDist) { float num1 = 0.0f; StellarBody containingPosition = this.m_CommanderAI.GetPlanetContainingPosition(attackCenter + currentAttackMatrix.Forward * offsetDist); if (containingPosition == null) { return(num1); } Matrix mat = Matrix.Inverse(currentAttackMatrix); float num2 = (double)Vector3.Transform(containingPosition.Parameters.Position, mat).X < 0.0 ? -1f : 1f; float radians = MathHelper.DegreesToRadians(30f); float num3 = (float)((double)containingPosition.Parameters.Radius + 750.0 + 500.0); for (bool flag = false; !flag; flag = false) { num1 += num2 * radians; Matrix rotationYpr = Matrix.CreateRotationYPR(currentAttackMatrix.EulerAngles.X + num1, 0.0f, 0.0f); if ((double)(attackCenter + rotationYpr.Forward * offsetDist - containingPosition.Parameters.Position).LengthSquared > (double)num3 * (double)num3) { break; } } return(num1); }
public override void ObjectRemoved(IGameObject obj) { foreach (Ship neumannSeekerPod in this.m_VonNeumannSeekerPods) { if (neumannSeekerPod == obj) { --this.m_NumPodsRemain; this.m_VonNeumannSeekerPods.Remove(neumannSeekerPod); break; } } foreach (PlanetTarget availableTarget in this.m_AvailableTargets) { if (availableTarget.Planet == obj) { this.m_AvailableTargets.Remove(availableTarget); break; } } if (obj != this.m_CurrentTarget) { return; } this.m_CurrentTarget = (StellarBody)null; }
public override void FindNewTarget(IEnumerable <IGameObject> objs) { if (this.m_ParentBerserker == null || !(this.m_ParentBerserker.GetTarget() is StellarBody)) { float num = float.MaxValue; IGameObject target = (IGameObject)null; foreach (IGameObject gameObject in objs) { if (gameObject is StellarBody) { StellarBody stellarBody = gameObject as StellarBody; if (stellarBody.Parameters.ColonyPlayerID != this.m_Pyramid.Player.ID) { float lengthSquared = (stellarBody.Parameters.Position - this.m_Pyramid.Position).LengthSquared; if ((double)lengthSquared < (double)num) { target = (IGameObject)stellarBody; num = lengthSquared; } } } } this.SetTarget(target); } else { this.SetTarget(this.m_ParentBerserker.GetTarget()); } }
private void ThinkSeek() { if (this.m_NumPodsRemain == 0) { this.m_State = VonNeumannSeekerStates.INITFLEE; } else if (this.m_CurrentTarget == null) { float num = float.MaxValue; foreach (PlanetTarget availableTarget in this.m_AvailableTargets) { if (!availableTarget.HasBeenVisted) { float lengthSquared = (availableTarget.Planet.Parameters.Position - this.m_VonNeumannSeeker.Position).LengthSquared; if ((double)lengthSquared < (double)num) { num = lengthSquared; this.m_CurrentTarget = availableTarget.Planet; } } } this.m_VonNeumannSeeker.SetShipTarget(this.m_CurrentTarget != null ? this.m_CurrentTarget.ObjectID : 0, Vector3.Zero, true, 0); if (this.m_CurrentTarget != null) { return; } this.m_State = VonNeumannSeekerStates.INITFLEE; } else { this.m_State = VonNeumannSeekerStates.TRACK; } }
private void ThinkWait() { bool flag = true; foreach (Ship neumannSeekerPod in this.m_VonNeumannSeekerPods) { if (!neumannSeekerPod.DockedWithParent) { flag = false; break; } } if (!flag) { return; } foreach (PlanetTarget availableTarget in this.m_AvailableTargets) { if (availableTarget.Planet == this.m_CurrentTarget) { availableTarget.HasBeenVisted = true; break; } } this.m_CurrentTarget = (StellarBody)null; this.m_State = VonNeumannSeekerStates.SEEK; }
private static IGameObject CreateProceduralStellarBody( App game, CombatConfig.DataContext context, XmlElement node) { float singleOrDefault1 = node["Radius"].ExtractSingleOrDefault(5000f); int integerOrDefault = node["RandomSeed"].ExtractIntegerOrDefault(0); string stringOrDefault1 = node["PlanetType"].ExtractStringOrDefault("normal"); float singleOrDefault2 = node["HazardRating"].ExtractSingleOrDefault(0.0f); string stringOrDefault2 = node["Faction"].ExtractStringOrDefault("human"); float singleOrDefault3 = node["Biosphere"].ExtractSingleOrDefault(0.0f); double doubleOrDefault = node["Population"].ExtractDoubleOrDefault(0.0); Vector3 vector3OrDefault = node["Position"].ExtractVector3OrDefault(Vector3.Zero); context.TransformPosition(ref vector3OrDefault); int?typeVariant = new int?(); if (node["Variant"] != null) { typeVariant = new int?(node["Variant"].ExtractIntegerOrDefault(0)); } StellarBody.Params stellarBodyParams = game.AssetDatabase.PlanetGenerationRules.GetStellarBodyParams("sysmap_planet", vector3OrDefault, singleOrDefault1, integerOrDefault, 0, stringOrDefault1, singleOrDefault2, 750f, stringOrDefault2, singleOrDefault3, doubleOrDefault, typeVariant, ColonyStage.Open, SystemColonyType.Normal); stellarBodyParams.Civilians = new StellarBody.PlanetCivilianData[0]; stellarBodyParams.ImperialPopulation = 0.0; stellarBodyParams.Suitability = 0.0f; stellarBodyParams.Infrastructure = 0.0f; return((IGameObject)StellarBody.Create(game, stellarBodyParams)); }
/// <summary> /// Returns a string containing the age of a star relative to the Sun. /// </summary> public static string GetAgeStringRel(StellarBody star, bool showUnits = true) { var age = String.Format("{0:0.00}", star.Age / GlobalConstants.SUN_AGE_IN_YEARS); var units = showUnits ? " Solar Ages" : ""; return(age + units); }
private SatelliteBody CreatePlanet(Seed seed, StellarBody star, int pos, string planetID) { return(new Planet(seed, star, star) { Position = pos, Name = planetID }); }
private bool HasTargetInRange(IEnumerable <IGameObject> objs) { bool flag = false; foreach (IGameObject gameObject in objs) { if (gameObject != this.m_Spector) { if (gameObject is Ship) { Ship ship = gameObject as Ship; if (ship.Player != this.m_Spector.Player && Ship.IsActiveShip(ship) && (!Ship.IsBattleRiderSize(ship.RealShipClass) && ship.IsDetected(this.m_Spector.Player))) { flag = true; break; } } else if (gameObject is StellarBody) { StellarBody stellarBody = gameObject as StellarBody; if (stellarBody.Population > 0.0 && stellarBody.Parameters.ColonyPlayerID != this.m_Spector.Player.ID) { float num = (float)((double)stellarBody.Parameters.Radius + (double)this.m_Spector.ShipSphere.radius + 15000.0); if ((double)(stellarBody.Parameters.Position - this.m_Spector.Position).LengthSquared < (double)num * (double)num) { flag = true; break; } } } } } return(flag); }
public override void SetTarget(IGameObject target) { if (!(target is StellarBody)) { return; } this.m_Target = target as StellarBody; }
public override void ObjectRemoved(IGameObject obj) { if (obj == this.m_TargetPlanet) { this.m_TargetPlanet = (StellarBody)null; } base.ObjectRemoved(obj); }
public virtual void Shutdown() { this.m_TargetTaskGroup = (TaskGroup)null; this.m_TargetEnemyGroup = (EnemyGroup)null; this.m_PoliceOwner = (Ship)null; this.m_Planet = (StellarBody)null; this.m_TaskGroups.Clear(); }
public RetreatObjective(StellarBody homeColony) { this.m_ObjectiveType = ObjectiveType.RETREAT; this.m_Planet = homeColony; this.m_Destination = homeColony.Parameters.Position; this.m_TaskGroups = new List <TaskGroup>(); this.m_RequestTaskGroup = false; }
void Awake() { GameEvents.eventManager.Pause += GamePaused; GameEvents.eventManager.Play += GameUnpaused; body = GetComponent <StellarBody>(); trail = GetComponent <TrailRenderer>(); }
private void Update() { if (paused) { //Checks if this object or its children are the last chosen objects if (FamilyLastChosen()) { selectionCircleSprite.enabled = true; //Checks if this already has a velocityChanger child if (velocityChanger == null) { velocityChanger = Instantiate(velChangerPrefab, transform); velocityChanger.transform.rotation = transform.rotation; Vector3 velocityOffset = velocity; velocityOffset.z = velocityChanger.transform.localPosition.z; velocityChanger.transform.position = transform.position + velocityOffset; } //Checks if the user has chosen to try and track or untrack an object if (Input.GetKeyDown("c")) { //If c is pressed and this object was already being tracked it will deselect itself if (trackedBody != this) { tracking = true; trackedBody = this; } else { tracking = false; trackedBody = null; } } } else { selectionCircleSprite.enabled = false; if (velocityChanger) { Destroy(velocityChanger.gameObject); velocityChanger = null; } } //Updating the stellar body's velocity based on the velocityChanger if (velocityChanger) { velocity = velocityChanger.GetVelocityVec(); } } else { //Checks if the user wants to untrack an object while the simulation is playing if (Input.GetKeyDown("c")) { tracking = false; trackedBody = null; } } }
public override void SetTarget(IGameObject target) { if (!(target is StellarBody) || this.m_VonNeumannBerserker == null) { return; } this.m_Target = target as StellarBody; this.m_VonNeumannBerserker.SetShipTarget(this.m_Target != null ? this.m_Target.ObjectID : 0, Vector3.Zero, true, 0); }
public void Terminate() { if (this._cachedPlanet != null) { this.App.ReleaseObject((IGameObject)this._cachedPlanet); this._cachedPlanet = (StellarBody)null; } this._crits.Dispose(); this.App.UI.PanelMessage -= new UIEventPanelMessage(this.UICommChannel_OnPanelMessage); }
public ScoutObjective(StellarBody ePlanet, Player player) { this.m_ObjectiveType = ObjectiveType.SCOUT; this.m_Planet = ePlanet; this.m_Destination = ePlanet.Parameters.Position; this.m_TaskGroups = new List <TaskGroup>(); this.m_Player = player; this.m_RequestTaskGroup = false; this.m_TargetEnemyGroup = (EnemyGroup)null; }
private static bool TargetInRange(StellarBody body, Vector3 pos, float range) { if (body == null) { return(false); } float num = body.Parameters.Radius + 750f + range; return((double)(body.Parameters.Position - pos).LengthSquared < (double)num * (double)num); }
private void CachePlanet(PlanetInfo planetInfo) { if (this._cachedPlanet != null) { this.App.ReleaseObject((IGameObject)this._cachedPlanet); this._cachedPlanet = (StellarBody)null; } this._cachedPlanetReady = false; this._cachedPlanet = Kerberos.Sots.GameStates.StarSystem.CreatePlanet(this.App.Game, Vector3.Zero, planetInfo, Matrix.Identity, 1f, false, Kerberos.Sots.GameStates.StarSystem.TerrestrialPlanetQuality.High); this._cachedPlanet.PostSetProp("AutoDraw", false); }
public override void FindNewTarget(IEnumerable <IGameObject> objs) { this.m_CurrentTarget = (IGameObject)null; float num = float.MaxValue; List <StellarBody> stellarBodyList = new List <StellarBody>(); List <Ship> shipList = new List <Ship>(); foreach (IGameObject gameObject in objs) { if (gameObject != this.m_GhostShip) { if (gameObject is Ship) { Ship ship = gameObject as Ship; if (ship.Player.ID != this.m_GhostShip.Player.ID && ship.RealShipClass == RealShipClasses.Station) { shipList.Add(ship); } } else if (gameObject is StellarBody) { StellarBody stellarBody = gameObject as StellarBody; if (stellarBody.Population > 0.0 && stellarBody.Parameters.ColonyPlayerID != this.m_GhostShip.Player.ID) { stellarBodyList.Add(gameObject as StellarBody); } } } } foreach (Ship ship in shipList) { float lengthSquared = (this.m_GhostShip.Position - ship.Position).LengthSquared; if ((double)lengthSquared < (double)num) { num = lengthSquared; this.m_CurrentTarget = (IGameObject)ship; } } if (this.m_CurrentTarget != null) { return; } foreach (StellarBody stellarBody in stellarBodyList) { float lengthSquared = (this.m_GhostShip.Position - stellarBody.Parameters.Position).LengthSquared; if ((double)lengthSquared < (double)num) { num = lengthSquared; this.m_CurrentTarget = (IGameObject)stellarBody; } } }
public override string[] CloseDialog() { if (this._cachedPlanet != null) { this._app.ReleaseObject((IGameObject)this._cachedPlanet); } this._cachedPlanet = (StellarBody)null; this._crits.Dispose(); this._starmapReduced.Dispose(); this._cameraReduced.Dispose(); this._stationModel.Dispose(); return((string[])null); }