private MySystemItem IsInsideRing(Vector3D position)
        {
            foreach (MySystemItem p in SystemGenerator.Static.m_objects)
            {
                if (p.Type == SystemObjectType.PLANET)
                {
                    MyPlanetItem planet = (MyPlanetItem)p;

                    if (planet.PlanetRing == null)
                    {
                        continue;
                    }
                    AsteroidRingShape shape = AsteroidRingShape.CreateFromRingItem(planet.PlanetRing);
                    if (shape.Contains(position) == ContainmentType.Contains)
                    {
                        return(planet.PlanetRing);
                    }
                }
                else if (p.Type == SystemObjectType.BELT)
                {
                    MySystemBeltItem  belt  = (MySystemBeltItem)p;
                    AsteroidBeltShape shape = AsteroidBeltShape.CreateFromRingItem(belt);
                    if (shape.Contains(position) == ContainmentType.Contains)
                    {
                        return(belt);
                    }
                }
            }
            return(null);
        }
Example #2
0
        private void UpdateRingVisual()
        {
            PluginDrawSession.Static.RemoveRenderObject(m_selectedPlanet.GetHashCode());

            AsteroidRingShape shape = AsteroidRingShape.CreateFromRingItem(GenerateRingItem());

            PluginDrawSession.Static.AddRenderObject(m_selectedPlanet.GetHashCode(), new RenderHollowCylinder(shape.worldMatrix, (float)shape.radius + shape.width, (float)shape.radius, shape.height, Color.LightGreen.ToVector4()));
        }
Example #3
0
        private void OnTeleportToRingButton(MyGuiControlButton button)
        {
            if (MySession.Static.CameraController != MySession.Static.LocalCharacter)
            {
                CloseScreen();
                AsteroidRingShape shape = AsteroidRingShape.CreateFromRingItem(m_selectedPlanet.PlanetRing);

                MyMultiplayer.TeleportControlledEntity(shape.LocationInRing(0));
                m_attachedEntity = 0L;
                m_selectedPlanet = null;
                MyGuiScreenGamePlay.SetCameraController();
            }
        }
Example #4
0
        private bool ObstructedPlace(Vector3D position, List <Vector3D> other, float minDistance, MyPlanetRingItem ring)
        {
            foreach (var obj in other)
            {
                if (Vector3D.Subtract(position, obj).Length() < minDistance)
                {
                    return(true);
                }
                if (ring != null)
                {
                    AsteroidRingShape shape = AsteroidRingShape.CreateFromRingItem(ring);
                    return(shape.Contains(position) != ContainmentType.Disjoint);
                }
            }

            return(false);
        }
Example #5
0
        public void UpdateGps(MyEntityTracker tracker)
        {
            foreach (MySystemItem p in SystemGenerator.Static.m_objects)
            {
                if (p.Type != SystemObjectType.PLANET || ((MyPlanetItem)p).PlanetRing == null)
                {
                    continue;
                }

                MyPlanetRingItem ring      = ((MyPlanetItem)p).PlanetRing;
                Vector3D         entityPos = tracker.Entity.PositionComp.GetPosition();

                string pre    = ((MyPlanetItem)p).DisplayName;
                var    center = ((MyPlanetItem)p).CenterPosition;
                int    l      = (int)(Math.Sqrt(center.X * center.X + center.Y * center.Y + center.Z * center.Z)) % 1000;
                pre = Regex.Replace(pre, @"-[\d\w]+$| \d+ \d+ - \w+$", " " + l.ToString());

                string name = pre + " Ring";

                if (Vector3D.Subtract(ring.Center, entityPos).Length() > 5000000)
                {
                    GlobalGpsManager.Static.RemoveDynamicGps(name, ((MyCharacter)tracker.Entity).GetPlayerIdentityId());
                    continue;
                }

                AsteroidRingShape shape = AsteroidRingShape.CreateFromRingItem(ring);

                if (shape.Contains(tracker.LastPosition) == ContainmentType.Contains)
                {
                    GlobalGpsManager.Static.RemoveDynamicGps(name, ((MyCharacter)tracker.Entity).GetPlayerIdentityId());
                    continue;
                }

                Vector3D pos = shape.ClosestPointAtRingCenter(entityPos);
                GlobalGpsManager.Static.AddOrUpdateDynamicGps(name, ((MyCharacter)tracker.Entity).GetPlayerIdentityId(), pos, Color.Gold);
            }
        }