(f87bfac85) Merge branch 'dev' of https://github.com/Regalis11/Barotrauma-development into dev

This commit is contained in:
Joonas Rikkonen
2019-06-12 16:45:24 +03:00
parent dce98349ea
commit adab8589da
14 changed files with 119 additions and 78 deletions
@@ -449,12 +449,11 @@ namespace Barotrauma
{ {
float depth = ActiveSprite.Depth - 0.0000015f; float depth = ActiveSprite.Depth - 0.0000015f;
// TODO: enable when the damage overlay textures have been remade. DamagedSprite.Draw(spriteBatch,
//DamagedSprite.Draw(spriteBatch, new Vector2(body.DrawPosition.X, -body.DrawPosition.Y),
// new Vector2(body.DrawPosition.X, -body.DrawPosition.Y), color * Math.Min(damageOverlayStrength, 1.0f), ActiveSprite.Origin,
// color * Math.Min(damageOverlayStrength, 1.0f), ActiveSprite.Origin, -body.DrawRotation,
// -body.DrawRotation, 1.0f, spriteEffect, depth);
// 1.0f, spriteEffect, depth);
} }
if (GameMain.DebugDraw) if (GameMain.DebugDraw)
@@ -20,8 +20,8 @@ namespace Barotrauma
/// </summary> /// </summary>
const float CharacterWaitOnSwitch = 10.0f; const float CharacterWaitOnSwitch = 10.0f;
private List<CharacterInfo> characterInfos = new List<CharacterInfo>(); private readonly List<CharacterInfo> characterInfos = new List<CharacterInfo>();
private List<Character> characters = new List<Character>(); private readonly List<Character> characters = new List<Character>();
private Point screenResolution; private Point screenResolution;
@@ -256,6 +256,18 @@ namespace Barotrauma
{ {
if (c.Info == null || c.Inventory == null) { continue; } if (c.Info == null || c.Inventory == null) { continue; }
var inventoryElement = new XElement("inventory"); var inventoryElement = new XElement("inventory");
// Recharge headset batteries
var headset = c.Inventory.FindItemByIdentifier("headset");
if (headset != null)
{
var battery = headset.OwnInventory.FindItemByTag("loadable");
if (battery != null)
{
battery.Condition = battery.MaxCondition;
}
}
c.SaveInventory(c.Inventory, inventoryElement); c.SaveInventory(c.Inventory, inventoryElement);
c.Info.InventoryData = inventoryElement; c.Info.InventoryData = inventoryElement;
c.Inventory?.DeleteAllItems(); c.Inventory?.DeleteAllItems();
@@ -620,6 +620,7 @@ namespace Barotrauma
{ {
if (DraggingItemToWorld && if (DraggingItemToWorld &&
Character.Controlled.FocusedItem?.OwnInventory != null && Character.Controlled.FocusedItem?.OwnInventory != null &&
Character.Controlled.FocusedItem.OwnInventory.CanBePut(draggingItem) &&
Character.Controlled.FocusedItem.OwnInventory.TryPutItem(draggingItem, Character.Controlled)) Character.Controlled.FocusedItem.OwnInventory.TryPutItem(draggingItem, Character.Controlled))
{ {
GUI.PlayUISound(GUISoundType.PickItem); GUI.PlayUISound(GUISoundType.PickItem);
@@ -142,24 +142,27 @@ namespace Barotrauma
backgroundPos.Y = -backgroundPos.Y; backgroundPos.Y = -backgroundPos.Y;
backgroundPos *= 0.05f; backgroundPos *= 0.05f;
if (level.GenerationParams.BackgroundTopSprite != null)
if (backgroundPos.Y < 1024)
{ {
if (backgroundPos.Y < 0 && level.GenerationParams.BackgroundTopSprite != null) int backgroundSize = (int)level.GenerationParams.BackgroundTopSprite.size.Y;
if (backgroundPos.Y < backgroundSize)
{ {
var backgroundTop = level.GenerationParams.BackgroundTopSprite; 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)), var backgroundTop = level.GenerationParams.BackgroundTopSprite;
color: level.BackgroundTextureColor); backgroundTop.SourceRect = new Rectangle((int)backgroundPos.X, (int)backgroundPos.Y, backgroundSize, (int)Math.Min(-backgroundPos.Y, backgroundSize));
} backgroundTop.DrawTiled(spriteBatch, Vector2.Zero, new Vector2(GameMain.GraphicsWidth, Math.Min(-backgroundPos.Y, GameMain.GraphicsHeight)),
if (backgroundPos.Y > -1024 && level.GenerationParams.BackgroundSprite != null) color: level.BackgroundTextureColor);
{ }
var background = level.GenerationParams.BackgroundSprite; if (-backgroundPos.Y < GameMain.GraphicsHeight && level.GenerationParams.BackgroundSprite != null)
background.SourceRect = new Rectangle((int)backgroundPos.X, (int)Math.Max(backgroundPos.Y, 0), 1024, 1024); {
background.DrawTiled(spriteBatch, var background = level.GenerationParams.BackgroundSprite;
(backgroundPos.Y < 0) ? new Vector2(0.0f, (int)-backgroundPos.Y) : Vector2.Zero, background.SourceRect = new Rectangle((int)backgroundPos.X, (int)Math.Max(backgroundPos.Y, 0), backgroundSize, backgroundSize);
new Vector2(GameMain.GraphicsWidth, (int)Math.Ceiling(1024 - backgroundPos.Y)), background.DrawTiled(spriteBatch,
color: level.BackgroundTextureColor); (backgroundPos.Y < 0) ? new Vector2(0.0f, (int)-backgroundPos.Y) : Vector2.Zero,
new Vector2(GameMain.GraphicsWidth, (int)Math.Min(Math.Ceiling(backgroundSize - backgroundPos.Y), backgroundSize)),
color: level.BackgroundTextureColor);
}
} }
} }
@@ -483,6 +483,26 @@ namespace Barotrauma
{ {
if (selectedList.Contains(entity)) { return; } if (selectedList.Contains(entity)) { return; }
selectedList.Add(entity); selectedList.Add(entity);
HandleDoorGapLinks(entity,
onGapFound: (door, gap) =>
{
door.RefreshLinkedGap();
if (!selectedList.Contains(gap))
{
selectedList.Add(gap);
}
},
onDoorFound: (door, gap) =>
{
if (!selectedList.Contains(door.Item))
{
selectedList.Add(door.Item);
}
});
}
private static void HandleDoorGapLinks(MapEntity entity, Action<Door, Gap> onGapFound, Action<Door, Gap> onDoorFound)
{
if (entity is Item i) if (entity is Item i)
{ {
var door = i.GetComponent<Door>(); var door = i.GetComponent<Door>();
@@ -491,31 +511,26 @@ namespace Barotrauma
var gap = door.LinkedGap; var gap = door.LinkedGap;
if (gap != null) if (gap != null)
{ {
door.RefreshLinkedGap(); onGapFound(door, gap);
if (!selectedList.Contains(gap))
{
selectedList.Add(gap);
}
} }
} }
} }
else if (entity is Gap gap)
{
var door = gap.ConnectedDoor;
if (door != null)
{
onDoorFound(door, gap);
}
}
} }
public static void RemoveSelection(MapEntity entity) public static void RemoveSelection(MapEntity entity)
{ {
selectedList.Remove(entity); selectedList.Remove(entity);
if (entity is Item i) HandleDoorGapLinks(entity,
{ onGapFound: (door, gap) => selectedList.Remove(gap),
var door = i.GetComponent<Door>(); onDoorFound: (door, gap) => selectedList.Remove(door.Item));
if (door != null)
{
var gap = door.LinkedGap;
if (gap != null)
{
selectedList.Remove(gap);
}
}
}
} }
static partial void UpdateAllProjSpecific(float deltaTime) static partial void UpdateAllProjSpecific(float deltaTime)
@@ -585,12 +600,11 @@ namespace Barotrauma
public static void UpdateEditor(Camera cam) public static void UpdateEditor(Camera cam)
{ {
FilteredSelectedList.Clear();
if (highlightedListBox != null) highlightedListBox.UpdateManually((float)Timing.Step); if (highlightedListBox != null) highlightedListBox.UpdateManually((float)Timing.Step);
if (editingHUD != null) if (editingHUD != null)
{ {
if (selectedList.Count == 0 || editingHUD.UserData != selectedList[0]) if (FilteredSelectedList.Count == 0 || editingHUD.UserData != FilteredSelectedList[0])
{ {
foreach (GUIComponent component in editingHUD.Children) foreach (GUIComponent component in editingHUD.Children)
{ {
@@ -601,7 +615,7 @@ namespace Barotrauma
editingHUD = null; editingHUD = null;
} }
} }
FilteredSelectedList.Clear();
if (selectedList.Count == 0) return; if (selectedList.Count == 0) return;
foreach (var e in selectedList) foreach (var e in selectedList)
{ {
@@ -441,36 +441,43 @@ namespace Barotrauma
characterPreviewFrame = null; characterPreviewFrame = null;
} }
if (Campaign is SinglePlayerCampaign) if (characterList != null)
{ {
var hireableCharacters = location.GetHireableCharacters(); if (Campaign is SinglePlayerCampaign)
foreach (GUIComponent child in characterList.Content.Children.ToList())
{ {
if (child.UserData is CharacterInfo character) var hireableCharacters = location.GetHireableCharacters();
foreach (GUIComponent child in characterList.Content.Children.ToList())
{ {
if (GameMain.GameSession.CrewManager.GetCharacterInfos().Contains(character)) { continue; } if (child.UserData is CharacterInfo character)
{
if (GameMain.GameSession.CrewManager != null)
{
if (GameMain.GameSession.CrewManager.GetCharacterInfos().Contains(character)) { continue; }
}
}
else if (child.UserData as string == "mycrew" || child.UserData as string == "hire")
{
continue;
}
characterList.RemoveChild(child);
} }
else if (child.UserData as string == "mycrew" || child.UserData as string == "hire") if (!hireableCharacters.Any())
{ {
continue; new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), characterList.Content.RectTransform), TextManager.Get("HireUnavailable"), textAlignment: Alignment.Center)
{
CanBeFocused = false
};
} }
characterList.RemoveChild(child); else
}
if (!hireableCharacters.Any())
{
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), characterList.Content.RectTransform), TextManager.Get("HireUnavailable"), textAlignment: Alignment.Center)
{ {
CanBeFocused = false foreach (CharacterInfo c in hireableCharacters)
}; {
} var frame = c.CreateCharacterFrame(characterList.Content, c.Name + " (" + c.Job.Name + ")", c);
else new GUITextBlock(new RectTransform(Vector2.One, frame.RectTransform, Anchor.TopRight), c.Salary.ToString(), textAlignment: Alignment.CenterRight);
{ }
foreach (CharacterInfo c in hireableCharacters)
{
var frame = c.CreateCharacterFrame(characterList.Content, c.Name + " (" + c.Job.Name + ")", c);
new GUITextBlock(new RectTransform(Vector2.One, frame.RectTransform, Anchor.TopRight), c.Salary.ToString(), textAlignment: Alignment.CenterRight);
} }
} }
characterList.UpdateScrollBarSize();
} }
characterList.UpdateScrollBarSize(); characterList.UpdateScrollBarSize();
@@ -948,7 +948,11 @@ namespace Barotrauma
new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("HostServerButton"), textAlignment: Alignment.Center, font: GUI.LargeFont) { ForceUpperCase = true }; new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("HostServerButton"), textAlignment: Alignment.Center, font: GUI.LargeFont) { ForceUpperCase = true };
var label = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("ServerName"), textAlignment: textAlignment); var label = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("ServerName"), textAlignment: textAlignment);
serverNameBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), textAlignment: textAlignment); serverNameBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), textAlignment: textAlignment)
{
MaxTextLength = NetConfig.ServerNameMaxLength,
OverflowClip = true
};
label = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("ServerPort"), textAlignment: textAlignment); label = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("ServerPort"), textAlignment: textAlignment);
portBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), textAlignment: textAlignment) portBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), textAlignment: textAlignment)
@@ -336,7 +336,11 @@ namespace Barotrauma
//server info ------------------------------------------------------------------ //server info ------------------------------------------------------------------
ServerName = new GUITextBox(new RectTransform(new Vector2(0.3f, 0.05f), infoFrameContent.RectTransform)); ServerName = new GUITextBox(new RectTransform(new Vector2(infoColumnContainer.RectTransform.RelativeSize.X, 0.05f), infoFrameContent.RectTransform))
{
MaxTextLength = NetConfig.ServerNameMaxLength,
OverflowClip = true
};
ServerName.OnDeselected += (textBox, key) => ServerName.OnDeselected += (textBox, key) =>
{ {
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Name); GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Name);
@@ -35,6 +35,7 @@ namespace Barotrauma.Networking
public bool CompareTo(string ipCompare) public bool CompareTo(string ipCompare)
{ {
if (string.IsNullOrEmpty(IP)) { return false; }
if (!IsRangeBan) if (!IsRangeBan)
{ {
return ipCompare == IP; return ipCompare == IP;
@@ -49,6 +50,7 @@ namespace Barotrauma.Networking
public bool CompareTo(IPAddress ipCompare) public bool CompareTo(IPAddress ipCompare)
{ {
if (string.IsNullOrEmpty(IP)) { return false; }
if (ipCompare.IsIPv4MappedToIPv6 && CompareTo(ipCompare.MapToIPv4().ToString())) if (ipCompare.IsIPv4MappedToIPv6 && CompareTo(ipCompare.MapToIPv4().ToString()))
{ {
return true; return true;
@@ -93,6 +93,10 @@ namespace Barotrauma.Networking
{ {
name = name.Replace(":", ""); name = name.Replace(":", "");
name = name.Replace(";", ""); name = name.Replace(";", "");
if (name.Length > NetConfig.ServerNameMaxLength)
{
name = name.Substring(0, NetConfig.ServerNameMaxLength);
}
this.name = name; this.name = name;
@@ -1295,15 +1295,6 @@
<Content Include="$(MSBuildThisFileDirectory)Content\Characters\Fractalguardian\fractalguardian.png"> <Content Include="$(MSBuildThisFileDirectory)Content\Characters\Fractalguardian\fractalguardian.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Characters\Human\damagedhead.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Characters\Human\damagedlegs.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Characters\Human\damagedtorso.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Characters\Human\firstnames_female.txt"> <Content Include="$(MSBuildThisFileDirectory)Content\Characters\Human\firstnames_female.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@@ -1553,7 +1553,7 @@ namespace Barotrauma
public void Use(float deltaTime, Character character = null, Limb targetLimb = null) public void Use(float deltaTime, Character character = null, Limb targetLimb = null)
{ {
if (RequireAimToUse && !character.IsKeyDown(InputType.Aim)) if (RequireAimToUse && (character == null || !character.IsKeyDown(InputType.Aim)))
{ {
return; return;
} }
Binary file not shown.