Release 1.9.7.0 - Summer Update 2025
This commit is contained in:
@@ -435,6 +435,13 @@ namespace Barotrauma
|
||||
{
|
||||
cam.OffsetAmount = targetOffsetAmount = item.Prefab.OffsetOnSelected * item.OffsetOnSelectedMultiplier;
|
||||
}
|
||||
else if (HeldItems.SelectMany(static item => item.GetComponents<Holdable>())
|
||||
.Where(static holdable => holdable.Aimable)
|
||||
.MaxOrNull(static holdable => holdable.CameraAimOffset) is float maxOffset
|
||||
&& maxOffset > 0f && IsKeyDown(InputType.Aim))
|
||||
{
|
||||
cam.OffsetAmount = targetOffsetAmount = maxOffset;
|
||||
}
|
||||
else if (SelectedItem != null && ViewTarget == null &&
|
||||
SelectedItem.Components.Any(ic => ic?.GuiFrame != null && ic.ShouldDrawHUD(this)))
|
||||
{
|
||||
|
||||
@@ -653,7 +653,10 @@ namespace Barotrauma
|
||||
(int)(HUDLayoutSettings.BottomRightInfoArea.Width / 2),
|
||||
(int)(HUDLayoutSettings.BottomRightInfoArea.Height * 0.7f)), character.Info.IsDisguisedAsAnother);
|
||||
float yOffset = (GameMain.GameSession?.Campaign is MultiPlayerCampaign ? -10 : 4) * GUI.Scale;
|
||||
character.Info.DrawPortrait(spriteBatch, HUDLayoutSettings.PortraitArea.Location.ToVector2(), new Vector2(-12 * GUI.Scale, yOffset), targetWidth: HUDLayoutSettings.PortraitArea.Width, true, character.Info.IsDisguisedAsAnother);
|
||||
|
||||
character.Info?.DrawIcon(spriteBatch,
|
||||
new Vector2(HUDLayoutSettings.PortraitArea.Center.X - 12 * GUI.Scale, HUDLayoutSettings.PortraitArea.Center.Y), HUDLayoutSettings.PortraitArea.Size.ToVector2(),
|
||||
flip: true);
|
||||
character.Info.DrawForeground(spriteBatch);
|
||||
}
|
||||
mouseOnPortrait = MouseOnCharacterPortrait() && !character.ShouldLockHud();
|
||||
@@ -733,8 +736,9 @@ namespace Barotrauma
|
||||
|
||||
string focusName = character.FocusedCharacter.Info == null ? character.FocusedCharacter.DisplayName : character.FocusedCharacter.Info.DisplayName;
|
||||
Vector2 textPos = startPos;
|
||||
Vector2 textSize = GUIStyle.Font.MeasureString(focusName);
|
||||
Vector2 largeTextSize = GUIStyle.SubHeadingFont.MeasureString(focusName);
|
||||
//measure arbitrary one-line text instead of the potentially-multi-line name
|
||||
Vector2 textSize = GUIStyle.Font.MeasureString("T");
|
||||
Vector2 largeTextSize = GUIStyle.SubHeadingFont.MeasureString("T");
|
||||
|
||||
textPos -= new Vector2(textSize.X / 2, textSize.Y);
|
||||
|
||||
|
||||
@@ -360,64 +360,6 @@ namespace Barotrauma
|
||||
GUIStyle.Font.DrawString(spriteBatch, str, new Vector2(barRect.Right - iconXOffset - scaledTextSizeX - GUI.IntScale(4), barRect.Center.Y - scaledTextSizeY / 2), GUIStyle.TextColorNormal, 0f, Vector2.Zero, textScale, SpriteEffects.None, 0f);
|
||||
}
|
||||
|
||||
public void DrawPortrait(SpriteBatch spriteBatch, Vector2 screenPos, Vector2 offset, float targetWidth, bool flip = false, bool evaluateDisguise = false)
|
||||
{
|
||||
if (evaluateDisguise && IsDisguised) { return; }
|
||||
|
||||
Vector2? sheetIndex;
|
||||
Sprite portraitToDraw;
|
||||
List<WearableSprite> attachmentsToDraw;
|
||||
|
||||
Color hairColor;
|
||||
Color facialHairColor;
|
||||
Color skinColor;
|
||||
|
||||
if (!IsDisguisedAsAnother || !evaluateDisguise)
|
||||
{
|
||||
sheetIndex = Head.SheetIndex;
|
||||
portraitToDraw = Portrait;
|
||||
attachmentsToDraw = AttachmentSprites;
|
||||
|
||||
hairColor = Head.HairColor;
|
||||
facialHairColor = Head.FacialHairColor;
|
||||
skinColor = Head.SkinColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
sheetIndex = disguisedSheetIndex;
|
||||
portraitToDraw = disguisedPortrait;
|
||||
attachmentsToDraw = disguisedAttachmentSprites;
|
||||
|
||||
hairColor = disguisedHairColor;
|
||||
facialHairColor = disguisedFacialHairColor;
|
||||
skinColor = disguisedSkinColor;
|
||||
}
|
||||
|
||||
if (portraitToDraw != null)
|
||||
{
|
||||
var currEffect = spriteBatch.GetCurrentEffect();
|
||||
// Scale down the head sprite 10%
|
||||
float scale = targetWidth * 0.9f / Portrait.size.X;
|
||||
if (sheetIndex.HasValue)
|
||||
{
|
||||
SetHeadEffect(spriteBatch);
|
||||
portraitToDraw.SourceRect = new Rectangle(CalculateOffset(portraitToDraw, sheetIndex.Value.ToPoint()), portraitToDraw.SourceRect.Size);
|
||||
}
|
||||
portraitToDraw.Draw(spriteBatch, screenPos + offset, skinColor, portraitToDraw.Origin, scale: scale, spriteEffect: flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None);
|
||||
if (attachmentsToDraw != null)
|
||||
{
|
||||
float depthStep = 0.000001f;
|
||||
foreach (var attachment in attachmentsToDraw)
|
||||
{
|
||||
SetAttachmentEffect(spriteBatch, attachment);
|
||||
DrawAttachmentSprite(spriteBatch, attachment, portraitToDraw, sheetIndex, screenPos + offset, scale, depthStep, GetAttachmentColor(attachment, hairColor, facialHairColor), flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None);
|
||||
depthStep += depthStep;
|
||||
}
|
||||
}
|
||||
spriteBatch.SwapEffect(currEffect);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: I hate this so much :(
|
||||
private SpriteBatch.EffectWithParams headEffectParameters;
|
||||
private Dictionary<WearableType, SpriteBatch.EffectWithParams> attachmentEffectParameters
|
||||
@@ -466,23 +408,26 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawIcon(SpriteBatch spriteBatch, Vector2 screenPos, Vector2 targetAreaSize)
|
||||
public void DrawIcon(SpriteBatch spriteBatch, Vector2 screenPos, Vector2 targetAreaSize, bool flip = false)
|
||||
{
|
||||
var headSprite = HeadSprite;
|
||||
if (headSprite != null)
|
||||
{
|
||||
var spriteEffects = flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
|
||||
var currEffect = spriteBatch.GetCurrentEffect();
|
||||
float scale = Math.Min(targetAreaSize.X / headSprite.size.X, targetAreaSize.Y / headSprite.size.Y);
|
||||
headSprite.SourceRect = new Rectangle(CalculateOffset(headSprite, Head.SheetIndex.ToPoint()), headSprite.SourceRect.Size);
|
||||
SetHeadEffect(spriteBatch);
|
||||
headSprite.Draw(spriteBatch, screenPos, scale: scale, color: Head.SkinColor);
|
||||
headSprite.Draw(spriteBatch, screenPos, scale: scale, color: Head.SkinColor, spriteEffect: spriteEffects);
|
||||
if (AttachmentSprites != null)
|
||||
{
|
||||
float depthStep = 0.000001f;
|
||||
foreach (var attachment in AttachmentSprites)
|
||||
{
|
||||
SetAttachmentEffect(spriteBatch, attachment);
|
||||
DrawAttachmentSprite(spriteBatch, attachment, headSprite, Head.SheetIndex, screenPos, scale, depthStep, GetAttachmentColor(attachment, Head.HairColor, Head.FacialHairColor));
|
||||
DrawAttachmentSprite(spriteBatch, attachment, headSprite, Head.SheetIndex, screenPos, scale, depthStep, GetAttachmentColor(attachment, Head.HairColor, Head.FacialHairColor),
|
||||
spriteEffects: spriteEffects);
|
||||
depthStep += depthStep;
|
||||
}
|
||||
}
|
||||
@@ -534,9 +479,6 @@ namespace Barotrauma
|
||||
{
|
||||
origin.Y = attachment.Sprite.size.Y - origin.Y;
|
||||
}
|
||||
//the portrait's origin is forced to 0,0 (presumably for easier drawing on the UI?), see LoadHeadElement
|
||||
//we need to take that into account here and draw the attachment at where the origin of the "actual" head sprite would be
|
||||
drawPos += HeadSprite.Origin * scale;
|
||||
}
|
||||
float depth = attachment.Sprite.Depth;
|
||||
if (attachment.InheritLimbDepth)
|
||||
@@ -545,7 +487,6 @@ namespace Barotrauma
|
||||
}
|
||||
attachment.Sprite.Draw(spriteBatch, drawPos, color ?? Color.White, origin, rotate: 0, scale: scale, depth: depth, spriteEffect: spriteEffects);
|
||||
}
|
||||
|
||||
public static CharacterInfo ClientRead(Identifier speciesName, IReadMessage inc, bool requireJobPrefabFound = true)
|
||||
{
|
||||
ushort infoID = inc.ReadUInt16();
|
||||
@@ -568,7 +509,6 @@ namespace Barotrauma
|
||||
Color hairColor = inc.ReadColorR8G8B8();
|
||||
Color facialHairColor = inc.ReadColorR8G8B8();
|
||||
|
||||
|
||||
Identifier npcId = inc.ReadIdentifier();
|
||||
|
||||
Identifier factionId = inc.ReadIdentifier();
|
||||
|
||||
@@ -833,6 +833,9 @@ namespace Barotrauma
|
||||
causeOfDeathAffliction = afflictionPrefab;
|
||||
}
|
||||
}
|
||||
|
||||
Character killer = FindEntityByID(msg.ReadUInt16()) as Character;
|
||||
|
||||
bool containsAfflictionData = msg.ReadBoolean();
|
||||
if (!IsDead)
|
||||
{
|
||||
@@ -842,7 +845,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
Kill(causeOfDeathType, causeOfDeathAffliction?.Instantiate(1.0f), true);
|
||||
Kill(causeOfDeathType, causeOfDeathAffliction?.Instantiate(1.0f, killer), true);
|
||||
}
|
||||
}
|
||||
if (containsAfflictionData)
|
||||
|
||||
@@ -221,7 +221,7 @@ namespace Barotrauma
|
||||
new GUICustomComponent(new RectTransform(new Vector2(0.2f, 1.0f), nameContainer.RectTransform, Anchor.CenterLeft),
|
||||
onDraw: (spriteBatch, component) =>
|
||||
{
|
||||
character.Info?.DrawPortrait(spriteBatch, new Vector2(component.Rect.X, component.Rect.Center.Y - component.Rect.Width / 2), Vector2.Zero, component.Rect.Width, false, character != Character.Controlled);
|
||||
character.Info?.DrawIcon(spriteBatch, component.Rect.Center.ToVector2(), component.Rect.Size.ToVector2());
|
||||
});
|
||||
characterName = new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), nameContainer.RectTransform), "", textAlignment: Alignment.CenterLeft, font: GUIStyle.SubHeadingFont)
|
||||
{
|
||||
@@ -1041,8 +1041,29 @@ namespace Barotrauma
|
||||
foreach (KeyValuePair<Affliction, LimbHealth> kvp in afflictions)
|
||||
{
|
||||
var affliction = kvp.Key;
|
||||
affliction.Prefab.AfflictionOverlay?.Draw(spriteBatch, Vector2.Zero, Color.White * affliction.GetAfflictionOverlayMultiplier(), Vector2.Zero, 0.0f,
|
||||
new Vector2(GameMain.GraphicsWidth / DamageOverlay.size.X, GameMain.GraphicsHeight / DamageOverlay.size.Y));
|
||||
if (affliction.Prefab is AfflictionPrefab { AfflictionOverlay: not null } afflictionPrefab)
|
||||
{
|
||||
Vector2 screenSize = new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
if (afflictionPrefab.AfflictionOverlay is SpriteSheet spriteSheet)
|
||||
{
|
||||
spriteSheet.Draw(spriteBatch,
|
||||
spriteIndex: spriteSheet.GetAnimatedSpriteIndex(afflictionPrefab.AfflictionOverlayAnimSpeed),
|
||||
pos: Vector2.Zero,
|
||||
color: Color.White * affliction.GetAfflictionOverlayMultiplier(),
|
||||
origin: Vector2.Zero,
|
||||
rotate: 0,
|
||||
scale: screenSize / spriteSheet.FrameSize.ToVector2());
|
||||
}
|
||||
else if (afflictionPrefab.AfflictionOverlay is Sprite sprite)
|
||||
{
|
||||
sprite.Draw(spriteBatch,
|
||||
pos: Vector2.Zero,
|
||||
color: Color.White * affliction.GetAfflictionOverlayMultiplier(),
|
||||
origin: Vector2.Zero,
|
||||
rotate: 0,
|
||||
scale: screenSize / sprite.size);
|
||||
}
|
||||
}
|
||||
|
||||
var activeEffect = affliction.GetActiveEffect();
|
||||
if (activeEffect is { ThermalOverlayRange: > 0.0f })
|
||||
@@ -1554,9 +1575,9 @@ namespace Barotrauma
|
||||
};
|
||||
|
||||
var description = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), parent.RectTransform),
|
||||
affliction.Prefab.GetDescription(
|
||||
RichString.Rich(affliction.Prefab.GetDescription(
|
||||
affliction.Strength,
|
||||
Character == Character.Controlled ? AfflictionPrefab.Description.TargetType.Self : AfflictionPrefab.Description.TargetType.OtherCharacter),
|
||||
Character == Character.Controlled ? AfflictionPrefab.Description.TargetType.Self : AfflictionPrefab.Description.TargetType.OtherCharacter)),
|
||||
textAlignment: Alignment.TopLeft, wrap: true)
|
||||
{
|
||||
CanBeFocused = false
|
||||
|
||||
Reference in New Issue
Block a user