Unstable 1.1.14.0

This commit is contained in:
Markus Isberg
2023-10-02 16:43:54 +03:00
parent 94f5a93a0c
commit cf8f0de659
606 changed files with 21906 additions and 11456 deletions
@@ -13,7 +13,7 @@ namespace Barotrauma.Items.Components
get { return item.Rect.Size.ToVector2(); }
}
public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1)
public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1, Color? overrideColor = null)
{
if (!IsActive || picker == null || !CanBeAttached(picker) || !picker.IsKeyDown(InputType.Aim) || picker != Character.Controlled)
{
@@ -50,7 +50,17 @@ namespace Barotrauma.Items.Components
Submarine.DrawGrid(spriteBatch, 14, gridPos, roundedGridPos, alpha: 0.4f);
item.Sprite.Draw(
Sprite sprite = item.Sprite;
foreach (ContainedItemSprite containedSprite in item.Prefab.ContainedSprites)
{
if (containedSprite.UseWhenAttached)
{
sprite = containedSprite.Sprite;
break;
}
}
sprite.Draw(
spriteBatch,
new Vector2(attachPos.X, -attachPos.Y),
item.SpriteColor * 0.5f,
@@ -1,11 +1,8 @@
using System;
using Barotrauma.IO;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Xml.Linq;
using Barotrauma.Extensions;
using Barotrauma.IO;
namespace Barotrauma.Items.Components
{
@@ -48,33 +45,36 @@ namespace Barotrauma.Items.Components
return;
}
foreach (ContentXElement limbElement in characterInfo.Ragdoll.MainElement.Elements())
if (characterInfo.Ragdoll.MainElement?.Elements() is { } limbElements)
{
if (!limbElement.GetAttributeString("type", "").Equals("head", StringComparison.OrdinalIgnoreCase)) { continue; }
ContentXElement spriteElement = limbElement.GetChildElement("sprite");
if (spriteElement == null) { continue; }
ContentPath contentPath = spriteElement.GetAttributeContentPath("texture");
string spritePath = characterInfo.ReplaceVars(contentPath.Value);
string fileName = Path.GetFileNameWithoutExtension(spritePath);
//go through the files in the directory to find a matching sprite
foreach (string file in Directory.GetFiles(Path.GetDirectoryName(spritePath)))
foreach (ContentXElement limbElement in limbElements)
{
if (!file.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
if (!limbElement.GetAttributeString("type", "").Equals("head", StringComparison.OrdinalIgnoreCase)) { continue; }
ContentXElement spriteElement = limbElement.GetChildElement("sprite");
if (spriteElement == null) { continue; }
ContentPath contentPath = spriteElement.GetAttributeContentPath("texture");
string spritePath = characterInfo.ReplaceVars(contentPath.Value);
string fileName = Path.GetFileNameWithoutExtension(spritePath);
//go through the files in the directory to find a matching sprite
foreach (string file in Directory.GetFiles(Path.GetDirectoryName(spritePath)))
{
continue;
if (!file.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
{
continue;
}
string fileWithoutTags = Path.GetFileNameWithoutExtension(file);
fileWithoutTags = fileWithoutTags.Split('[', ']').First();
if (fileWithoutTags != fileName) { continue; }
Portrait = new Sprite(spriteElement, "", file) { RelativeOrigin = Vector2.Zero };
break;
}
string fileWithoutTags = Path.GetFileNameWithoutExtension(file);
fileWithoutTags = fileWithoutTags.Split('[', ']').First();
if (fileWithoutTags != fileName) { continue; }
Portrait = new Sprite(spriteElement, "", file) { RelativeOrigin = Vector2.Zero };
break;
}
break;
}
if (characterInfo.Wearables != null)
@@ -60,7 +60,7 @@ namespace Barotrauma.Items.Components
}
}
public override void UpdateHUD(Character character, float deltaTime, Camera cam)
public override void UpdateHUDComponentSpecific(Character character, float deltaTime, Camera cam)
{
currentCrossHairScale = currentCrossHairPointerScale = cam == null ? 1.0f : cam.Zoom;
if (crosshairSprite != null)
@@ -118,6 +118,7 @@ namespace Barotrauma.Items.Components
else if (chargeSoundChannel != null)
{
chargeSoundChannel.FrequencyMultiplier = MathHelper.Lerp(0.5f, 1.5f, chargeRatio);
chargeSoundChannel.Position = new Vector3(item.WorldPosition, 0.0f);
}
break;
default:
@@ -51,7 +51,7 @@ namespace Barotrauma.Items.Components
private int spraySetting = 0;
private readonly Point[] sprayArray = new Point[8];
public override void UpdateHUD(Character character, float deltaTime, Camera cam)
public override void UpdateHUDComponentSpecific(Character character, float deltaTime, Camera cam)
{
if (character == null || !character.IsKeyDown(InputType.Aim)) return;
@@ -130,7 +130,7 @@ namespace Barotrauma.Items.Components
if (body.UserData is Item item)
{
var door = item.GetComponent<Door>();
if (door != null && door.CanBeTraversed) { continue; }
if (door != null && (door.IsOpen || door.IsBroken)) { continue; }
}
targetHull = null;
@@ -288,7 +288,7 @@ namespace Barotrauma.Items.Components
}
}
public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1)
public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1, Color? overrideColor = null)
{
#if DEBUG
if (GameMain.DebugDraw && Character.Controlled != null && Character.Controlled.IsKeyDown(InputType.Aim))