Exemplo n.º 1
0
        public static Matrix GetSpawnTransform(App app, Kerberos.Sots.GameStates.StarSystem starSystem)
        {
            float              num1            = 0.0f;
            float              num2            = 5000f;
            Vector3            vector3         = Vector3.Zero;
            Vector3            forward         = -Vector3.UnitZ;
            List <StellarBody> stellarBodyList = new List <StellarBody>();

            foreach (StellarBody stellarBody in starSystem.GetPlanetsInSystem())
            {
                List <Ship> stationsAroundPlanet = starSystem.GetStationsAroundPlanet(stellarBody.Parameters.OrbitalID);
                stellarBodyList.Add(stellarBody);
                foreach (Ship ship in stationsAroundPlanet)
                {
                    float lengthSquared = ship.Position.LengthSquared;
                    if ((double)lengthSquared > (double)num1)
                    {
                        num1    = lengthSquared;
                        vector3 = ship.Position;
                        num2    = ship.ShipSphere.radius;
                        forward = stellarBody.Parameters.Position - ship.Position;
                    }
                }
            }
            if ((double)num1 <= 0.0)
            {
                foreach (StellarBody stellarBody in stellarBodyList)
                {
                    if (stellarBody.Population > 0.0)
                    {
                        float lengthSquared = stellarBody.Parameters.Position.LengthSquared;
                        if ((double)lengthSquared > (double)num1)
                        {
                            num1    = lengthSquared;
                            vector3 = stellarBody.Parameters.Position;
                            num2    = stellarBody.Parameters.Radius;
                            int orbitalId = stellarBody.Parameters.OrbitalID;
                            forward = -vector3;
                        }
                    }
                }
            }
            double num3 = (double)forward.Normalize();

            return(Matrix.CreateWorld(vector3 - forward * (num2 + 20000f), forward, Vector3.UnitY));
        }
Exemplo n.º 2
0
        public static Matrix GetSpawnTransform(App app, Kerberos.Sots.GameStates.StarSystem starSystem)
        {
            List <CombatZonePositionInfo> list = starSystem.NeighboringSystems.Select <NeighboringSystemInfo, CombatZonePositionInfo>((Func <NeighboringSystemInfo, CombatZonePositionInfo>)(x => starSystem.GetEnteryZoneForOuterSystem(x.SystemID))).ToList <CombatZonePositionInfo>();
            CombatZonePositionInfo        zonePositionInfo1 = (CombatZonePositionInfo)null;
            Vector3            forward         = new Vector3();
            float              num1            = float.MaxValue;
            List <StellarBody> stellarBodyList = new List <StellarBody>();

            foreach (StellarBody stellarBody in starSystem.GetPlanetsInSystem())
            {
                if (stellarBody.Population != 0.0)
                {
                    foreach (CombatZonePositionInfo zonePositionInfo2 in list)
                    {
                        Vector3 vector3       = stellarBody.Parameters.Position - zonePositionInfo2.Center;
                        float   lengthSquared = vector3.LengthSquared;
                        if ((double)lengthSquared < (double)num1)
                        {
                            num1              = lengthSquared;
                            forward           = vector3;
                            zonePositionInfo1 = zonePositionInfo2;
                        }
                    }
                }
            }
            if (zonePositionInfo1 == null)
            {
                forward.X = (App.GetSafeRandom().CoinToss(0.5) ? -1f : 1f) * App.GetSafeRandom().NextInclusive(0.0001f, 1f);
                forward.Y = 0.0f;
                forward.Z = (App.GetSafeRandom().CoinToss(0.5) ? -1f : 1f) * App.GetSafeRandom().NextInclusive(0.0001f, 1f);
                double num2 = (double)forward.Normalize();
                float  num3 = App.GetSafeRandom().NextInclusive(10000f, starSystem.GetSystemRadius());
                return(Matrix.CreateWorld(forward * num3, -forward, Vector3.UnitY));
            }
            double num4 = (double)forward.Normalize();

            return(Matrix.CreateWorld(zonePositionInfo1.Center, forward, Vector3.UnitY));
        }