예제 #1
0
파일: Ammo.cs 프로젝트: Souper07/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;

            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;
                }
            }
        }
예제 #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);
                Logger log = new Logger("WeaponDescription", () => 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();
            }
        }
예제 #3
0
파일: Facer.cs 프로젝트: helppass/Autopilot
		/// <param name="mover">The mover to use</param>
		/// <param name="navSet">The settings to use</param>
		/// <param name="rotBlock">The block to rotate</param>
		public Facer(Mover mover, AllNavigationSettings navSet, PseudoBlock rotBlock)
			: base(mover, navSet)
		{
			this.m_logger = new Logger("Facer", m_controlBlock.CubeBlock);

			this.m_pseudoBlock = rotBlock;
			this.m_laser = rotBlock.Block as IMyLaserAntenna;
			if (this.m_laser == null)
			{
				if (!(rotBlock.Block is Ingame.IMySolarPanel) && !(rotBlock.Block is Ingame.IMyOxygenFarm))
				{
					m_logger.alwaysLog("Block is of wrong type: " + rotBlock.Block.DisplayNameText, "Facer()", Logger.severity.FATAL);
					throw new Exception("Block is of wrong type: " + rotBlock.Block.DisplayNameText);
				}
			}

			m_navSet.Settings_Task_NavRot.NavigatorRotator = this;
		}
예제 #4
0
        public Cluster(IMyEntity master, Builder_Cluster builder)
        {
            this.m_logger = new Logger(GetType().Name);
            this.Master = master;
            this.MinOffMult = builder.MinOffMult;
            this.OffsetMulti = builder.OffsetMulti;
            this.masterVelocity = master.Physics.LinearVelocity;

            this.Slaves = new List<IMyEntity>(builder.Slaves.Length);
            this.SlaveOffsets = new List<Vector3>(builder.Slaves.Length);
            for (int index = 0; index < builder.Slaves.Length; index++)
            {
                IMyEntity slave;
                if (!MyAPIGateway.Entities.TryGetEntityById(builder.Slaves[index], out slave))
                {
                    m_logger.alwaysLog("Failed to get slave for " + builder.Slaves[index], Logger.severity.WARNING);
                    continue;
                }
                this.Slaves[index] = slave;
                this.SlaveOffsets[index] = builder.SlaveOffsets[index];
            }
        }