Skip to content

Commit

Permalink
v0.11.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Regalis11 committed Dec 9, 2020
1 parent bbf06f0 commit f433a7b
Show file tree
Hide file tree
Showing 325 changed files with 13,852 additions and 3,557 deletions.
14 changes: 12 additions & 2 deletions Barotrauma/BarotraumaClient/ClientSource/Camera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ public void MoveCamera(float deltaTime, bool allowMove = true, bool allowZoom =
{
previousOffset = offset;
}

//how much to zoom out (zoom completely out when offset is 1000)
float zoomOutAmount = Math.Min(offset.Length() / 1000.0f, 1.0f);
float zoomOutAmount = GetZoomAmount(offset);
//zoom amount when resolution is not taken into account
float unscaledZoom = MathHelper.Lerp(DefaultZoom, MinZoom, zoomOutAmount);
//zoom with resolution taken into account (zoom further out on smaller resolutions)
Expand Down Expand Up @@ -409,5 +409,15 @@ public Vector2 WorldToScreen(Vector2 coords)
//Vector2 screenCoords = Vector2.Transform(coords, transform);
return Vector2.Transform(coords, transform);
}

private float GetZoomAmount(Vector2 offset)
{
return Math.Min(offset.Length() / 1000.0f, 1.0f);
}

