Fixed PlayUISound crashing the launcher, generatic ladder waypoints, AICharacter sync bugfix, chatbox resizing according to resolution
This commit is contained in:
@@ -404,7 +404,12 @@ namespace Barotrauma
|
||||
|
||||
public static void PlayUISound(GUISoundType soundType)
|
||||
{
|
||||
sounds[(int)soundType].Play();
|
||||
if (sounds == null) return;
|
||||
|
||||
int soundIndex = (int)soundType;
|
||||
if (soundIndex < 0 || soundIndex >= sounds.Length) return;
|
||||
|
||||
sounds[soundIndex].Play();
|
||||
}
|
||||
|
||||
private static void DrawMessages(SpriteBatch spriteBatch, float deltaTime)
|
||||
|
||||
@@ -40,9 +40,8 @@ namespace Barotrauma
|
||||
box = new GUIFrame(rect, Color.DarkGray, null, this);
|
||||
box.HoverColor = Color.Gray;
|
||||
box.SelectedColor = Color.DarkGray;
|
||||
|
||||
|
||||
text = new GUITextBlock(new Rectangle(rect.X + 40, rect.Y, 200, rect.Height), label, Color.Transparent, Color.White, Alignment.TopLeft, null, this);
|
||||
|
||||
text = new GUITextBlock(new Rectangle(rect.X + 30, rect.Y+2, 200, rect.Height), label, Color.Transparent, Color.White, Alignment.TopLeft, null, this);
|
||||
|
||||
this.rect = new Rectangle(box.Rect.X, box.Rect.Y, 240, rect.Height);
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace Barotrauma
|
||||
{
|
||||
get
|
||||
{
|
||||
return ConvertUnits.ToDisplayUnits(subBody.Position);
|
||||
return subBody.Position;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -352,13 +352,48 @@ namespace Barotrauma
|
||||
FixedArray2<Vector2> points;
|
||||
contact.GetWorldManifold(out normal2, out points);
|
||||
|
||||
var pickedBody = Submarine.PickBody(
|
||||
points[0] - limb.LinearVelocity * ((float)Physics.step) - ConvertUnits.ToSimUnits(submarine.Position) - submarine.Velocity * ((float)Physics.step),
|
||||
points[0] - ConvertUnits.ToSimUnits(submarine.Position), null, Physics.CollisionWall);
|
||||
Vector2 targetPos = ConvertUnits.ToDisplayUnits(points[0] + limb.LinearVelocity * ((float)Physics.step));
|
||||
|
||||
if (pickedBody != null)
|
||||
Hull newHull = Hull.FindHull(targetPos, null);
|
||||
|
||||
if (newHull == null) return true;
|
||||
|
||||
var gaps = newHull.FindGaps();
|
||||
|
||||
bool gapFound = false;
|
||||
foreach (Gap gap in gaps)
|
||||
{
|
||||
|
||||
if (gap.isHorizontal)
|
||||
{
|
||||
if (targetPos.Y < gap.WorldRect.Y && targetPos.Y > gap.WorldRect.Y - gap.WorldRect.Height)
|
||||
{
|
||||
gapFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (targetPos.X > gap.WorldRect.X && targetPos.X < gap.WorldRect.Right)
|
||||
{
|
||||
gapFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//if (Submarine.RectContains(gap.WorldRect, targetPos))
|
||||
//{
|
||||
// gapFound = true;
|
||||
// break;
|
||||
//}
|
||||
}
|
||||
|
||||
//var pickedBody = Submarine.PickBody(
|
||||
// points[0] - limb.LinearVelocity * ((float)Physics.step) - ConvertUnits.ToSimUnits(submarine.Position) - submarine.Velocity * ((float)Physics.step),
|
||||
// points[0] - ConvertUnits.ToSimUnits(submarine.Position), null, Physics.CollisionWall);
|
||||
|
||||
if (!gapFound)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -297,6 +297,7 @@ namespace Barotrauma
|
||||
wayPoint = new WayPoint(
|
||||
new Vector2(borders.X + borders.Width * i, y) + Submarine.HiddenSubPosition,
|
||||
SpawnType.Path, Submarine.Loaded);
|
||||
|
||||
if (y == borders.Y - borders.Height)
|
||||
{
|
||||
wayPoint.ConnectTo(cornerWaypoint[1, i]);
|
||||
@@ -304,9 +305,7 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
wayPoint.ConnectTo(WayPoint.WayPointList[WayPointList.Count - 2]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
wayPoint.ConnectTo(cornerWaypoint[0, i]);
|
||||
@@ -345,6 +344,30 @@ namespace Barotrauma
|
||||
|
||||
stairPoints[0].ConnectTo(stairPoints[1]);
|
||||
}
|
||||
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
var ladders = item.GetComponent<Items.Components.Ladder>();
|
||||
if (ladders == null) continue;
|
||||
|
||||
WayPoint[] ladderPoints = new WayPoint[2];
|
||||
|
||||
ladderPoints[0] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y - item.Rect.Height + heightFromFloor), SpawnType.Path, Submarine.Loaded);
|
||||
|
||||
ladderPoints[1] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y - heightFromFloor), SpawnType.Path, Submarine.Loaded);
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
for (int dir = -1; dir <= 1; dir += 2)
|
||||
{
|
||||
WayPoint closest = ladderPoints[i].FindClosest(dir, true, 30.0f);
|
||||
if (closest == null) continue;
|
||||
ladderPoints[i].ConnectTo(closest);
|
||||
}
|
||||
}
|
||||
|
||||
ladderPoints[0].ConnectTo(ladderPoints[1]);
|
||||
}
|
||||
|
||||
foreach (Gap gap in Gap.GapList)
|
||||
{
|
||||
|
||||
@@ -555,11 +555,8 @@ namespace Barotrauma.Networking
|
||||
//int gameModeIndex = inc.ReadInt32();
|
||||
|
||||
GameMain.GameSession = new GameSession(GameMain.NetLobbyScreen.SelectedSub, "", gameMode);
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
GameMain.GameSession.StartShift(levelSeed);
|
||||
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
//myCharacter = ReadCharacterData(inc);
|
||||
|
||||
@@ -290,7 +290,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (!(c is AICharacter) || c.IsDead) continue;
|
||||
|
||||
Vector2 diff = Submarine.Loaded.WorldPosition - c.WorldPosition;
|
||||
Vector2 diff = c.WorldPosition-Submarine.Loaded.WorldPosition;
|
||||
|
||||
if (FarseerPhysics.ConvertUnits.ToSimUnits(diff.Length()) > NetConfig.CharacterIgnoreDistance) continue;
|
||||
|
||||
|
||||
@@ -104,17 +104,20 @@ namespace Barotrauma.Networking
|
||||
inGameHUD = new GUIFrame(new Rectangle(0,0,0,0), null, null);
|
||||
inGameHUD.CanBeFocused = false;
|
||||
|
||||
int width = 350, height = 100;
|
||||
int width = (int)MathHelper.Clamp(GameMain.GraphicsWidth * 0.35f, 350, 500);
|
||||
int height = (int)MathHelper.Clamp(GameMain.GraphicsHeight * 0.15f, 100, 200);
|
||||
chatBox = new GUIListBox(new Rectangle(
|
||||
GameMain.GraphicsWidth - 20 - width,
|
||||
GameMain.GraphicsHeight - 40 - 25 - height,
|
||||
width, height),
|
||||
Color.White * 0.5f, GUI.Style, inGameHUD);
|
||||
chatBox.Padding = Vector4.Zero;
|
||||
|
||||
chatMsgBox = new GUITextBox(
|
||||
new Rectangle(chatBox.Rect.X, chatBox.Rect.Y + chatBox.Rect.Height + 20, chatBox.Rect.Width, 25),
|
||||
Color.White * 0.5f, Color.Black, Alignment.TopLeft, Alignment.Left, GUI.Style, inGameHUD);
|
||||
chatMsgBox.Font = GUI.SmallFont;
|
||||
chatMsgBox.Padding = Vector4.Zero;
|
||||
chatMsgBox.OnEnterPressed = EnterChatMessage;
|
||||
|
||||
|
||||
|
||||
@@ -253,28 +253,28 @@ namespace Barotrauma
|
||||
seedBox.OnTextChanged = SelectSeed;
|
||||
LevelSeed = ToolBox.RandomSeed(8);
|
||||
|
||||
//automatic restart ------------------------------------------------------------------
|
||||
|
||||
autoRestartBox = new GUITickBox(new Rectangle(columnX, 190, 20, 20), "Automatic restart", Alignment.TopLeft, infoFrame);
|
||||
autoRestartBox.OnSelected = ToggleAutoRestart;
|
||||
|
||||
var restartText = new GUITextBlock(new Rectangle(columnX, 210, 20, 20), "", GUI.Style, infoFrame);
|
||||
restartText.TextGetter = AutoRestartText;
|
||||
|
||||
//traitor probability ------------------------------------------------------------------
|
||||
|
||||
var traitorText = new GUITextBlock(new Rectangle(columnX, 230, 20, 20), "Traitors:", GUI.Style, infoFrame);
|
||||
var traitorText = new GUITextBlock(new Rectangle(columnX, 180, 20, 20), "Traitors:", GUI.Style, infoFrame);
|
||||
|
||||
traitorProbabilityButtons = new GUIButton[2];
|
||||
|
||||
traitorProbabilityButtons[0] = new GUIButton(new Rectangle(columnX, 260, 20, 20), "<", GUI.Style, infoFrame);
|
||||
traitorProbabilityButtons[0] = new GUIButton(new Rectangle(columnX, 205, 20, 20), "<", GUI.Style, infoFrame);
|
||||
traitorProbabilityButtons[0].UserData = -1;
|
||||
|
||||
traitorProbabilityText = new GUITextBlock(new Rectangle(columnX+20, 260, 150, 20), "No", null,null, Alignment.TopCenter, GUI.Style, infoFrame);
|
||||
traitorProbabilityText = new GUITextBlock(new Rectangle(columnX, 205, 120, 20), "No", null,null, Alignment.TopCenter, GUI.Style, infoFrame);
|
||||
|
||||
traitorProbabilityButtons[1] = new GUIButton(new Rectangle(columnX + 150, 260, 20, 20), ">", GUI.Style, infoFrame);
|
||||
traitorProbabilityButtons[1] = new GUIButton(new Rectangle(columnX + 100, 205, 20, 20), ">", GUI.Style, infoFrame);
|
||||
traitorProbabilityButtons[1].UserData = 1;
|
||||
|
||||
//automatic restart ------------------------------------------------------------------
|
||||
|
||||
autoRestartBox = new GUITickBox(new Rectangle(columnX, 240, 20, 20), "Automatic restart", Alignment.TopLeft, infoFrame);
|
||||
autoRestartBox.OnSelected = ToggleAutoRestart;
|
||||
|
||||
var restartText = new GUITextBlock(new Rectangle(columnX, 265, 20, 20), "", GUI.Style, infoFrame);
|
||||
restartText.Font = GUI.SmallFont;
|
||||
restartText.TextGetter = AutoRestartText;
|
||||
|
||||
//server info ------------------------------------------------------------------
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user