private static void ProxyExplosionRequest(Vector3D center, float radius, MyExplosionTypeEnum type, Vector3D voxelCenter, float particleScale) { //Dont create explosion particles if message is bufferred, it is useless to create hundred explosion after scene load if (MySession.Static.Ready) { // Create explosion MyExplosionInfo info = new MyExplosionInfo() { PlayerDamage = 0, //Damage = m_ammoProperties.Damage, Damage = 200, ExplosionType = type, ExplosionSphere = new BoundingSphere(center, radius), LifespanMiliseconds = MyExplosionsConstants.EXPLOSION_LIFESPAN, CascadeLevel = 0, HitEntity = null, ParticleScale = particleScale, OwnerEntity = null, Direction = Vector3.Forward, VoxelExplosionCenter = voxelCenter, ExplosionFlags = MyExplosionFlags.CREATE_DEBRIS | MyExplosionFlags.CREATE_DECALS | MyExplosionFlags.CREATE_PARTICLE_EFFECT | MyExplosionFlags.CREATE_SHRAPNELS, VoxelCutoutScale = 1.0f, PlaySound = true, ObjectsRemoveDelayInMiliseconds = 40 }; MyExplosions.AddExplosion(ref info, false); } }
public static void CreateExplosion(Vector3D position, float radius, int damage = 5000) { MyExplosionTypeEnum explosionTypeEnum = MyExplosionTypeEnum.WARHEAD_EXPLOSION_50; if (radius < 2.0) { explosionTypeEnum = MyExplosionTypeEnum.WARHEAD_EXPLOSION_02; } else if (radius < 15.0) { explosionTypeEnum = MyExplosionTypeEnum.WARHEAD_EXPLOSION_15; } else if (radius < 30.0) { explosionTypeEnum = MyExplosionTypeEnum.WARHEAD_EXPLOSION_30; } MyExplosionInfo explosionInfo = new MyExplosionInfo() { PlayerDamage = 0.0f, Damage = damage, ExplosionType = explosionTypeEnum, ExplosionSphere = new BoundingSphereD(position, radius), LifespanMiliseconds = 700, ParticleScale = 1f, Direction = Vector3.Down, VoxelExplosionCenter = position, ExplosionFlags = MyExplosionFlags.CREATE_DEBRIS | MyExplosionFlags.AFFECT_VOXELS | MyExplosionFlags.APPLY_FORCE_AND_DAMAGE | MyExplosionFlags.CREATE_DECALS | MyExplosionFlags.CREATE_PARTICLE_EFFECT | MyExplosionFlags.CREATE_SHRAPNELS | MyExplosionFlags.APPLY_DEFORMATION, VoxelCutoutScale = 1f, PlaySound = true, ApplyForceAndDamage = true, ObjectsRemoveDelayInMiliseconds = 40 }; MyExplosions.AddExplosion(ref explosionInfo); }
public static void CreateExplosion(Vector3D coords, int radius, int damage, IMyEntity ownerEntity, bool damageIgnoreVoxels) { MyExplosionTypeEnum myExplosionTypeEnum = MyExplosionTypeEnum.WARHEAD_EXPLOSION_02; myExplosionTypeEnum = ((radius <= 6.0) ? MyExplosionTypeEnum.WARHEAD_EXPLOSION_02 : ((radius <= 20.0) ? MyExplosionTypeEnum.WARHEAD_EXPLOSION_15 : ((!(radius <= 40.0)) ? MyExplosionTypeEnum.WARHEAD_EXPLOSION_50 : MyExplosionTypeEnum.WARHEAD_EXPLOSION_30))); MyExplosionInfo myExplosionInfo = default(MyExplosionInfo); myExplosionInfo.PlayerDamage = damage; myExplosionInfo.Damage = damage; myExplosionInfo.ExplosionType = myExplosionTypeEnum; myExplosionInfo.ExplosionSphere = new BoundingSphereD(coords, radius); myExplosionInfo.LifespanMiliseconds = 700; myExplosionInfo.HitEntity = ownerEntity as MyEntity; myExplosionInfo.ParticleScale = 1f; myExplosionInfo.OwnerEntity = ownerEntity as MyEntity; myExplosionInfo.Direction = Vector3D.Forward; myExplosionInfo.VoxelExplosionCenter = coords; myExplosionInfo.ExplosionFlags = (MyExplosionFlags.CREATE_DEBRIS | MyExplosionFlags.APPLY_FORCE_AND_DAMAGE | MyExplosionFlags.CREATE_DECALS | MyExplosionFlags.CREATE_PARTICLE_EFFECT | MyExplosionFlags.CREATE_SHRAPNELS | MyExplosionFlags.APPLY_DEFORMATION); if (!damageIgnoreVoxels) { myExplosionInfo.ExplosionFlags |= MyExplosionFlags.AFFECT_VOXELS; myExplosionInfo.VoxelCutoutScale = 1f; } myExplosionInfo.PlaySound = true; myExplosionInfo.ApplyForceAndDamage = true; myExplosionInfo.ObjectsRemoveDelayInMiliseconds = 40; MyExplosionInfo explosionInfo = myExplosionInfo; MyExplosions.AddExplosion(ref explosionInfo); }
public void Explode() { if (m_isExploded || !MySession.Static.WeaponsEnabled || CubeGrid.Physics == null) { return; } m_isExploded = true; if (!m_marked) { MarkForExplosion(); } MyExplosionTypeEnum particleID = MyExplosionTypeEnum.WARHEAD_EXPLOSION_02; if (m_explosionFullSphere.Radius <= 6) { particleID = MyExplosionTypeEnum.WARHEAD_EXPLOSION_02; } else if (m_explosionFullSphere.Radius <= 20) { particleID = MyExplosionTypeEnum.WARHEAD_EXPLOSION_15; } else if (m_explosionFullSphere.Radius <= 40) { particleID = MyExplosionTypeEnum.WARHEAD_EXPLOSION_30; } else { particleID = MyExplosionTypeEnum.WARHEAD_EXPLOSION_50; } // Create explosion MyExplosionInfo info = new MyExplosionInfo() { PlayerDamage = 0, //Damage = m_ammoProperties.Damage, Damage = MyFakes.ENABLE_VOLUMETRIC_EXPLOSION ? m_warheadDefinition.WarheadExplosionDamage : 5000, ExplosionType = particleID, ExplosionSphere = m_explosionFullSphere, LifespanMiliseconds = MyExplosionsConstants.EXPLOSION_LIFESPAN, CascadeLevel = 0, HitEntity = this, ParticleScale = 1, OwnerEntity = CubeGrid, Direction = (Vector3)WorldMatrix.Forward, VoxelExplosionCenter = m_explosionFullSphere.Center,// + 2 * WorldMatrix.Forward * 0.5f, ExplosionFlags = MyExplosionFlags.AFFECT_VOXELS | MyExplosionFlags.APPLY_FORCE_AND_DAMAGE | MyExplosionFlags.CREATE_DEBRIS | MyExplosionFlags.CREATE_DECALS | MyExplosionFlags.CREATE_PARTICLE_EFFECT | MyExplosionFlags.CREATE_SHRAPNELS | MyExplosionFlags.APPLY_DEFORMATION, VoxelCutoutScale = 1.0f, PlaySound = true, ApplyForceAndDamage = true, ObjectsRemoveDelayInMiliseconds = 40 }; MyExplosions.AddExplosion(ref info); }
/// <summary> /// Creates new instance of prefab configuration without model /// </summary> /// <param name="buildType">Build type</param> /// <param name="categoryType">Category type</param> /// <param name="subCategoryType">Subcategory type</param> /// <param name="materialType">Material type</param> /// <param name="prefabTypeFlag">Prefab type flags</param> /// <param name="factionSpecific">To which faction is this prefab specific. Null if prefab is for all factions. Used for material (texture) set availability. </param> /// <param name="previewPointOfView">Indicates whether the preview image for this prefab should be from a different angle than normal. Use for flat objects that have incorrect default previews (such as signs). </param> protected MyPrefabConfiguration( BuildTypesEnum buildType, CategoryTypesEnum categoryType, SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, PrefabTypesFlagEnum prefabTypeFlag, MyMwcObjectBuilder_Prefab_AppearanceEnum? factionSpecific = null, bool needsUpdate = false, bool initPhysics = true, bool enabledInEditor = true, float rotatingVelocity = DEFAULT_ROTATING_VELOCITY, MySoundCuesEnum? startRotatingCue = null, MySoundCuesEnum? loopRotatingCue = null, MySoundCuesEnum? loopRotatingDamagedCue = null, MySoundCuesEnum? endRotatingCue = null, MyPreviewPointOfViewEnum previewPointOfView = MyPreviewPointOfViewEnum.Front, float minElectricCapacity = MyGameplayConstants.DEFAULT_MIN_ELECTRIC_CAPACITY, float maxElectricCapacity = MyGameplayConstants.DEFAULT_MAX_ELECTRIC_CAPACITY, MyExplosionTypeEnum explosionType = MyExplosionTypeEnum.SMALL_SHIP_EXPLOSION, float explosionRadiusMultiplier = 1.5f, float explosionDamageMultiplier = 1, float minSizeForExplosion = MyExplosionsConstants.MIN_OBJECT_SIZE_TO_CAUSE_EXPLOSION_AND_CREATE_DEBRIS, bool causesAlarm = false, bool requiresEnergy = false, float explosionParticleEffectScale = 1, bool displayHud = false) { //m_modelLod0Enum = null; m_modelLod1Enum = null; BuildType = buildType; CategoryType = categoryType; SubCategoryType = subCategoryType; MaterialType = materialType; PrefabTypeFlag = prefabTypeFlag; FactionSpecific = factionSpecific; EnabledInEditor = enabledInEditor; RotatingVelocity = rotatingVelocity; StartRotatingCue = startRotatingCue; LoopRotatingCue = loopRotatingCue; LoopRotatingDamagedCue = loopRotatingDamagedCue; EndRotatingCue = endRotatingCue; PreviewPointOfView = new MyPreviewPointOfView(previewPointOfView); MinElectricCapacity = minElectricCapacity; MaxElectricCapacity = maxElectricCapacity; NeedsUpdate = needsUpdate; InitPhysics = initPhysics; ExplosionType = explosionType; ExplosionRadiusMultiplier = explosionRadiusMultiplier; ExplosionDamage = explosionDamageMultiplier; ExplosionParticleEffectScale = explosionParticleEffectScale; MinSizeForExplosion = minSizeForExplosion; CausesAlarm = causesAlarm; RequiresEnergy = requiresEnergy; DisplayHud = displayHud; }
public void RequestExplosion(Vector3 center, float radius, MyExplosionTypeEnum type, Vector3 voxelCenter, float particleScale) { var msg = new ProxyExplosionMsg(); msg.Center = center; msg.Radius = radius; msg.Type = type; msg.VoxelCenter = voxelCenter; msg.ParticleScale = particleScale; MySession.Static.SyncLayer.SendMessageToServer(ref msg); }
public void AddExplosion(Vector3 position, MyExplosionTypeEnum explosionType, float damage, float radius, bool forceDebris, bool createDecals) { var msg = new MyEventAddExplosion(); msg.CreateDecals = createDecals; msg.ForceDebris = forceDebris; msg.Damage = damage; msg.Position = position; msg.EntityId = null; msg.ExplosionType = (byte)explosionType; msg.Radius = radius; Peers.SendToAll(ref msg, NetDeliveryMethod.ReliableOrdered); }
public MyPrefabConfigurationLargeWeapon( BuildTypesEnum buildType, CategoryTypesEnum categoryType, SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, MyMwcObjectBuilder_PrefabLargeWeapon_TypesEnum weaponType, MyMwcObjectBuilder_Prefab_AppearanceEnum? factionSpecific = null, MyExplosionTypeEnum explosionType = MyExplosionTypeEnum.SMALL_SHIP_EXPLOSION, float explosionRadiusMultiplier = 5, float explosionDamageMultiplier = 300) : base(buildType, categoryType, subCategoryType, materialType, PrefabTypesFlagEnum.Default, factionSpecific: factionSpecific, explosionType: explosionType, explosionRadiusMultiplier: explosionRadiusMultiplier, explosionDamageMultiplier: explosionDamageMultiplier, requiresEnergy: true, displayHud: true) { WeaponType = weaponType; }
public MyPrefabConfigurationLargeWeapon( BuildTypesEnum buildType, CategoryTypesEnum categoryType, SubCategoryTypesEnum?subCategoryType, MyMaterialType materialType, MyMwcObjectBuilder_PrefabLargeWeapon_TypesEnum weaponType, MyMwcObjectBuilder_Prefab_AppearanceEnum?factionSpecific = null, MyExplosionTypeEnum explosionType = MyExplosionTypeEnum.SMALL_SHIP_EXPLOSION, float explosionRadiusMultiplier = 5, float explosionDamageMultiplier = 300) : base(buildType, categoryType, subCategoryType, materialType, PrefabTypesFlagEnum.Default, factionSpecific: factionSpecific, explosionType: explosionType, explosionRadiusMultiplier: explosionRadiusMultiplier, explosionDamageMultiplier: explosionDamageMultiplier, requiresEnergy: true, displayHud: true) { WeaponType = weaponType; }
public MyPrefabConfigurationLargeShip( MyModelsEnum modelLod0Enum, MyModelsEnum? modelLod1Enum, BuildTypesEnum buildType, CategoryTypesEnum categoryType, SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, MyMwcObjectBuilder_Prefab_AppearanceEnum? factionSpecific = null, MyModelsEnum? collisionModelEnum = null, MyExplosionTypeEnum explosionType = MyExplosionTypeEnum.BOMB_EXPLOSION, float particleScale = 1) : base(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, PrefabTypesFlagEnum.LargeShip, factionSpecific: factionSpecific, needsUpdate: true, collisionModelEnum: collisionModelEnum, explosionType: explosionType, explosionParticleEffectScale: particleScale) { }
public void AddExplosion(MyEntity entity, MyExplosionTypeEnum explosionType, float damage, float radius, bool forceDebris, bool createDecals, MyParticleEffectsIDEnum? particleIDOverride = null) { Debug.Assert(entity != null && entity.EntityId.HasValue); var msg = new MyEventAddExplosion(); msg.Damage = damage; msg.EntityId = entity.EntityId.Value.NumericValue; msg.ExplosionType = (byte)explosionType; msg.Radius = radius; msg.ParticleIDOverride = (int?)particleIDOverride; msg.CreateDecals = createDecals; msg.ForceDebris = forceDebris; Peers.SendToAll(ref msg, NetDeliveryMethod.ReliableOrdered); }
public MyPrefabConfigurationLargeShip( MyModelsEnum modelLod0Enum, MyModelsEnum?modelLod1Enum, BuildTypesEnum buildType, CategoryTypesEnum categoryType, SubCategoryTypesEnum?subCategoryType, MyMaterialType materialType, MyMwcObjectBuilder_Prefab_AppearanceEnum?factionSpecific = null, MyModelsEnum?collisionModelEnum = null, MyExplosionTypeEnum explosionType = MyExplosionTypeEnum.BOMB_EXPLOSION, float particleScale = 1) : base(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, PrefabTypesFlagEnum.LargeShip, factionSpecific: factionSpecific, needsUpdate: true, collisionModelEnum: collisionModelEnum, explosionType: explosionType, explosionParticleEffectScale: particleScale) { }
public void AddExplosion(MyEntity entity, MyExplosionTypeEnum explosionType, float damage, float radius, bool forceDebris, bool createDecals, MyParticleEffectsIDEnum?particleIDOverride = null) { Debug.Assert(entity != null && entity.EntityId.HasValue); var msg = new MyEventAddExplosion(); msg.Damage = damage; msg.EntityId = entity.EntityId.Value.NumericValue; msg.ExplosionType = (byte)explosionType; msg.Radius = radius; msg.ParticleIDOverride = (int?)particleIDOverride; msg.CreateDecals = createDecals; msg.ForceDebris = forceDebris; Peers.SendToAll(ref msg, NetDeliveryMethod.ReliableOrdered); }
public static void CreatePhantomExplosion(Vector3D position, float radius, float damage, long blockEntityId = 0, bool showParticles = false, bool damageVoxels = false, bool createForceImpulse = true) { MyExplosionTypeEnum explosionType = MyExplosionTypeEnum.WARHEAD_EXPLOSION_50; if (radius < 2f) { explosionType = MyExplosionTypeEnum.WARHEAD_EXPLOSION_02; } else if (radius < 15f) { explosionType = MyExplosionTypeEnum.WARHEAD_EXPLOSION_15; } else if (radius < 30f) { explosionType = MyExplosionTypeEnum.WARHEAD_EXPLOSION_30; } MyExplosionInfo myExplosionInfo = default(MyExplosionInfo); myExplosionInfo.PlayerDamage = 0f; myExplosionInfo.OriginEntity = blockEntityId; myExplosionInfo.Damage = damage; myExplosionInfo.ExplosionType = explosionType; myExplosionInfo.ExplosionSphere = new BoundingSphereD(position, radius); myExplosionInfo.LifespanMiliseconds = 700; myExplosionInfo.ParticleScale = 1f; myExplosionInfo.Direction = Vector3.Down; myExplosionInfo.VoxelExplosionCenter = position; myExplosionInfo.ExplosionFlags = (MyExplosionFlags.CREATE_DEBRIS | MyExplosionFlags.AFFECT_VOXELS | MyExplosionFlags.APPLY_FORCE_AND_DAMAGE | MyExplosionFlags.CREATE_DECALS | MyExplosionFlags.CREATE_PARTICLE_EFFECT | MyExplosionFlags.CREATE_SHRAPNELS | MyExplosionFlags.APPLY_DEFORMATION); myExplosionInfo.VoxelCutoutScale = 1f; myExplosionInfo.PlaySound = true; myExplosionInfo.ApplyForceAndDamage = true; if (createForceImpulse == false) { myExplosionInfo.StrengthAngularImpulse = 0; myExplosionInfo.StrengthImpulse = 0; } myExplosionInfo.ObjectsRemoveDelayInMiliseconds = 40; myExplosionInfo.CreateParticleEffect = showParticles; myExplosionInfo.AffectVoxels = damageVoxels; MyExplosionInfo explosionInfo = myExplosionInfo; MyExplosions.AddExplosion(ref explosionInfo); }
MySoundCuesEnum GetCueEnumByExplosionType(MyExplosionTypeEnum explosionType) { MySoundCuesEnum?cueEnum = null; switch (explosionType) { case MyExplosionTypeEnum.MISSILE_EXPLOSION: cueEnum = MySoundCuesEnum.WepMissileExplosion; break; case MyExplosionTypeEnum.SMALL_SHIP_EXPLOSION: cueEnum = MySoundCuesEnum.SfxShipSmallExplosion; break; case MyExplosionTypeEnum.BOMB_EXPLOSION: cueEnum = MySoundCuesEnum.WepBombExplosion; break; case MyExplosionTypeEnum.METEOR_EXPLOSION: cueEnum = MySoundCuesEnum.SfxMeteorExplosion; break; case MyExplosionTypeEnum.FLASH_EXPLOSION: cueEnum = MySoundCuesEnum.WepBombFlash; break; case MyExplosionTypeEnum.GRAVITY_EXPLOSION: cueEnum = MySoundCuesEnum.WepBombGravSuck; break; case MyExplosionTypeEnum.EMP_EXPLOSION: cueEnum = MySoundCuesEnum.WepEpmExplosion; break; case MyExplosionTypeEnum.LARGE_SHIP_EXPLOSION: cueEnum = MySoundCuesEnum.SfxShipLargeExplosion; break; default: cueEnum = MySoundCuesEnum.WepMissileExplosion; break; } return(cueEnum.Value); }
public MyExplosionInfo(float playerDamage, float damage, BoundingSphereD explosionSphere, MyExplosionTypeEnum type, bool playSound, bool checkIntersection = true) { PlayerDamage = playerDamage; Damage = damage; ExplosionSphere = explosionSphere; StrengthImpulse = StrengthAngularImpulse = 0.0f; ExcludedEntity = OwnerEntity = HitEntity = null; CascadeLevel = 0; ExplosionFlags = MyExplosionFlags.AFFECT_VOXELS | MyExplosionFlags.APPLY_FORCE_AND_DAMAGE | MyExplosionFlags.CREATE_DEBRIS | MyExplosionFlags.CREATE_DECALS | MyExplosionFlags.CREATE_PARTICLE_EFFECT | MyExplosionFlags.APPLY_DEFORMATION; ExplosionType = type; LifespanMiliseconds = MyExplosionsConstants.EXPLOSION_LIFESPAN; ObjectsRemoveDelayInMiliseconds = 0; ParticleScale = 1.0f; VoxelCutoutScale = 1.0f; Direction = null; VoxelExplosionCenter = explosionSphere.Center; PlaySound = playSound; CheckIntersections = checkIntersection; Velocity = Vector3.Zero; }
public MyExplosionInfo(float playerDamage, float damage, float empDamage, BoundingSphere explosionSphere, MyExplosionTypeEnum type, bool playSound, MyDummyPoint customEffect = null, bool checkIntersection = true) { PlayerDamage = playerDamage; Damage = damage; EmpDamage = empDamage; ExplosionSphere = explosionSphere; ExplosionForceDirection = MyExplosionForceDirection.EXPLOSION; StrengthImpulse = StrengthAngularImpulse = 0.0f; ExcludedEntity = OwnerEntity = HitEntity = null; CascadeLevel = 0; ExplosionFlags = MyExplosionFlags.AFFECT_VOXELS | MyExplosionFlags.APPLY_FORCE_AND_DAMAGE | MyExplosionFlags.CREATE_DEBRIS | MyExplosionFlags.CREATE_DECALS | MyExplosionFlags.CREATE_PARTICLE_EFFECT; ExplosionType = type; LifespanMiliseconds = MyExplosionsConstants.EXPLOSION_LIFESPAN; GroupMask = MyGroupMask.Empty; ParticleScale = 1.0f; VoxelCutoutScale = 1.0f; Direction = null; VoxelExplosionCenter = explosionSphere.Center; PlaySound = playSound; CustomEffect = customEffect; CheckIntersections = checkIntersection; }
// Start explosion at specified position, with radius and lifespan. // type - specifies what type of object exploded // explosionSphere - position and radius // lifespanInMiliseconds - explosion life span // IMPORTANT: This class isn't realy inicialized by constructor, but by Start() public void Start(float playerDamage, float damage, float empDamage, MyExplosionTypeEnum type, BoundingSphere explosionSphere, int lifespanInMiliseconds, int cascadeLevel = 0, MyEntity hitEntity = null, float particleScale = 1.0f, MyEntity ownerEntity = null, bool forceDebris = false, bool createDecals = true, float voxelCutoutScale = 1.0f, bool playSound = true, bool checkIntersections = true) { // Call main explosion starter MyExplosionInfo info = new MyExplosionInfo(playerDamage, damage, empDamage, explosionSphere, type, playSound) { LifespanMiliseconds = lifespanInMiliseconds, ExplosionForceDirection = MyExplosionForceDirection.EXPLOSION, GroupMask = MyGroupMask.Empty, ExplosionFlags = MyExplosionFlags.CREATE_DEBRIS | MyExplosionFlags.AFFECT_VOXELS | MyExplosionFlags.APPLY_FORCE_AND_DAMAGE | MyExplosionFlags.CREATE_PARTICLE_EFFECT, CascadeLevel = cascadeLevel, HitEntity = hitEntity, ParticleScale = particleScale, OwnerEntity = ownerEntity, Direction = null, VoxelCutoutScale = voxelCutoutScale, CheckIntersections = checkIntersections, }; info.ForceDebris = forceDebris; info.CreateDecals = createDecals; info.VoxelExplosionCenter = explosionSphere.Center; Start(ref info); }
// This method realy initiates/starts the missile // IMPORTANT: Direction vector must be normalized! public override void Start(Vector3D position, Vector3D initialVelocity, Vector3D direction, long owner) { m_collidedEntity = null; m_collisionPoint = null; m_maxTrajectory = m_missileAmmoDefinition.MaxTrajectory; m_owner = owner; m_isExploded = false; base.Start(position, initialVelocity, direction, owner); Physics.RigidBody.MaxLinearVelocity = m_missileAmmoDefinition.DesiredSpeed; m_explosionType = MyExplosionTypeEnum.MISSILE_EXPLOSION; MySoundPair shootSound = m_weaponDefinition.WeaponAmmoDatas[(int)MyAmmoType.Missile].ShootSound; if (shootSound != null) { // Plays cue (looping) m_soundEmitter.PlaySingleSound(shootSound, true); } m_light = MyLights.AddLight(); if (m_light != null) { m_light.Start(MyLight.LightTypeEnum.PointLight, (Vector3)PositionComp.GetPosition(), GetMissileLightColor(), 1, MyMissileConstants.MISSILE_LIGHT_RANGE); } if (MyParticlesManager.TryCreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_Missile, out m_smokeEffect)) { var matrix = PositionComp.WorldMatrix; matrix.Translation -= matrix.Forward * m_smokeEffectOffsetMultiplier; m_smokeEffect.WorldMatrix = matrix; m_smokeEffect.AutoDelete = false; m_smokeEffect.CalculateDeltaMatrix = true; } }
/// <summary> /// Creates new instance of prefab configuration with default prefab type flags /// </summary> /// <param name="modelLod0Enum">Model LOD0</param> /// <param name="modelLod1Enum">Model LOD2</param> /// <param name="buildType">Build type</param> /// <param name="categoryType">Category type</param> /// <param name="subCategoryType">Subcategory type</param> /// <param name="materialType">Material type</param> /// <param name="factionSpecific">To which faction is this prefab specific. Null if prefab is for all factions. Used for material (texture) set availability. </param> public MyPrefabConfiguration( MyModelsEnum modelLod0Enum, MyModelsEnum? modelLod1Enum, BuildTypesEnum buildType, CategoryTypesEnum categoryType, SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, MyMwcObjectBuilder_Prefab_AppearanceEnum? factionSpecific = null, MyModelsEnum? collisionModelEnum = null, bool needsUpdate = false, bool initPhysics = true, bool enabledInEditor = true, float rotatingVelocity = DEFAULT_ROTATING_VELOCITY, MySoundCuesEnum? startRotatingCue = null, MySoundCuesEnum? loopRotatingCue = null, MySoundCuesEnum? loopRotatingDamagedCue = null, MySoundCuesEnum? endRotatingCue = null, MyPreviewPointOfViewEnum previewAngle = MyPreviewPointOfViewEnum.Front, MyExplosionTypeEnum explosionType = MyExplosionTypeEnum.SMALL_SHIP_EXPLOSION, float explosionRadiusMultiplier = 1, float explosionDamageMultiplier = 1, float minSizeForExplosion = MyExplosionsConstants.MIN_OBJECT_SIZE_TO_CAUSE_EXPLOSION_AND_CREATE_DEBRIS, bool causesAlarm = false, bool requiresEnergy = false, float explosionParticleEffectScale = 1, bool displayHud = false) : this(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, PrefabTypesFlagEnum.Default, collisionModelEnum, factionSpecific, needsUpdate, initPhysics, enabledInEditor, rotatingVelocity, startRotatingCue, loopRotatingCue, loopRotatingDamagedCue, endRotatingCue, previewAngle, explosionType: explosionType, explosionRadiusMultiplier: explosionRadiusMultiplier, explosionDamage: explosionDamageMultiplier, minSizeForExplosion: minSizeForExplosion, causesAlarm: causesAlarm, requiresEnergy: requiresEnergy, explosionParticleEffectScale: explosionParticleEffectScale, displayHud: displayHud) { System.Diagnostics.Debug.Assert(modelLod0Enum != modelLod1Enum, "LOD0 and LOD1 models are the same!"); if (collisionModelEnum != null) { System.Diagnostics.Debug.Assert(modelLod0Enum != collisionModelEnum, "LOD0 and COL models are the same!"); System.Diagnostics.Debug.Assert(modelLod1Enum != collisionModelEnum, "LOD1 and COL models are the same!"); } }
/// <summary> /// Creates new instance of prefab configuration /// </summary> /// <param name="modelLod0Enum">Model LOD0</param> /// <param name="modelLod1Enum">Model LOD2</param> /// <param name="buildType">Build type</param> /// <param name="categoryType">Category type</param> /// <param name="subCategoryType">Subcategory type</param> /// <param name="materialType">Material type</param> /// <param name="prefabTypeFlag">Prefab type flags</param> protected MyPrefabConfiguration( MyModelsEnum modelLod0Enum, MyModelsEnum? modelLod1Enum, BuildTypesEnum buildType, CategoryTypesEnum categoryType, SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, PrefabTypesFlagEnum prefabTypeFlag, MyModelsEnum? collisionModelEnum = null, MyMwcObjectBuilder_Prefab_AppearanceEnum? factionSpecific = null, bool needsUpdate = false, bool initPhysics = true, bool enabledInEditor = true, float rotatingVelocity = DEFAULT_ROTATING_VELOCITY, MySoundCuesEnum? startRotatingCue = null, MySoundCuesEnum? loopRotatingCue = null, MySoundCuesEnum? loopRotatingDamagedCue = null, MySoundCuesEnum? endRotatingCue = null, MyPreviewPointOfViewEnum previewAngle = MyPreviewPointOfViewEnum.Front, float minElectricCapacity = MyGameplayConstants.DEFAULT_MIN_ELECTRIC_CAPACITY, float maxElectricCapacity = MyGameplayConstants.DEFAULT_MAX_ELECTRIC_CAPACITY, MyExplosionTypeEnum explosionType = MyExplosionTypeEnum.SMALL_SHIP_EXPLOSION, float explosionRadiusMultiplier = 1, float explosionDamage = 1, float minSizeForExplosion = MyExplosionsConstants.MIN_OBJECT_SIZE_TO_CAUSE_EXPLOSION_AND_CREATE_DEBRIS, bool causesAlarm = false, bool requiresEnergy = false, float explosionParticleEffectScale = 1, bool displayHud = false) : this(buildType, categoryType, subCategoryType, materialType, prefabTypeFlag, factionSpecific, needsUpdate, initPhysics, enabledInEditor, rotatingVelocity, startRotatingCue, loopRotatingCue, loopRotatingDamagedCue, endRotatingCue, previewAngle, minElectricCapacity, maxElectricCapacity, explosionType, explosionRadiusMultiplier, explosionDamage, minSizeForExplosion, causesAlarm, requiresEnergy: requiresEnergy, explosionParticleEffectScale: explosionParticleEffectScale, displayHud: displayHud) { m_modelLod0Enum = modelLod0Enum; m_modelLod1Enum = modelLod1Enum; m_collisionModelEnum = collisionModelEnum; }
public void Start(float playerDamage, float damage, float empDamage, MyExplosionTypeEnum type, BoundingSphere explosionSphere, int lifespanInMiliseconds, MyExplosionForceDirection explosionForceDirection, MyGroupMask groupMask, bool createExplosionDebris, int cascadeLevel = 0, MyEntity hitEntity = null, float particleScale = 1.0f, MyEntity ownerEntity = null, bool affectVoxels = true, bool applyForceAndDamage = true, bool createDecals = true, Vector3?direction = null, bool forceDebris = false, bool playSound = false) { MyExplosionInfo info = new MyExplosionInfo(playerDamage, damage, empDamage, explosionSphere, type, playSound) { LifespanMiliseconds = lifespanInMiliseconds, ExplosionForceDirection = explosionForceDirection, GroupMask = groupMask, ExplosionFlags = MyExplosionFlags.CREATE_PARTICLE_EFFECT, CascadeLevel = cascadeLevel, HitEntity = hitEntity, ParticleScale = particleScale, OwnerEntity = ownerEntity, Direction = direction, VoxelCutoutScale = 1.0f, }; info.AffectVoxels = affectVoxels; info.ApplyForceAndDamage = applyForceAndDamage; info.CreateDebris = createExplosionDebris; info.CreateDecals = createDecals; info.ForceDebris = forceDebris; info.VoxelExplosionCenter = explosionSphere.Center; Start(ref info); }
// This method realy initiates/starts the missile // IMPORTANT: Direction vector must be normalized! public virtual void Start(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum type, Vector3 position, Vector3 initialVelocity, Vector3 direction, Vector3 relativePos, MyEntity minerShip, MyEntity target, float customMaxDistance, bool isDummy, bool isLightWeight) { m_ammoProperties = MyAmmoConstants.GetAmmoProperties(type); m_missileType = type; m_isExploded = false; m_collidedEntity = null; m_collisionPoint = null; m_maxTrajectory = customMaxDistance > 0 ? customMaxDistance : m_ammoProperties.MaxTrajectory; IsDummy = isDummy; Faction = minerShip.Faction; Vector3? correctedDirection = null; if (MyGameplayConstants.GameplayDifficultyProfile.EnableAimCorrection) { if (minerShip == MinerWars.AppCode.Game.Managers.Session.MySession.PlayerShip) { correctedDirection = MyEntities.GetDirectionFromStartPointToHitPointOfNearestObject(minerShip, position, m_ammoProperties.MaxTrajectory); } } if (correctedDirection != null) direction = correctedDirection.Value; base.Start(position, initialVelocity, direction, 0, minerShip); if (correctedDirection != null) //override the base class behaviour, update the missile direction { Matrix ammoWorld = minerShip.WorldMatrix; ammoWorld.Translation = position; ammoWorld.Forward = correctedDirection.Value; SetWorldMatrix(ammoWorld); } switch (m_missileType) { //just going forward (deprecated) case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic: m_initTime = MyMissileConstants.MISSILE_INIT_TIME; m_initDir = MyMissileConstants.MISSILE_INIT_DIR; m_blendVelocities = MyMissileConstants.MISSILE_BLEND_VELOCITIES_IN_MILISECONDS; m_missileTimeout = MyMissileConstants.MISSILE_TIMEOUT; m_explosionType = MyExplosionTypeEnum.MISSILE_EXPLOSION; break; case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_BioChem: m_initTime = MyMissileConstants.MISSILE_INIT_TIME; m_initDir = MyMissileConstants.MISSILE_INIT_DIR; m_blendVelocities = MyMissileConstants.MISSILE_BLEND_VELOCITIES_IN_MILISECONDS; m_missileTimeout = MyMissileConstants.MISSILE_TIMEOUT; m_explosionType = MyExplosionTypeEnum.BIOCHEM_EXPLOSION; break; case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_EMP: m_initTime = MyMissileConstants.MISSILE_INIT_TIME; m_initDir = MyMissileConstants.MISSILE_INIT_DIR; m_blendVelocities = MyMissileConstants.MISSILE_BLEND_VELOCITIES_IN_MILISECONDS; m_missileTimeout = MyMissileConstants.MISSILE_TIMEOUT; m_explosionType = MyExplosionTypeEnum.EMP_EXPLOSION; break; //Missile is guided to the nearest enemy in the radius case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Engine_Detection: //Missile is guided to the closest enemy in the visible spot case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Visual_Detection: //Missile is guided to actual selected target by smallship radar case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Radar_Detection: m_initDir.X = 5.0f * MathHelper.Clamp(relativePos.X, -1, 1); m_blendVelocities = MyGuidedMissileConstants.MISSILE_BLEND_VELOCITIES_IN_MILISECONDS; m_missileTimeout = MyGuidedMissileConstants.MISSILE_TIMEOUT; m_turnSpeed = MyGuidedMissileConstants.MISSILE_TURN_SPEED; m_explosionType = MyExplosionTypeEnum.MISSILE_EXPLOSION; GuidedInMultiplayer = true; break; default: throw new NotImplementedException(); } UpdateTarget(target); if (!isLightWeight) { // Play missile thrust cue (looping) m_thrusterCue = MyAudio.AddCue3D(m_ammoProperties.ShotSound, GetPosition(), WorldMatrix.Forward, WorldMatrix.Up, m_initialVelocity); m_light = MyLights.AddLight(); if (m_light != null) { m_light.Start(MyLight.LightTypeEnum.PointLight, GetPosition(), MyMissileHelperUtil.GetMissileLightColor(), 1, MyMissileConstants.MISSILE_LIGHT_RANGE); } } #if DEBUG_MISSILE m_trailDebug.Clear(); #endif if (m_missileType == MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic) { /* MyParticleEffect startEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_MissileStart); startEffect.WorldMatrix = WorldMatrix; */ m_smokeEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_Missile); m_smokeEffect.WorldMatrix = WorldMatrix; m_smokeEffect.AutoDelete = false; } }
//Provided by Phoera public static void Explode(Vector3D position, float damage, double radius, IMyEntity owner, MyExplosionTypeEnum type, bool affectVoxels = true) { var exp = new MyExplosionInfo(damage, damage, new BoundingSphereD(position, radius), type, true) { Direction = Vector3D.Up, ExplosionFlags = MyExplosionFlags.APPLY_FORCE_AND_DAMAGE | MyExplosionFlags.CREATE_PARTICLE_EFFECT | MyExplosionFlags.APPLY_DEFORMATION, OwnerEntity = owner as MyEntity, VoxelExplosionCenter = position }; if (affectVoxels) { exp.AffectVoxels = true; } MyExplosions.AddExplosion(ref exp); }
public void Start(float playerDamage, float damage, float empDamage, MyExplosionTypeEnum type, BoundingSphere explosionSphere, int lifespanInMiliseconds, MyExplosionForceDirection explosionForceDirection, MyGroupMask groupMask, bool createExplosionDebris, int cascadeLevel = 0, MyEntity hitEntity = null, float particleScale = 1.0f, MyEntity ownerEntity = null, bool affectVoxels = true, bool applyForceAndDamage = true, bool createDecals = true, Vector3? direction = null, bool forceDebris = false, bool playSound = false) { MyExplosionInfo info = new MyExplosionInfo(playerDamage, damage, empDamage, explosionSphere, type, playSound) { LifespanMiliseconds = lifespanInMiliseconds, ExplosionForceDirection = explosionForceDirection, GroupMask = groupMask, ExplosionFlags = MyExplosionFlags.CREATE_PARTICLE_EFFECT, CascadeLevel = cascadeLevel, HitEntity = hitEntity, ParticleScale = particleScale, OwnerEntity = ownerEntity, Direction = direction, VoxelCutoutScale = 1.0f, }; info.AffectVoxels = affectVoxels; info.ApplyForceAndDamage = applyForceAndDamage; info.CreateDebris = createExplosionDebris; info.CreateDecals = createDecals; info.ForceDebris = forceDebris; info.VoxelExplosionCenter = explosionSphere.Center; Start(ref info); }
MySoundCuesEnum GetCueEnumByExplosionType(MyExplosionTypeEnum explosionType) { MySoundCuesEnum? cueEnum = null; switch (explosionType) { case MyExplosionTypeEnum.MISSILE_EXPLOSION: cueEnum = MySoundCuesEnum.WepMissileExplosion; break; case MyExplosionTypeEnum.SMALL_SHIP_EXPLOSION: cueEnum = MySoundCuesEnum.SfxShipSmallExplosion; break; case MyExplosionTypeEnum.BOMB_EXPLOSION: cueEnum = MySoundCuesEnum.WepBombExplosion; break; case MyExplosionTypeEnum.METEOR_EXPLOSION: cueEnum = MySoundCuesEnum.SfxMeteorExplosion; break; case MyExplosionTypeEnum.FLASH_EXPLOSION: cueEnum = MySoundCuesEnum.WepBombFlash; break; case MyExplosionTypeEnum.GRAVITY_EXPLOSION: cueEnum = MySoundCuesEnum.WepBombGravSuck; break; case MyExplosionTypeEnum.EMP_EXPLOSION: cueEnum = MySoundCuesEnum.WepEpmExplosion; break; case MyExplosionTypeEnum.LARGE_SHIP_EXPLOSION: cueEnum = MySoundCuesEnum.SfxShipLargeExplosion; break; default: cueEnum = MySoundCuesEnum.WepMissileExplosion; break; } return cueEnum.Value; }
// This method realy initiates/starts the missile // IMPORTANT: Direction vector must be normalized! public virtual void Start(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum type, Vector3 position, Vector3 initialVelocity, Vector3 direction, Vector3 relativePos, MyEntity minerShip, MyEntity target, float customMaxDistance, bool isDummy, bool isLightWeight) { m_ammoProperties = MyAmmoConstants.GetAmmoProperties(type); m_missileType = type; m_isExploded = false; m_collidedEntity = null; m_collisionPoint = null; m_maxTrajectory = customMaxDistance > 0 ? customMaxDistance : m_ammoProperties.MaxTrajectory; IsDummy = isDummy; Faction = minerShip.Faction; Vector3?correctedDirection = null; if (MyGameplayConstants.GameplayDifficultyProfile.EnableAimCorrection) { if (minerShip == MinerWars.AppCode.Game.Managers.Session.MySession.PlayerShip) { correctedDirection = MyEntities.GetDirectionFromStartPointToHitPointOfNearestObject(minerShip, position, m_ammoProperties.MaxTrajectory); } } if (correctedDirection != null) { direction = correctedDirection.Value; } base.Start(position, initialVelocity, direction, 0, minerShip); if (correctedDirection != null) //override the base class behaviour, update the missile direction { Matrix ammoWorld = minerShip.WorldMatrix; ammoWorld.Translation = position; ammoWorld.Forward = correctedDirection.Value; SetWorldMatrix(ammoWorld); } switch (m_missileType) { //just going forward (deprecated) case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic: m_initTime = MyMissileConstants.MISSILE_INIT_TIME; m_initDir = MyMissileConstants.MISSILE_INIT_DIR; m_blendVelocities = MyMissileConstants.MISSILE_BLEND_VELOCITIES_IN_MILISECONDS; m_missileTimeout = MyMissileConstants.MISSILE_TIMEOUT; m_explosionType = MyExplosionTypeEnum.MISSILE_EXPLOSION; break; case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_BioChem: m_initTime = MyMissileConstants.MISSILE_INIT_TIME; m_initDir = MyMissileConstants.MISSILE_INIT_DIR; m_blendVelocities = MyMissileConstants.MISSILE_BLEND_VELOCITIES_IN_MILISECONDS; m_missileTimeout = MyMissileConstants.MISSILE_TIMEOUT; m_explosionType = MyExplosionTypeEnum.BIOCHEM_EXPLOSION; break; case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_EMP: m_initTime = MyMissileConstants.MISSILE_INIT_TIME; m_initDir = MyMissileConstants.MISSILE_INIT_DIR; m_blendVelocities = MyMissileConstants.MISSILE_BLEND_VELOCITIES_IN_MILISECONDS; m_missileTimeout = MyMissileConstants.MISSILE_TIMEOUT; m_explosionType = MyExplosionTypeEnum.EMP_EXPLOSION; break; //Missile is guided to the nearest enemy in the radius case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Engine_Detection: //Missile is guided to the closest enemy in the visible spot case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Visual_Detection: //Missile is guided to actual selected target by smallship radar case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Radar_Detection: m_initDir.X = 5.0f * MathHelper.Clamp(relativePos.X, -1, 1); m_blendVelocities = MyGuidedMissileConstants.MISSILE_BLEND_VELOCITIES_IN_MILISECONDS; m_missileTimeout = MyGuidedMissileConstants.MISSILE_TIMEOUT; m_turnSpeed = MyGuidedMissileConstants.MISSILE_TURN_SPEED; m_explosionType = MyExplosionTypeEnum.MISSILE_EXPLOSION; GuidedInMultiplayer = true; break; default: throw new NotImplementedException(); } UpdateTarget(target); if (!isLightWeight) { // Play missile thrust cue (looping) m_thrusterCue = MyAudio.AddCue3D(m_ammoProperties.ShotSound, GetPosition(), WorldMatrix.Forward, WorldMatrix.Up, m_initialVelocity); m_light = MyLights.AddLight(); if (m_light != null) { m_light.Start(MyLight.LightTypeEnum.PointLight, GetPosition(), MyMissileHelperUtil.GetMissileLightColor(), 1, MyMissileConstants.MISSILE_LIGHT_RANGE); } } #if DEBUG_MISSILE m_trailDebug.Clear(); #endif if (m_missileType == MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic) { /* * MyParticleEffect startEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_MissileStart); * startEffect.WorldMatrix = WorldMatrix; */ m_smokeEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_Missile); m_smokeEffect.WorldMatrix = WorldMatrix; m_smokeEffect.AutoDelete = false; } }
// This method realy initiates/starts the missile // IMPORTANT: Direction vector must be normalized! public void Start(Vector3 position, Vector3 initialVelocity, Vector3 directionNormalized, MyMwcObjectBuilder_SmallShip_Ammo usedAmmo, MySmallShip minerShip) { m_usedAmmo = usedAmmo; m_ammoProperties = MyAmmoConstants.GetAmmoProperties(usedAmmo.AmmoType); m_gameplayProperties = MyGameplayConstants.GetGameplayProperties(m_usedAmmo, Faction); m_penetratedVoxelMap = null; m_wasPenetration = false; m_hasExplosion = false; m_isExploded = false; m_collidedEntity = null; m_collisionPoint = null; Matrix orientation = GetWorldRotation(); Vector3 pos = position; // Play missile thrust cue (looping) m_thrusterCue = MyAudio.AddCue3D(MySoundCuesEnum.WepMissileFly, pos, orientation.Forward, orientation.Up, this.Physics.LinearVelocity); m_light = MyLights.AddLight(); if (m_light != null) { m_light.Start(MyLight.LightTypeEnum.PointLight, GetPosition(), MyMissileHelperUtil.GetCannonShotLightColor(), 1, MyMissileConstants.MISSILE_LIGHT_RANGE); } m_diffuseColor = m_ammoProperties.TrailColor; switch (usedAmmo.AmmoType) { case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Basic: case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_High_Speed: case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Armor_Piercing_Incendiary: case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_SAPHEI: case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Proximity_Explosive: m_explosionType = MyExplosionTypeEnum.MISSILE_EXPLOSION; break; case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_BioChem: m_explosionType = MyExplosionTypeEnum.BIOCHEM_EXPLOSION; break; case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_EMP: m_explosionType = MyExplosionTypeEnum.EMP_EXPLOSION; break; case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Tunnel_Buster: m_explosionType = MyExplosionTypeEnum.BLASTER_EXPLOSION; break; default: throw new MyMwcExceptionApplicationShouldNotGetHere(); break; } this.Physics.Mass = m_gameplayProperties.WeightPerUnit; Vector3?correctedDirection = null; if (MyGameplayConstants.GameplayDifficultyProfile.EnableAimCorrection) { if (minerShip == MinerWars.AppCode.Game.Managers.Session.MySession.PlayerShip) { correctedDirection = MyEntities.GetDirectionFromStartPointToHitPointOfNearestObject(minerShip, position, m_ammoProperties.MaxTrajectory); } } if (correctedDirection != null) { directionNormalized = correctedDirection.Value; } base.Start(position, initialVelocity, directionNormalized, m_ammoProperties.DesiredSpeed, minerShip); if (correctedDirection != null) //override the base class behaviour, update the missile direction { Matrix ammoWorld = minerShip.WorldMatrix; ammoWorld.Translation = position; ammoWorld.Forward = correctedDirection.Value; SetWorldMatrix(ammoWorld); } m_smokeEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_CannonShot); m_smokeEffect.AutoDelete = false; m_smokeEffect.WorldMatrix = WorldMatrix; }
MySoundPair GetCueByExplosionType(MyExplosionTypeEnum explosionType) { MySoundPair cueEnum = null; switch (explosionType) { case MyExplosionTypeEnum.MISSILE_EXPLOSION: { { bool found = false; if (m_explosionInfo.HitEntity is MyCubeGrid) { MyCubeGrid grid = m_explosionInfo.HitEntity as MyCubeGrid; foreach (var slimBlock in grid.GetBlocks()) { if (slimBlock.FatBlock is MyCockpit) { MyCockpit cockpit = slimBlock.FatBlock as MyCockpit; if (cockpit.Pilot == MySession.Static.ControlledEntity) { // player's ship hit cueEnum = m_smMissileShip; found = true; break; } } } } if (!found) // any other hit or no hit cueEnum = m_smMissileExpl; } break; } case MyExplosionTypeEnum.WARHEAD_EXPLOSION_02: case MyExplosionTypeEnum.WARHEAD_EXPLOSION_15: { cueEnum = m_smWarheadExpl; break; } case MyExplosionTypeEnum.WARHEAD_EXPLOSION_30: case MyExplosionTypeEnum.WARHEAD_EXPLOSION_50: { cueEnum = m_lrgWarheadExpl; break; } case MyExplosionTypeEnum.BOMB_EXPLOSION: { cueEnum = m_lrgWarheadExpl; break; } default: { cueEnum = m_missileExpl; break; } } return cueEnum; }
// This method realy initiates/starts the missile // IMPORTANT: Direction vector must be normalized! public void Start(Vector3 position, Vector3 initialVelocity, Vector3 directionNormalized, MyMwcObjectBuilder_SmallShip_Ammo usedAmmo, MySmallShip minerShip) { m_usedAmmo = usedAmmo; m_ammoProperties = MyAmmoConstants.GetAmmoProperties(usedAmmo.AmmoType); m_gameplayProperties = MyGameplayConstants.GetGameplayProperties(m_usedAmmo, Faction); m_penetratedVoxelMap = null; m_wasPenetration = false; m_hasExplosion = false; m_isExploded = false; m_collidedEntity = null; m_collisionPoint = null; Matrix orientation = GetWorldRotation(); Vector3 pos = position; // Play missile thrust cue (looping) m_thrusterCue = MyAudio.AddCue3D(MySoundCuesEnum.WepMissileFly, pos, orientation.Forward, orientation.Up, this.Physics.LinearVelocity); m_light = MyLights.AddLight(); if (m_light != null) { m_light.Start(MyLight.LightTypeEnum.PointLight, GetPosition(), MyMissileHelperUtil.GetCannonShotLightColor(), 1, MyMissileConstants.MISSILE_LIGHT_RANGE); } m_diffuseColor = m_ammoProperties.TrailColor; switch (usedAmmo.AmmoType) { case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Basic: case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_High_Speed: case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Armor_Piercing_Incendiary: case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_SAPHEI: case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Proximity_Explosive: m_explosionType = MyExplosionTypeEnum.MISSILE_EXPLOSION; break; case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_BioChem: m_explosionType = MyExplosionTypeEnum.BIOCHEM_EXPLOSION; break; case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_EMP: m_explosionType = MyExplosionTypeEnum.EMP_EXPLOSION; break; case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Tunnel_Buster: m_explosionType = MyExplosionTypeEnum.BLASTER_EXPLOSION; break; default: throw new MyMwcExceptionApplicationShouldNotGetHere(); break; } this.Physics.Mass = m_gameplayProperties.WeightPerUnit; Vector3? correctedDirection = null; if (MyGameplayConstants.GameplayDifficultyProfile.EnableAimCorrection) { if (minerShip == MinerWars.AppCode.Game.Managers.Session.MySession.PlayerShip) { correctedDirection = MyEntities.GetDirectionFromStartPointToHitPointOfNearestObject(minerShip, position, m_ammoProperties.MaxTrajectory); } } if (correctedDirection != null) directionNormalized = correctedDirection.Value; base.Start(position, initialVelocity, directionNormalized, m_ammoProperties.DesiredSpeed, minerShip); if (correctedDirection != null) //override the base class behaviour, update the missile direction { Matrix ammoWorld = minerShip.WorldMatrix; ammoWorld.Translation = position; ammoWorld.Forward = correctedDirection.Value; SetWorldMatrix(ammoWorld); } m_smokeEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_CannonShot); m_smokeEffect.AutoDelete = false; m_smokeEffect.WorldMatrix = WorldMatrix; }