Merge branch 'master' of https://bitbucket.org/Regalis11/barotrauma into multisub

Conflicts:
	Subsurface/Source/GUI/GUI.cs
This commit is contained in:
Regalis11
2016-06-09 18:39:54 +03:00
28 changed files with 346 additions and 66 deletions

View File

@@ -156,6 +156,13 @@ namespace Barotrauma
}
strongestImpact = 0.0f;
if (stunTimer > 0)
{
stunTimer -= deltaTime;
return;
}
if (character.LockHands)
{
var leftHand = GetLimb(LimbType.LeftHand);
@@ -185,15 +192,13 @@ namespace Barotrauma
//rightHand.pullJoint.Enabled = true;
//rightHand.pullJoint.WorldAnchorB = midPos;
}
if (stunTimer > 0)
else
{
stunTimer -= deltaTime;
return;
}
if (Anim != Animation.UsingConstruction) ResetPullJoints();
if (Anim != Animation.UsingConstruction) ResetPullJoints();
}
if (SimplePhysicsEnabled)
{
UpdateStandingSimple();
@@ -287,7 +292,7 @@ namespace Barotrauma
float slowdownFactor = (float)limbsInWater / (float)Limbs.Count();
float maxSpeed = Math.Max(TargetMovement.Length() - slowdownFactor, 1.0f);
if (character.SelectedCharacter!=null) maxSpeed = Math.Min(maxSpeed, 1.0f);
// if (character.SelectedCharacter!=null) maxSpeed = Math.Min(maxSpeed, 1.0f);
TargetMovement = Vector2.Normalize(TargetMovement) * maxSpeed;
}
@@ -933,10 +938,11 @@ namespace Barotrauma
{
pullLimb.pullJoint.Enabled = true;
pullLimb.pullJoint.WorldAnchorB = targetLimb.SimPosition;
pullLimb.pullJoint.MaxForce = 100.0f;
pullLimb.pullJoint.MaxForce = 10000.0f;
targetLimb.pullJoint.Enabled = true;
targetLimb.pullJoint.WorldAnchorB = pullLimb.SimPosition;
targetLimb.pullJoint.MaxForce = 10000.0f;
}
}

View File

