Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Regalis11/Barotrauma
Browse files Browse the repository at this point in the history
  • Loading branch information
evilfactory committed Jun 21, 2023
2 parents fd74c08 + c67f668 commit 6b149e0
Show file tree
Hide file tree
Showing 30 changed files with 242 additions and 137 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ body:
label: Version
description: Which version of the game did the bug happen in? You can see the current version number in the bottom left corner of your screen in the main menu.
options:
- v1.0.20.1
- v1.0.21.0
- Other
validations:
required: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ public void ClientReadPosition(IReadMessage msg, float sendingTime)
keys[(int)InputType.Use].Held = useInput;
keys[(int)InputType.Use].SetState(false, useInput);

bool crouching = msg.ReadBoolean();
if (AnimController is HumanoidAnimController)
{
bool crouching = msg.ReadBoolean();
keys[(int)InputType.Crouch].Held = crouching;
keys[(int)InputType.Crouch].SetState(false, crouching);
}
Expand Down Expand Up @@ -269,7 +269,34 @@ public void ClientReadPosition(IReadMessage msg, float sendingTime)
if (readStatus)
{
ReadStatus(msg);
AIController?.ClientRead(msg);
bool isEnemyAi = msg.ReadBoolean();
if (isEnemyAi)
{
byte aiState = msg.ReadByte();
if (AIController is EnemyAIController enemyAi)
{
enemyAi.State = (AIState)aiState;
}
else
{
DebugConsole.AddWarning($"Received enemy AI data for a character with no {nameof(EnemyAIController)}. Ignoring...");
}
bool isPet = msg.ReadBoolean();
if (isPet)
{
byte happiness = msg.ReadByte();
byte hunger = msg.ReadByte();
if ((AIController as EnemyAIController)?.PetBehavior is PetBehavior petBehavior)
{
petBehavior.Happiness = (float)happiness / byte.MaxValue * petBehavior.MaxHappiness;
petBehavior.Hunger = (float)hunger / byte.MaxValue * petBehavior.MaxHunger;
}
else
{
DebugConsole.AddWarning($"Received pet AI data for a character with no {nameof(PetBehavior)}. Ignoring...");
}
}
}
}

msg.ReadPadBits();
Expand Down
15 changes: 12 additions & 3 deletions Barotrauma/BarotraumaClient/ClientSource/GUI/GUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public enum OutlinePosition
/// </summary>
public static float AspectRatioAdjustment => HorizontalAspectRatio < 1.4f ? (1.0f - (1.4f - HorizontalAspectRatio)) : 1.0f;

public static bool IsUltrawide => HorizontalAspectRatio > 2.0f;
public static bool IsUltrawide => HorizontalAspectRatio > 2.3f;

public static int UIWidth
{
Expand Down Expand Up @@ -2438,13 +2438,15 @@ public static void TogglePauseMenu()

var pauseMenuInner = new GUIFrame(new RectTransform(new Vector2(0.13f, 0.3f), PauseMenu.RectTransform, Anchor.Center) { MinSize = new Point(250, 300) });

var buttonContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.7f, 0.6f), pauseMenuInner.RectTransform, Anchor.Center))
float padding = 0.06f;

var buttonContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.7f, 0.8f), pauseMenuInner.RectTransform, Anchor.BottomCenter) { RelativeOffset = new Vector2(0.0f, padding) })
{
Stretch = true,
RelativeSpacing = 0.05f
};

new GUIButton(new RectTransform(new Vector2(0.1f, 0.1f), pauseMenuInner.RectTransform, Anchor.TopRight) { AbsoluteOffset = new Point((int)(15 * GUI.Scale)) },
new GUIButton(new RectTransform(new Vector2(0.1f, 0.07f), pauseMenuInner.RectTransform, Anchor.TopRight) { RelativeOffset = new Vector2(padding) },
"", style: "GUIBugButton")
{
IgnoreLayoutGroups = true,
Expand Down Expand Up @@ -2520,6 +2522,13 @@ public static void TogglePauseMenu()
}

GUITextBlock.AutoScaleAndNormalize(buttonContainer.Children.Where(c => c is GUIButton).Select(c => ((GUIButton)c).TextBlock));
//scale to ensure there's enough room for all the buttons
pauseMenuInner.RectTransform.MinSize = new Point(
pauseMenuInner.RectTransform.MinSize.X,
Math.Max(
(int)(buttonContainer.Children.Sum(c => c.Rect.Height + buttonContainer.Rect.Height * buttonContainer.RelativeSpacing)),
pauseMenuInner.RectTransform.MinSize.X));

}

