private void SetupSlots()
 {
     this.Slots.Clear();
     foreach (ModuleSlotData slot in this.ActiveHull.ModuleSlotList)
     {
         SlotStruct ss = new SlotStruct();
         PrimitiveQuad pq = new PrimitiveQuad(slot.Position.X + this.offset.X - 8f, slot.Position.Y + this.offset.Y - 8f, 16f, 16f);
         ss.pq = pq;
         ss.Restrictions = slot.Restrictions;
         ss.facing = slot.facing;
         ss.ModuleUID = slot.InstalledModuleUID;
         ss.state = slot.state;
         ss.slotReference = slot;
         ss.SlotOptions = slot.SlotOptions;
         this.Slots.Add(ss);
     }
     foreach (SlotStruct slot in this.Slots)
     {
         if (slot.ModuleUID == null)
         {
             continue;
         }
         this.ActiveModule = Ship_Game.ResourceManager.GetModule(slot.ModuleUID);
         this.ChangeModuleState(slot.state);
         this.InstallModuleFromLoad(slot);
         if (slot.module == null || slot.module.ModuleType != ShipModuleType.Hangar)
         {
             continue;
         }
         slot.module.hangarShipUID = slot.SlotOptions;
     }
     this.ActiveModule = null;
     this.ActiveModState = ShipDesignScreen.ActiveModuleState.Normal;
 }
 private void ConfigureSlots()
 {
     this.border = new PrimitiveQuad(this.aspect.X / 2f - 256f, this.aspect.Y / 2f - 256f, 512f, 512f);
     this.spriteBatch = new SpriteBatch(base.ScreenManager.GraphicsDevice);
     for (int x = -32; x < 32; x++)
     {
         for (int y = -32; y < 32; y++)
         {
             PrimitiveQuad newCell = new PrimitiveQuad((float)((int)this.Center.X + 16 * x), (float)((int)this.Center.Y + 16 * y), (float)this.slotsize, (float)this.slotsize);
             SlotStruct newslot = new SlotStruct()
             {
                 pq = newCell,
                 Restrictions = Restrictions.I
             };
             this.SlotList.Add(newslot);
         }
     }
 }
 public override void LoadContent()
 {
     base.ScreenManager.inter.ObjectManager.Clear();
     PrimitiveQuad.graphicsDevice = base.ScreenManager.GraphicsDevice;
     this.aspect = new Vector2((float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth, (float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight);
     this.border = new PrimitiveQuad(this.aspect.X / 2f - 512f, this.aspect.Y / 2f - 512f, 1024f, 1024f);
     this.what = this.border.enclosingRect;
     ToggleButton Internal = new ToggleButton(new Rectangle(this.what.X - 32, this.what.Y + 5, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "I");
     this.DesignStateButtons.Add(Internal);
     Internal.Action = "I";
     ToggleButton InternalO = new ToggleButton(new Rectangle(this.what.X - 32, this.what.Y + 5 + 29, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "IO");
     this.DesignStateButtons.Add(InternalO);
     InternalO.Action = "IO";
     ToggleButton External = new ToggleButton(new Rectangle(this.what.X - 32, this.what.Y + 5 + 58, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "O");
     this.DesignStateButtons.Add(External);
     External.Action = "O";
     ToggleButton Engines = new ToggleButton(new Rectangle(this.what.X - 32, this.what.Y + 5 + 87, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "E");
     this.DesignStateButtons.Add(Engines);
     Engines.Action = "E";
     this.ModuleSlotTexture = base.ScreenManager.Content.Load<Texture2D>("Textures/Ships/singlebox");
     this.LoadModelButton = new DanButton(new Vector2(20f, (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 50)), "Load Model");
     this.SaveHullButton = new DanButton(new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 200), (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 50)), "Save Hull");
     this.ShipNameBox = new UITextEntry()
     {
         ClickableArea = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 200, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 115, 180, 20),
         Text = this.HullName
     };
     LightRig rig = base.ScreenManager.Content.Load<LightRig>("example/ShipyardLightrig");
     base.ScreenManager.inter.LightManager.Clear();
     base.ScreenManager.inter.LightManager.Submit(rig);
     base.ScreenManager.environment = base.ScreenManager.Content.Load<SceneEnvironment>("example/scene_environment");
     float width = (float)base.ScreenManager.GraphicsDevice.Viewport.Width;
     Viewport viewport = base.ScreenManager.GraphicsDevice.Viewport;
     float aspectRatio = width / (float)viewport.Height;
     Vector3 camPos = this.cameraPosition * new Vector3(-1f, 1f, 1f);
     this.view = ((Matrix.CreateTranslation(0f, 0f, 0f) * Matrix.CreateRotationY(MathHelper.ToRadians(180f))) * Matrix.CreateRotationX(MathHelper.ToRadians(0f))) * Matrix.CreateLookAt(camPos, new Vector3(camPos.X, camPos.Y, 0f), new Vector3(0f, -1f, 0f));
     this.projection = Matrix.CreatePerspectiveFieldOfView(0.7853982f, aspectRatio, 1f, 10000f);
     this.moduleSlot = base.ScreenManager.Content.Load<Texture2D>("Textures/Ships/singlebox");
     this.DottedLine = base.ScreenManager.Content.Load<Texture2D>("Textures/UI/DottedLine");
     this.Center = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2), (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2));
     this.ConfigureSlots();
     this.ThrusterEffect = base.ScreenManager.Content.Load<Effect>("Effects/Thrust");
     this.thruster = new Thruster();
     this.ScreenRect = new Rectangle(0, 0, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight);
     this.thruster.load_and_assign_effects(base.ScreenManager.Content, "Effects/ThrustCylinderB", "Effects/NoiseVolume", this.ThrusterEffect);
     base.LoadContent();
 }
        protected void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (this.spriteBatch != null)
                        this.spriteBatch.Dispose();
                    if (this.border != null)
                        this.border.Dispose();

                }
                this.spriteBatch = null;
                this.border = null;
                this.disposed = true;
            }
        }
 public override void Draw(GameTime gameTime)
 {
     this.spriteBatch = base.ScreenManager.SpriteBatch;
     base.ScreenManager.sceneState.BeginFrameRendering(this.view, this.projection, gameTime, base.ScreenManager.environment, true);
     base.ScreenManager.editor.BeginFrameRendering(base.ScreenManager.sceneState);
     base.ScreenManager.inter.BeginFrameRendering(base.ScreenManager.sceneState);
     base.ScreenManager.GraphicsDevice.Clear(Color.Black);
     if (this.applyThruster)
     {
         this.thruster.draw(ref this.view, ref this.projection, this.ThrusterEffect);
     }
     base.ScreenManager.inter.RenderManager.Render();
     Rectangle rectangle = new Rectangle(this.border.X, this.border.Y, 512, 512);
     this.spriteBatch.Begin();
     Vector2 TitlePos = new Vector2(20f, 20f);
     HelperFunctions.DrawDropShadowText(base.ScreenManager, "Ship Mod Tools", TitlePos, Fonts.Arial20Bold);
     TitlePos.Y = TitlePos.Y + (float)(Fonts.Arial20Bold.LineSpacing + 3);
     base.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, "Use this tool to create module patterns for your ships", TitlePos, Color.White);
     if (this.shipSO != null)
     {
         TitlePos = new Vector2((float)this.what.X, 20f);
         SpriteBatch spriteBatch = base.ScreenManager.SpriteBatch;
         SpriteFont arial12Bold = Fonts.Arial12Bold;
         float radius = this.shipSO.WorldBoundingSphere.Radius;
         spriteBatch.DrawString(arial12Bold, string.Concat("Radius: ", radius.ToString()), TitlePos, Color.White);
         TitlePos.Y = TitlePos.Y + 20f;
         string text = "If you can't see your model then your radius is likely too big or too small. A radius of 512 will fit snugly inside the box. Change the scale when you compile the model. If it is rotated oddly change the X, Y, and Z axis. If the model is off-center then you will need to re-export the 3D model from Blender, making sure to Set Origin to the desired pivot point of your model";
         base.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, HelperFunctions.parseText(Fonts.Arial12, text, 600f), TitlePos, Color.White);
     }
     Vector2 WhichSelectionPos = new Vector2((float)this.what.X, (float)(this.what.Y - Fonts.Arial20Bold.LineSpacing));
     this.spriteBatch.DrawString(Fonts.Arial20Bold, string.Concat(this.DesignState, " - ", this.GetDesignStateText()), WhichSelectionPos, Color.Orange);
     WhichSelectionPos.X = WhichSelectionPos.X + 150f;
     WhichSelectionPos.Y = WhichSelectionPos.Y + (float)Fonts.Arial20Bold.LineSpacing;
     WhichSelectionPos.Y = WhichSelectionPos.Y - Fonts.Arial12Bold.MeasureString(HelperFunctions.parseText(Fonts.Arial12Bold, this.DescriptionOfState, 512f)).Y;
     Primitives2D.DrawRectangle(base.ScreenManager.SpriteBatch, this.what, Color.White);
     foreach (SlotStruct slot in this.SlotList)
     {
         if (!this.applyThruster && slot.pq.isFilled)
         {
             this.spriteBatch.Draw(this.moduleSlot, slot.pq.enclosingRect, Color.White);
             this.spriteBatch.DrawString(Fonts.Arial20Bold, string.Concat(" ", slot.Restrictions), new Vector2((float)slot.pq.enclosingRect.X, (float)slot.pq.enclosingRect.Y), Color.Navy, 0f, Vector2.Zero, 0.4f, SpriteEffects.None, 1f);
         }
         if (this.applyThruster || slot.ModuleUID == null)
         {
             continue;
         }
         if (slot.module.XSIZE > 1 || slot.module.YSIZE > 1)
         {
             this.spriteBatch.Draw(slot.tex, new Rectangle(slot.pq.enclosingRect.X, slot.pq.enclosingRect.Y, 16 * slot.module.XSIZE, 16 * slot.module.YSIZE), Color.White);
         }
         else
         {
             this.spriteBatch.Draw(slot.tex, slot.pq.enclosingRect, Color.White);
         }
     }
     this.DrawHorizontalLine(this.SelectionBox.Y);
     this.DrawHorizontalLine(this.SelectionBox.Y + this.SelectionBox.Height);
     this.DrawVerticalLine(this.SelectionBox.X);
     this.DrawVerticalLine(this.SelectionBox.X + this.SelectionBox.Width);
     foreach (ToggleButton button in this.DesignStateButtons)
     {
         button.Draw(base.ScreenManager);
     }
     if (this.ActiveModule != null)
     {
         this.spriteBatch.Draw(Ship_Game.ResourceManager.TextureDict[Ship_Game.ResourceManager.ShipModulesDict[this.ActiveModule.UID].IconTexturePath], new Rectangle(this.mouseStateCurrent.X, this.mouseStateCurrent.Y, 16 * this.ActiveModule.XSIZE, 16 * this.ActiveModule.YSIZE), Color.White);
         for (int i = 0; i < this.ActiveModule.XSIZE; i++)
         {
             for (int j = 0; j < this.ActiveModule.YSIZE; j++)
             {
                 PrimitiveQuad pq = new PrimitiveQuad(new Rectangle(this.mouseStateCurrent.X + i * 16, this.mouseStateCurrent.Y + j * 16, 16, 16));
                 pq.Draw(this.spriteBatch, Color.White);
             }
         }
     }
     Vector2 InfoPos = new Vector2((float)(this.SaveHullButton.r.X - 50), (float)(this.SaveHullButton.r.Y - 20));
     base.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, "Hulls are saved to StarDrive/Ship Tools", InfoPos, Color.White);
     this.ShipNameBox.Draw(Fonts.Arial20Bold, base.ScreenManager.SpriteBatch, new Vector2((float)this.ShipNameBox.ClickableArea.X, (float)this.ShipNameBox.ClickableArea.Y), gameTime, Color.Orange);
     this.SaveHullButton.Draw(base.ScreenManager);
     this.LoadModelButton.Draw(base.ScreenManager);
     this.spriteBatch.End();
     base.ScreenManager.inter.EndFrameRendering();
     base.ScreenManager.editor.EndFrameRendering();
     base.ScreenManager.sceneState.EndFrameRendering();
 }