Ejemplo n.º 1
0
        public TurretSetting RetrieveTerminalValues(IMyLargeMissileTurret turret)
        {
            Logger.Instance.LogDebug("RetrieveTerminalValues");
            var settings = m_TurretSettings.FirstOrDefault((x) => x.EntityId == turret.EntityId);

            return(settings);
        }
Ejemplo n.º 2
0
        public void DeleteTerminalValues(IMyLargeMissileTurret turret)
        {
            Logger.Instance.LogDebug("DeleteTerminalValues");
            var settings = m_TurretSettings.FirstOrDefault((x) => x.EntityId == turret.EntityId);

            if (settings != null)
            {
                TurretSpotlightSettings.Instance.m_TurretSettings.Remove(settings);
            }
        }
Ejemplo n.º 3
0
 private void SetTerminalValues(IMyLargeMissileTurret turret)
 {
     // set loaded data
     SetTurretLightColor(Light_Color);
     SetTurretLightIntensity(Light_Intensity);
     SetTurretLightRadius(Light_Radius);
     SetTurretLightOffset(Light_Offset);
     SetTurretLightBlinkInterval(Light_Blink_Interval);
     SetTurretLightBlinkLength(Light_Blink_Length);
     SetTurretLightBlinkOffset(Light_Blink_Offset);
     SetTurretOrientation(Turret_Azimuth, Turret_Elevation);
 }
Ejemplo n.º 4
0
        bool FuncTest(IMyLargeMissileTurret block)
        {
            //Missile Turret
            //Interface name: IMyLargeMissileTurret
            //Parent: IMyLargeConveyorTurretBase
            //Parent: IMyLargeTurretBase
            //Parent: IMyFunctionalBlock
            //Fields:
            bool  UseConveyorSystem = block.UseConveyorSystem;
            bool  CanControl        = block.CanControl;
            float Range             = block.Range;

            return(true);
        }
Ejemplo n.º 5
0
 private void LoadTerminalValues(IMyLargeMissileTurret turret, TurretSetting settings)
 {
     // load data
     if (settings != null)
     {
         Logger.Instance.LogDebug("Found settings for block: " + turret.CustomName);
         turret.GameLogic.GetAs <TurretSpotlight>().Light_Color          = settings.LightColor;
         turret.GameLogic.GetAs <TurretSpotlight>().Light_Radius         = settings.LightRadius;
         turret.GameLogic.GetAs <TurretSpotlight>().Light_Intensity      = settings.LightIntensity;
         turret.GameLogic.GetAs <TurretSpotlight>().Light_Offset         = settings.LightOffset;
         turret.GameLogic.GetAs <TurretSpotlight>().Light_Blink_Interval = settings.LightBlinkInterval;
         turret.GameLogic.GetAs <TurretSpotlight>().Light_Blink_Length   = settings.LightBlinkLength;
         turret.GameLogic.GetAs <TurretSpotlight>().Light_Blink_Offset   = settings.LightBlinkOffset;
         turret.GameLogic.GetAs <TurretSpotlight>().Turret_Azimuth       = settings.TurretAzimuth;
         turret.GameLogic.GetAs <TurretSpotlight>().Turret_Elevation     = settings.TurretElevation;
     }
 }
Ejemplo n.º 6
0
        public void StoreTerminalValues(IMyLargeMissileTurret turret)
        {
            var settings = m_TurretSettings.FirstOrDefault((x) => x.EntityId == turret.EntityId);

            if (settings == null)
            {
                settings          = new TurretSetting();
                settings.EntityId = turret.EntityId;
                m_TurretSettings.Add(settings);
            }
            settings.LightColor         = turret.GameLogic.GetAs <TurretSpotlight>().Light_Color;
            settings.LightRadius        = turret.GameLogic.GetAs <TurretSpotlight>().Light_Radius;
            settings.LightIntensity     = turret.GameLogic.GetAs <TurretSpotlight>().Light_Intensity;
            settings.LightOffset        = turret.GameLogic.GetAs <TurretSpotlight>().Light_Offset;
            settings.LightBlinkInterval = turret.GameLogic.GetAs <TurretSpotlight>().Light_Blink_Interval;
            settings.LightBlinkLength   = turret.GameLogic.GetAs <TurretSpotlight>().Light_Blink_Length;
            settings.LightBlinkOffset   = turret.GameLogic.GetAs <TurretSpotlight>().Light_Blink_Offset;
            settings.TurretAzimuth      = turret.GameLogic.GetAs <TurretSpotlight>().Turret_Azimuth;
            settings.TurretElevation    = turret.GameLogic.GetAs <TurretSpotlight>().Turret_Elevation;
        }
Ejemplo n.º 7
0
        public override void Init(MyObjectBuilder_EntityBase objectBuilder)
        {
            m_turret = (Container.Entity as IMyLargeMissileTurret);

            string Subtype = (m_turret as IMyTerminalBlock).BlockDefinition.SubtypeId;

            m_enabledCheck = (Subtype == "Spotlight_Turret_Large" || Subtype == "Spotlight_Turret_Small" || Subtype == "SmallSpotlight_Turret_Small");

            if (m_enabledCheck == true)
            {
                Logger.Instance.LogMessage("Init");
                NeedsUpdate |= VRage.ModAPI.MyEntityUpdateEnum.BEFORE_NEXT_FRAME;


                // event handlers
                m_turret.OnClosing       += OnClosing;
                m_light_cone_texture_path = MyAPIGateway.Utilities.GamePaths.ContentPath + m_LightConeTextureString;
                //Logger.Instance.LogMessage("Test Texture Path: " + m_light_cone_texture_path);
            }
        }
