예제 #1
0
        //  This method realy initiates/starts the missile
        //  IMPORTANT: Direction vector must be normalized!
        public void Start(MyAmmoProperties ammoProperties, MyEntity ignoreEntity, Vector3 origin, Vector3 initialVelocity, Vector3 directionNormalized,
                          bool groupStart, float thicknessMultiplier, MyEntity weapon
                          )
        {
            if (MySession.Is25DSector)
            {
                directionNormalized.Y = 0;
                directionNormalized.Normalize();
                initialVelocity.Y = 0;
            }

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Projectile.Start");
            m_ammoProperties   = ammoProperties;
            m_state            = MyProjectileStateEnum.ACTIVE;
            m_ignorePhysObject = ignoreEntity;
            m_origin           = origin;
            m_position         = origin;
            m_externalAddition = 1.0f;
            m_weapon           = weapon;

            IsDummy = weapon != null && weapon.IsDummy;

            LengthMultiplier       = 1;
            FrontBillboardMaterial = null;
            FrontBillboardSize     = 1;
            BlendByCameraDirection = false;

            Vector3?correctedDirection = null;

            if (MyGameplayConstants.GameplayDifficultyProfile.EnableAimCorrection)
            {
                MyEntity entityToCheck;
                if (MyGuiScreenGamePlay.Static.ControlledEntity is MyPrefabLargeWeapon)
                {
                    entityToCheck = (MyGuiScreenGamePlay.Static.ControlledEntity as MyPrefabLargeWeapon).GetGun();
                }
                else
                {
                    entityToCheck = MyGuiScreenGamePlay.Static.ControlledEntity;
                }
                // TODO: Make proper test that source off projectile is player ship, testing ignore object is STUPID!
                if (m_ammoProperties.AllowAimCorrection && (ignoreEntity == entityToCheck)) // Autoaim only available for player
                {
                    MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Projectile.Start autoaim generic");
                    //Intersection ignores children of "ignoreEntity", thus we must not hit our own barrels
                    correctedDirection = MyEntities.GetDirectionFromStartPointToHitPointOfNearestObject(ignoreEntity, origin, m_ammoProperties.MaxTrajectory);
                    MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                }
            }

            if (correctedDirection != null)
            {
                m_directionNormalized = correctedDirection.Value;
            }
            else
            {
                m_directionNormalized = directionNormalized;
            }

            m_speed            = ammoProperties.DesiredSpeed * (ammoProperties.SpeedVar > 0.0f ? MyMwcUtils.GetRandomFloat(1 - ammoProperties.SpeedVar, 1 + ammoProperties.SpeedVar) : 1.0f);
            m_externalVelocity = initialVelocity;
            m_velocity         = m_directionNormalized * m_speed;
            m_maxTrajectory    = ammoProperties.MaxTrajectory * MyMwcUtils.GetRandomFloat(0.8f, 1.2f); // +/- 20%


            m_thicknessMultiplier = thicknessMultiplier;

            m_checkIntersectionIndex  = checkIntersectionCounter % CHECK_INTERSECTION_INTERVAL;
            checkIntersectionCounter += 3;
            m_positionChecked         = false;
            m_groupStart              = groupStart;

            if (groupStart)
            {
                m_trailEffect             = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Trail_Shotgun);
                m_trailEffect.AutoDelete  = false;
                m_trailEffect.WorldMatrix = Matrix.CreateTranslation(m_position);
            }

            if (groupStart)
            {
                LastProjectileGroup = m_ownGroup;
                m_ownGroup.Killed   = false;
            }

            if (LastProjectileGroup != null && LastProjectileGroup.Killed == false)
            {
                m_sharedGroup = LastProjectileGroup;
            }
            else
            {
                m_sharedGroup = null;
            }

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
        }
예제 #2
0
        //  This method realy initiates/starts the missile
        //  IMPORTANT: Direction vector must be normalized!
        public void Start(MyAmmoProperties ammoProperties, MyEntity ignoreEntity, Vector3 origin, Vector3 initialVelocity, Vector3 directionNormalized, 
            bool groupStart, float thicknessMultiplier, MyEntity weapon
            )
        {
            if (MySession.Is25DSector)
            {
                directionNormalized.Y = 0;
                directionNormalized.Normalize();
                initialVelocity.Y = 0;
            }

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Projectile.Start");
            m_ammoProperties = ammoProperties;
            m_state = MyProjectileStateEnum.ACTIVE;
            m_ignorePhysObject = ignoreEntity;
            m_origin = origin;
            m_position = origin;
            m_externalAddition = 1.0f;
            m_weapon = weapon;

            IsDummy = weapon != null && weapon.IsDummy;

            LengthMultiplier = 1;
            FrontBillboardMaterial = null;
            FrontBillboardSize = 1;
            BlendByCameraDirection = false;

            Vector3? correctedDirection = null;

            if (MyGameplayConstants.GameplayDifficultyProfile.EnableAimCorrection)
            {
                MyEntity entityToCheck;
                if (MyGuiScreenGamePlay.Static.ControlledEntity is MyPrefabLargeWeapon)
                {
                    entityToCheck = (MyGuiScreenGamePlay.Static.ControlledEntity as MyPrefabLargeWeapon).GetGun();
                }
                else
                {
                    entityToCheck = MyGuiScreenGamePlay.Static.ControlledEntity;
                }
                // TODO: Make proper test that source off projectile is player ship, testing ignore object is STUPID!
                if (m_ammoProperties.AllowAimCorrection && (ignoreEntity == entityToCheck)) // Autoaim only available for player
                {
                    MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Projectile.Start autoaim generic");
                    //Intersection ignores children of "ignoreEntity", thus we must not hit our own barrels
                    correctedDirection = MyEntities.GetDirectionFromStartPointToHitPointOfNearestObject(ignoreEntity, origin, m_ammoProperties.MaxTrajectory);
                    MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                }
            }

            if (correctedDirection != null)
            {
                m_directionNormalized = correctedDirection.Value;
            }
            else
            {
                m_directionNormalized = directionNormalized;
            }

            m_speed = ammoProperties.DesiredSpeed * (ammoProperties.SpeedVar > 0.0f ? MyMwcUtils.GetRandomFloat(1 - ammoProperties.SpeedVar, 1 + ammoProperties.SpeedVar) : 1.0f);
            m_externalVelocity = initialVelocity;
            m_velocity = m_directionNormalized * m_speed;
            m_maxTrajectory = ammoProperties.MaxTrajectory * MyMwcUtils.GetRandomFloat(0.8f, 1.2f); // +/- 20%

           
            m_thicknessMultiplier = thicknessMultiplier;

            m_checkIntersectionIndex = checkIntersectionCounter % CHECK_INTERSECTION_INTERVAL;
            checkIntersectionCounter += 3;
            m_positionChecked = false;
            m_groupStart = groupStart;

            if (groupStart)
            {
                m_trailEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Trail_Shotgun);
                m_trailEffect.AutoDelete = false;
                m_trailEffect.WorldMatrix = Matrix.CreateTranslation(m_position);
            }

            if (groupStart)
            {
                LastProjectileGroup = m_ownGroup;
                m_ownGroup.Killed = false;
            }

            if (LastProjectileGroup != null && LastProjectileGroup.Killed == false)
            {
                m_sharedGroup = LastProjectileGroup;
            }
            else
                m_sharedGroup = null;

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
        }