Пример #1
0
        protected virtual void ClampToWorld()
        {
            var   resPosition = PositionComp.GetPosition();
            float offset      = 10;

            if (resPosition.X > MySession.Static.WorldBoundaries.Max.X)
            {
                resPosition.X = MySession.Static.WorldBoundaries.Max.X - offset;
            }
            else if (resPosition.X < MySession.Static.WorldBoundaries.Min.X)
            {
                resPosition.X = MySession.Static.WorldBoundaries.Min.X + offset;
            }
            if (resPosition.Y > MySession.Static.WorldBoundaries.Max.Y)
            {
                resPosition.Y = MySession.Static.WorldBoundaries.Max.Y - offset;
            }
            else if (resPosition.Y < MySession.Static.WorldBoundaries.Min.Y)
            {
                resPosition.Y = MySession.Static.WorldBoundaries.Min.Y + offset;
            }
            if (resPosition.Z > MySession.Static.WorldBoundaries.Max.Z)
            {
                resPosition.Z = MySession.Static.WorldBoundaries.Max.Z - offset;
            }
            else if (resPosition.Z < MySession.Static.WorldBoundaries.Min.Z)
            {
                resPosition.Z = MySession.Static.WorldBoundaries.Min.Z + offset;
            }
            PositionComp.SetPosition(resPosition);
        }
        public void Init(IMyEnvironmentOwner owner, ref MyEnvironmentSectorParameters parameters)
        {
            // Copy parameters in
            SectorCenter = parameters.Center;

            Bounds = parameters.Bounds;

            m_dataRange = parameters.DataRange;

            m_environment = (MyProceduralEnvironmentDefinition)parameters.Environment;

            EnvironmentDefinition = parameters.Environment;

            m_owner = owner;

            m_provider = parameters.Provider;

            // Compute appropriate render origin.
            Vector3D center = parameters.Center;

            owner.ProjectPointToSurface(ref center);

            if (!Engine.Platform.Game.IsDedicated)
            {
                m_render = new MyInstancedRenderSector(string.Format("{0}:Sector({1:X})", owner, parameters.SectorId), MatrixD.CreateTranslation(center));
            }

            SectorId = parameters.SectorId;

            BoundingBoxD worldBounds = BoundingBoxD.CreateInvalid();

            for (int i = 0; i < 8; ++i)
            {
                worldBounds.Include(Bounds[i]);
            }

            // Entity stuff
            PositionComp.SetPosition(parameters.Center);
            PositionComp.WorldAABB = worldBounds;

            // Add missing stuff
            AddDebugRenderComponent(new MyDebugRenderComponentEnvironmentSector(this));
            GameLogic = new MyNullGameLogicComponent();
            Save      = false;

            IsClosed = false;
        }
Пример #3
0
 protected override void SetVariablePosition(PositionComp positionComp, float value) =>
 positionComp.SetPosition(x: value);
Пример #4
0
 protected override void SetFixedPosition(PositionComp positionComp, float value) =>
 positionComp.SetPosition(y: value);
Пример #5
0
 void IMyEntity.SetPosition(VRageMath.Vector3D pos)
 {
     PositionComp.SetPosition(pos);
 }
Пример #6
0
 public void Teleport(Vector3D pos)
 {
     PositionComp.SetPosition(pos);
 }