Merge branch 'NewCoordinateSystem'

Conflicts:
	Subsurface/Barotrauma.csproj
	Subsurface_Solution.v12.suo
This commit is contained in:
Regalis
2015-12-17 18:29:26 +02:00
105 changed files with 2401 additions and 1288 deletions
@@ -134,6 +134,8 @@ namespace Barotrauma
GUIComponent.MouseOn = null;
characterMode = false;
if (Submarine.Loaded != null) cam.Position = Submarine.Loaded.Position + Submarine.HiddenSubPosition;
//CreateDummyCharacter();
}
+26 -73
View File
@@ -15,12 +15,7 @@ namespace Barotrauma
readonly RenderTarget2D renderTargetWater;
readonly RenderTarget2D renderTargetAir;
readonly Sprite background, backgroundTop;
readonly Texture2D dustParticles;
Vector2 dustOffset;
public BackgroundSpriteManager BackgroundSpriteManager;
public BackgroundCreatureManager BackgroundCreatureManager;
public Camera Cam
{
@@ -36,17 +31,16 @@ namespace Barotrauma
renderTargetWater = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
renderTargetAir = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
background = new Sprite("Content/Map/background.png", Vector2.Zero);
backgroundTop = new Sprite("Content/Map/background2.png", Vector2.Zero);
dustParticles = Sprite.LoadTexture("Content/Map/dustparticles.png");
BackgroundSpriteManager = new BackgroundSpriteManager("Content/BackgroundSprites/BackgroundSpritePrefabs.xml");
BackgroundCreatureManager = new BackgroundCreatureManager("Content/BackgroundSprites/BackgroundCreaturePrefabs.xml");
}
public override void Select()
{
base.Select();
if (Submarine.Loaded != null) cam.TargetPos = Submarine.Loaded.Position;
foreach (MapEntity entity in MapEntity.mapEntityList)
entity.IsHighlighted = false;
}
@@ -58,6 +52,8 @@ namespace Barotrauma
Sounds.SoundManager.LowPassHFGain = 1.0f;
}
int rendc;
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
@@ -81,30 +77,38 @@ namespace Barotrauma
GameMain.GameSession.Submarine.ApplyForce(targetMovement * 1000000.0f);
}
#endif
dustOffset -= Vector2.UnitY * 10.0f * (float)deltaTime;
if (GameMain.GameSession!=null) GameMain.GameSession.Update((float)deltaTime);
//EventManager.Update(gameTime);
if (Level.Loaded != null) Level.Loaded.Update((float)deltaTime);
Character.UpdateAll(cam, (float)deltaTime);
BackgroundSpriteManager.Update(cam, (float)deltaTime);
BackgroundCreatureManager.Update(cam, (float)deltaTime);
GameMain.ParticleManager.Update((float)deltaTime);
StatusEffect.UpdateAll((float)deltaTime);
Physics.accumulator = Math.Min(Physics.accumulator, Physics.step * 4);
Physics.accumulator = Math.Min(Physics.accumulator, Physics.step * 6);
//Physics.accumulator = Physics.step;
while (Physics.accumulator >= Physics.step)
{
cam.MoveCamera((float)Physics.step);
if (Character.Controlled != null)
{
cam.TargetPos = Character.Controlled.WorldPosition;
Lights.LightManager.ViewPos = Character.Controlled.WorldPosition;
}
if (Submarine.Loaded != null) Submarine.Loaded.SetPrevTransform(Submarine.Loaded.Position);
foreach (PhysicsBody pb in PhysicsBody.list)
{
pb.SetPrevTransform(pb.SimPosition, pb.Rotation);
}
MapEntity.UpdateAll(cam, (float)Physics.step);
Character.UpdateAnimAll((float)Physics.step);
@@ -118,7 +122,7 @@ namespace Barotrauma
GameMain.World.Step((float)Physics.step);
Level.AfterWorldStep();
//Level.AfterWorldStep();
Physics.accumulator -= Physics.step;
}
@@ -164,11 +168,15 @@ namespace Barotrauma
public void DrawMap(GraphicsDevice graphics, SpriteBatch spriteBatch)
{
if (Submarine.Loaded != null) Submarine.Loaded.UpdateTransform();
GameMain.LightManager.ObstructVision = Character.Controlled != null && Character.Controlled.ObstructVision;
GameMain.LightManager.UpdateLightMap(graphics, spriteBatch, cam);
GameMain.LightManager.UpdateObstructVision(graphics, spriteBatch, cam,
Character.Controlled==null ? LightManager.ViewPos : Character.Controlled.CursorPosition);
Character.Controlled==null ? LightManager.ViewPos : Character.Controlled.CursorWorldPosition);
//----------------------------------------------------------------------------------------
//1. draw the background, characters and the parts of the submarine that are behind them
@@ -177,57 +185,8 @@ namespace Barotrauma
graphics.SetRenderTarget(renderTarget);
graphics.Clear(new Color(11, 18, 26, 255));
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap);
if (Level.Loaded != null) Level.Loaded.DrawBack(spriteBatch, cam, BackgroundCreatureManager);
Vector2 backgroundPos = cam.Position;
if (Level.Loaded != null) backgroundPos -= Level.Loaded.Position;
backgroundPos.Y = -backgroundPos.Y;
backgroundPos /= 20.0f;
if (backgroundPos.Y < 1024)
{
if (backgroundPos.Y > -1024)
{
background.SourceRect = new Rectangle((int)backgroundPos.X, (int)Math.Max(backgroundPos.Y, 0), 1024, 1024);
background.DrawTiled(spriteBatch,
(backgroundPos.Y < 0) ? new Vector2(0.0f, -backgroundPos.Y) : Vector2.Zero,
new Vector2(GameMain.GraphicsWidth, 1024 - backgroundPos.Y),
Vector2.Zero, Color.White);
}
if (backgroundPos.Y < 0)
{
backgroundTop.SourceRect = new Rectangle((int)backgroundPos.X, (int)backgroundPos.Y, 1024, (int)Math.Min(-backgroundPos.Y, 1024));
backgroundTop.DrawTiled(spriteBatch, Vector2.Zero, new Vector2(GameMain.GraphicsWidth, Math.Min(-backgroundPos.Y, GameMain.GraphicsHeight)),
Vector2.Zero, Color.White);
}
}
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.BackToFront,
BlendState.AlphaBlend,
SamplerState.LinearWrap, DepthStencilState.Default, null, null,
cam.Transform);
BackgroundSpriteManager.Draw(spriteBatch);
backgroundPos = new Vector2(cam.WorldView.X, cam.WorldView.Y) + dustOffset;
if (Level.Loaded != null) backgroundPos -= Level.Loaded.Position;
Rectangle viewRect = cam.WorldView;
viewRect.Y = -viewRect.Y;
float multiplier = 0.8f;
for (int i = 1; i < 4; i++)
{
spriteBatch.Draw(dustParticles, viewRect,
new Rectangle((int)((backgroundPos.X * multiplier)), (int)((-backgroundPos.Y * multiplier)), cam.WorldView.Width, cam.WorldView.Height),
Color.White * multiplier, 0.0f, Vector2.Zero, SpriteEffects.None, 1.0f-multiplier);
multiplier -= 0.15f;
}
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.BackToFront,
BlendState.AlphaBlend,
@@ -320,12 +279,6 @@ namespace Barotrauma
Hull.renderer.Render(graphics, cam, renderTargetAir, Cam.ShaderTransform);
if (GameMain.GameSession != null && GameMain.GameSession.Level != null)
{
GameMain.GameSession.Level.Render(graphics, cam);
//GameMain.GameSession.Level.SetObserverPosition(cam.WorldViewCenter);
}
//----------------------------------------------------------------------------------------
//3. draw the sections of the map that are on top of the water
//----------------------------------------------------------------------------------------
@@ -339,7 +292,7 @@ namespace Barotrauma
Submarine.DrawFront(spriteBatch);
if (Level.Loaded!=null) Level.Loaded.Draw(spriteBatch);
if (Level.Loaded!=null) Level.Loaded.DrawFront(spriteBatch);
spriteBatch.End();
+4 -8
View File
@@ -1,7 +1,4 @@
using FarseerPhysics;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Factories;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
@@ -362,7 +359,7 @@ namespace Barotrauma
UpdateCharacterLists();
}
graphics.Clear(Color.CornflowerBlue);
graphics.Clear(Color.Black);
//GameMain.GameScreen.DrawMap(graphics, spriteBatch);
@@ -370,9 +367,8 @@ namespace Barotrauma
Sprite backGround = GameMain.GameSession.Map.CurrentLocation.Type.Background;
spriteBatch.Draw(backGround.Texture, Vector2.Zero, null, Color.White, 0.0f, Vector2.Zero,
Math.Max((float)GameMain.GraphicsWidth / backGround.SourceRect.Width, (float)GameMain.GraphicsHeight / backGround.SourceRect.Width), SpriteEffects.None, 0.0f);
Math.Max((float)GameMain.GraphicsWidth / backGround.SourceRect.Width, (float)GameMain.GraphicsHeight / backGround.SourceRect.Height), SpriteEffects.None, 0.0f);
topPanel.Draw(spriteBatch);
bottomPanel[selectedRightPanel].Draw(spriteBatch);
+38 -27
View File
@@ -36,6 +36,8 @@ namespace Barotrauma
public bool IsServer;
public string ServerName, ServerMessage;
private Sprite backgroundSprite;
private GUITextBox serverMessage;
public GUIListBox SubList
@@ -98,7 +100,10 @@ namespace Barotrauma
}
private set
{
if (levelSeed == value) return;
levelSeed = value;
backgroundSprite = LocationType.Random(levelSeed).Background;
seedBox.Text = levelSeed;
}
}
@@ -266,13 +271,12 @@ namespace Barotrauma
serverMessage.Wrap = true;
serverMessage.TextGetter = GetServerMessage;
serverMessage.OnTextChanged = UpdateServerMessage;
}
public override void Deselect()
{
textBox.Deselect();
seedBox.Text = ToolBox.RandomSeed(8);
}
public override void Select()
@@ -284,7 +288,7 @@ namespace Barotrauma
textBox.Select();
Character.Controlled = null;
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
//GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
subList.Enabled = GameMain.Server != null || GameMain.NetworkMember.Voting.AllowSubVoting;
playerList.Enabled = GameMain.Server != null;
@@ -320,18 +324,18 @@ namespace Barotrauma
banListButton.OnClicked = GameMain.Server.BanList.ToggleBanFrame;
banListButton.UserData = "banListButton";
if (subList.CountChildren > 0 && subList.Selected == null) subList.Select(-1);
if (GameModePreset.list.Count > 0 && modeList.Selected == null) modeList.Select(-1);
if (subList.CountChildren > 0 && subList.Selected == null) subList.Select(0);
if (GameModePreset.list.Count > 0 && modeList.Selected == null) modeList.Select(0);
if (myPlayerFrame.children.Find(c => c.UserData as string == "playyourself") == null)
{
var playYourself = new GUITickBox(new Rectangle(-10, -10, 20, 20), "Play yourself", Alignment.TopLeft, myPlayerFrame);
var playYourself = new GUITickBox(new Rectangle(0, -10, 20, 20), "Play yourself", Alignment.TopLeft, myPlayerFrame);
playYourself.Selected = GameMain.Server.CharacterInfo != null;
playYourself.OnSelected = TogglePlayYourself;
playYourself.UserData = "playyourself";
}
if (GameMain.Server.RandomizeSeed) seedBox.Text = ToolBox.RandomSeed(8);
if (GameMain.Server.RandomizeSeed) LevelSeed = ToolBox.RandomSeed(8);
if (GameMain.Server.SubSelectionMode == SelectionMode.Random) subList.Select(Rand.Range(0,subList.CountChildren));
if (GameMain.Server.ModeSelectionMode == SelectionMode.Random) modeList.Select(Rand.Range(0, modeList.CountChildren));
}
@@ -358,7 +362,7 @@ namespace Barotrauma
if (IsServer && GameMain.Server != null)
{
var playYourself = new GUITickBox(new Rectangle(-10, -10, 20, 20), "Play yourself", Alignment.TopLeft, myPlayerFrame);
var playYourself = new GUITickBox(new Rectangle(0, -10, 20, 20), "Play yourself", Alignment.TopLeft, myPlayerFrame);
playYourself.Selected = GameMain.Server.CharacterInfo != null;
playYourself.OnSelected = TogglePlayYourself;
playYourself.UserData = "playyourself";
@@ -597,19 +601,19 @@ namespace Barotrauma
{
base.Update(deltaTime);
Vector2 pos = new Vector2(
Submarine.Borders.X + Submarine.Borders.Width / 2,
Submarine.Borders.Y - Submarine.Borders.Height / 2);
//Vector2 pos = new Vector2(
// Submarine.Borders.X + Submarine.Borders.Width / 2,
// Submarine.Borders.Y - Submarine.Borders.Height / 2);
camAngle += (float)deltaTime / 10.0f;
Vector2 offset = (new Vector2(
(float)Math.Cos(camAngle) * (Submarine.Borders.Width / 2.0f),
(float)Math.Sin(camAngle) * (Submarine.Borders.Height / 2.0f)));
//camAngle += (float)deltaTime / 10.0f;
//Vector2 offset = (new Vector2(
// (float)Math.Cos(camAngle) * (Submarine.Borders.Width / 2.0f),
// (float)Math.Sin(camAngle) * (Submarine.Borders.Height / 2.0f)));
pos += offset * 0.8f;
//pos += offset * 0.8f;
GameMain.GameScreen.Cam.TargetPos = pos;
GameMain.GameScreen.Cam.MoveCamera((float)deltaTime);
//GameMain.GameScreen.Cam.TargetPos = pos;
//GameMain.GameScreen.Cam.MoveCamera((float)deltaTime);
menu.Update((float)deltaTime);
@@ -632,12 +636,17 @@ namespace Barotrauma
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
{
graphics.Clear(Color.CornflowerBlue);
GameMain.GameScreen.DrawMap(graphics, spriteBatch);
graphics.Clear(Color.Black);
spriteBatch.Begin();
if (backgroundSprite!=null)
{
spriteBatch.Draw(backgroundSprite.Texture, Vector2.Zero, null, Color.White, 0.0f, Vector2.Zero,
Math.Max((float)GameMain.GraphicsWidth / backgroundSprite.SourceRect.Width, (float)GameMain.GraphicsHeight / backgroundSprite.SourceRect.Height),
SpriteEffects.None, 0.0f);
}
menu.Draw(spriteBatch);
if (jobInfoFrame != null) jobInfoFrame.Draw(spriteBatch);
@@ -732,6 +741,8 @@ namespace Barotrauma
GameModePreset modePreset = obj as GameModePreset;
if (modePreset == null) return false;
if (GameMain.Server != null) GameMain.Server.UpdateNetLobby(obj);
return true;
}
@@ -875,11 +886,11 @@ namespace Barotrauma
//msg.Write(AllowSubVoting);
//msg.Write(AllowModeVoting);
msg.Write(modeList.SelectedIndex-1);
msg.Write(modeList.SelectedIndex);
//msg.Write(durationBar.BarScroll);
msg.Write(LevelSeed);
msg.Write(GameMain.Server==null ? false : GameMain.Server.AutoRestart);
msg.Write(GameMain.Server == null ? false : GameMain.Server.AutoRestart);
msg.Write(GameMain.Server == null ? 0.0f : GameMain.Server.AutoRestartTimer);
msg.Write((byte)(playerList.CountChildren));
@@ -896,7 +907,7 @@ namespace Barotrauma
int modeIndex = 0;
//float durationScroll = 0.0f;
string levelSeed = "";
string newSeed = "";
bool autoRestart = false;
@@ -917,7 +928,7 @@ namespace Barotrauma
//durationScroll = msg.ReadFloat();
levelSeed = msg.ReadString();
newSeed = msg.ReadString();
autoRestart = msg.ReadBoolean();
restartTimer = msg.ReadFloat();
@@ -945,7 +956,7 @@ namespace Barotrauma
//durationBar.BarScroll = durationScroll;
LevelSeed = levelSeed;
LevelSeed = newSeed;
}
}
@@ -81,7 +81,6 @@ namespace Barotrauma
GUIButton button = new GUIButton(new Rectangle(-20, -20, 100, 30), "Back", Alignment.TopLeft, GUI.Style, menu);
button.OnClicked = GameMain.MainMenuScreen.SelectTab;
button.CanBeSelected = false;
button.SelectedColor = button.Color;
refreshDisableTimer = DateTime.Now;