Beispiel #1
0
        protected override void Update100_Options_TargetingThread(TargetingOptions current)
        {
            if (CurrentControl == Control.Engager)
            {
                return;
            }

            //Log.DebugLog("Turret flag: " + current.FlagSet(TargetingFlags.Turret) + ", No motor turret: " + (MyMotorTurret == null) + ", CanControl = " + CanControl, "Update_Options()");
            if (current.FlagSet(TargetingFlags.Turret))
            {
                if (MyMotorTurret == null && CanControl)
                {
                    //Log.DebugLog("MotorTurret is now enabled", "Update_Options()", Logger.severity.INFO);
                    MyMotorTurret = new MotorTurret(CubeBlock, MyMotorTurret_OnStatorChange, 1, WeaponDefinition.RequiredAccuracyRadians);
                }
            }
            else
            {
                if (MyMotorTurret != null)
                {
                    //Log.DebugLog("MotorTurret is now disabled", "Update_Options()", Logger.severity.INFO);
                    MyMotorTurret.Dispose();
                    MyMotorTurret = null;                     // MyMotorTurret will not be updated, so it will be recreated later incase something weird happens to motors
                }
            }
        }
Beispiel #2
0
		public void Update1()
		{
			try
			{
				updateCount++;

				if (myMotorTurret != null)
					myMotorTurret.FaceTowards(RelativeDirection3F.FromWorld(myBlock.CubeGrid, SunProperties.SunDirection));

				if (sinceNameChange < 2)
				{
					sinceNameChange++;
					myMotorTurret = null;
					return;
				}
				if (sinceNameChange > 2)
					return;

				sinceNameChange++;
				bool nowFace = myBlock.DisplayNameText.looseContains("[face sun]");
				if (nowFace == (myMotorTurret == null))
				{
					if (nowFace)
						myLogger.debugLog("now set to face sun", "Update10()", Logger.severity.INFO);
					else
						myLogger.debugLog("no longer set to face sun", "Update10()", Logger.severity.INFO);

					myMotorTurret = new MotorTurret(myBlock);
					myMotorTurret.RotationSpeedMultiplier = 10f;
					//myMotorTurret.SpeedLimt = 0.25f;
				}
			}
			catch (Exception ex)
			{ myLogger.alwaysLog("Exception: " + ex, "Update1()", Logger.severity.ERROR); }
		}
Beispiel #3
0
        public void Update100()
        {
            if (m_termControl_faceSun)
            {
                FaceSun();
                return;
            }

            if (m_nameCommand_faceSun)
            {
                FaceSun();
            }
            else
            {
                Log.DebugLog("no longer facing the sun", Logger.severity.DEBUG, condition: myMotorTurret != null);
                if (myMotorTurret != null)
                {
                    myMotorTurret.Dispose();
                    myMotorTurret = null;
                }
            }

            if (sinceNameChange > 2)
            {
                return;
            }

            if (sinceNameChange++ < 2)
            {
                return;
            }

            m_nameCommand_faceSun = myBlock.DisplayNameText.looseContains("[face sun]");
        }
Beispiel #4
0
        private void FaceSun()
        {
            if (myMotorTurret == null)
            {
                Log.DebugLog("Now facing sun", Logger.severity.DEBUG);
                myMotorTurret = new MotorTurret(myBlock);
            }

            myMotorTurret.FaceTowards(SunProperties.SunDirection);
        }
Beispiel #5
0
        public void Update100()
        {
            if (m_termControl_faceSun.Value)
            {
                FaceSun();
                return;
            }

            if (m_nameCommand_faceSun)
                FaceSun();
            else
            {
                myLogger.debugLog(myMotorTurret != null, "no longer facing the sun", Logger.severity.DEBUG);
                myMotorTurret = null;
            }

            if (sinceNameChange > 2)
                return;

            if (sinceNameChange++ < 2)
                return;

            m_nameCommand_faceSun = myBlock.DisplayNameText.looseContains("[face sun]");
        }
Beispiel #6
0
        protected override void Update_Options(TargetingOptions current)
        {
            if (ControllingEngager)
                return;

            //myLogger.debugLog("Turret flag: " + current.FlagSet(TargetingFlags.Turret) + ", No motor turret: " + (MyMotorTurret == null) + ", CanControl = " + CanControl, "Update_Options()");
            if (current.FlagSet(TargetingFlags.Turret))
            {
                if (MyMotorTurret == null && CanControl)
                {
                    myLogger.debugLog("Turret is now enabled", "Update_Options()", Logger.severity.INFO);
                    MyMotorTurret = new MotorTurret(CubeBlock, MyMotorTurret_OnStatorChange);
                    AllowedState = State.Targeting;
                }
            }
            else
            {
                if (MyMotorTurret != null)
                {
                    myLogger.debugLog("Turret is now disabled", "Update_Options()", Logger.severity.INFO);
                    MyMotorTurret = null; // MyMotorTurret will not be updated, so it will be recreated later incase something weird happens to motors
                    AllowedState = State.GetOptions;
                }
            }
        }
Beispiel #7
0
        private void FaceSun()
        {
            if (myMotorTurret == null)
            {
                myLogger.debugLog("Now facing sun", Logger.severity.DEBUG);
                myMotorTurret = new MotorTurret(myBlock);
                myMotorTurret.RotationSpeedMultiplier = 2f;
            }

            myMotorTurret.FaceTowards(RelativeDirection3F.FromWorld(myBlock.CubeGrid, SunProperties.SunDirection));
        }