Some cleanup (mostly removing redundancies from the GameMain class)
This commit is contained in:
@@ -7,30 +7,15 @@ using Microsoft.Xna.Framework;
|
|||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Barotrauma.Networking;
|
using Barotrauma.Networking;
|
||||||
using Barotrauma.Particles;
|
using Barotrauma.Particles;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using System.Xml;
|
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
class GameMain : Game
|
class GameMain : Game
|
||||||
{
|
{
|
||||||
public static GraphicsDeviceManager Graphics;
|
|
||||||
static int graphicsWidth, graphicsHeight;
|
|
||||||
static SpriteBatch spriteBatch;
|
|
||||||
|
|
||||||
public static GameMain Instance;
|
|
||||||
|
|
||||||
public static bool WindowActive
|
|
||||||
{
|
|
||||||
get { return Instance == null || Instance.IsActive; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool DebugDraw;
|
public static bool DebugDraw;
|
||||||
|
|
||||||
public static GraphicsDevice CurrGraphicsDevice;
|
|
||||||
|
|
||||||
public static FrameCounter FrameCounter;
|
public static FrameCounter FrameCounter;
|
||||||
|
|
||||||
public static readonly Version Version = Assembly.GetEntryAssembly().GetName().Version;
|
public static readonly Version Version = Assembly.GetEntryAssembly().GetName().Version;
|
||||||
@@ -52,20 +37,16 @@ namespace Barotrauma
|
|||||||
get { return Config.SelectedContentPackage; }
|
get { return Config.SelectedContentPackage; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Level Level;
|
|
||||||
|
|
||||||
public static GameSession GameSession;
|
public static GameSession GameSession;
|
||||||
|
|
||||||
public static NetworkMember NetworkMember;
|
public static NetworkMember NetworkMember;
|
||||||
|
|
||||||
public static ParticleManager ParticleManager;
|
public static ParticleManager ParticleManager;
|
||||||
|
|
||||||
//public static TextureLoader TextureLoader;
|
|
||||||
|
|
||||||
public static World World;
|
public static World World;
|
||||||
|
|
||||||
public static LoadingScreen TitleScreen;
|
public static LoadingScreen TitleScreen;
|
||||||
private static bool loadingScreenOpen;
|
private bool loadingScreenOpen;
|
||||||
|
|
||||||
public static GameSettings Config;
|
public static GameSettings Config;
|
||||||
|
|
||||||
@@ -74,25 +55,35 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private GameTime fixedTime;
|
private GameTime fixedTime;
|
||||||
|
|
||||||
//public static Random localRandom;
|
private static SpriteBatch spriteBatch;
|
||||||
//public static Random random;
|
|
||||||
|
|
||||||
//private Stopwatch renderTimer;
|
public static GameMain Instance
|
||||||
//public static int renderTimeElapsed;
|
|
||||||
|
|
||||||
public Camera Cam
|
|
||||||
{
|
{
|
||||||
get { return GameScreen.Cam; }
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GraphicsDeviceManager GraphicsDeviceManager
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GraphicsWidth
|
public static int GraphicsWidth
|
||||||
{
|
{
|
||||||
get { return graphicsWidth; }
|
get;
|
||||||
|
private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GraphicsHeight
|
public static int GraphicsHeight
|
||||||
{
|
{
|
||||||
get { return graphicsHeight; }
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool WindowActive
|
||||||
|
{
|
||||||
|
get { return Instance == null || Instance.IsActive; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameServer Server
|
public static GameServer Server
|
||||||
@@ -122,7 +113,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public GameMain()
|
public GameMain()
|
||||||
{
|
{
|
||||||
Graphics = new GraphicsDeviceManager(this);
|
GraphicsDeviceManager = new GraphicsDeviceManager(this);
|
||||||
|
|
||||||
Window.Title = "Barotrauma";
|
Window.Title = "Barotrauma";
|
||||||
|
|
||||||
@@ -142,10 +133,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
FrameCounter = new FrameCounter();
|
FrameCounter = new FrameCounter();
|
||||||
|
|
||||||
//IsMouseVisible = true;
|
|
||||||
|
|
||||||
IsFixedTimeStep = false;
|
IsFixedTimeStep = false;
|
||||||
//TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 55);
|
|
||||||
|
|
||||||
Timing.Accumulator = 0.0f;
|
Timing.Accumulator = 0.0f;
|
||||||
fixedTime = new GameTime();
|
fixedTime = new GameTime();
|
||||||
@@ -155,22 +143,21 @@ namespace Barotrauma
|
|||||||
FarseerPhysics.Settings.ContinuousPhysics = false;
|
FarseerPhysics.Settings.ContinuousPhysics = false;
|
||||||
FarseerPhysics.Settings.VelocityIterations = 1;
|
FarseerPhysics.Settings.VelocityIterations = 1;
|
||||||
FarseerPhysics.Settings.PositionIterations = 1;
|
FarseerPhysics.Settings.PositionIterations = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ApplyGraphicsSettings()
|
public void ApplyGraphicsSettings()
|
||||||
{
|
{
|
||||||
graphicsWidth = Config.GraphicsWidth;
|
GraphicsWidth = Config.GraphicsWidth;
|
||||||
graphicsHeight = Config.GraphicsHeight;
|
GraphicsHeight = Config.GraphicsHeight;
|
||||||
Graphics.SynchronizeWithVerticalRetrace = Config.VSyncEnabled;
|
GraphicsDeviceManager.SynchronizeWithVerticalRetrace = Config.VSyncEnabled;
|
||||||
|
|
||||||
Graphics.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed;
|
GraphicsDeviceManager.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed;
|
||||||
|
|
||||||
Graphics.IsFullScreen = Config.WindowMode == WindowMode.Fullscreen || Config.WindowMode == WindowMode.BorderlessWindowed;
|
GraphicsDeviceManager.IsFullScreen = Config.WindowMode == WindowMode.Fullscreen || Config.WindowMode == WindowMode.BorderlessWindowed;
|
||||||
Graphics.PreferredBackBufferWidth = graphicsWidth;
|
GraphicsDeviceManager.PreferredBackBufferWidth = GraphicsWidth;
|
||||||
Graphics.PreferredBackBufferHeight = graphicsHeight;
|
GraphicsDeviceManager.PreferredBackBufferHeight = GraphicsHeight;
|
||||||
|
|
||||||
Graphics.ApplyChanges();
|
GraphicsDeviceManager.ApplyChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -183,8 +170,6 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
CurrGraphicsDevice = GraphicsDevice;
|
|
||||||
|
|
||||||
ScissorTestEnable = new RasterizerState() { ScissorTestEnable = true };
|
ScissorTestEnable = new RasterizerState() { ScissorTestEnable = true };
|
||||||
|
|
||||||
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Character));
|
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Character));
|
||||||
@@ -199,25 +184,25 @@ namespace Barotrauma
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void LoadContent()
|
protected override void LoadContent()
|
||||||
{
|
{
|
||||||
graphicsWidth = GraphicsDevice.Viewport.Width;
|
GraphicsWidth = GraphicsDevice.Viewport.Width;
|
||||||
graphicsHeight = GraphicsDevice.Viewport.Height;
|
GraphicsHeight = GraphicsDevice.Viewport.Height;
|
||||||
|
|
||||||
Sound.Init();
|
Sound.Init();
|
||||||
|
|
||||||
ConvertUnits.SetDisplayUnitToSimUnitRatio(Physics.DisplayToSimRation);
|
ConvertUnits.SetDisplayUnitToSimUnitRatio(Physics.DisplayToSimRation);
|
||||||
|
|
||||||
spriteBatch = new SpriteBatch(GraphicsDevice);
|
spriteBatch = new SpriteBatch(base.GraphicsDevice);
|
||||||
TextureLoader.Init(GraphicsDevice);
|
TextureLoader.Init(base.GraphicsDevice);
|
||||||
|
|
||||||
loadingScreenOpen = true;
|
loadingScreenOpen = true;
|
||||||
TitleScreen = new LoadingScreen(GraphicsDevice);
|
TitleScreen = new LoadingScreen(base.GraphicsDevice);
|
||||||
|
|
||||||
loadingCoroutine = CoroutineManager.StartCoroutine(Load());
|
loadingCoroutine = CoroutineManager.StartCoroutine(Load());
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<object> Load()
|
public IEnumerable<object> Load()
|
||||||
{
|
{
|
||||||
GUI.GraphicsDevice = GraphicsDevice;
|
GUI.GraphicsDevice = base.GraphicsDevice;
|
||||||
GUI.Init(Content);
|
GUI.Init(Content);
|
||||||
|
|
||||||
GUIComponent.Init(Window);
|
GUIComponent.Init(Window);
|
||||||
@@ -225,9 +210,9 @@ namespace Barotrauma
|
|||||||
DebugConsole.Log(SelectedPackage == null ? "No content package selected" : "Content package \"" + SelectedPackage.Name + "\" selected");
|
DebugConsole.Log(SelectedPackage == null ? "No content package selected" : "Content package \"" + SelectedPackage.Name + "\" selected");
|
||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
|
|
||||||
LightManager = new Lights.LightManager(GraphicsDevice);
|
LightManager = new Lights.LightManager(base.GraphicsDevice);
|
||||||
|
|
||||||
Hull.renderer = new WaterRenderer(GraphicsDevice, Content);
|
Hull.renderer = new WaterRenderer(base.GraphicsDevice, Content);
|
||||||
TitleScreen.LoadState = 1.0f;
|
TitleScreen.LoadState = 1.0f;
|
||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
|
|
||||||
@@ -272,7 +257,7 @@ namespace Barotrauma
|
|||||||
TitleScreen.LoadState = 80.0f;
|
TitleScreen.LoadState = 80.0f;
|
||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
|
|
||||||
GameScreen = new GameScreen(Graphics.GraphicsDevice, Content);
|
GameScreen = new GameScreen(GraphicsDeviceManager.GraphicsDevice, Content);
|
||||||
TitleScreen.LoadState = 90.0f;
|
TitleScreen.LoadState = 90.0f;
|
||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
|
|
||||||
@@ -286,7 +271,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
|
|
||||||
ParticleManager = new ParticleManager("Content/Particles/ParticlePrefabs.xml", Cam);
|
ParticleManager = new ParticleManager("Content/Particles/ParticlePrefabs.xml", GameScreen.Cam);
|
||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
|
|
||||||
LocationType.Init();
|
LocationType.Init();
|
||||||
@@ -320,8 +305,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
while (Timing.Accumulator >= Timing.Step)
|
while (Timing.Accumulator >= Timing.Step)
|
||||||
{
|
{
|
||||||
TotalElapsedTime = gameTime.TotalGameTime.TotalSeconds;
|
|
||||||
|
|
||||||
fixedTime.IsRunningSlowly = gameTime.IsRunningSlowly;
|
fixedTime.IsRunningSlowly = gameTime.IsRunningSlowly;
|
||||||
TimeSpan addTime = new TimeSpan(0, 0, 0, 0, 16);
|
TimeSpan addTime = new TimeSpan(0, 0, 0, 0, 16);
|
||||||
fixedTime.ElapsedGameTime = addTime;
|
fixedTime.ElapsedGameTime = addTime;
|
||||||
@@ -409,11 +392,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (loadingScreenOpen)
|
if (loadingScreenOpen)
|
||||||
{
|
{
|
||||||
TitleScreen.Draw(spriteBatch, GraphicsDevice, (float)deltaTime);
|
TitleScreen.Draw(spriteBatch, base.GraphicsDevice, (float)deltaTime);
|
||||||
}
|
}
|
||||||
else if (hasLoaded)
|
else if (hasLoaded)
|
||||||
{
|
{
|
||||||
Screen.Selected.Draw(deltaTime, GraphicsDevice, spriteBatch);
|
Screen.Selected.Draw(deltaTime, base.GraphicsDevice, spriteBatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DebugDraw) return;
|
if (!DebugDraw) return;
|
||||||
@@ -426,7 +409,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool waitForKeyHit = true;
|
static bool waitForKeyHit = true;
|
||||||
public static CoroutineHandle ShowLoading(IEnumerable<object> loader, bool waitKeyHit = true)
|
public CoroutineHandle ShowLoading(IEnumerable<object> loader, bool waitKeyHit = true)
|
||||||
{
|
{
|
||||||
waitForKeyHit = waitKeyHit;
|
waitForKeyHit = waitKeyHit;
|
||||||
loadingScreenOpen = true;
|
loadingScreenOpen = true;
|
||||||
|
|||||||
@@ -22,11 +22,6 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//public void AddCasualty(Character character, CauseOfDeath causeOfDeath)
|
|
||||||
//{
|
|
||||||
// casualties.Add(new Casualty(character.Info, causeOfDeath, ""));
|
|
||||||
//}
|
|
||||||
|
|
||||||
public GUIFrame CreateSummaryFrame(string endMessage)
|
public GUIFrame CreateSummaryFrame(string endMessage)
|
||||||
{
|
{
|
||||||
bool singleplayer = GameMain.NetworkMember == null;
|
bool singleplayer = GameMain.NetworkMember == null;
|
||||||
@@ -90,7 +85,6 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
if (character.IsUnconscious)
|
if (character.IsUnconscious)
|
||||||
{
|
{
|
||||||
statusText = "Unconscious";
|
statusText = "Unconscious";
|
||||||
@@ -101,11 +95,12 @@ namespace Barotrauma
|
|||||||
statusText = "Injured";
|
statusText = "Injured";
|
||||||
statusColor = Color.DarkOrange;
|
statusColor = Color.DarkOrange;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(0, 0, 0, 20), statusText,
|
new GUITextBlock(
|
||||||
"", Alignment.BottomLeft, Alignment.TopCenter, characterFrame, true, GUI.SmallFont).Color = statusColor * 0.7f;
|
new Rectangle(0, 0, 0, 20), statusText, statusColor * 0.8f, Color.White,
|
||||||
|
Alignment.BottomLeft, Alignment.Center,
|
||||||
|
null, characterFrame, true, GUI.SmallFont);
|
||||||
|
|
||||||
x += characterFrame.Rect.Width + 10;
|
x += characterFrame.Rect.Width + 10;
|
||||||
}
|
}
|
||||||
@@ -120,12 +115,10 @@ namespace Barotrauma
|
|||||||
new GUITextBlock(new Rectangle(0, y, innerFrame.Rect.Width - 170, 0),
|
new GUITextBlock(new Rectangle(0, y, innerFrame.Rect.Width - 170, 0),
|
||||||
(GameMain.GameSession.Mission.Completed) ? GameMain.GameSession.Mission.SuccessMessage : GameMain.GameSession.Mission.FailureMessage,
|
(GameMain.GameSession.Mission.Completed) ? GameMain.GameSession.Mission.SuccessMessage : GameMain.GameSession.Mission.FailureMessage,
|
||||||
"", innerFrame, true);
|
"", innerFrame, true);
|
||||||
//y += 50;
|
|
||||||
|
|
||||||
if (GameMain.GameSession.Mission.Completed && singleplayer)
|
if (GameMain.GameSession.Mission.Completed && singleplayer)
|
||||||
{
|
{
|
||||||
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Reward: " + GameMain.GameSession.Mission.Reward, "", Alignment.BottomLeft, Alignment.BottomLeft, innerFrame);
|
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Reward: " + GameMain.GameSession.Mission.Reward, "", Alignment.BottomLeft, Alignment.BottomLeft, innerFrame);
|
||||||
//y += 30;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -365,8 +365,8 @@ namespace Barotrauma
|
|||||||
vsyncTickBox.OnSelected = (GUITickBox box) =>
|
vsyncTickBox.OnSelected = (GUITickBox box) =>
|
||||||
{
|
{
|
||||||
VSyncEnabled = !VSyncEnabled;
|
VSyncEnabled = !VSyncEnabled;
|
||||||
GameMain.Graphics.SynchronizeWithVerticalRetrace = VSyncEnabled;
|
GameMain.GraphicsDeviceManager.SynchronizeWithVerticalRetrace = VSyncEnabled;
|
||||||
GameMain.Graphics.ApplyChanges();
|
GameMain.GraphicsDeviceManager.ApplyChanges();
|
||||||
UnsavedSettings = true;
|
UnsavedSettings = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (wallEdgeEffect == null)
|
if (wallEdgeEffect == null)
|
||||||
{
|
{
|
||||||
wallEdgeEffect = new BasicEffect(GameMain.CurrGraphicsDevice)
|
wallEdgeEffect = new BasicEffect(GameMain.Instance.GraphicsDevice)
|
||||||
{
|
{
|
||||||
DiffuseColor = new Vector3(0.8f, 0.8f, 0.8f),
|
DiffuseColor = new Vector3(0.8f, 0.8f, 0.8f),
|
||||||
VertexColorEnabled = false,
|
VertexColorEnabled = false,
|
||||||
@@ -53,7 +53,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (wallCenterEffect == null)
|
if (wallCenterEffect == null)
|
||||||
{
|
{
|
||||||
wallCenterEffect = new BasicEffect(GameMain.CurrGraphicsDevice)
|
wallCenterEffect = new BasicEffect(GameMain.Instance.GraphicsDevice)
|
||||||
{
|
{
|
||||||
VertexColorEnabled = false,
|
VertexColorEnabled = false,
|
||||||
TextureEnabled = true,
|
TextureEnabled = true,
|
||||||
@@ -90,13 +90,13 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public void SetWallVertices(VertexPositionTexture[] vertices)
|
public void SetWallVertices(VertexPositionTexture[] vertices)
|
||||||
{
|
{
|
||||||
wallVertices = new VertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length,BufferUsage.WriteOnly);
|
wallVertices = new VertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length,BufferUsage.WriteOnly);
|
||||||
wallVertices.SetData(vertices);
|
wallVertices.SetData(vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetBodyVertices(VertexPositionTexture[] vertices)
|
public void SetBodyVertices(VertexPositionTexture[] vertices)
|
||||||
{
|
{
|
||||||
bodyVertices = new VertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
|
bodyVertices = new VertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
|
||||||
bodyVertices.SetData(vertices);
|
bodyVertices.SetData(vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
spriteBatch.End();
|
spriteBatch.End();
|
||||||
|
|
||||||
RenderWalls(GameMain.CurrGraphicsDevice, cam);
|
RenderWalls(GameMain.Instance.GraphicsDevice, cam);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(SpriteBatch spriteBatch)
|
public void Draw(SpriteBatch spriteBatch)
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (basicEffect == null)
|
if (basicEffect == null)
|
||||||
{
|
{
|
||||||
basicEffect = new BasicEffect(GameMain.CurrGraphicsDevice);
|
basicEffect = new BasicEffect(GameMain.Instance.GraphicsDevice);
|
||||||
basicEffect.VertexColorEnabled = false;
|
basicEffect.VertexColorEnabled = false;
|
||||||
|
|
||||||
basicEffect.TextureEnabled = true;
|
basicEffect.TextureEnabled = true;
|
||||||
|
|||||||
@@ -113,13 +113,13 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public void SetWallVertices(VertexPositionTexture[] vertices)
|
public void SetWallVertices(VertexPositionTexture[] vertices)
|
||||||
{
|
{
|
||||||
wallVertices = new VertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
|
wallVertices = new VertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
|
||||||
wallVertices.SetData(vertices);
|
wallVertices.SetData(vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetBodyVertices(VertexPositionColor[] vertices)
|
public void SetBodyVertices(VertexPositionColor[] vertices)
|
||||||
{
|
{
|
||||||
bodyVertices = new VertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionColor.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
|
bodyVertices = new VertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionColor.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
|
||||||
bodyVertices.SetData(vertices);
|
bodyVertices.SetData(vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -173,12 +173,12 @@ namespace Barotrauma.Lights
|
|||||||
{
|
{
|
||||||
if (shadowEffect == null)
|
if (shadowEffect == null)
|
||||||
{
|
{
|
||||||
shadowEffect = new BasicEffect(GameMain.CurrGraphicsDevice);
|
shadowEffect = new BasicEffect(GameMain.Instance.GraphicsDevice);
|
||||||
shadowEffect.VertexColorEnabled = true;
|
shadowEffect.VertexColorEnabled = true;
|
||||||
}
|
}
|
||||||
if (penumbraEffect == null)
|
if (penumbraEffect == null)
|
||||||
{
|
{
|
||||||
penumbraEffect = new BasicEffect(GameMain.CurrGraphicsDevice);
|
penumbraEffect = new BasicEffect(GameMain.Instance.GraphicsDevice);
|
||||||
penumbraEffect.TextureEnabled = true;
|
penumbraEffect.TextureEnabled = true;
|
||||||
//shadowEffect.VertexColorEnabled = true;
|
//shadowEffect.VertexColorEnabled = true;
|
||||||
penumbraEffect.LightingEnabled = false;
|
penumbraEffect.LightingEnabled = false;
|
||||||
@@ -601,7 +601,7 @@ namespace Barotrauma.Lights
|
|||||||
}
|
}
|
||||||
|
|
||||||
CalculateShadowVertices(lightSourcePos, los);
|
CalculateShadowVertices(lightSourcePos, los);
|
||||||
ShadowBuffer = new VertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionColor.VertexDeclaration, 6 * 2, BufferUsage.None);
|
ShadowBuffer = new VertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionColor.VertexDeclaration, 6 * 2, BufferUsage.None);
|
||||||
ShadowBuffer.SetData(shadowVertices, 0, shadowVertices.Length);
|
ShadowBuffer.SetData(shadowVertices, 0, shadowVertices.Length);
|
||||||
|
|
||||||
graphicsDevice.SetVertexBuffer(ShadowBuffer);
|
graphicsDevice.SetVertexBuffer(ShadowBuffer);
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ namespace Barotrauma.Lights
|
|||||||
|
|
||||||
if (lightEffect == null)
|
if (lightEffect == null)
|
||||||
{
|
{
|
||||||
lightEffect = new BasicEffect(GameMain.CurrGraphicsDevice);
|
lightEffect = new BasicEffect(GameMain.Instance.GraphicsDevice);
|
||||||
lightEffect.VertexColorEnabled = false;
|
lightEffect.VertexColorEnabled = false;
|
||||||
|
|
||||||
lightEffect.TextureEnabled = true;
|
lightEffect.TextureEnabled = true;
|
||||||
|
|||||||
@@ -490,16 +490,16 @@ namespace Barotrauma.Lights
|
|||||||
//now we just create a buffer for 64 verts and make it larger if needed
|
//now we just create a buffer for 64 verts and make it larger if needed
|
||||||
if (lightVolumeBuffer == null)
|
if (lightVolumeBuffer == null)
|
||||||
{
|
{
|
||||||
lightVolumeBuffer = new DynamicVertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, Math.Max(64, (int)(vertexCount*1.5)), BufferUsage.None);
|
lightVolumeBuffer = new DynamicVertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionTexture.VertexDeclaration, Math.Max(64, (int)(vertexCount*1.5)), BufferUsage.None);
|
||||||
lightVolumeIndexBuffer = new DynamicIndexBuffer(GameMain.CurrGraphicsDevice, typeof(short), Math.Max(64*3, (int)(indexCount * 1.5)), BufferUsage.None);
|
lightVolumeIndexBuffer = new DynamicIndexBuffer(GameMain.Instance.GraphicsDevice, typeof(short), Math.Max(64*3, (int)(indexCount * 1.5)), BufferUsage.None);
|
||||||
}
|
}
|
||||||
else if (vertexCount > lightVolumeBuffer.VertexCount)
|
else if (vertexCount > lightVolumeBuffer.VertexCount)
|
||||||
{
|
{
|
||||||
lightVolumeBuffer.Dispose();
|
lightVolumeBuffer.Dispose();
|
||||||
lightVolumeIndexBuffer.Dispose();
|
lightVolumeIndexBuffer.Dispose();
|
||||||
|
|
||||||
lightVolumeBuffer = new DynamicVertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, (int)(vertexCount*1.5), BufferUsage.None);
|
lightVolumeBuffer = new DynamicVertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionTexture.VertexDeclaration, (int)(vertexCount*1.5), BufferUsage.None);
|
||||||
lightVolumeIndexBuffer = new DynamicIndexBuffer(GameMain.CurrGraphicsDevice, typeof(short), (int)(indexCount * 1.5), BufferUsage.None);
|
lightVolumeIndexBuffer = new DynamicIndexBuffer(GameMain.Instance.GraphicsDevice, typeof(short), (int)(indexCount * 1.5), BufferUsage.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
lightVolumeBuffer.SetData<VertexPositionTexture>(vertices.ToArray());
|
lightVolumeBuffer.SetData<VertexPositionTexture>(vertices.ToArray());
|
||||||
@@ -566,10 +566,10 @@ namespace Barotrauma.Lights
|
|||||||
}
|
}
|
||||||
lightEffect.CurrentTechnique.Passes[0].Apply();
|
lightEffect.CurrentTechnique.Passes[0].Apply();
|
||||||
|
|
||||||
GameMain.CurrGraphicsDevice.SetVertexBuffer(lightVolumeBuffer);
|
GameMain.Instance.GraphicsDevice.SetVertexBuffer(lightVolumeBuffer);
|
||||||
GameMain.CurrGraphicsDevice.Indices = lightVolumeIndexBuffer;
|
GameMain.Instance.GraphicsDevice.Indices = lightVolumeIndexBuffer;
|
||||||
|
|
||||||
GameMain.CurrGraphicsDevice.DrawIndexedPrimitives
|
GameMain.Instance.GraphicsDevice.DrawIndexedPrimitives
|
||||||
(
|
(
|
||||||
PrimitiveType.TriangleList, 0, 0, indexCount / 3
|
PrimitiveType.TriangleList, 0, 0, indexCount / 3
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -561,7 +561,7 @@ namespace Barotrauma.Networking
|
|||||||
case (byte)PacketTypes.StartGame:
|
case (byte)PacketTypes.StartGame:
|
||||||
if (Screen.Selected == GameMain.GameScreen) continue;
|
if (Screen.Selected == GameMain.GameScreen) continue;
|
||||||
|
|
||||||
startGameCoroutine = GameMain.ShowLoading(StartGame(inc), false);
|
startGameCoroutine = GameMain.Instance.ShowLoading(StartGame(inc), false);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case (byte)PacketTypes.EndGame:
|
case (byte)PacketTypes.EndGame:
|
||||||
|
|||||||
@@ -932,7 +932,7 @@ namespace Barotrauma.Networking
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
startGameCoroutine = GameMain.ShowLoading(StartGame(selectedSub, selectedShuttle, selectedMode), false);
|
startGameCoroutine = GameMain.Instance.ShowLoading(StartGame(selectedSub, selectedShuttle, selectedMode), false);
|
||||||
|
|
||||||
yield return CoroutineStatus.Success;
|
yield return CoroutineStatus.Success;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -524,10 +524,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (GameMain.GameSession.Map.SelectedConnection == null) return false;
|
if (GameMain.GameSession.Map.SelectedConnection == null) return false;
|
||||||
|
|
||||||
GameMain.ShowLoading(ShiftLoading());
|
GameMain.Instance.ShowLoading(ShiftLoading());
|
||||||
|
|
||||||
//GameMain.GameSession.StartShift(selectedLevel, false);
|
|
||||||
//GameMain.GameScreen.Select();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user