@@ -1030,6 +1030,12 @@ namespace Barotrauma
PressureTimer = 0.0f;
}
}
if (controlled == this)
{
Lights.LightManager.ViewTarget = this;
CharacterHUD.Update(deltaTime, this);
}
if (IsUnconscious)
{
@@ -1039,8 +1045,6 @@ namespace Barotrauma
if (controlled == this)
{
Lights.LightManager.ViewTarget = this;
CharacterHUD.Update(deltaTime,this);
ControlLocalPlayer(deltaTime, cam);
}

View File

@@ -82,7 +82,7 @@ namespace Barotrauma
DrawStatusIcons(spriteBatch, character);
if (!character.IsUnconscious)
if (!character.IsUnconscious && character.Stun <= 0.0f)
{
if (character.Inventory != null && !character.LockHands &&
character.Stun >= -0.1f) character.Inventory.DrawOwn(spriteBatch, Vector2.Zero);
@@ -193,7 +193,10 @@ namespace Barotrauma
suicideButton.OnClicked = (button, userData) =>
{
character.Kill(character.CauseOfDeath);
if (Character.Controlled != null)
{
Character.Controlled.Kill(Character.Controlled.CauseOfDeath);
}
return true;
};
}

View File

@@ -398,27 +398,27 @@ namespace Barotrauma
if (GameMain.DebugDraw)
{
spriteBatch.DrawString(Font,
spriteBatch.DrawString(SmallFont,
"FPS: " + (int)GameMain.FrameCounter.AverageFramesPerSecond,
new Vector2(10, 10), Color.White);
spriteBatch.DrawString(Font,
spriteBatch.DrawString(SmallFont,
"Physics: " + GameMain.World.UpdateTime,
new Vector2(10, 20), Color.White);
spriteBatch.DrawString(SmallFont,
"Bodies: " + GameMain.World.BodyList.Count + " (" + GameMain.World.BodyList.FindAll(b => b.Awake && b.Enabled).Count + " awake)",
new Vector2(10, 30), Color.White);
spriteBatch.DrawString(Font,
"Bodies: " + GameMain.World.BodyList.Count + " (" + GameMain.World.BodyList.FindAll(b => b.Awake && b.Enabled).Count + " awake)",
new Vector2(10, 50), Color.White);
spriteBatch.DrawString(Font,
"Camera pos: " + GameMain.GameScreen.Cam.Position,
new Vector2(10, 70), Color.White);
spriteBatch.DrawString(SmallFont,
"Camera pos: " + GameMain.GameScreen.Cam.Position.ToPoint(),
new Vector2(10, 40), Color.White);
if (Submarine.MainSub != null)
{
spriteBatch.DrawString(Font,
"Sub pos: " + Submarine.MainSub.Position,
new Vector2(10, 90), Color.White);
spriteBatch.DrawString(SmallFont,
"Sub pos: " + Submarine.MainSub.Position.ToPoint(),
new Vector2(10, 50), Color.White);
}
}

View File

@@ -36,6 +36,13 @@ namespace Barotrauma.Items.Components
get { return maxOutput; }
}
[HasDefaultValue(10.0f, true), Editable]
public float Capacity
{
get { return capacity; }
set { capacity = Math.Max(value, 1.0f); }
}
[Editable, HasDefaultValue(0.0f, true)]
public float Charge
{
@@ -47,13 +54,6 @@ namespace Barotrauma.Items.Components
}
}
[HasDefaultValue(10.0f, true), Editable]
public float Capacity
{
get { return capacity; }
set { capacity = Math.Max(value, 1.0f); }
}
[HasDefaultValue(10.0f, true), Editable]
public float RechargeSpeed
{

View File

@@ -67,6 +67,8 @@ namespace Barotrauma.Items.Components
Vector2 vector = ToolBox.ParseToVector2(value);
minRotation = MathHelper.ToRadians(vector.X);
maxRotation = MathHelper.ToRadians(vector.Y);
rotation = (minRotation + maxRotation) / 2;
}
}

View File

@@ -813,6 +813,9 @@ namespace Barotrauma
if (prefab.sprite != null)
{
float depth = Sprite.Depth;
depth += (ID % 255) * 0.000001f;
if (body == null)
{
if (prefab.ResizeHorizontal || prefab.ResizeVertical)
@@ -821,7 +824,7 @@ namespace Barotrauma
}
else
{
prefab.sprite.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y), color);
prefab.sprite.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y), color, 0.0f, 1.0f, SpriteEffects.None, depth);
}
}
@@ -830,7 +833,6 @@ namespace Barotrauma
var holdable = GetComponent<Holdable>();
if (holdable!=null && holdable.Picker !=null)
{
float depth = Sprite.Depth;
if (holdable.Picker.SelectedItems[0]==this)
{
depth = holdable.Picker.AnimController.GetLimb(LimbType.RightHand).sprite.Depth + 0.000001f;
@@ -844,7 +846,7 @@ namespace Barotrauma
}
else
{
body.Draw(spriteBatch, prefab.sprite, color);
body.Draw(spriteBatch, prefab.sprite, color, depth);
}
}
}

View File