void CreateButton(string textTag, GUIComponent parent, Action action, string verificationTextTag = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ public static void CreateAreas()
int crewAreaY = ButtonAreaTop.Bottom + Padding;
int crewAreaHeight = ObjectiveAnchor.Top - Padding - crewAreaY;

float crewAreaWidthMultiplier = GUI.IsUltrawide ? GUI.HorizontalAspectRatio : 1.0f;
CrewArea = new Rectangle(Padding, crewAreaY, (int)(Math.Max(400 * GUI.Scale, 220) * crewAreaWidthMultiplier), crewAreaHeight);
CrewArea = new Rectangle(Padding, crewAreaY,
(int)MathHelper.Clamp(400 * GUI.Scale, 220, GameMain.GraphicsHeight * 0.4f),
crewAreaHeight);
InventoryAreaLower = new Rectangle(ChatBoxArea.Right + Padding * 7, inventoryTopY, GameMain.GraphicsWidth - Padding * 9 - ChatBoxArea.Width, GameMain.GraphicsHeight - inventoryTopY);

int healthWindowWidth = (int)(GameMain.GraphicsWidth * 0.5f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ partial void InitProjectSpecific()
{
CanBeFocused = false
};
crewArea.RectTransform.NonScaledSize = HUDLayoutSettings.CrewArea.Size;

// AbsoluteOffset is set in UpdateProjectSpecific based on crewListOpenState
crewList = new GUIListBox(new RectTransform(Vector2.One, crewArea.RectTransform), style: null, isScrollBarOnDefaultSide: false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ public void CalculateLosVertices(Vector2 lightSourcePos)

if (IsSegmentFacing(losVertices[0].Pos, losVertices[1].Pos, lightSourcePos))
{
Array.Reverse(ShadowVertices);
Array.Reverse(ShadowVertices, 0, ShadowVertexCount);
}

CalculateLosPenumbraVertices(lightSourcePos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ static void DrawCharacters(SpriteBatch spriteBatch, Camera cam, bool drawDeformS
{
foreach (MapEntity e in (Submarine.VisibleEntities ?? MapEntity.mapEntityList))
{
if (e is Item item && item.GetComponent<Wire>() is Wire wire)
if (e is Item item && !item.HiddenInGame && item.GetComponent<Wire>() is Wire wire)
{
wire.DebugDraw(spriteBatch, alpha: 0.4f);
}
Expand Down Expand Up @@ -719,6 +719,7 @@ public void UpdateObstructVision(GraphicsDevice graphics, SpriteBatch spriteBatc
{
foreach (var ch in convexHulls)
{
if (!ch.Enabled) { continue; }
Vector2 currentViewPos = pos;
Vector2 defaultViewPos = ViewTarget.DrawPosition;
if (ch.ParentEntity?.Submarine != null)
Expand All @@ -742,10 +743,13 @@ public void UpdateObstructVision(GraphicsDevice graphics, SpriteBatch spriteBatc
{
if (!convexHull.Enabled || !convexHull.Intersects(camView)) { continue; }

Vector2 relativeLightPos = pos;
if (convexHull.ParentEntity?.Submarine != null) { relativeLightPos -= convexHull.ParentEntity.Submarine.Position; }
Vector2 relativeViewPos = pos;
if (convexHull.ParentEntity?.Submarine != null)
{
relativeViewPos -= convexHull.ParentEntity.Submarine.DrawPosition;
}

convexHull.CalculateLosVertices(relativeLightPos);
convexHull.CalculateLosVertices(relativeViewPos);

for (int i = 0; i < convexHull.ShadowVertexCount; i++)
{
Expand Down
35 changes: 21 additions & 14 deletions Barotrauma/BarotraumaClient/ClientSource/Map/Lights/LightSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ class LightSource

private readonly List<ConvexHullList> convexHullsInRange;

private readonly HashSet<ConvexHull> visibleConvexHulls = new HashSet<ConvexHull>();

public Texture2D texture;

public SpriteEffects LightSpriteEffect;
Expand Down Expand Up @@ -717,6 +719,8 @@ private void FindRaycastHits()

public void RayCastTask(Vector2 drawPos, float rotation)
{
visibleConvexHulls.Clear();

Vector2 drawOffset = Vector2.Zero;
float boundsExtended = TextureRange;
if (OverrideLightTexture != null)
Expand Down Expand Up @@ -904,31 +908,26 @@ public void RayCastTask(Vector2 drawPos, float rotation)
bool isPoint1 = MathUtils.LineToPointDistanceSquared(seg1.Start.WorldPos, seg1.End.WorldPos, p.WorldPos) < 25.0f;
bool isPoint2 = MathUtils.LineToPointDistanceSquared(seg2.Start.WorldPos, seg2.End.WorldPos, p.WorldPos) < 25.0f;

bool markAsVisible = false;
if (isPoint1 && isPoint2)
{
//hit at the current segmentpoint -> place the segmentpoint into the list
verts.Add(p.WorldPos);

foreach (ConvexHullList hullList in convexHullsInRange)
{
hullList.IsHidden.Remove(p.ConvexHull);
hullList.IsHidden.Remove(seg1.ConvexHull);
hullList.IsHidden.Remove(seg2.ConvexHull);
}
markAsVisible = true;
}
else if (intersection1.index != intersection2.index)
{
//the raycasts landed on different segments
//we definitely want to generate new geometry here
verts.Add(isPoint1 ? p.WorldPos : intersection1.pos);
verts.Add(isPoint2 ? p.WorldPos : intersection2.pos);

foreach (ConvexHullList hullList in convexHullsInRange)
{
hullList.IsHidden.Remove(p.ConvexHull);
hullList.IsHidden.Remove(seg1.ConvexHull);
hullList.IsHidden.Remove(seg2.ConvexHull);
}
markAsVisible = true;
}
if (markAsVisible)
{
visibleConvexHulls.Add(p.ConvexHull);
visibleConvexHulls.Add(seg1.ConvexHull);
visibleConvexHulls.Add(seg2.ConvexHull);
}
//if neither of the conditions above are met, we just assume
//that the raycasts both resulted on the same segment
Expand Down Expand Up @@ -1396,6 +1395,14 @@ public void DrawLightVolume(SpriteBatch spriteBatch, BasicEffect lightEffect, Ma
return;
}

foreach (var visibleConvexHull in visibleConvexHulls)
{
foreach (var convexHullList in convexHullsInRange)
{
convexHullList.IsHidden.Remove(visibleConvexHull);
}
}

CalculateLightVertices(verts);

LastRecalculationTime = (float)Timing.TotalTime;
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaClient/LinuxClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product>
<Version>1.0.20.1</Version>
<Version>1.0.21.0</Version>
<Copyright>Copyright © FakeFish 2018-2023</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaClient/MacClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product>
<Version>1.0.20.1</Version>
<Version>1.0.21.0</Version>
<Copyright>Copyright © FakeFish 2018-2023</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaClient/WindowsClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product>
<Version>1.0.20.1</Version>
<Version>1.0.21.0</Version>
<Copyright>Copyright © FakeFish 2018-2023</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaServer/LinuxServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product>
<Version>1.0.20.1</Version>
<Version>1.0.21.0</Version>
<Copyright>Copyright © FakeFish 2018-2023</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaServer/MacServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product>
<Version>1.0.20.1</Version>
<Version>1.0.21.0</Version>
<Copyright>Copyright © FakeFish 2018-2023</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,9 @@ public void ServerWritePosition(ReadWriteMessage tempBuffer, Client c)
tempBuffer.WriteBoolean(aiming);
tempBuffer.WriteBoolean(shoot);
tempBuffer.WriteBoolean(use);
if (AnimController is HumanoidAnimController)
{
tempBuffer.WriteBoolean(((HumanoidAnimController)AnimController).Crouching);
}

tempBuffer.WriteBoolean(AnimController is HumanoidAnimController { Crouching: true });

tempBuffer.WriteBoolean(attack);

Vector2 relativeCursorPos = cursorPosition - AimRefPosition;
Expand Down Expand Up @@ -434,7 +433,17 @@ public void ServerWritePosition(ReadWriteMessage tempBuffer, Client c)
if (writeStatus)
{
WriteStatus(tempBuffer);
AIController?.ServerWrite(tempBuffer);
tempBuffer.WriteBoolean(AIController is EnemyAIController);
if (AIController is EnemyAIController enemyAi)
{
tempBuffer.WriteByte((byte)enemyAi.State);
tempBuffer.WriteBoolean(enemyAi.PetBehavior is PetBehavior);
if (enemyAi.PetBehavior is PetBehavior petBehavior)
{
tempBuffer.WriteByte((byte)((petBehavior.Happiness / petBehavior.MaxHappiness) * byte.MaxValue));
tempBuffer.WriteByte((byte)((petBehavior.Hunger / petBehavior.MaxHunger) * byte.MaxValue));
}
}
HealthUpdatePending = false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaServer/WindowsServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product>
<Version>1.0.20.1</Version>
<Version>1.0.21.0</Version>
<Copyright>Copyright © FakeFish 2018-2023</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,5 @@ public void ResetEscape()

protected virtual void OnStateChanged(AIState from, AIState to) { }
protected virtual void OnTargetChanged(AITarget previousTarget, AITarget newTarget) { }

public virtual void ClientRead(IReadMessage msg) { }
public virtual void ServerWrite(IWriteMessage msg) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4055,18 +4055,6 @@ private static Character GetOwner(Item item)
}
return null;
}

public override void ServerWrite(IWriteMessage msg)
{
msg.WriteByte((byte)State);
PetBehavior?.ServerWrite(msg);
}

public override void ClientRead(IReadMessage msg)
{
State = (AIState)msg.ReadByte();
PetBehavior?.ClientRead(msg);
}
}

//the "memory" of the Character
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ void ReportWeldingFuelTankCount()
Leak.linkedTo.Any(e => e is Hull h && (character.CurrentHull == h || h.linkedTo.Contains(character.CurrentHull))),
endNodeFilter = IsSuitableEndNode,
// The Go To objective can be abandoned if the leak is fixed (in which case we don't want to use the dialogue)
SpeakCannotReachCondition = () => !CheckObjectiveSpecific()
// Only report about contextual targets.
SpeakCannotReachCondition = () => isPriority && !CheckObjectiveSpecific()
},
onAbandon: () =>
{
Expand Down
Loading

0 comments on commit 6b149e0

Please sign in to comment.