// Kills this missile. Must be called at her end (after explosion or timeout) // This method must be called when this object dies or is removed // E.g. it removes lights, sounds, etc protected override void Closing() { base.Closing(); if (this.Physics != null) { MyMissiles.Remove(this); } if (m_collidedEntity != null) { m_collidedEntity.OnClose -= m_collidedEntity_OnClose; m_collidedEntity = null; } if (m_smokeEffect != null) { m_smokeEffect.Stop(); m_smokeEffect = null; } // Free the light if (m_light != null) { MyLights.RemoveLight(m_light); m_light = null; } // Stop cue (needed because sound is looping) m_soundEmitter.StopSound(true); }
private void AddMissile(MyWeaponPropertiesWrapper weaponProperties, Vector3D initialPosition, Vector3D initialVelocity, Vector3D direction) { MyMissileAmmoDefinition missileAmmoDefinition = weaponProperties.GetCurrentAmmoDefinitionAs <MyMissileAmmoDefinition>(); Vector3 missileDeviatedVector = direction; if (weaponProperties.IsDeviated) { missileDeviatedVector = GetDeviatedVector(weaponProperties.WeaponDefinition.DeviateShotAngle, direction); missileDeviatedVector.Normalize(); } initialVelocity += missileDeviatedVector * missileAmmoDefinition.MissileInitialSpeed; if (m_user.Launcher != null) { MyMissiles.Add(weaponProperties, initialPosition, initialVelocity, missileDeviatedVector, m_user.OwnerId); } else { MyMissiles.AddUnsynced(weaponProperties, initialPosition + 2 * missileDeviatedVector, initialVelocity, missileDeviatedVector, m_user.OwnerId);//start missile 2 beters in front of launcher - prevents hit of own turret } }