@@ -40,9 +40,9 @@ namespace Barotrauma
return;
}
for (int x = Math.Max(indices.X, 0); x <= Math.Min(indices.Width, entities.GetLength(0)); x++)
for (int x = Math.Max(indices.X, 0); x <= Math.Min(indices.Width, entities.GetLength(0)-1); x++)
{
for (int y = Math.Max(indices.Y,0); y <= Math.Min(indices.Height, entities.GetLength(1)); y++)
for (int y = Math.Max(indices.Y,0); y <= Math.Min(indices.Height, entities.GetLength(1)-1); y++)
{
entities[x, y].Add(entity);
}

View File

@@ -128,7 +128,7 @@ namespace Barotrauma
if (limb.WorldPosition == worldPosition) continue;
c.AddDamage(limb.SimPosition, DamageType.None,
c.AddDamage(limb.WorldPosition, DamageType.None,
damage / c.AnimController.Limbs.Length * distFactor, 0.0f, stun * distFactor, false);
if (force > 0.0f)
{

View File

@@ -522,9 +522,13 @@ namespace Barotrauma
new Rectangle(drawRect.X, -drawRect.Y, rect.Width, rect.Height),
Color.Red*((100.0f-OxygenPercentage)/400.0f), true);
spriteBatch.DrawString(GUI.Font, "Pressure: " + ((int)pressure - rect.Y).ToString() +
" - Oxygen: " + ((int)OxygenPercentage), new Vector2(drawRect.X + 10, -drawRect.Y + 10), Color.Black);
spriteBatch.DrawString(GUI.Font, volume + " / " + FullVolume, new Vector2(drawRect.X + 10, -drawRect.Y + 30), Color.Black);
if (GameMain.DebugDraw)
{
spriteBatch.DrawString(GUI.SmallFont, "Pressure: " + ((int)pressure - rect.Y).ToString() +
" - Oxygen: " + ((int)OxygenPercentage), new Vector2(drawRect.X + 5, -drawRect.Y + 5), Color.White);
spriteBatch.DrawString(GUI.SmallFont, volume + " / " + FullVolume, new Vector2(drawRect.X + 5, -drawRect.Y + 20), Color.White);
}
if ((isSelected || isHighlighted) && editing)
{

View File

@@ -834,7 +834,7 @@ namespace Barotrauma.Networking
Character character = obj as Character;
if (character == null) return false;
if (character != myCharacter)
if (character != myCharacter && Voting.AllowVoteKick)
{
var client = GameMain.NetworkMember.ConnectedClients.Find(c => c.Character == character);
if (client != null)

View File

@@ -1725,8 +1725,9 @@ namespace Barotrauma.Networking
Client preferredClient = null;
foreach (Client c in clients)
{
int index = c.jobPreferences.FindIndex(jp => jp == job);
if (index == 0) index = 1000;
int index = c.jobPreferences.IndexOf(job);
if (index == -1) index = 1000;
if (preferredClient == null || index < bestPreference)
{
bestPreference = index;

View File

@@ -93,6 +93,12 @@ namespace Barotrauma.Networking
get { return allowSpectating; }
}
public bool AllowVoteKick
{
get;
private set;
}
public float EndVoteRequiredRatio = 0.5f;
public float KickVoteRequiredRatio = 0.5f;
@@ -159,10 +165,9 @@ namespace Barotrauma.Networking
private void CreateSettingsFrame()
{
settingsFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f);
settingsFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f);
GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, 400, 400), null, Alignment.Center, GUI.Style, settingsFrame);
GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, 400, 420), null, Alignment.Center, GUI.Style, settingsFrame);
innerFrame.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f);
new GUITextBlock(new Rectangle(0, -5, 0, 20), "Server settings", GUI.Style, innerFrame, GUI.LargeFont);
@@ -175,6 +180,7 @@ namespace Barotrauma.Networking
y += 30;
var endVoteBox = new GUITickBox(new Rectangle(0, y, 20, 20), "End round by voting", Alignment.Left, innerFrame);
endVoteBox.Selected = Voting.AllowEndVoting;
endVoteBox.OnSelected = (GUITickBox) =>
@@ -199,6 +205,33 @@ namespace Barotrauma.Networking
return true;
};
votesRequiredSlider.OnMoved(votesRequiredSlider, votesRequiredSlider.BarScroll);
y += 40;
var voteKickBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Allow vote kicking", Alignment.Left, innerFrame);
voteKickBox.Selected = Voting.AllowVoteKick;
voteKickBox.OnSelected = (GUITickBox) =>
{
Voting.AllowVoteKick = !Voting.AllowVoteKick;
GameMain.Server.UpdateVoteStatus();
return true;
};
var kickVotesRequiredText = new GUITextBlock(new Rectangle(20, y + 20, 20, 20), "Votes required: 50 %", GUI.Style, innerFrame, GUI.SmallFont);
var kickVoteSlider = new GUIScrollBar(new Rectangle(150, y + 22, 100, 10), GUI.Style, 0.1f, innerFrame);
kickVoteSlider.UserData = kickVotesRequiredText;
kickVoteSlider.Step = 0.2f;
kickVoteSlider.BarScroll = (KickVoteRequiredRatio - 0.5f) * 2.0f;
kickVoteSlider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
{
GUITextBlock voteText = scrollBar.UserData as GUITextBlock;
KickVoteRequiredRatio = barScroll / 2.0f + 0.5f;
voteText.Text = "Votes required: " + (int)MathUtils.Round(KickVoteRequiredRatio * 100.0f, 10.0f) + " %";
return true;
};
kickVoteSlider.OnMoved(kickVoteSlider, kickVoteSlider.BarScroll);
y += 40;

