// Draw muzzle flash not matter if in frustum (it's because it's above the frustum) public override bool Draw(MyRenderObject renderObject) { if (base.Draw(renderObject) == false) { return(false); } m_barrel.Draw(); if (MyMinerGame.IsPaused()) { return(false); } // Draw muzzle flash int deltaTime = MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot; if (deltaTime <= MyMachineGunConstants.MUZZLE_FLASH_MACHINE_GUN_LIFESPAN) { MyParticleEffects.GenerateMuzzleFlash(m_positionMuzzleInWorldSpace, WorldMatrix.Forward, m_muzzleFlashRadius, m_muzzleFlashLength, MyRender.GetCurrentLodDrawPass() == MyLodTypeEnum.LOD_NEAR); } if (m_smokeEffect != null) { m_smokeEffect.Near = MyRender.GetCurrentLodDrawPass() == MyLodTypeEnum.LOD_NEAR; } return(true); }
protected override void Init(MyObjectBuilder_DefinitionBase builder) { base.Init(builder); var ob = builder as MyObjectBuilder_ProjectileAmmoDefinition; MyDebug.AssertDebug(ob != null); this.AmmoType = MyAmmoType.HighSpeed; MyObjectBuilder_ProjectileAmmoDefinition.AmmoProjectileProperties projectileProperties = ob.ProjectileProperties; MyDebug.AssertDebug(projectileProperties != null); this.ProjectileHealthDamage = projectileProperties.ProjectileHealthDamage; this.ProjectileHitImpulse = projectileProperties.ProjectileHitImpulse; this.ProjectileMassDamage = projectileProperties.ProjectileMassDamage; this.ProjectileOnHitMaterialParticles = MyParticleEffects.GetCustomHitMaterialMethodById((int)projectileProperties.ProjectileOnHitMaterialParticlesType); this.ProjectileOnHitParticles = MyParticleEffects.GetCustomHitParticlesMethodById((int)projectileProperties.ProjectileOnHitParticlesType); this.ProjectileTrailColor = projectileProperties.ProjectileTrailColor; this.ProjectileTrailMaterial = projectileProperties.ProjectileTrailMaterial; this.ProjectileTrailProbability = projectileProperties.ProjectileTrailProbability; this.ProjectileTrailScale = projectileProperties.ProjectileTrailScale; this.HeadShot = projectileProperties.HeadShot; this.ProjectileHeadShotDamage = projectileProperties.ProjectileHeadShotDamage; this.ProjectileType = projectileProperties.ProjectileType; }
public override bool Draw(MyRenderObject renderObject) { if (base.Draw(renderObject) == false) { return(false); } // if (IsControlledByPlayer()) return true; Matrix worldMatrix = WorldMatrix; List <MyModelDummy> muzzles = GetMuzzleFlashMatrix(); Vector3 muzzleFlashPosition = MyUtils.GetTransform(muzzles[m_activeMuzzle].Matrix.Translation, ref worldMatrix); // Draw muzzle flash: int dt = MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot; if (dt <= MyMachineGunConstants.MUZZLE_FLASH_MACHINE_GUN_LIFESPAN && m_muzzleFlashLength > 0) { MyParticleEffects.GenerateMuzzleFlash(muzzleFlashPosition, worldMatrix.Forward, m_muzzleFlashRadius, m_muzzleFlashLength); } // Draw smoke: if (m_shotSmoke != null) { m_shotSmoke.UserBirthMultiplier = m_smokeToGenerate; m_shotSmoke.WorldMatrix = Matrix.CreateTranslation(muzzleFlashPosition); } return(true); }
public override void Draw() { // Draw muzzle flash int deltaTime = MySandboxGame.TotalGamePlayTimeInMilliseconds - m_rifleGun.LastTimeShoot; MyGunBase rifleBase = m_rifleGun.GunBase; if (deltaTime <= rifleBase.MuzzleFlashLifeSpan) { MyParticleEffects.GenerateMuzzleFlashLocal(this.Entity, rifleBase.GetMuzzleLocalPosition(), Vector3.Forward, 0.2f, 0.3f); } }
public override void Draw() { // Draw muzzle flash int deltaTime = MySandboxGame.TotalGamePlayTimeInMilliseconds - m_rifleGun.LastTimeShoot; MyGunBase rifleBase = m_rifleGun.GunBase; if (rifleBase.UseDefaultMuzzleFlash && deltaTime <= rifleBase.MuzzleFlashLifeSpan) { MyParticleEffects.GenerateMuzzleFlash(rifleBase.GetMuzzleWorldPosition(), rifleBase.GetMuzzleWorldMatrix().Forward, 0.1f, 0.3f); } }
public override void Draw() { base.Draw(); // Draw muzzle flash int deltaTime = MySandboxGame.TotalGamePlayTimeInMilliseconds - m_gatlingGun.LastTimeShoot; if (deltaTime <= m_gatlingGun.GunBase.MuzzleFlashLifeSpan) { var worldToLocal = MatrixD.Invert(m_gatlingGun.PositionComp.WorldMatrix); MyParticleEffects.GenerateMuzzleFlash(m_gatlingGun.GunBase.GetMuzzleWorldPosition(), m_gatlingGun.PositionComp.WorldMatrix.Forward, GetRenderObjectID(), ref worldToLocal, m_gatlingGun.MuzzleFlashRadius, m_gatlingGun.MuzzleFlashLength); } }
public override void Draw() { base.Draw(); // Draw muzzle flash int deltaTime = MySandboxGame.TotalGamePlayTimeInMilliseconds - m_gatlingGun.LastTimeShoot; if (deltaTime <= m_gatlingGun.GunBase.MuzzleFlashLifeSpan) { Vector3 velocityAtNewCOM = Vector3.Cross(m_gatlingGun.CubeGrid.Physics.AngularVelocity, m_gatlingGun.GunBase.GetMuzzleWorldPosition() - m_gatlingGun.CubeGrid.Physics.CenterOfMassWorld); var velocity = m_gatlingGun.CubeGrid.Physics.RigidBody.LinearVelocity + velocityAtNewCOM; var worldToLocal = MatrixD.Invert(m_gatlingGun.PositionComp.WorldMatrix); MyParticleEffects.GenerateMuzzleFlash(m_gatlingGun.GunBase.GetMuzzleWorldPosition(), m_gatlingGun.PositionComp.WorldMatrix.Forward, GetRenderObjectID(), ref worldToLocal, m_gatlingGun.MuzzleFlashRadius, m_gatlingGun.MuzzleFlashLength, NearFlag); } }
public override bool Draw(Render.MyRenderObject renderObject = null) { if (base.Draw(renderObject)) { // Draw muzzle flash int deltaTime = MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot; if (deltaTime <= MyMachineGunConstants.MUZZLE_FLASH_MACHINE_GUN_LIFESPAN) { MyParticleEffects.GenerateMuzzleFlash(GetMuzzlePosition(), WorldMatrix.Forward, MyMwcUtils.GetRandomFloat(0.8f, 1.2f), MyMwcUtils.GetRandomFloat(1, 2), MyRender.GetCurrentLodDrawPass() == MyLodTypeEnum.LOD_NEAR); } return(true); } return(false); }
// Draw muzzle flash not matter if in frustum (it's because it's above the frustum) public override bool Draw(MyRenderObject renderObject) { if (base.Draw(renderObject) == false) { return(false); } // Draw muzzle flash int deltaTime = MyMinerGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot; if (deltaTime <= MyMachineGunConstants.MUZZLE_FLASH_MACHINE_GUN_LIFESPAN) { MyParticleEffects.GenerateMuzzleFlash(m_positionMuzzleInWorldSpace + WorldMatrix.Forward, WorldMatrix.Forward, 0.4f, 0.7f); } return(true); }
public override void Draw() { // Draw muzzle flash int deltaTime = MySandboxGame.TotalGamePlayTimeInMilliseconds - m_rifleGun.LastTimeShoot; MyGunBase rifleBase = m_rifleGun.GunBase; if (deltaTime <= rifleBase.MuzzleFlashLifeSpan) { if (MySandboxGame.Config.GraphicsRenderer == MySandboxGame.DirectX9RendererKey) { MyParticleEffects.GenerateMuzzleFlashLocal(Container.Entity, rifleBase.GetMuzzleLocalPosition(), Vector3.Forward, 0.1f, 0.3f); } else { MyParticleEffects.GenerateMuzzleFlash(rifleBase.GetMuzzleWorldPosition(), rifleBase.GetMuzzleWorldMatrix().Forward, 0.1f, 0.3f); } } }
public override void Draw() { // Draw muzzle flash: int dt = MySandboxGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot; if (dt <= m_gunBase.MuzzleFlashLifeSpan && m_muzzleFlashLength > 0) { var worldToLocal = MatrixD.Invert(m_entity.WorldMatrix); MyParticleEffects.GenerateMuzzleFlash(m_gunBase.GetMuzzleWorldPosition(), (Vector3)m_entity.WorldMatrix.Forward, m_entity.Render.GetRenderObjectID(), ref worldToLocal, m_muzzleFlashRadius, m_muzzleFlashLength); } if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW) { VRageRender.MyRenderProxy.DebugDrawLine3D(m_entity.PositionComp.GetPosition(), m_entity.PositionComp.GetPosition() + m_entity.WorldMatrix.Forward, Color.Green, Color.GreenYellow, false); if (GetWeaponBase().Target != null) { VRageRender.MyRenderProxy.DebugDrawSphere(GetWeaponBase().Target.PositionComp.GetPosition(), 0.4f, Color.Green, 1, false); } } }
// Update position, check collisions, etc. // Return false if projectile dies/timeouts in this tick. public bool Update() { // Projectile was killed , but still not last time drawn, so we don't need to do update (we are waiting for last draw) if (m_state == MyProjectileStateEnum.KILLED) { return(true); } // Projectile was killed and last time drawn, so we can finally remove it from buffer if (m_state == MyProjectileStateEnum.KILLED_AND_DRAWN) { StopEffect(); return(false); } Vector3D position = m_position; m_position += m_velocity * VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS * MyFakes.SIMULATION_SPEED; // Distance timeout Vector3 positionDelta = m_position - m_origin; if (Vector3.Dot(positionDelta, positionDelta) >= m_maxTrajectory * m_maxTrajectory) { StopEffect(); m_state = MyProjectileStateEnum.KILLED; return(true); } m_checkIntersectionIndex = ++m_checkIntersectionIndex % CHECK_INTERSECTION_INTERVAL; if (m_checkIntersectionIndex != 0 && m_positionChecked) //check only each n-th intersection { return(true); } // Calculate hit point, create decal and throw debris particles Vector3D lineEndPosition = position + CHECK_INTERSECTION_INTERVAL * (m_velocity * VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS * MyFakes.SIMULATION_SPEED); LineD line = new LineD(m_positionChecked ? position : m_origin, lineEndPosition); m_positionChecked = true; IMyEntity entity; MyHitInfo hitInfo; object customdata; GetHitEntityAndPosition(line, out entity, out hitInfo, out customdata); if (entity == null || entity.Physics == null) { return(true); } if (IsIgnoredEntity(entity)) { return(true); // prevent player shooting himself } ProfilerShort.Begin("Projectile.Update"); bool headShot = false; MyCharacter hitCharacter = entity as MyCharacter; if (hitCharacter != null) { IStoppableAttackingTool stoppableTool = hitCharacter.CurrentWeapon as IStoppableAttackingTool; if (stoppableTool != null) { stoppableTool.StopShooting(OwnerEntity); } headShot = (customdata as MyCharacterHitInfo).HitHead && m_projectileAmmoDefinition.HeadShot; // allow head shots only for ammo supporting it in definition } m_position = hitInfo.Position; bool isProjectileGroupKilled = false; if (!isProjectileGroupKilled) { MySurfaceImpactEnum surfaceImpact; MyStringHash materialType; GetSurfaceAndMaterial(entity, ref line, ref hitInfo.Position, out surfaceImpact, out materialType); PlayHitSound(materialType, entity, hitInfo.Position, m_projectileAmmoDefinition.PhysicalMaterial); hitInfo.Velocity = m_velocity; float damage = entity is IMyCharacter ? (headShot ? m_projectileAmmoDefinition.ProjectileHeadShotDamage : m_projectileAmmoDefinition.ProjectileHealthDamage) : m_projectileAmmoDefinition.ProjectileMassDamage; DoDamage(damage, hitInfo, customdata, entity); MyDecals.HandleAddDecal(entity, hitInfo, materialType, m_projectileAmmoDefinition.PhysicalMaterial, (customdata as MyCharacterHitInfo), damage); //particle effect defined in materialProperties.sbc Vector3D particleHitPosition = hitInfo.Position + (Vector3D)line.Direction * -0.2; bool createdEffect = MyMaterialPropertiesHelper.Static.TryCreateCollisionEffect(MyMaterialPropertiesHelper.CollisionType.Hit, particleHitPosition, hitInfo.Normal, m_projectileAmmoDefinition.PhysicalMaterial, materialType); if (!createdEffect && surfaceImpact != MySurfaceImpactEnum.CHARACTER) { MyParticleEffects.CreateBasicHitParticles(m_projectileAmmoDefinition.ProjectileOnHitEffectName, ref hitInfo.Position, ref hitInfo.Normal, ref line.Direction, entity, m_weapon, 1, OwnerEntity); } CreateDecal(materialType); if (m_weapon == null || (entity.GetTopMostParent() != m_weapon.GetTopMostParent())) { ApplyProjectileForce(entity, hitInfo.Position, m_directionNormalized, false, m_projectileAmmoDefinition.ProjectileHitImpulse * m_impulseMultiplier); } StopEffect(); m_state = MyProjectileStateEnum.KILLED; } ProfilerShort.End(); return(true); }