public WeaponEffect(MyModelDummy dummy, int effectId, MyWeaponDefinition.WeaponEffectAction action, MyParticleEffect effect) { this.Dummy = dummy; this.EffectId = effectId; this.Effect = effect; this.Action = action; }
public WeaponEffect(string name, Matrix localMatrix, int effectId, MyWeaponDefinition.WeaponEffectAction action, MyParticleEffect effect) { this.Name = name; this.EffectId = effectId; this.Effect = effect; this.Action = action; this.LocalMatrix = localMatrix; }
public WeaponDefinitionExpanded(MyWeaponDefinition weaponDefn) { this.WeaponDefinition = weaponDefn; for (int i = 0; i < weaponDefn.WeaponAmmoDatas.Length; i++) { if (weaponDefn.WeaponAmmoDatas[i] != null) { AmmoType = (MyAmmoType)i; FirstAmmo = Ammo.GetAmmo(WeaponDefinition.AmmoMagazinesId[0]); RequiredAccuracy = (float)Math.Cos(0.02f + Math.Min(weaponDefn.WeaponAmmoDatas[i].RateOfFire, 1000) / 72000f); return; } } AmmoType = MyAmmoType.Unknown; RequiredAccuracy = 2f; }
public virtual void Init(MyWeaponPropertiesWrapper weaponProperties, string modelName, bool spherePhysics = true, bool capsulePhysics = false, bool bulletType = false) { System.Diagnostics.Debug.Assert(MyEntityIdentifier.AllocationSuspended == false, "Allocation was not suspended in MyAmmoBase.Init(...)"); bool oldSuspend = MyEntityIdentifier.AllocationSuspended; MyEntityIdentifier.AllocationSuspended = true; base.Init(null, modelName, null, null, null); m_weaponDefinition = weaponProperties.WeaponDefinition; // Collision skin if (spherePhysics) { this.InitSpherePhysics(MyMaterialType.AMMO, Model, 100, MyPerGameSettings.DefaultLinearDamping, MyPerGameSettings.DefaultAngularDamping, MyPhysics.AmmoLayer, bulletType ? RigidBodyFlag.RBF_BULLET : RigidBodyFlag.RBF_DEFAULT); } if (capsulePhysics) { this.InitCapsulePhysics(MyMaterialType.AMMO, new Vector3(0, 0, -Model.BoundingBox.HalfExtents.Z * 0.8f), new Vector3(0, 0, Model.BoundingBox.HalfExtents.Z * 0.8f), 0.1f, 10, 0, 0, MyPhysics.AmmoLayer, bulletType ? RigidBodyFlag.RBF_BULLET : RigidBodyFlag.RBF_DEFAULT); m_ammoOffsetSize = Model.BoundingBox.HalfExtents.Z * 0.8f + 0.1f; } else { this.InitBoxPhysics(MyMaterialType.AMMO, Model, 1, MyPerGameSettings.DefaultAngularDamping, MyPhysics.AmmoLayer, bulletType ? RigidBodyFlag.RBF_BULLET : RigidBodyFlag.RBF_DEFAULT); } NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME; Render.CastShadows = false; Closed = true; //Because ammobase instance is going to pool. It is started by Start() Physics.RigidBody.ContactPointCallbackEnabled = true; Physics.ContactPointCallback += listener_ContactPointCallback; MyEntityIdentifier.AllocationSuspended = oldSuspend; }
public void RemoveOldEffects(MyWeaponDefinition.WeaponEffectAction action = MyWeaponDefinition.WeaponEffectAction.Shoot) { for (int i = 0; i < m_activeEffects.Count; i++) { if (m_activeEffects[i].Action == action) { m_activeEffects[i].Effect.Stop(); m_activeEffects[i].Effect.Close(false); m_activeEffects.RemoveAt(i); i--; } } }
protected void CreateEffects(MyWeaponDefinition.WeaponEffectAction action) { if (dummies != null && dummies.Count > 0 && WeaponProperties.WeaponDefinition.WeaponEffects.Length > 0) { for (int i = 0; i < WeaponProperties.WeaponDefinition.WeaponEffects.Length; i++) { if (WeaponProperties.WeaponDefinition.WeaponEffects[i].Action == action) { MyModelDummy dummy; if (dummies.TryGetValue(WeaponProperties.WeaponDefinition.WeaponEffects[i].Dummy, out dummy)) { MyParticleEffect effect; bool add = true; int effectId = -1; MyParticlesLibrary.GetParticleEffectsID(WeaponProperties.WeaponDefinition.WeaponEffects[i].Particle, out effectId); if (WeaponProperties.WeaponDefinition.WeaponEffects[i].Loop) { for (int j = 0; j < m_activeEffects.Count; j++) { if (m_activeEffects[j].Dummy == dummy && m_activeEffects[j].EffectId == effectId) { add = false; break; } } } if (add && MyParticlesManager.TryCreateParticleEffect(effectId, out effect)) { if (WeaponProperties.WeaponDefinition.WeaponEffects[i].Loop) { m_activeEffects.Add(new WeaponEffect(dummy, effectId, action, effect)); } else { effect.WorldMatrix = MatrixD.Multiply(MatrixD.Normalize(dummy.Matrix), WorldMatrix); } } } } } } }