View File

@@ -306,8 +306,8 @@ namespace Barotrauma.Networking
{
if (gameStarted && Screen.Selected == GameMain.GameScreen)
{
//chatBox.Visible = Character.Controlled == null || !Character.Controlled.IsUnconscious;
chatMsgBox.Visible = Character.Controlled == null || !Character.Controlled.IsUnconscious;
chatMsgBox.Visible = Character.Controlled == null ||
(!Character.Controlled.IsUnconscious && Character.Controlled.Stun >= 0.0f);
inGameHUD.Update(deltaTime);

View File

@@ -354,6 +354,7 @@ namespace Barotrauma
if (IsServer && GameMain.Server != null)
{
int prevSelected = subList.SelectedIndex;
UpdateSubList(Submarine.SavedSubmarines);
modeList.OnSelected = VotableClicked;
@@ -377,8 +378,11 @@ namespace Barotrauma
var banListButton = new GUIButton(new Rectangle(0, 30, 100, 20), "Banned IPs", Alignment.BottomRight, GUI.Style, playerList.Parent);
banListButton.OnClicked = GameMain.Server.BanList.ToggleBanFrame;
banListButton.UserData = "banListButton";
if (subList.CountChildren > 0 && subList.Selected == null) subList.Select(0);
if (subList.CountChildren > 0 && subList.Selected == null)
{
subList.Select(Math.Max(0, prevSelected));
}
if (GameModePreset.list.Count > 0 && modeList.Selected == null) modeList.Select(0);
if (myPlayerFrame.children.Find(c => c.UserData as string == "playyourself") == null)

View File

@@ -12,6 +12,8 @@ namespace Barotrauma
{
private bool allowSubVoting, allowModeVoting;
public bool AllowVoteKick = true;
public bool AllowEndVoting = true;
public bool AllowSubVoting
@@ -243,8 +245,9 @@ namespace Barotrauma
{
msg.Write((byte)voters.Count(v => v.GetVote<bool>(VoteType.EndRound)));
msg.Write((byte)voters.Count);
}
}
msg.Write(AllowVoteKick);
}
public void ReadData(NetIncomingMessage msg)
@@ -286,6 +289,8 @@ namespace Barotrauma
GameMain.NetworkMember.EndVoteCount = msg.ReadByte();
GameMain.NetworkMember.EndVoteMax = msg.ReadByte();
}
AllowVoteKick = msg.ReadBoolean();
}
}
}

View File

@@ -7,6 +7,7 @@ using FarseerPhysics.Dynamics;
using Microsoft.Xna.Framework;
using Barotrauma.Sounds;
using System.Collections.Generic;
using System.IO;
namespace Barotrauma
{
@@ -249,7 +250,16 @@ namespace Barotrauma
if (currMusicVolume < 0.01f)
{
Sound.StopStream();
if (targetMusic != null) Sound.StartStream(targetMusic.file, currMusicVolume);
try
{
if (targetMusic != null) Sound.StartStream(targetMusic.file, currMusicVolume);
}
catch (FileNotFoundException e)
{
DebugConsole.ThrowError("Music clip " + targetMusic.file + " not found!");
}
currentMusic = targetMusic;
}
}