public float GetZoomAmountFromPrevious()
{
return GetZoomAmount(previousOffset);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ namespace Barotrauma
{
partial class HumanAIController : AIController
{
public static bool debugai;

partial void InitProjSpecific()
{
/*if (GameMain.GameSession != null && GameMain.GameSession.CrewManager != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ private Character FindCharacterAtPosition(Vector2 mouseSimPos, float maxDist = 1

foreach (Character c in CharacterList)
{
if (!CanInteractWith(c, checkVisibility: false)) continue;
if (!CanInteractWith(c, checkVisibility: false) || (c.AnimController?.SimplePhysicsEnabled ?? true)) { continue; }

float dist = Vector2.DistanceSquared(mouseSimPos, c.SimPosition);
if (dist < maxDist * maxDist && (closestCharacter == null || dist < closestDist))
Expand Down Expand Up @@ -686,7 +686,7 @@ public void DrawHUD(SpriteBatch spriteBatch, Camera cam, bool drawHealth = true)

public virtual void DrawFront(SpriteBatch spriteBatch, Camera cam)
{
if (!Enabled || InvisibleTimer > 0.0f) { return; }
if (!Enabled || InvisibleTimer > 0.0f || (AnimController?.SimplePhysicsEnabled ?? true)) { return; }

if (GameMain.DebugDraw)
{
Expand Down Expand Up @@ -810,7 +810,7 @@ public virtual void DrawFront(SpriteBatch spriteBatch, Camera cam)
var iconStyle = GUI.Style.GetComponentStyle("CampaignInteractionBubble." + CampaignInteractionType);
if (iconStyle != null)
{
Vector2 headPos = AnimController.GetLimb(LimbType.Head)?.WorldPosition ?? WorldPosition + Vector2.UnitY * 100.0f;
Vector2 headPos = AnimController.GetLimb(LimbType.Head)?.body?.DrawPosition ?? DrawPosition + Vector2.UnitY * 100.0f;
Vector2 iconPos = headPos;
iconPos.Y = -iconPos.Y;
nameColor = iconStyle.Color;
Expand All @@ -835,7 +835,7 @@ public virtual void DrawFront(SpriteBatch spriteBatch, Camera cam)
var iconStyle = GUI.Style.GetComponentStyle("PetIcon." + petStatus);
if (iconStyle != null)
{
Vector2 headPos = AnimController.GetLimb(LimbType.Head)?.WorldPosition ?? WorldPosition + Vector2.UnitY * 100.0f;
Vector2 headPos = AnimController.GetLimb(LimbType.Head)?.body?.DrawPosition ?? DrawPosition + Vector2.UnitY * 100.0f;
Vector2 iconPos = headPos;
iconPos.Y = -iconPos.Y;
var icon = iconStyle.Sprites[GUIComponent.ComponentState.None].First();
Expand Down
55 changes: 33 additions & 22 deletions Barotrauma/BarotraumaClient/ClientSource/Characters/CharacterHUD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ namespace Barotrauma
{
class CharacterHUD
{
private static Dictionary<ISpatialEntity, int> orderIndicatorCount = new Dictionary<ISpatialEntity, int>();
private static readonly Dictionary<ISpatialEntity, int> orderIndicatorCount = new Dictionary<ISpatialEntity, int>();
const float ItemOverlayDelay = 1.0f;
private static Item focusedItem;
private static float focusedItemOverlayTimer;

private static List<Item> brokenItems = new List<Item>();
private static readonly List<Item> brokenItems = new List<Item>();
private static float brokenItemsCheckTimer;

private static Dictionary<string, string> cachedHudTexts = new Dictionary<string, string>();
private static readonly Dictionary<string, string> cachedHudTexts = new Dictionary<string, string>();

private static GUIFrame hudFrame;
public static GUIFrame HUDFrame
Expand Down Expand Up @@ -126,6 +126,11 @@ public static void Update(float deltaTime, Character character, Camera cam)
{
character.Inventory.Update(deltaTime, cam);
}
else
{
character.Inventory.ClearSubInventories();
}

for (int i = 0; i < character.Inventory.Items.Length - 1; i++)
{
var item = character.Inventory.Items[i];
Expand Down Expand Up @@ -199,9 +204,18 @@ public static void Draw(SpriteBatch spriteBatch, Character character, Camera cam
if (GameMain.GameSession?.CrewManager != null)
{
orderIndicatorCount.Clear();
foreach (Pair<Order, float> timedOrder in GameMain.GameSession.CrewManager.ActiveOrders)
foreach (Pair<Order, float?> activeOrder in GameMain.GameSession.CrewManager.ActiveOrders)
{
DrawOrderIndicator(spriteBatch, cam, character, timedOrder.First, MathHelper.Clamp(timedOrder.Second / 10.0f, 0.2f, 1.0f));
if (activeOrder.Second.HasValue)
{
DrawOrderIndicator(spriteBatch, cam, character, activeOrder.First, iconAlpha: MathHelper.Clamp(activeOrder.Second.Value / 10.0f, 0.2f, 1.0f));
}
else
{
float iconAlpha = GetDistanceBasedIconAlpha(activeOrder.First.TargetSpatialEntity, maxDistance: 350.0f);
if (iconAlpha <= 0.0f) { continue; }
DrawOrderIndicator(spriteBatch, cam, character, activeOrder.First, iconAlpha: iconAlpha, createOffset: false, scaleMultiplier: 0.5f);
}
}

if (character.CurrentOrder != null)
Expand All @@ -218,14 +232,18 @@ public static void Draw(SpriteBatch spriteBatch, Character character, Camera cam
foreach (Item brokenItem in brokenItems)
{
if (brokenItem.NonInteractable) { continue; }
float dist = Vector2.Distance(character.WorldPosition, brokenItem.WorldPosition);
Vector2 drawPos = brokenItem.DrawPosition;
float alpha = Math.Min((1000.0f - dist) / 1000.0f * 2.0f, 1.0f);
float alpha = GetDistanceBasedIconAlpha(brokenItem);
if (alpha <= 0.0f) continue;
GUI.DrawIndicator(spriteBatch, drawPos, cam, 100.0f, GUI.BrokenIcon,
GUI.DrawIndicator(spriteBatch, brokenItem.DrawPosition, cam, 100.0f, GUI.BrokenIcon,
Color.Lerp(GUI.Style.Red, GUI.Style.Orange * 0.5f, brokenItem.Condition / brokenItem.MaxCondition) * alpha);
}

float GetDistanceBasedIconAlpha(ISpatialEntity target, float maxDistance = 1000.0f)
{
float dist = Vector2.Distance(character.WorldPosition, target.WorldPosition);
return Math.Min((maxDistance - dist) / maxDistance * 2.0f, 1.0f);
}

if (!character.IsIncapacitated && character.Stun <= 0.0f && !IsCampaignInterfaceOpen && (!character.IsKeyDown(InputType.Aim) || character.SelectedItems.Any(it => it?.GetComponent<Sprayer>() == null)))
{
if (character.FocusedCharacter != null && character.FocusedCharacter.CanBeSelected)
Expand Down Expand Up @@ -362,8 +380,8 @@ public static void Draw(SpriteBatch spriteBatch, Character character, Camera cam
(int)(HUDLayoutSettings.BottomRightInfoArea.X + HUDLayoutSettings.BottomRightInfoArea.Width * 0.05f),
(int)(HUDLayoutSettings.BottomRightInfoArea.Y + HUDLayoutSettings.BottomRightInfoArea.Height * 0.1f),
(int)(HUDLayoutSettings.BottomRightInfoArea.Width / 2),
(int)(HUDLayoutSettings.BottomRightInfoArea.Height * 0.7f)));
character.Info.DrawPortrait(spriteBatch, HUDLayoutSettings.PortraitArea.Location.ToVector2(), new Vector2(-12 * GUI.Scale, 4 * GUI.Scale), targetWidth: HUDLayoutSettings.PortraitArea.Width, true);
(int)(HUDLayoutSettings.BottomRightInfoArea.Height * 0.7f)), character.Info.IsDisguisedAsAnother);
character.Info.DrawPortrait(spriteBatch, HUDLayoutSettings.PortraitArea.Location.ToVector2(), new Vector2(-12 * GUI.Scale, 4 * GUI.Scale), targetWidth: HUDLayoutSettings.PortraitArea.Width, true, character.Info.IsDisguisedAsAnother);
}
mouseOnPortrait = HUDLayoutSettings.BottomRightInfoArea.Contains(PlayerInput.MousePosition) && !character.ShouldLockHud();
if (mouseOnPortrait)
Expand Down Expand Up @@ -475,19 +493,12 @@ private static bool LockInventory(Character character)
return character.ShouldLockHud();
}

private static void DrawOrderIndicator(SpriteBatch spriteBatch, Camera cam, Character character, Order order, float iconAlpha = 1.0f)
private static void DrawOrderIndicator(SpriteBatch spriteBatch, Camera cam, Character character, Order order, float iconAlpha = 1.0f, bool createOffset = true, float scaleMultiplier = 1.0f)
{
if (order?.SymbolSprite == null) { return; }
if (order.IsReport && order.OrderGiver != character && !order.HasAppropriateJob(character)) { return; }

if (order.TargetAllCharacters)
{
if (order.OrderGiver != character && !order.HasAppropriateJob(character))
{
return;
}
}

ISpatialEntity target = order.ConnectedController != null ? order.ConnectedController.Item : order.TargetSpatialEntity;
ISpatialEntity target = order.ConnectedController?.Item ?? order.TargetSpatialEntity;
if (target == null) { return; }

//don't show the indicator if far away and not inside the same sub
Expand All @@ -503,7 +514,7 @@ private static void DrawOrderIndicator(SpriteBatch spriteBatch, Camera cam, Char
Vector2 drawPos = target is Entity ? (target as Entity).DrawPosition :
target.Submarine == null ? target.Position : target.Position + target.Submarine.DrawPosition;
drawPos += Vector2.UnitX * order.SymbolSprite.size.X * 1.5f * orderIndicatorCount[target];
GUI.DrawIndicator(spriteBatch, drawPos, cam, 100.0f, order.SymbolSprite, order.Color * iconAlpha);
GUI.DrawIndicator(spriteBatch, drawPos, cam, 100.0f, order.SymbolSprite, order.Color * iconAlpha, createOffset: createOffset, scaleMultiplier: scaleMultiplier);

orderIndicatorCount[target] = orderIndicatorCount[target] + 1;
}
Expand Down
Loading

0 comments on commit f433a7b

Please sign in to comment.