Skip to content

Commit

Permalink
Merge pull request #4 from Regalis11/master
Browse files Browse the repository at this point in the history
Synced
  • Loading branch information
BlueTheKing authored Sep 14, 2018
2 parents 7a7958b + bf87006 commit 33ed7eb
Show file tree
Hide file tree
Showing 163 changed files with 3,881 additions and 1,711 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
*.cs text eol=crlf
*.xml text eol=crlf
4 changes: 2 additions & 2 deletions Barotrauma/BarotraumaClient/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.8.1.5")]
[assembly: AssemblyFileVersion("0.8.1.5")]
[assembly: AssemblyVersion("0.8.2.0")]
[assembly: AssemblyFileVersion("0.8.2.0")]
4 changes: 2 additions & 2 deletions Barotrauma/BarotraumaClient/Source/Camera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public Matrix ShaderTransform

public Camera()
{
zoom = 1.0f;
zoom = prevZoom = 1.0f;
rotation = 0.0f;
position = Vector2.Zero;

Expand All @@ -112,7 +112,7 @@ public Camera()
viewMatrix =
Matrix.CreateTranslation(new Vector3(GameMain.GraphicsWidth / 2.0f, GameMain.GraphicsHeight / 2.0f, 0));

UpdateTransform();
UpdateTransform(false);
}

public Vector2 TargetPos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public virtual void Draw(SpriteBatch spriteBatch)
if (Limbs == null)
{
DebugConsole.ThrowError("Failed to draw a ragdoll, limbs have been removed. Character: \"" + character.Name + "\", removed: " + character.Removed + "\n" + Environment.StackTrace);
GameAnalyticsManager.AddErrorEventOnce("Ragdoll.Draw:LimbsRemoved",
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
"Failed to draw a ragdoll, limbs have been removed. Character: \"" + character.Name + "\", removed: " + character.Removed + "\n" + Environment.StackTrace);
return;
}

Expand All @@ -97,7 +100,6 @@ public void DebugDraw(SpriteBatch spriteBatch)

foreach (Limb limb in Limbs)
{

if (limb.pullJoint != null)
{
Vector2 pos = ConvertUnits.ToDisplayUnits(limb.pullJoint.WorldAnchorA);
Expand Down Expand Up @@ -134,6 +136,16 @@ public void DebugDraw(SpriteBatch spriteBatch)
}
}

if (outsideCollisionBlocker.Enabled && currentHull.Submarine != null)
{
var edgeShape = outsideCollisionBlocker.FixtureList[0].Shape as FarseerPhysics.Collision.Shapes.EdgeShape;
Vector2 startPos = ConvertUnits.ToDisplayUnits(outsideCollisionBlocker.GetWorldPoint(edgeShape.Vertex1)) + currentHull.Submarine.Position;
Vector2 endPos = ConvertUnits.ToDisplayUnits(outsideCollisionBlocker.GetWorldPoint(edgeShape.Vertex2)) + currentHull.Submarine.Position;
startPos.Y = -startPos.Y;
endPos.Y = -endPos.Y;
GUI.DrawLine(spriteBatch, startPos, endPos, Color.Gray, 0, 5);
}

