示例#1
0
文件: Ammo.cs 项目: zrisher/ARMS
            public static AmmoDescription CreateFrom(MyAmmoDefinition ammo)
            {
                if (string.IsNullOrWhiteSpace(ammo.DescriptionString))
                {
                    return(null);
                }

                AmmoDescription desc = new AmmoDescription();

                try
                {
                    XML_Amendments <AmmoDescription> ammender = new XML_Amendments <AmmoDescription>(desc);
                    ammender.primarySeparator = new char[] { ';' };
                    ammender.AmendAll(ammo.DescriptionString, true);
                    desc = ammender.Deserialize();
                    desc.CosAcquisitionAngle = (float)Math.Cos(desc.AcquisitionAngle);
                    return(desc);
                }
                catch (Exception ex)
                {
                    Logger.DebugNotify("Failed to load description for an ammo", 10000, Logger.severity.ERROR);
                    Logable Log = new Logable(ammo.Id.SubtypeName);
                    Log.AlwaysLog("Failed to load description for an ammo", Logger.severity.ERROR);
                    Log.AlwaysLog("Exception: " + ex, Logger.severity.ERROR);
                    return(null);
                }
            }
示例#2
0
        private static WeaponDescription CreateFrom(MyCubeBlockDefinition definition)
        {
            if (string.IsNullOrWhiteSpace(definition.DescriptionString))
            {
                return(new WeaponDescription());
            }

            WeaponDescription desc = new WeaponDescription();

            try
            {
                XML_Amendments <WeaponDescription> ammender = new XML_Amendments <WeaponDescription>(desc);
                ammender.AmendAll(definition.DescriptionString, true);
                return(ammender.Deserialize());
            }
            catch (Exception ex)
            {
                Logger.DebugNotify("Failed to load description for a weapon", 10000, Logger.severity.ERROR);
                Logable Log = new Logable(definition.Id.ToString());
                Log.AlwaysLog("Failed to load description for a weapon", Logger.severity.ERROR);
                Log.AlwaysLog("Exception: " + ex, Logger.severity.ERROR);
                return(new WeaponDescription());
            }
        }