Esempio n. 1
0
        protected override MyEntity CreateEntity(string hudLabelText, MyMwcObjectBuilder_Base objectBuilder, Matrix matrix, Vector2?screenPosition)
        {
            MyEntity entity = base.CreateEntity(hudLabelText, objectBuilder, matrix, screenPosition);

            // add waypoints
            if (entity is MyPrefabBase)
            {
                (entity as MyPrefabBase).InitWaypoints();
            }
            else if (entity is MyPrefabContainer)
            {
                foreach (var prefab in (entity as MyPrefabContainer).GetPrefabs())
                {
                    (prefab as MyPrefabBase).InitWaypoints();
                }
            }

            float distanceFromCamera = entity.WorldVolume.Radius * (entity is MyPrefabBase ? 4 : 2);

            Vector3 newPosition;

            if (screenPosition.HasValue)
            {
                Ray ray = MyUtils.ConvertMouseToRay(MyGuiManager.GetScreenCoordinateFromNormalizedCoordinate(screenPosition.Value));
                newPosition = ray.Position + ray.Direction * distanceFromCamera;
            }
            else
            {
                newPosition = MySpectator.Position + distanceFromCamera * MySpectator.Orientation;
            }

            entity.MoveAndRotate(newPosition, entity.GetWorldRotation());

            return(entity);
        }
        public void UpdateEntity(MyEntity entity)
        {
            Vector3    position;
            Quaternion rotation;

            GetValues(m_time, out position, out rotation);
            entity.MoveAndRotate(position, Matrix.CreateFromQuaternion(rotation));
        }
        private void SpeakCaptainOnOnMissionSuccess(MyMissionBase sender)
        {
            MyScriptWrapper.AddNotification(MyScriptWrapper.CreateNotification(MyTextsWrapperEnum.NewMissionRecieved, MyHudConstants.FRIEND_FONT, 10000));
            var position = m_madelynDummy.GetPosition();
            var rotation = m_madelynDummy.GetOrientation();

            m_madelyn.MoveAndRotate(position, rotation);

            //m_madelyn.SetWorldMatrix(m_madelynDummy.GetWorldMatrixForDraw());
            MyScriptWrapper.UnhideEntity(MyScriptWrapper.GetEntity((uint)EntityID.PrefabContainer));
            MyScriptWrapper.SetEntityEnabled(MyScriptWrapper.GetEntity((uint)EntityID.Scanner1), false);
            MyScriptWrapper.SetEntityEnabled(MyScriptWrapper.GetEntity((uint)EntityID.Scanner2), false);
        }
        public void UpdateTangent(MyEntity entity, Vector3 up)
        {
            Vector3    position0, position1;
            Quaternion rotation0, rotation1;

            GetValues(m_time - 0.05f, out position0, out rotation0);
            GetValues(m_time + 0.05f, out position1, out rotation1);

            Vector3 forward = position1 - position0;

            if (!MyUtils.IsValid(forward))
            {
                forward = entity.WorldMatrix.Forward;
            }

            entity.MoveAndRotate((position0 + position1) / 2, Matrix.CreateWorld(Vector3.Zero, forward, up));
        }