if (character.MemState.Count > 1)
{
Vector2 prevPos = ConvertUnits.ToDisplayUnits(character.MemState[0].Position);
Expand Down
4 changes: 2 additions & 2 deletions Barotrauma/BarotraumaClient/Source/Characters/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ partial void DisposeProjSpecific()
{
GameMain.GameSession.CrewManager.RemoveCharacter(this);
}

if (GameMain.Client != null && GameMain.Client.Character == this) GameMain.Client.Character = null;
if (GameMain.NetworkMember?.Character == this) GameMain.NetworkMember.Character = null;

if (Lights.LightManager.ViewTarget == this) Lights.LightManager.ViewTarget = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void Reset()

public static void TakeDamage(float amount)
{
healthBar.Flash();
healthBar?.Flash();

damageOverlayTimer = MathHelper.Clamp(amount * 0.1f, 0.2f, 1.0f);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public virtual void ClientRead(ServerNetObject type, NetBuffer msg, float sendin
msg.ReadPadBits();

int index = 0;
if (GameMain.NetworkMember.Character == this)
if (GameMain.NetworkMember.Character == this && AllowInput)
{
var posInfo = new CharacterStateInfo(pos, rotation, networkUpdateID, facingRight ? Direction.Right : Direction.Left, selectedEntity, animation);
while (index < memState.Count && NetIdUtils.IdMoreRecent(posInfo.ID, memState[index].ID))
Expand Down Expand Up @@ -188,6 +188,7 @@ public virtual void ClientRead(ServerNetObject type, NetBuffer msg, float sendin

controlled = this;
IsRemotePlayer = false;
GameMain.Client.HasSpawned = true;
GameMain.Client.Character = this;
GameMain.LightManager.LosEnabled = true;
}
Expand Down Expand Up @@ -286,6 +287,7 @@ public static Character ReadSpawnData(NetBuffer inc, bool spawn = true)

if (GameMain.Client.ID == ownerId)
{
GameMain.Client.HasSpawned = true;
GameMain.Client.Character = character;
Controlled = character;

Expand Down Expand Up @@ -342,7 +344,7 @@ private void ReadStatus(NetBuffer msg)
}
else
{
this.isDead = false;
if (this.isDead) Revive();

health = msg.ReadRangedSingle(minHealth, maxHealth, 8);

Expand Down
5 changes: 3 additions & 2 deletions Barotrauma/BarotraumaClient/Source/Characters/Limb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,11 @@ public void Draw(SpriteBatch spriteBatch)
}
}

Color wearableColor = wearable.WearableComponent.Item.GetSpriteColor();
wearable.Sprite.Draw(spriteBatch,
new Vector2(body.DrawPosition.X, -body.DrawPosition.Y),
color, origin,
-body.DrawRotation,
new Color((color.R * wearableColor.R) / (255.0f * 255.0f), (color.G * wearableColor.G) / (255.0f * 255.0f), (color.B * wearableColor.B) / (255.0f * 255.0f)) * ((color.A * wearableColor.A) / (255.0f * 255.0f)),
origin, -body.DrawRotation,
Scale, spriteEffect, depth);
}

Expand Down
6 changes: 4 additions & 2 deletions Barotrauma/BarotraumaClient/Source/DebugConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ private static void InitProjectSpecific()
NewMessage("Removed " + me.Name + " (simposition " + me.SimPosition + ")", Color.Orange);
MapEntity.mapEntityList.RemoveAt(i);
}
else if (me.MoveWithLevel)
else if (!me.ShouldBeSaved)
{
NewMessage("Removed " + me.Name + " (MoveWithLevel==true)", Color.Orange);
NewMessage("Removed " + me.Name + " (!ShouldBeSaved)", Color.Orange);
MapEntity.mapEntityList.RemoveAt(i);
}
else if (me is Item)
Expand Down Expand Up @@ -438,6 +438,8 @@ private static void InitProjectSpecific()
NewMessage("Resolution set to 0 x 0 (screen resolution will be used)", Color.Green);
NewMessage("Fullscreen enabled", Color.Green);
GameSettings.ShowUserStatisticsPrompt = true;
GameSettings.VerboseLogging = false;
if (GameMain.Config.MasterServerUrl != "http://www.undertowgames.com/baromaster")
Expand Down
9 changes: 3 additions & 6 deletions Barotrauma/BarotraumaClient/Source/GUI/GUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,9 @@ private static bool QuitClicked(GUIButton button, object obj)

if (GameMain.GameSession != null)
{
if (GameSettings.SendUserStatistics)
{
Mission mission = GameMain.GameSession.Mission;
GameAnalyticsSDK.Net.GameAnalytics.AddDesignEvent("QuitRound:" + (save ? "Save" : "NoSave"));
GameAnalyticsSDK.Net.GameAnalytics.AddDesignEvent("EndRound:" + (mission == null ? "NoMission" : (mission.Completed ? "MissionCompleted" : "MissionFailed")));
}
Mission mission = GameMain.GameSession.Mission;
GameAnalyticsManager.AddDesignEvent("QuitRound:" + (save ? "Save" : "NoSave"));
GameAnalyticsManager.AddDesignEvent("EndRound:" + (mission == null ? "NoMission" : (mission.Completed ? "MissionCompleted" : "MissionFailed")));
GameMain.GameSession = null;
}

Expand Down
43 changes: 40 additions & 3 deletions Barotrauma/BarotraumaClient/Source/GameMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Diagnostics;
using System.Reflection;
using GameAnalyticsSDK.Net;
using System.Threading;

namespace Barotrauma
{
Expand Down Expand Up @@ -74,7 +75,8 @@ public static GraphicsDeviceManager GraphicsDeviceManager
get;
private set;
}

private static bool FullscreenOnTabIn;

public static WindowMode WindowMode
{
get;
Expand Down Expand Up @@ -134,7 +136,7 @@ public GameMain()
Config.WasGameUpdated = false;
Config.Save("config.xml");
}

ApplyGraphicsSettings();

Content.RootDirectory = "Content";
Expand Down Expand Up @@ -231,8 +233,37 @@ protected override void LoadContent()
TitleScreen = new LoadingScreen(GraphicsDevice);

loadingCoroutine = CoroutineManager.StartCoroutine(Load());

var myForm = (System.Windows.Forms.Form)System.Windows.Forms.Form.FromHandle(Window.Handle);
myForm.Deactivate += new EventHandler(HandleDefocus);
myForm.Activated += new EventHandler(HandleFocus);
}

