private async Task _handleColonyDataPushAsync(MessageColonyDataPush res)
        {
            var s = await _shipManager.GetShipAsync(res.ShipID);

            if (s?.CurrentAreaId == null)
            {
                return;
            }

            var a = _galaxyManager.GetArea(s.CurrentAreaId);

            if (a?.AreaType != AreaTypes.Colony)
            {
                return;
            }

            _handleDataPush(res, (Colony)a, s);
        }
示例#2
0
        public static bool CheckForCollisions(PSystem system, Planet pp, Planet moon, int planetDistanceApart,
                                              int moonDistanceFromSun, int moonDistanceApart, GalaxyManager galaxyManager)
        {
            // Generate locations of: Other planet, basePlanetPos+MoonPos, OtherMoonParentPos+MoonPos
            if (system.PlanetCount >= 1)
            {
                float moon1PosX = 0, moon1PosY = 0; // Outside because used twice
                float Distance;
                foreach (Planet p in system.GetPlanets())
                {
                    if (moon.IDToOrbit == p.Id)
                    {
                        continue;
                    }

                    // Planet 1 Calculation
                    float planet1PosX, planet1PosY;
                    GetPosition(p, out planet1PosX, out planet1PosY);


                    // Planet 2 Calculation
                    float planet2PosX, planet2PosY;
                    GetPosition(pp, out planet2PosX, out planet2PosY);


                    // Moon 1 Calculation
                    GetPosition(moon, planet2PosX, planet2PosY, out moon1PosX, out moon1PosY);


                    // Distance check between points
                    Distance = Distance2D(planet1PosX, planet1PosY, moon1PosX, moon1PosY);

                    if (Distance < planetDistanceApart) // We don't want moons too close to other planets!
                    {
                        return(true);
                    }

                    // Distance check between points
                    Distance = Distance2D(0, 0, moon1PosX, moon1PosY); // Assuming sun is 0,0

                    if (Distance < moonDistanceFromSun)                // We don't want moons too close to the sun!
                    {
                        return(true);
                    }
                }

                // This is in a second forloop because otherwise we do waaaay extra calculations
                foreach (Planet m in system.GetMoons())
                {
                    // We need to get the parent planet to get the location
                    // Planet 1 Calculation
                    float planetParentPosX, planetParentPosY;
                    GetPosition((Planet)galaxyManager.GetArea(m.IDToOrbit), out planetParentPosX, out planetParentPosY);

                    // Moon 2 Calculation
                    float moon2PosX, moon2PosY;
                    GetPosition(m, planetParentPosX, planetParentPosY, out moon2PosX, out moon2PosY);

                    // Distance check between points
                    Distance = Distance2D(moon1PosX, moon1PosY, moon2PosX, moon2PosY);

                    if (Distance < moonDistanceApart) // We don't want moons too close to other moons!
                    {
                        return(true);
                    }
                }
            }
            return(false); // Return false if no collisions
        }