Ejemplo n.º 8
0
 public static void DeleteTerminalValues(this IMyLargeMissileTurret turret)
 {
     TurretSpotlightSettings.Instance.DeleteTerminalValues(turret);
 }
Ejemplo n.º 9
0
 public static TurretSetting RetrieveTerminalValues(this IMyLargeMissileTurret turret)
 {
     return(TurretSpotlightSettings.Instance.RetrieveTerminalValues(turret));
 }
Ejemplo n.º 10
0
 void Initialize()        // Handles the initialization of blocks. Is run at the end of each loop to ensure everything is there.
 {
     inventories.Clear(); // This must be done to avoid memory leaks.
     refineries.Clear();
     furnaces.Clear();
     assemblers.Clear();
     reactors.Clear();
     gasGenerators.Clear();
     gatlings.Clear();
     missileLaunchers.Clear();
     lcds.Clear();
     if (!Me.CustomName.ToLower().Contains(TAG.ToLower())) // If we have no tag at all.
     {
         Me.CustomName += " " + TAG;                       // Add a tag.
     }//
     else if (!Me.CustomName.Contains(TAG))                // We know we have a tag, but run this when the tag isn't exactly equal.
     {
         string customName = Me.CustomName;                // Replacing the incorrect tag with the proper version.
         int    index      = customName.ToLower().IndexOf(TAG.ToLower());
         customName    = customName.Remove(index, TAG.Length);
         customName    = customName.Insert(index, TAG);
         Me.CustomName = customName;
     }//
     GridTerminalSystem.SearchBlocksOfName(TAG, blocks);
     foreach (IMyTerminalBlock block in blocks)
     {
         if (!block.CustomName.Contains(TAG))// If the tag doesn't match up exactly, correct the tag.
         {
             string customName = block.CustomName;
             int    index      = customName.ToLower().IndexOf(TAG.ToLower());
             customName       = customName.Remove(index, TAG.Length);
             customName       = customName.Insert(index, TAG);
             block.CustomName = customName;
         }//
         IMyRefinery refinery = block as IMyRefinery;// This will return null if the block isn't a refinery block.
         if (refinery != null)
         {
             if (refinery.BlockDefinition.SubtypeId.Equals(FURNACE_TYPE_ID))// Both Refinieries and Arc Furnaces are refineries. Seperate them by subtype.
             {
                 furnaces.Add(refinery);
             }
             else
             {
                 refineries.Add(refinery);
             }
             continue;
         }//
         IMyAssembler assembler = block as IMyAssembler;
         if (assembler != null)
         {
             assemblers.Add(assembler);
             continue;
         }//
         IMyReactor reactor = block as IMyReactor;
         if (reactor != null)
         {
             reactors.Add(reactor);
             continue;
         }//
         IMyGasGenerator gasGenerator = block as IMyGasGenerator;
         if (gasGenerator != null)
         {
             gasGenerators.Add(gasGenerator);
             continue;
         }//
         IMyLargeGatlingTurret gatlingTurret = block as IMyLargeGatlingTurret;
         IMySmallGatlingGun    gatlingGun    = block as IMySmallGatlingGun;
         if ((gatlingTurret != null) | (gatlingGun != null))
         {
             gatlings.Add(block);
             continue;
         }//
         IMyLargeMissileTurret         missileTurret       = block as IMyLargeMissileTurret;
         IMySmallMissileLauncherReload smallLauncherReload = block as IMySmallMissileLauncherReload;
         if ((missileTurret != null) | (smallLauncherReload != null))
         {
             missileLaunchers.Add(block);
             continue;
         }//
         IMySmallMissileLauncher missileLauncher = block as IMySmallMissileLauncher;
         if ((missileLauncher != null) & (block.BlockDefinition.SubtypeId.Equals("LargeMissileLauncher")))
         {
             missileLaunchers.Add(block);
             continue;
         }//
         IMyProgrammableBlock programmableBlock = block as IMyProgrammableBlock;
         if (programmableBlock != null)
         {
             if (!programmableBlock.Equals(Me) & programmableBlock.IsWorking)                     // If the programmable block isn't the one running this instance and it is working.
             {
                 if (programmableBlock.CustomName.ToLower().Contains(CONNECTED_PB_TAG.ToLower())) // Check if it has the connected PB tag.
                 {
                     if (!programmableBlock.CustomName.Contains(CONNECTED_PB_TAG))
                     {
                         string customName = programmableBlock.CustomName;
                         int    index      = customName.ToLower().IndexOf(CONNECTED_PB_TAG.ToLower());
                         customName = customName.Remove(index, CONNECTED_PB_TAG.Length);
                         customName = customName.Insert(index, CONNECTED_PB_TAG);
                         programmableBlock.CustomName = customName;
                     }//
                     connectedPBs.Add(programmableBlock);
                     continue;
                 }    //
                 else // Assume this PB is running the same script.
                 {
                     if (programmableBlock.CubeGrid.EntityId == Me.CubeGrid.EntityId)
                     {
                         Echo("ERROR: MORE THAN ONE IAN ON ONE GRID");
                         active = false;// Both PBs will disable themselves and show an error.
                         continue;
                     }//
                     else if (programmableBlock.CubeGrid.GridSize > Me.CubeGrid.GridSize)// The PB with the biggest grid size will be dominant.
                     {
                         active = false;
                         continue;
                     }
                     active = true;// None of the exceptions have occured, so we are free to resume functioning. This will ensure IAN plays nice with it's double.
                     continue;
                 }//
             } //
         }     //
         IMyTextPanel panel = block as IMyTextPanel;
         if (panel != null)
         {
             lcds.Add(panel);
         }
     } //
 }     //