private void HandleDefocus(object sender, EventArgs e)
{
if (GraphicsDeviceManager.IsFullScreen && GraphicsDeviceManager.HardwareModeSwitch)
{
GraphicsDeviceManager.IsFullScreen = false;
GraphicsDeviceManager.ApplyChanges();
FullscreenOnTabIn = true;
Thread.Sleep(500);
}
}

private void HandleFocus(object sender, EventArgs e)
{
if (FullscreenOnTabIn)
{
GraphicsDeviceManager.HardwareModeSwitch = true;
GraphicsDeviceManager.IsFullScreen = true;
GraphicsDeviceManager.ApplyChanges();
FullscreenOnTabIn = false;
Thread.Sleep(500);
}
}



private void InitUserStats()
{
if (GameSettings.ShowUserStatisticsPrompt)
Expand All @@ -244,12 +275,18 @@ private void InitUserStats()
new string[] { "Yes", "No" });
userStatsPrompt.Buttons[0].OnClicked += (btn, userdata) =>
{
GameSettings.ShowUserStatisticsPrompt = false;
GameSettings.SendUserStatistics = true;
GameAnalyticsManager.Init();
return true;
};
userStatsPrompt.Buttons[0].OnClicked += userStatsPrompt.Close;
userStatsPrompt.Buttons[1].OnClicked += (btn, userdata) => { GameSettings.SendUserStatistics = false; return true; };
userStatsPrompt.Buttons[1].OnClicked += (btn, userdata) =>
{
GameSettings.ShowUserStatisticsPrompt = false;
GameSettings.SendUserStatistics = false;
return true;
};
userStatsPrompt.Buttons[1].OnClicked += userStatsPrompt.Close;
}
else if (GameSettings.SendUserStatistics)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ public void ClientWrite(NetBuffer msg)
msg.Write(map.SelectedLocationIndex == -1 ? UInt16.MaxValue : (UInt16)map.SelectedLocationIndex);

