示例#1
0
 public virtual void Init(MyWeaponPropertiesWrapper weaponProperties)
 {
     m_missileAmmoDefinition = weaponProperties.GetCurrentAmmoDefinitionAs<MyMissileAmmoDefinition>();
     Init(weaponProperties, m_missileAmmoDefinition.MissileModelName, false, true, true);
     m_canByAffectedByExplosionForce = false;
     UseDamageSystem = true;
 }
示例#2
0
        private Ammo(MyAmmoMagazineDefinition ammoMagDef)
        {
            MyAmmoDefinition ammoDef = MyDefinitionManager.Static.GetAmmoDefinition(ammoMagDef.AmmoDefinitionId);
            this.myLogger = new Logger("Ammo", () => ammoMagDef.Id.ToString(), () => ammoDef.Id.ToString());

            this.AmmoDefinition = ammoDef;
            this.MissileDefinition = AmmoDefinition as MyMissileAmmoDefinition;
            this.MagazineDefinition = ammoMagDef;

            if (MissileDefinition != null && !MissileDefinition.MissileSkipAcceleration)
            {
                this.TimeToMaxSpeed = (MissileDefinition.DesiredSpeed - MissileDefinition.MissileInitialSpeed) / MissileDefinition.MissileAcceleration;
                this.DistanceToMaxSpeed = (MissileDefinition.DesiredSpeed + MissileDefinition.MissileInitialSpeed) / 2 * TimeToMaxSpeed;
            }
            else
            {
                this.TimeToMaxSpeed = 0;
                this.DistanceToMaxSpeed = 0;
            }

            Description = AmmoDescription.CreateFrom(AmmoDefinition);

            if (Description == null)
                return;

            if (Description.ClusterCooldown > 0f)
            {
                myLogger.debugLog("Is a cluster missile");
                IsCluster = true;
            }
            if (!string.IsNullOrWhiteSpace(Description.Radar))
            {
                try
                {
                    RadarDefinition = new RadarEquipment.Definition();
                    XML_Amendments<RadarEquipment.Definition> ammender = new XML_Amendments<RadarEquipment.Definition>(RadarDefinition);
                    ammender.primarySeparator = new char[] { ',' };
                    ammender.AmendAll(Description.Radar, true);
                    RadarDefinition = ammender.Deserialize();
                    myLogger.debugLog("Loaded description for radar", Logger.severity.DEBUG);
                }
                catch (Exception ex)
                {
                    Logger.debugNotify("Failed to load radar description for an ammo", 10000, Logger.severity.ERROR);
                    myLogger.alwaysLog("Failed to load radar description for an ammo", Logger.severity.ERROR);
                    myLogger.alwaysLog("Exception: " + ex, Logger.severity.ERROR);
                    RadarDefinition = null;
                }
            }
        }
示例#3
0
文件: Ammo.cs 项目: Sutima/Autopilot
		private Ammo(MyAmmoMagazineDefinition ammoMagDef)
		{
			MyAmmoDefinition ammoDef = MyDefinitionManager.Static.GetAmmoDefinition(ammoMagDef.AmmoDefinitionId);
			this.myLogger = new Logger("Ammo", () => ammoMagDef.Id.ToString(), () => ammoDef.Id.ToString());

			this.AmmoDefinition = ammoDef;
			this.MissileDefinition = AmmoDefinition as MyMissileAmmoDefinition;
			this.MagazineDefinition = ammoMagDef;

			if (MissileDefinition != null && !MissileDefinition.MissileSkipAcceleration)
			{
				this.TimeToMaxSpeed = (MissileDefinition.DesiredSpeed - MissileDefinition.MissileInitialSpeed) / MissileDefinition.MissileAcceleration;
				this.DistanceToMaxSpeed = (MissileDefinition.DesiredSpeed + MissileDefinition.MissileInitialSpeed) / 2 * TimeToMaxSpeed;
			}
			else
			{
				this.TimeToMaxSpeed = 0;
				this.DistanceToMaxSpeed = 0;
			}

			Description = AmmoDescription.CreateFrom(AmmoDefinition);

			if (Description == null)
				return;

			#region Check Cluster

			//if (Description.ClusterSplitRange < 1 || Description.ClusterCooldown < 1) // if any value is bad
			//{
			//	if (Description.ClusterSplitRange >= 1 || Description.ClusterCooldown >= 1) // if any value is good
			//	{
			//		Logger.debugNotify("Cluster description is incomplete", 10000, Logger.severity.ERROR);
			//		//myLogger.alwaysLog("Cluster description is incomplete: " + Description.ClusterSplitRange + ", " + Description.ClusterSpread + ", " + Description.ClusterCooldown, "VerifyCluster()", Logger.severity.ERROR);
			//	}
			//	return;
			//}

			if (Description.ClusterCooldown < 1)
				return;

			// BuildOffsets
			// ClusterOffset_Back can be +/-
			//Description.ClusterOffset_Radial = MathHelper.Max(Description.ClusterOffset_Radial, 0f);
			//Description.ClusterFormDistance = MathHelper.Max(Description.ClusterFormDistance, 1f);
			//ClusterOffsets = new Vector3[ammoMagDef.Capacity - 1];
			//float radius = ClusterOffsets.Length / MathHelper.TwoPi * Description.ClusterOffset_Radial;
			//float angle = MathHelper.TwoPi / ClusterOffsets.Length;

			//for (int i = 0; i < ClusterOffsets.Length; i++)
			//{
			//	float partAngle = angle * i;
			//	float right = (float)Math.Sin(partAngle) * radius;
			//	float up = (float)Math.Cos(partAngle) * radius;
			//	ClusterOffsets[i] = new Vector3(right, up, Description.ClusterOffset_Back);
			//}

			myLogger.debugLog("Is a cluster missile", "VerifyCluster()");
			IsCluster = true;

			#endregion
		}