msg.Write((UInt16)CargoManager.PurchasedItems.Count);
foreach (ItemPrefab ip in CargoManager.PurchasedItems)
foreach (PurchasedItem pi in CargoManager.PurchasedItems)
{
msg.Write((UInt16)MapEntityPrefab.List.IndexOf(ip));
msg.Write((UInt16)MapEntityPrefab.List.IndexOf(pi.itemPrefab));
msg.Write((UInt16)pi.quantity);
}
}

Expand All @@ -111,11 +112,12 @@ public static void ClientRead(NetBuffer msg)
int money = msg.ReadInt32();

UInt16 purchasedItemCount = msg.ReadUInt16();
List<ItemPrefab> purchasedItems = new List<ItemPrefab>();
List<PurchasedItem> purchasedItems = new List<PurchasedItem>();
for (int i = 0; i < purchasedItemCount; i++)
{
UInt16 itemPrefabIndex = msg.ReadUInt16();
purchasedItems.Add(MapEntityPrefab.List[itemPrefabIndex] as ItemPrefab);
UInt16 itemQuantity = msg.ReadUInt16();
purchasedItems.Add(new PurchasedItem(MapEntityPrefab.List[itemPrefabIndex] as ItemPrefab, itemQuantity));
}

MultiPlayerCampaign campaign = GameMain.GameSession?.GameMode as MultiPlayerCampaign;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public override IEnumerable<object> UpdateState()
}
yield return new WaitForSeconds(0.5f);

infoBox = CreateInfoFrame("The green rectangle in the middle is the submarine, and the flickering shapes outside it are the walls of an underwater cavern. "
infoBox = CreateInfoFrame("The blue rectangle in the middle is the submarine, and the flickering shapes outside it are the walls of an underwater cavern. "
+ "Try moving the submarine by clicking somewhere on the monitor and dragging the pointer to the direction you want to go to.");

while (steering.TargetVelocity == Vector2.Zero && steering.TargetVelocity.Length() < 50.0f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,21 +224,27 @@ private bool LoadElemProjSpecific(XElement subElement)
}

//Starts a coroutine that will read the correct state of the component from the NetBuffer when correctionTimer reaches zero.
protected void StartDelayedCorrection(ServerNetObject type, NetBuffer buffer, float sendingTime)
protected void StartDelayedCorrection(ServerNetObject type, NetBuffer buffer, float sendingTime, bool waitForMidRoundSync = false)
{
if (delayedCorrectionCoroutine != null) CoroutineManager.StopCoroutines(delayedCorrectionCoroutine);

delayedCorrectionCoroutine = CoroutineManager.StartCoroutine(DoDelayedCorrection(type, buffer, sendingTime));
delayedCorrectionCoroutine = CoroutineManager.StartCoroutine(DoDelayedCorrection(type, buffer, sendingTime, waitForMidRoundSync));
}

private IEnumerable<object> DoDelayedCorrection(ServerNetObject type, NetBuffer buffer, float sendingTime)
private IEnumerable<object> DoDelayedCorrection(ServerNetObject type, NetBuffer buffer, float sendingTime, bool waitForMidRoundSync)
{
while (correctionTimer > 0.0f)
while (GameMain.Client != null &&
(correctionTimer > 0.0f || (waitForMidRoundSync && GameMain.Client.MidRoundSyncing)))
{
correctionTimer -= CoroutineManager.DeltaTime;
yield return CoroutineStatus.Running;
}

if (item.Removed || GameMain.Client == null)
{
yield return CoroutineStatus.Success;
}

((IServerSerializable)this).ClientRead(type, buffer, sendingTime);

correctionTimer = 0.0f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ partial class Controller : ItemComponent
{
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
{
var focusTarget = GetFocusTarget();
if (focusTarget == null) return;
if (character.ViewTarget == focusTarget)
if (focusTarget != null && character.ViewTarget == focusTarget)
{
foreach (ItemComponent ic in focusTarget.components)
{
Expand Down
Loading

0 comments on commit 33ed7eb

Please sign in to comment.