Unstable 1.2.1.0
This commit is contained in:
@@ -336,7 +336,10 @@ namespace Barotrauma
|
||||
float pressure = AnimController.CurrentHull == null ? 100.0f : AnimController.CurrentHull.LethalPressure;
|
||||
if (pressure > 0.0f)
|
||||
{
|
||||
float zoomInEffectStrength = MathHelper.Clamp(pressure / 100.0f, 0.1f, 1.0f);
|
||||
//lerp in during the 1st second of the pressure timer so the zoom doesn't
|
||||
//"flicker" in and out if the pressure fluctuates around the minimum threshold
|
||||
float timerMultiplier = (PressureTimer / 100.0f);
|
||||
float zoomInEffectStrength = MathHelper.Clamp(pressure / 100.0f * timerMultiplier, 0.0f, 1.0f);
|
||||
cam.Zoom = MathHelper.Lerp(cam.Zoom,
|
||||
cam.DefaultZoom + (Math.Max(pressure, 10) / 150.0f) * Rand.Range(0.9f, 1.1f),
|
||||
zoomInEffectStrength);
|
||||
|
||||
@@ -8,24 +8,25 @@ namespace Barotrauma
|
||||
{
|
||||
internal abstract partial class CircuitBoxConnection
|
||||
{
|
||||
public string Name => Label.Value.Value;
|
||||
public string Name => Connection.Name;
|
||||
|
||||
public CircuitBoxLabel Label { get; private set; }
|
||||
|
||||
private Sprite? knobSprite,
|
||||
screwSprite,
|
||||
connectorSprite;
|
||||
|
||||
private static int padding => GUI.IntScale(8);
|
||||
private static int Padding => GUI.IntScale(8);
|
||||
|
||||
private Option<LocalizedString> tooltip = Option.None;
|
||||
|
||||
private partial void InitProjSpecific(CircuitBox circuitBox)
|
||||
{
|
||||
Label = new CircuitBoxLabel(Connection.Name, GUIStyle.SubHeadingFont);
|
||||
Label = new CircuitBoxLabel(Connection.DisplayName, GUIStyle.SubHeadingFont);
|
||||
knobSprite = circuitBox.ConnectionSprite;
|
||||
screwSprite = circuitBox.ConnectionScrewSprite;
|
||||
connectorSprite = circuitBox.WireConnectorSprite;
|
||||
Length = Rect.Width + padding + Label.Size.X;
|
||||
Length = Rect.Width + Padding + Label.Size.X;
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, Vector2 drawPos, Vector2 parentPos, Color color)
|
||||
@@ -41,11 +42,11 @@ namespace Barotrauma
|
||||
float xPos;
|
||||
if (IsOutput)
|
||||
{
|
||||
xPos = drawRect.Left - padding - Label.Size.X;
|
||||
xPos = drawRect.Left - Padding - Label.Size.X;
|
||||
}
|
||||
else
|
||||
{
|
||||
xPos = drawRect.Right + padding;
|
||||
xPos = drawRect.Right + Padding;
|
||||
}
|
||||
|
||||
Vector2 stringPos = new Vector2(xPos, drawRect.Center.Y - Label.Size.Y / 2f);
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Barotrauma
|
||||
bool allowCheats = GameMain.NetworkMember == null && (GameMain.GameSession?.GameMode is TestGameMode || Screen.Selected is { IsEditor: true });
|
||||
if (!allowCheats && !CheatsEnabled && IsCheat)
|
||||
{
|
||||
NewMessage("You need to enable cheats using the command \"enablecheats\" before you can use the command \"" + names[0] + "\".", Color.Red);
|
||||
NewMessage("You need to enable cheats using the command \"enablecheats\" before you can use the command \"" + Names[0] + "\".", Color.Red);
|
||||
#if USE_STEAM
|
||||
NewMessage("Enabling cheats will disable Steam achievements during this play session.", Color.Red);
|
||||
#endif
|
||||
@@ -215,9 +215,9 @@ namespace Barotrauma
|
||||
SoundPlayer.PlayUISound(GUISoundType.Select);
|
||||
}
|
||||
|
||||
private static bool IsCommandPermitted(string command, GameClient client)
|
||||
private static bool IsCommandPermitted(Identifier command, GameClient client)
|
||||
{
|
||||
switch (command)
|
||||
switch (command.Value.ToLowerInvariant())
|
||||
{
|
||||
case "kick":
|
||||
return client.HasPermission(ClientPermissions.Kick);
|
||||
@@ -304,7 +304,7 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
var textBlock = new GUITextBlock(new RectTransform(new Point(listBox.Content.Rect.Width - 5, 0), textContainer.RectTransform, Anchor.TopLeft) { AbsoluteOffset = new Point(2, 2) },
|
||||
msg.Text, textAlignment: Alignment.TopLeft, font: GUIStyle.SmallFont, wrap: true)
|
||||
RichString.Rich(msg.Text), textAlignment: Alignment.TopLeft, font: GUIStyle.SmallFont, wrap: true)
|
||||
{
|
||||
CanBeFocused = false,
|
||||
TextColor = msg.Color
|
||||
@@ -346,7 +346,7 @@ namespace Barotrauma
|
||||
CanBeFocused = false
|
||||
};
|
||||
var textBlock = new GUITextBlock(new RectTransform(new Point(listBox.Content.Rect.Width - 170, 0), textContainer.RectTransform, Anchor.TopRight) { AbsoluteOffset = new Point(20, 0) },
|
||||
command.help, textAlignment: Alignment.TopLeft, font: GUIStyle.SmallFont, wrap: true)
|
||||
command.Help, textAlignment: Alignment.TopLeft, font: GUIStyle.SmallFont, wrap: true)
|
||||
{
|
||||
CanBeFocused = false,
|
||||
TextColor = Color.White
|
||||
@@ -354,7 +354,7 @@ namespace Barotrauma
|
||||
textContainer.RectTransform.NonScaledSize = new Point(textContainer.RectTransform.NonScaledSize.X, textBlock.RectTransform.NonScaledSize.Y + 5);
|
||||
textBlock.SetTextPos();
|
||||
new GUITextBlock(new RectTransform(new Point(150, textContainer.Rect.Height), textContainer.RectTransform),
|
||||
command.names[0], textAlignment: Alignment.TopLeft);
|
||||
command.Names[0].Value, textAlignment: Alignment.TopLeft);
|
||||
|
||||
listBox.UpdateScrollBarSize();
|
||||
listBox.BarScroll = 1.0f;
|
||||
@@ -364,7 +364,7 @@ namespace Barotrauma
|
||||
|
||||
private static void AssignOnClientExecute(string names, Action<string[]> onClientExecute)
|
||||
{
|
||||
Command command = commands.Find(c => c.names.Intersect(names.Split('|')).Count() > 0);
|
||||
Command command = commands.Find(c => c.Names.Intersect(names.Split('|').ToIdentifiers()).Any());
|
||||
if (command == null)
|
||||
{
|
||||
throw new Exception("AssignOnClientExecute failed. Command matching the name(s) \"" + names + "\" not found.");
|
||||
@@ -378,7 +378,7 @@ namespace Barotrauma
|
||||
|
||||
private static void AssignRelayToServer(string names, bool relay)
|
||||
{
|
||||
Command command = commands.Find(c => c.names.Intersect(names.Split('|')).Count() > 0);
|
||||
Command command = commands.Find(c => c.Names.Intersect(names.Split('|').ToIdentifiers()).Any());
|
||||
if (command == null)
|
||||
{
|
||||
DebugConsole.Log("Could not assign to relay to server: " + names);
|
||||
@@ -706,6 +706,8 @@ namespace Barotrauma
|
||||
AssignRelayToServer("showmoney", true);
|
||||
AssignRelayToServer("setskill", true);
|
||||
AssignRelayToServer("readycheck", true);
|
||||
commands.Add(new Command("debugjobassignment", "", (string[] args) => { }));
|
||||
AssignRelayToServer("debugjobassignment", true);
|
||||
|
||||
AssignRelayToServer("givetalent", true);
|
||||
AssignRelayToServer("unlocktalents", true);
|
||||
|
||||
@@ -374,13 +374,12 @@ namespace Barotrauma
|
||||
btn.RectTransform.MinSize = new Point(0, (int)(btn.TextBlock.Rect.Height * 1.2f));
|
||||
}
|
||||
|
||||
textContent.RectTransform.MinSize = new Point(0, textContent.Children.Sum(c => c.Rect.Height) + GUI.IntScale(16));
|
||||
textContent.RectTransform.MinSize = new Point(0, textContent.Children.Sum(c => c.Rect.Height + textContent.AbsoluteSpacing) + GUI.IntScale(16));
|
||||
content.RectTransform.MinSize = new Point(0, content.Children.Sum(c => c.Rect.Height));
|
||||
|
||||
// Recalculate the text size as it is scaled up and no longer matching the text height due to the textContent's minSize increasing
|
||||
textBlock.CalculateHeightFromText();
|
||||
textBlock.TextAlignment = Alignment.TopLeft;
|
||||
//content.RectTransform.MinSize = new Point(0, textContent.Rect.Height);
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
float theoreticalMaxMonsterStrength = 10000;
|
||||
float relativeMaxMonsterStrength = theoreticalMaxMonsterStrength * (GameMain.GameSession?.LevelData?.Difficulty ?? 0f) / 100;
|
||||
float relativeMaxMonsterStrength = theoreticalMaxMonsterStrength * (GameMain.GameSession?.Level?.Difficulty ?? 0f) / 100;
|
||||
float absoluteMonsterStrength = monsterStrength / theoreticalMaxMonsterStrength;
|
||||
float relativeMonsterStrength = monsterStrength / relativeMaxMonsterStrength;
|
||||
|
||||
|
||||
@@ -51,7 +51,8 @@ namespace Barotrauma
|
||||
if (requiredDeliveryAmount == 0) { requiredDeliveryAmount = items.Count; }
|
||||
if (requiredDeliveryAmount > items.Count)
|
||||
{
|
||||
DebugConsole.AddWarning($"Error in mission \"{Prefab.Identifier}\". Required delivery amount is {requiredDeliveryAmount} but there's only {items.Count} items to deliver.");
|
||||
DebugConsole.AddWarning($"Error in mission \"{Prefab.Identifier}\". Required delivery amount is {requiredDeliveryAmount} but there's only {items.Count} items to deliver.",
|
||||
contentPackage: Prefab.ContentPackage);
|
||||
requiredDeliveryAmount = items.Count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -81,6 +82,8 @@ namespace Barotrauma
|
||||
|
||||
public bool FlashOnAutoCloseCondition { get; set; }
|
||||
|
||||
public Action OnEnterPressed { get; set; }
|
||||
|
||||
public Type MessageBoxType => type;
|
||||
|
||||
public static GUIComponent VisibleBox => MessageBoxes.LastOrDefault();
|
||||
@@ -89,6 +92,10 @@ namespace Barotrauma
|
||||
: this(headerText, text, new LocalizedString[] { "OK" }, relativeSize, minSize, type: type)
|
||||
{
|
||||
this.Buttons[0].OnClicked = Close;
|
||||
OnEnterPressed = () =>
|
||||
{
|
||||
Buttons[0].OnClicked(Buttons[0], Buttons[0].UserData);
|
||||
};
|
||||
}
|
||||
|
||||
public GUIMessageBox(RichString headerText, RichString text, LocalizedString[] buttons,
|
||||
@@ -516,6 +523,11 @@ namespace Barotrauma
|
||||
|
||||
protected override void Update(float deltaTime)
|
||||
{
|
||||
if (PlayerInput.KeyHit(Keys.Enter))
|
||||
{
|
||||
OnEnterPressed?.Invoke();
|
||||
}
|
||||
|
||||
if (Draggable)
|
||||
{
|
||||
GUIComponent parent = GUI.MouseOn?.Parent?.Parent;
|
||||
|
||||
@@ -18,6 +18,20 @@ namespace Barotrauma
|
||||
public GUIButton PlusButton { get; private set; }
|
||||
public GUIButton MinusButton { get; private set; }
|
||||
|
||||
private void UpdatePlusMinusButtonVisibility()
|
||||
{
|
||||
if (ForceShowPlusMinusButtons
|
||||
|| inputType == NumberType.Int
|
||||
|| (inputType == NumberType.Float && MinValueFloat > float.MinValue && MaxValueFloat < float.MaxValue))
|
||||
{
|
||||
ShowPlusMinusButtons();
|
||||
}
|
||||
else
|
||||
{
|
||||
HidePlusMinusButtons();
|
||||
}
|
||||
}
|
||||
|
||||
private NumberType inputType;
|
||||
public NumberType InputType
|
||||
{
|
||||
@@ -26,15 +40,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (inputType == value) { return; }
|
||||
inputType = value;
|
||||
if (inputType == NumberType.Int ||
|
||||
(inputType == NumberType.Float && MinValueFloat > float.MinValue && MaxValueFloat < float.MaxValue))
|
||||
{
|
||||
ShowPlusMinusButtons();
|
||||
}
|
||||
else
|
||||
{
|
||||
HidePlusMinusButtons();
|
||||
}
|
||||
UpdatePlusMinusButtonVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,15 +52,7 @@ namespace Barotrauma
|
||||
{
|
||||
minValueFloat = value;
|
||||
ClampFloatValue();
|
||||
if (inputType == NumberType.Int ||
|
||||
(inputType == NumberType.Float && MinValueFloat > float.MinValue && MaxValueFloat < float.MaxValue))
|
||||
{
|
||||
ShowPlusMinusButtons();
|
||||
}
|
||||
else
|
||||
{
|
||||
HidePlusMinusButtons();
|
||||
}
|
||||
UpdatePlusMinusButtonVisibility();
|
||||
}
|
||||
}
|
||||
public float? MaxValueFloat
|
||||
@@ -64,15 +62,7 @@ namespace Barotrauma
|
||||
{
|
||||
maxValueFloat = value;
|
||||
ClampFloatValue();
|
||||
if (inputType == NumberType.Int ||
|
||||
(inputType == NumberType.Float && MinValueFloat > float.MinValue && MaxValueFloat < float.MaxValue))
|
||||
{
|
||||
ShowPlusMinusButtons();
|
||||
}
|
||||
else
|
||||
{
|
||||
HidePlusMinusButtons();
|
||||
}
|
||||
UpdatePlusMinusButtonVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +86,19 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private bool forceShowPlusMinusButtons;
|
||||
|
||||
public bool ForceShowPlusMinusButtons
|
||||
{
|
||||
get { return forceShowPlusMinusButtons; }
|
||||
set
|
||||
{
|
||||
if (forceShowPlusMinusButtons == value) { return; }
|
||||
forceShowPlusMinusButtons = value;
|
||||
UpdatePlusMinusButtonVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
private int decimalsToDisplay = 1;
|
||||
public int DecimalsToDisplay
|
||||
{
|
||||
@@ -184,7 +187,7 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
public bool WrapAround;
|
||||
|
||||
public float valueStep;
|
||||
public float ValueStep;
|
||||
|
||||
private float pressedTimer;
|
||||
private readonly float pressedDelay = 0.5f;
|
||||
@@ -339,12 +342,12 @@ namespace Barotrauma
|
||||
{
|
||||
if (inputType == NumberType.Int)
|
||||
{
|
||||
IntValue -= valueStep > 0 ? (int)valueStep : 1;
|
||||
IntValue -= ValueStep > 0 ? (int)ValueStep : 1;
|
||||
ClampIntValue();
|
||||
}
|
||||
else if (maxValueFloat.HasValue && minValueFloat.HasValue)
|
||||
{
|
||||
FloatValue -= valueStep > 0 ? valueStep : Round();
|
||||
FloatValue -= ValueStep > 0 ? ValueStep : Round();
|
||||
ClampFloatValue();
|
||||
}
|
||||
}
|
||||
@@ -353,12 +356,12 @@ namespace Barotrauma
|
||||
{
|
||||
if (inputType == NumberType.Int)
|
||||
{
|
||||
IntValue += valueStep > 0 ? (int)valueStep : 1;
|
||||
IntValue += ValueStep > 0 ? (int)ValueStep : 1;
|
||||
ClampIntValue();
|
||||
}
|
||||
else if (inputType == NumberType.Float)
|
||||
{
|
||||
FloatValue += valueStep > 0 ? valueStep : Round();
|
||||
FloatValue += ValueStep > 0 ? ValueStep : Round();
|
||||
ClampFloatValue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,9 +341,9 @@ namespace Barotrauma
|
||||
};
|
||||
|
||||
var panelMaxWidth = (int)(GUI.xScale * (GUI.HorizontalAspectRatio < 1.4f ? 650 : 560));
|
||||
var storeContent = new GUILayoutGroup(new RectTransform(new Vector2(0.45f, 1.0f), campaignUI.GetTabContainer(CampaignMode.InteractionType.Store).RectTransform)
|
||||
var storeContent = new GUILayoutGroup(new RectTransform(new Vector2(0.45f, 1.0f), campaignUI.GetTabContainer(CampaignMode.InteractionType.Store).RectTransform, Anchor.BottomLeft)
|
||||
{
|
||||
MaxSize = new Point(panelMaxWidth, campaignUI.GetTabContainer(CampaignMode.InteractionType.Store).Rect.Height)
|
||||
MaxSize = new Point(panelMaxWidth, campaignUI.GetTabContainer(CampaignMode.InteractionType.Store).Rect.Height - HUDLayoutSettings.ButtonAreaTop.Bottom)
|
||||
})
|
||||
{
|
||||
Stretch = true,
|
||||
@@ -583,9 +583,9 @@ namespace Barotrauma
|
||||
|
||||
// Shopping Crate ------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
var shoppingCrateContent = new GUILayoutGroup(new RectTransform(new Vector2(0.45f, 1.0f), campaignUI.GetTabContainer(CampaignMode.InteractionType.Store).RectTransform, anchor: Anchor.TopRight)
|
||||
var shoppingCrateContent = new GUILayoutGroup(new RectTransform(new Vector2(0.45f, 1.0f), campaignUI.GetTabContainer(CampaignMode.InteractionType.Store).RectTransform, anchor: Anchor.BottomRight)
|
||||
{
|
||||
MaxSize = new Point(panelMaxWidth, campaignUI.GetTabContainer(CampaignMode.InteractionType.Store).Rect.Height)
|
||||
MaxSize = new Point(panelMaxWidth, campaignUI.GetTabContainer(CampaignMode.InteractionType.Store).Rect.Height - HUDLayoutSettings.ButtonAreaTop.Bottom)
|
||||
})
|
||||
{
|
||||
Stretch = true,
|
||||
@@ -922,15 +922,12 @@ namespace Barotrauma
|
||||
{
|
||||
if (itemPrefab.CanBeBoughtFrom(ActiveStore, out PriceInfo priceInfo) && itemPrefab.CanCharacterBuy())
|
||||
{
|
||||
|
||||
bool isDailySpecial = ActiveStore.DailySpecials.Contains(itemPrefab);
|
||||
var itemFrame = isDailySpecial ?
|
||||
storeDailySpecialsGroup.FindChild(c => c.UserData is PurchasedItem pi && pi.ItemPrefab == itemPrefab) :
|
||||
storeBuyList.Content.FindChild(c => c.UserData is PurchasedItem pi && pi.ItemPrefab == itemPrefab);
|
||||
if (CargoManager.GetPurchasedItem(ActiveStore, itemPrefab) is { } purchasedItem)
|
||||
{
|
||||
quantity = Math.Max(quantity - purchasedItem.Quantity, 0);
|
||||
}
|
||||
|
||||
quantity = Math.Max(quantity - CargoManager.GetPurchasedItemCount(ActiveStore, itemPrefab), 0);
|
||||
if (CargoManager.GetBuyCrateItem(ActiveStore, itemPrefab) is { } buyCrateItem)
|
||||
{
|
||||
quantity = Math.Max(quantity - buyCrateItem.Quantity, 0);
|
||||
@@ -1245,9 +1242,9 @@ namespace Barotrauma
|
||||
int totalPrice = 0;
|
||||
if (ActiveStore != null)
|
||||
{
|
||||
foreach (PurchasedItem item in items)
|
||||
foreach (PurchasedItem item in items.ToList())
|
||||
{
|
||||
if (!(item.ItemPrefab.GetPriceInfo(ActiveStore) is { } priceInfo)) { continue; }
|
||||
if (item.ItemPrefab.GetPriceInfo(ActiveStore) is not { } priceInfo) { continue; }
|
||||
GUINumberInput numInput = null;
|
||||
if (!(listBox.Content.FindChild(c => c.UserData is PurchasedItem pi && pi.ItemPrefab.Identifier == item.ItemPrefab.Identifier) is { } itemFrame))
|
||||
{
|
||||
@@ -1749,7 +1746,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
// Add items already purchased
|
||||
CargoManager?.GetPurchasedItems(ActiveStore).ForEach(pi => AddNonEmptyOwnedItems(pi));
|
||||
CargoManager?.GetPurchasedItems(ActiveStore).Where(pi => !pi.DeliverImmediately).ForEach(pi => AddNonEmptyOwnedItems(pi));
|
||||
|
||||
ownedItemsUpdateTimer = 0.0f;
|
||||
|
||||
@@ -1959,14 +1956,13 @@ namespace Barotrauma
|
||||
}
|
||||
catch (NotImplementedException e)
|
||||
{
|
||||
DebugConsole.LogError($"Error getting item availability: Uknown store tab type. {e.StackTrace.CleanupStackTrace()}");
|
||||
DebugConsole.LogError($"Error getting item availability: Unknown store tab type. {e.StackTrace.CleanupStackTrace()}");
|
||||
}
|
||||
if (list != null && list.Find(i => i.ItemPrefab == itemPrefab) is PurchasedItem item)
|
||||
{
|
||||
if (mode == StoreTab.Buy)
|
||||
{
|
||||
var purchasedItem = CargoManager.GetPurchasedItem(ActiveStore, item.ItemPrefab);
|
||||
if (purchasedItem != null) { return Math.Max(item.Quantity - purchasedItem.Quantity, 0); }
|
||||
return Math.Max(item.Quantity - CargoManager.GetPurchasedItemCount(ActiveStore, item.ItemPrefab), 0);
|
||||
}
|
||||
return item.Quantity;
|
||||
}
|
||||
@@ -2093,13 +2089,49 @@ namespace Barotrauma
|
||||
}
|
||||
itemsToRemove.ForEach(i => itemsToPurchase.Remove(i));
|
||||
if (itemsToPurchase.None() || Balance < totalPrice) { return false; }
|
||||
CargoManager.PurchaseItems(ActiveStore.Identifier, itemsToPurchase, true);
|
||||
GameMain.Client?.SendCampaignState();
|
||||
var dialog = new GUIMessageBox(
|
||||
TextManager.Get("newsupplies"),
|
||||
TextManager.GetWithVariable("suppliespurchasedmessage", "[location]", campaignUI?.Campaign?.Map?.CurrentLocation?.Name),
|
||||
new LocalizedString[] { TextManager.Get("Ok") });
|
||||
dialog.Buttons[0].OnClicked += dialog.Close;
|
||||
|
||||
if (CampaignMode.AllowImmediateItemDelivery())
|
||||
{
|
||||
var deliveryPrompt = new GUIMessageBox(
|
||||
TextManager.Get("newsupplies"),
|
||||
TextManager.Get("suppliespurchased.deliverymethod"),
|
||||
new LocalizedString[]
|
||||
{
|
||||
TextManager.Get("suppliespurchased.deliverymethod.deliverimmediately"),
|
||||
TextManager.Get("suppliespurchased.deliverymethod.delivertosub")
|
||||
});
|
||||
deliveryPrompt.Buttons[0].OnClicked = (btn, userdata) =>
|
||||
{
|
||||
ConfirmPurchase(deliverImmediately: true);
|
||||
deliveryPrompt.Close();
|
||||
return true;
|
||||
};
|
||||
deliveryPrompt.Buttons[1].OnClicked = (btn, userdata) =>
|
||||
{
|
||||
ConfirmPurchase(deliverImmediately: false);
|
||||
deliveryPrompt.Close();
|
||||
return true;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
ConfirmPurchase(deliverImmediately: false);
|
||||
}
|
||||
|
||||
void ConfirmPurchase(bool deliverImmediately)
|
||||
{
|
||||
itemsToPurchase.ForEach(it => it.DeliverImmediately = deliverImmediately);
|
||||
CargoManager.PurchaseItems(ActiveStore.Identifier, itemsToPurchase, removeFromCrate: true);
|
||||
GameMain.Client?.SendCampaignState();
|
||||
if (!deliverImmediately)
|
||||
{
|
||||
var dialog = new GUIMessageBox(
|
||||
TextManager.Get("newsupplies"),
|
||||
TextManager.GetWithVariable("suppliespurchasedmessage", "[location]", campaignUI?.Campaign?.Map?.CurrentLocation?.Name));
|
||||
dialog.Buttons[0].OnClicked += dialog.Close;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace Barotrauma
|
||||
else if (Tile)
|
||||
{
|
||||
Vector2 startPos = new Vector2(rect.X, rect.Y);
|
||||
Sprite.DrawTiled(spriteBatch, startPos, new Vector2(rect.Width, rect.Height), color, startOffset: uvOffset);
|
||||
Sprite.DrawTiled(spriteBatch, startPos, new Vector2(rect.Width, rect.Height), color: color, startOffset: uvOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1110,7 +1110,7 @@ namespace Barotrauma
|
||||
|
||||
public static UpgradeFrame CreateUpgradeFrame(UpgradePrefab prefab, UpgradeCategory category, CampaignMode campaign, RectTransform rectTransform, bool addBuyButton = true)
|
||||
{
|
||||
int price = prefab.Price.GetBuyPrice(campaign.UpgradeManager.GetUpgradeLevel(prefab, category), campaign.Map?.CurrentLocation, characterList);
|
||||
int price = prefab.Price.GetBuyPrice(prefab, campaign.UpgradeManager.GetUpgradeLevel(prefab, category), campaign.Map?.CurrentLocation, characterList);
|
||||
return CreateUpgradeEntry(rectTransform, prefab.Sprite, prefab.Name, prefab.Description, price, new CategoryData(category, prefab), addBuyButton, upgradePrefab: prefab, currentLevel: campaign.UpgradeManager.GetUpgradeLevel(prefab, category));
|
||||
}
|
||||
|
||||
@@ -1267,7 +1267,7 @@ namespace Barotrauma
|
||||
{
|
||||
LocalizedString promptBody = TextManager.GetWithVariables("Upgrades.PurchasePromptBody",
|
||||
("[upgradename]", prefab.Name),
|
||||
("[amount]", prefab.Price.GetBuyPrice(Campaign.UpgradeManager.GetUpgradeLevel(prefab, category), Campaign.Map?.CurrentLocation, characterList).ToString()));
|
||||
("[amount]", prefab.Price.GetBuyPrice(prefab, Campaign.UpgradeManager.GetUpgradeLevel(prefab, category), Campaign.Map?.CurrentLocation, characterList).ToString()));
|
||||
currectConfirmation = EventEditorScreen.AskForConfirmation(TextManager.Get("Upgrades.PurchasePromptTitle"), promptBody, () =>
|
||||
{
|
||||
if (GameMain.NetworkMember != null)
|
||||
@@ -1682,7 +1682,7 @@ namespace Barotrauma
|
||||
|
||||
GUITextBlock priceLabel = (GUITextBlock)buttonParent.FindChild(UpgradeStoreUserData.PriceLabel, recursive: true);
|
||||
priceLabel.Visible = true;
|
||||
int price = prefab.Price.GetBuyPrice(campaign.UpgradeManager.GetUpgradeLevel(prefab, category), campaign.Map?.CurrentLocation, characterList);
|
||||
int price = prefab.Price.GetBuyPrice(prefab, campaign.UpgradeManager.GetUpgradeLevel(prefab, category), campaign.Map?.CurrentLocation, characterList);
|
||||
|
||||
if (!WaitForServerUpdate)
|
||||
{
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace Barotrauma
|
||||
}
|
||||
catch (NotImplementedException e)
|
||||
{
|
||||
DebugConsole.LogError($"Error selling items: uknown store tab type \"{sellingMode}\".\n{e.StackTrace.CleanupStackTrace()}");
|
||||
DebugConsole.LogError($"Error selling items: unknown store tab type \"{sellingMode}\".\n{e.StackTrace.CleanupStackTrace()}");
|
||||
return;
|
||||
}
|
||||
bool canAddToRemoveQueue = campaign.IsSinglePlayer && Entity.Spawner != null;
|
||||
|
||||
@@ -121,6 +121,16 @@ namespace Barotrauma
|
||||
{
|
||||
return AllowedToManageCampaign(ClientPermissions.ManageMoney);
|
||||
}
|
||||
|
||||
public static bool AllowImmediateItemDelivery()
|
||||
{
|
||||
if (GameMain.Client == null) { return true; }
|
||||
return
|
||||
GameMain.Client.ServerSettings.AllowImmediateItemDelivery ||
|
||||
GameMain.Client.HasPermission(ClientPermissions.ManageCampaign) ||
|
||||
GameMain.Client.IsServerOwner;
|
||||
}
|
||||
|
||||
protected GUIButton CreateEndRoundButton()
|
||||
{
|
||||
int buttonWidth = (int)(450 * GUI.xScale * (GUI.IsUltrawide ? 3.0f : 1.0f));
|
||||
|
||||
@@ -535,7 +535,7 @@ namespace Barotrauma
|
||||
|
||||
bool refreshCampaignUI = false;
|
||||
|
||||
if (!(GameMain.GameSession?.GameMode is MultiPlayerCampaign campaign) || campaignID != campaign.CampaignID)
|
||||
if (GameMain.GameSession?.GameMode is not MultiPlayerCampaign campaign || campaignID != campaign.CampaignID)
|
||||
{
|
||||
string savePath = SaveUtil.CreateSavePath(SaveUtil.SaveType.Multiplayer);
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace Barotrauma
|
||||
if (gameSession.Missions.Any(m => m is CombatMission))
|
||||
{
|
||||
crewHeader.Text = CombatMission.GetTeamName(CharacterTeamType.Team1);
|
||||
GUIFrame crewFrame2 = new GUIFrame(new RectTransform(new Vector2(0.35f, 0.45f), background.RectTransform, Anchor.TopCenter, minSize: new Point(minWidth, minHeight)));
|
||||
GUIFrame crewFrame2 = new GUIFrame(new RectTransform(crewFrame.RectTransform.RelativeSize, background.RectTransform, Anchor.TopCenter, minSize: new Point(minWidth, minHeight)));
|
||||
rightPanels.Add(crewFrame2);
|
||||
GUIFrame crewFrameInner2 = new GUIFrame(new RectTransform(new Point(crewFrame2.Rect.Width - padding * 2, crewFrame2.Rect.Height - padding * 2), crewFrame2.RectTransform, Anchor.Center), style: "InnerFrame");
|
||||
var crewContent2 = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), crewFrameInner2.RectTransform, Anchor.Center))
|
||||
|
||||
@@ -54,7 +54,9 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (deconstructor.InputContainer.Inventory.AllItems.Count() == 2)
|
||||
{
|
||||
if (!deconstructor.InputContainer.Inventory.AllItems.All(it => it.Prefab == item.Prefab))
|
||||
var otherGeneticMaterial =
|
||||
deconstructor.InputContainer.Inventory.AllItems.FirstOrDefault(it => it != item && it.Prefab == item.Prefab)?.GetComponent<GeneticMaterial>();
|
||||
if (otherGeneticMaterial == null)
|
||||
{
|
||||
buttonText = TextManager.Get("researchstation.combine");
|
||||
infoText = TextManager.Get("researchstation.combine.infotext");
|
||||
@@ -62,7 +64,7 @@ namespace Barotrauma.Items.Components
|
||||
else
|
||||
{
|
||||
buttonText = TextManager.Get("researchstation.refine");
|
||||
int taintedProbability = (int)(GetTaintedProbabilityOnRefine(Character.Controlled) * 100);
|
||||
int taintedProbability = (int)(GetTaintedProbabilityOnRefine(otherGeneticMaterial, Character.Controlled) * 100);
|
||||
infoText = TextManager.GetWithVariable("researchstation.refine.infotext", "[taintedprobability]", taintedProbability.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,7 +497,8 @@ namespace Barotrauma.Items.Components
|
||||
case "guiframe":
|
||||
if (subElement.GetAttribute("rect") != null)
|
||||
{
|
||||
DebugConsole.ThrowError($"Error in item config \"{item.ConfigFilePath}\" - GUIFrame defined as rect, use RectTransform instead.");
|
||||
DebugConsole.ThrowError($"Error in item config \"{item.ConfigFilePath}\" - GUIFrame defined as rect, use RectTransform instead.",
|
||||
contentPackage: subElement.ContentPackage);
|
||||
break;
|
||||
}
|
||||
GuiFrameSource = subElement;
|
||||
@@ -516,7 +517,8 @@ namespace Barotrauma.Items.Components
|
||||
if (filePath.IsNullOrEmpty())
|
||||
{
|
||||
DebugConsole.ThrowError(
|
||||
$"Error when instantiating item \"{item.Name}\" - sound with no file path set");
|
||||
$"Error when instantiating item \"{item.Name}\" - sound with no file path set",
|
||||
contentPackage: subElement.ContentPackage);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -528,7 +530,8 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError($"Invalid sound type \"{typeStr}\" in item \"{item.Prefab.Identifier}\"!", e);
|
||||
DebugConsole.ThrowError($"Invalid sound type \"{typeStr}\" in item \"{item.Prefab.Identifier}\"!", e,
|
||||
contentPackage: subElement.ContentPackage);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -158,7 +158,8 @@ namespace Barotrauma.Items.Components
|
||||
IndicatorStyle = GUIStyle.GetComponentStyle("ContainedStateIndicator." + ContainedStateIndicatorStyle);
|
||||
if (ContainedStateIndicator != null || ContainedStateIndicatorEmpty != null)
|
||||
{
|
||||
DebugConsole.AddWarning($"Item \"{item.Name}\" defines both a contained state indicator style and a custom indicator sprite. Will use the custom sprite...");
|
||||
DebugConsole.AddWarning($"Item \"{item.Name}\" defines both a contained state indicator style and a custom indicator sprite. Will use the custom sprite...",
|
||||
contentPackage: item.Prefab.ContentPackage);
|
||||
}
|
||||
}
|
||||
if (GuiFrame == null)
|
||||
|
||||
@@ -393,6 +393,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
partial void SelectProjSpecific(Character character)
|
||||
{
|
||||
if (character != Character.Controlled) { return; }
|
||||
|
||||
var nonItems = itemList.Content.Children.Where(c => c.UserData is not FabricationRecipe).ToList();
|
||||
nonItems.ForEach(i => itemList.Content.RemoveChild(i));
|
||||
|
||||
@@ -784,6 +786,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private void HideEmptyItemListCategories()
|
||||
{
|
||||
bool visibleElementsChanged = false;
|
||||
//go through the elements backwards, and disable the labels ("insufficient skills to fabricate", "recipe required...") if there's no items below them
|
||||
bool recipeVisible = false;
|
||||
foreach (GUIComponent child in itemList.Content.Children.Reverse())
|
||||
@@ -792,7 +795,11 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (child.Enabled)
|
||||
{
|
||||
child.Visible = recipeVisible;
|
||||
if (child.Visible != recipeVisible)
|
||||
{
|
||||
child.Visible = recipeVisible;
|
||||
visibleElementsChanged = true;
|
||||
}
|
||||
}
|
||||
recipeVisible = false;
|
||||
}
|
||||
@@ -802,8 +809,11 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
itemList.UpdateScrollBarSize();
|
||||
itemList.BarScroll = 0.0f;
|
||||
if (visibleElementsChanged)
|
||||
{
|
||||
itemList.UpdateScrollBarSize();
|
||||
itemList.BarScroll = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ClearFilter()
|
||||
|
||||
@@ -66,7 +66,15 @@ namespace Barotrauma.Items.Components
|
||||
private float prevPassivePingRadius;
|
||||
|
||||
private Vector2 center;
|
||||
private float displayScale;
|
||||
|
||||
/// <summary>
|
||||
/// Current scale of the display, taking zoom into account. In other words, the scaling factor of world coordinates to coordinates on the display.
|
||||
/// </summary>
|
||||
public float DisplayScale
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
} = 1.0f;
|
||||
|
||||
private const float DisruptionUpdateInterval = 0.2f;
|
||||
private float disruptionUpdateTimer;
|
||||
@@ -751,9 +759,9 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
var activePing = activePings[pingIndex];
|
||||
float pingRadius = DisplayRadius * activePing.State / zoom;
|
||||
if (disruptionUpdateTimer <= 0.0f) { UpdateDisruptions(transducerCenter, pingRadius / displayScale); }
|
||||
if (disruptionUpdateTimer <= 0.0f) { UpdateDisruptions(transducerCenter, pingRadius / DisplayScale); }
|
||||
Ping(transducerCenter, transducerCenter,
|
||||
pingRadius, activePing.PrevPingRadius, displayScale, range / zoom, passive: false, pingStrength: 2.0f);
|
||||
pingRadius, activePing.PrevPingRadius, DisplayScale, range / zoom, passive: false, pingStrength: 2.0f);
|
||||
activePing.PrevPingRadius = pingRadius;
|
||||
}
|
||||
if (disruptionUpdateTimer <= 0.0f)
|
||||
@@ -770,7 +778,7 @@ namespace Barotrauma.Items.Components
|
||||
if (c.Params.HideInSonar) { continue; }
|
||||
|
||||
if (!c.IsUnconscious && c.Params.DistantSonarRange > 0.0f &&
|
||||
((c.WorldPosition - transducerCenter) * displayScale).LengthSquared() > DisplayRadius * DisplayRadius)
|
||||
((c.WorldPosition - transducerCenter) * DisplayScale).LengthSquared() > DisplayRadius * DisplayRadius)
|
||||
{
|
||||
Vector2 targetVector = c.WorldPosition - transducerCenter;
|
||||
if (targetVector.LengthSquared() > MathUtils.Pow2(c.Params.DistantSonarRange)) { continue; }
|
||||
@@ -818,7 +826,7 @@ namespace Barotrauma.Items.Components
|
||||
if (dist > prevPassivePingRadius * Range && dist <= passivePingRadius * Range && Rand.Int(sonarBlips.Count) < 500)
|
||||
{
|
||||
Ping(t.WorldPosition, transducerCenter,
|
||||
t.SoundRange * displayScale, 0, displayScale, range,
|
||||
t.SoundRange * DisplayScale, 0, DisplayScale, range,
|
||||
passive: true, pingStrength: 0.5f, needsToBeInSector: t);
|
||||
if (t.IsWithinSector(transducerCenter))
|
||||
{
|
||||
@@ -857,7 +865,7 @@ namespace Barotrauma.Items.Components
|
||||
displayBorderSize = 0.2f;
|
||||
center = rect.Center.ToVector2();
|
||||
DisplayRadius = (rect.Width / 2.0f) * (1.0f - displayBorderSize);
|
||||
displayScale = DisplayRadius / range * zoom;
|
||||
DisplayScale = DisplayRadius / range * zoom;
|
||||
|
||||
screenBackground?.Draw(spriteBatch, center, 0.0f, rect.Width / screenBackground.size.X);
|
||||
|
||||
@@ -972,7 +980,7 @@ namespace Barotrauma.Items.Components
|
||||
aiTarget.SonarIconIdentifier,
|
||||
aiTarget,
|
||||
aiTarget.WorldPosition, transducerCenter,
|
||||
displayScale, center, DisplayRadius * 0.975f);
|
||||
DisplayScale, center, DisplayRadius * 0.975f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -987,7 +995,7 @@ namespace Barotrauma.Items.Components
|
||||
(Level.Loaded.StartOutpost != null ? "outpost" : "location").ToIdentifier(),
|
||||
"startlocation",
|
||||
Level.Loaded.StartExitPosition, transducerCenter,
|
||||
displayScale, center, DisplayRadius);
|
||||
DisplayScale, center, DisplayRadius);
|
||||
}
|
||||
|
||||
if (Level.Loaded is { EndLocation.Type.ShowSonarMarker: true, Type: LevelData.LevelType.LocationConnection })
|
||||
@@ -997,7 +1005,7 @@ namespace Barotrauma.Items.Components
|
||||
(Level.Loaded.EndOutpost != null ? "outpost" : "location").ToIdentifier(),
|
||||
"endlocation",
|
||||
Level.Loaded.EndExitPosition, transducerCenter,
|
||||
displayScale, center, DisplayRadius);
|
||||
DisplayScale, center, DisplayRadius);
|
||||
}
|
||||
|
||||
for (int i = 0; i < Level.Loaded.Caves.Count; i++)
|
||||
@@ -1009,7 +1017,7 @@ namespace Barotrauma.Items.Components
|
||||
"cave".ToIdentifier(),
|
||||
"cave" + i,
|
||||
cave.StartPos.ToVector2(), transducerCenter,
|
||||
displayScale, center, DisplayRadius);
|
||||
DisplayScale, center, DisplayRadius);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1026,7 +1034,7 @@ namespace Barotrauma.Items.Components
|
||||
mission.SonarIconIdentifier,
|
||||
"mission" + missionIndex + ":" + i,
|
||||
position, transducerCenter,
|
||||
displayScale, center, DisplayRadius * 0.95f);
|
||||
DisplayScale, center, DisplayRadius * 0.95f);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
@@ -1059,7 +1067,7 @@ namespace Barotrauma.Items.Components
|
||||
DrawMarker(spriteBatch,
|
||||
i.Name, "mineral".ToIdentifier(), "mineralcluster" + i,
|
||||
c.center, transducerCenter,
|
||||
displayScale, center, DisplayRadius * 0.95f,
|
||||
DisplayScale, center, DisplayRadius * 0.95f,
|
||||
onlyShowTextOnMouseOver: true);
|
||||
}
|
||||
}
|
||||
@@ -1088,19 +1096,19 @@ namespace Barotrauma.Items.Components
|
||||
(sub.Info.HasTag(SubmarineTag.Shuttle) ? "shuttle" : "submarine").ToIdentifier(),
|
||||
sub,
|
||||
sub.WorldPosition, transducerCenter,
|
||||
displayScale, center, DisplayRadius * 0.95f);
|
||||
DisplayScale, center, DisplayRadius * 0.95f);
|
||||
}
|
||||
|
||||
if (GameMain.DebugDraw)
|
||||
{
|
||||
var steering = item.GetComponent<Steering>();
|
||||
steering?.DebugDrawHUD(spriteBatch, transducerCenter, displayScale, DisplayRadius, center);
|
||||
steering?.DebugDrawHUD(spriteBatch, transducerCenter, DisplayScale, DisplayRadius, center);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawOwnSubmarineBorders(SpriteBatch spriteBatch, Vector2 transducerCenter, float signalStrength)
|
||||
{
|
||||
float simScale = displayScale * Physics.DisplayToSimRation * zoom;
|
||||
float simScale = DisplayScale * Physics.DisplayToSimRation;
|
||||
|
||||
foreach (Submarine submarine in Submarine.Loaded)
|
||||
{
|
||||
@@ -1167,7 +1175,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private void DrawDockingPorts(SpriteBatch spriteBatch, Vector2 transducerCenter, float signalStrength)
|
||||
{
|
||||
float scale = displayScale * zoom;
|
||||
float scale = DisplayScale;
|
||||
|
||||
Steering steering = item.GetComponent<Steering>();
|
||||
if (steering != null && steering.DockingModeEnabled && steering.ActiveDockingSource != null)
|
||||
@@ -1219,7 +1227,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private void DrawDockingIndicator(SpriteBatch spriteBatch, Steering steering, ref Vector2 transducerCenter)
|
||||
{
|
||||
float scale = displayScale * zoom;
|
||||
float scale = DisplayScale;
|
||||
|
||||
Vector2 worldFocusPos = (steering.ActiveDockingSource.Item.WorldPosition + steering.DockingTarget.Item.WorldPosition) / 2.0f;
|
||||
worldFocusPos.X = steering.DockingTarget.Item.WorldPosition.X;
|
||||
@@ -1591,7 +1599,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
lineStep /= zoom;
|
||||
zStep /= zoom;
|
||||
range *= displayScale;
|
||||
range *= DisplayScale;
|
||||
float length = (point1 - point2).Length();
|
||||
Vector2 lineDir = (point2 - point1) / length;
|
||||
for (float x = 0; x < length; x += lineStep * Rand.Range(0.8f, 1.2f))
|
||||
@@ -1602,12 +1610,12 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
//ignore if outside the display
|
||||
Vector2 transducerDiff = point - transducerPos;
|
||||
Vector2 transducerDisplayDiff = transducerDiff * displayScale;
|
||||
Vector2 transducerDisplayDiff = transducerDiff * DisplayScale / zoom;
|
||||
if (transducerDisplayDiff.LengthSquared() > DisplayRadius * DisplayRadius) { continue; }
|
||||
|
||||
//ignore if the point is not within the ping
|
||||
Vector2 pointDiff = point - pingSource;
|
||||
Vector2 displayPointDiff = pointDiff * displayScale;
|
||||
Vector2 displayPointDiff = pointDiff * DisplayScale / zoom;
|
||||
float displayPointDistSqr = displayPointDiff.LengthSquared();
|
||||
if (displayPointDistSqr < prevPingRadius * prevPingRadius || displayPointDistSqr > pingRadius * pingRadius) { continue; }
|
||||
|
||||
@@ -1628,9 +1636,9 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
float displayPointDist = (float)Math.Sqrt(displayPointDistSqr);
|
||||
float alpha = pingStrength * Rand.Range(1.5f, 2.0f);
|
||||
for (float z = 0; z < DisplayRadius - transducerDist * displayScale; z += zStep)
|
||||
for (float z = 0; z < DisplayRadius - transducerDist * DisplayScale; z += zStep)
|
||||
{
|
||||
Vector2 pos = point + Rand.Vector(150.0f / zoom) + pingDirection * z / displayScale;
|
||||
Vector2 pos = point + Rand.Vector(150.0f / zoom) + pingDirection * z / DisplayScale;
|
||||
float fadeTimer = alpha * (1.0f - displayPointDist / range);
|
||||
|
||||
if (needsToBeInSector != null)
|
||||
@@ -1697,7 +1705,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private bool CheckBlipVisibility(SonarBlip blip, Vector2 transducerPos)
|
||||
{
|
||||
Vector2 pos = (blip.Position - transducerPos) * displayScale * zoom;
|
||||
Vector2 pos = (blip.Position - transducerPos) * DisplayScale;
|
||||
pos.Y = -pos.Y;
|
||||
|
||||
float posDistSqr = pos.LengthSquared();
|
||||
@@ -1731,7 +1739,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
if (currentPingIndex != -1 && activePings[currentPingIndex].IsDirectional)
|
||||
{
|
||||
var pos = (resourcePos - transducerPos) * displayScale * zoom;
|
||||
var pos = (resourcePos - transducerPos) * DisplayScale;
|
||||
pos.Y = -pos.Y;
|
||||
var length = pos.Length();
|
||||
var dir = pos / length;
|
||||
@@ -1749,7 +1757,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
float distort = 1.0f - item.Condition / item.MaxCondition;
|
||||
|
||||
Vector2 pos = (blip.Position - transducerPos) * displayScale * zoom;
|
||||
Vector2 pos = (blip.Position - transducerPos) * DisplayScale;
|
||||
pos.Y = -pos.Y;
|
||||
|
||||
if (Rand.Range(0.5f, 2.0f) < distort) { pos.X = -pos.X; }
|
||||
@@ -1825,14 +1833,13 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
Vector2 position = worldPosition - transducerPosition;
|
||||
|
||||
position *= zoom;
|
||||
position *= scale;
|
||||
position.Y = -position.Y;
|
||||
|
||||
float textAlpha = MathHelper.Clamp(1.5f - dist / 50000.0f, 0.5f, 1.0f);
|
||||
|
||||
Vector2 dir = Vector2.Normalize(position);
|
||||
Vector2 markerPos = (linearDist * zoom * scale > radius) ? dir * radius : position;
|
||||
Vector2 markerPos = (linearDist * scale > radius) ? dir * radius : position;
|
||||
markerPos += center;
|
||||
|
||||
markerPos.X = (int)markerPos.X;
|
||||
|
||||
@@ -589,7 +589,8 @@ namespace Barotrauma.Items.Components
|
||||
Sonar sonar = item.GetComponent<Sonar>();
|
||||
if (sonar != null && controlledSub != null)
|
||||
{
|
||||
Vector2 displayPosToMaintain = ((posToMaintain.Value - controlledSub.WorldPosition)) / sonar.Range * sonar.DisplayRadius * sonar.Zoom;
|
||||
Vector2 displayPosToMaintain = ((posToMaintain.Value - controlledSub.WorldPosition)) * sonar.DisplayScale;
|
||||
|
||||
displayPosToMaintain.Y = -displayPosToMaintain.Y;
|
||||
displayPosToMaintain = displayPosToMaintain.ClampLength(velRect.Width / 2);
|
||||
displayPosToMaintain = steerArea.Rect.Center.ToVector2() + displayPosToMaintain;
|
||||
@@ -670,14 +671,14 @@ namespace Barotrauma.Items.Components
|
||||
pos2.Y = -pos2.Y;
|
||||
pos2 += center;
|
||||
|
||||
GUI.DrawLine(spriteBatch,
|
||||
pos1,
|
||||
GUI.DrawLine(spriteBatch,
|
||||
pos1,
|
||||
pos2,
|
||||
GUIStyle.Red * 0.6f, width: 3);
|
||||
|
||||
if (obstacle.Intersection.HasValue)
|
||||
{
|
||||
Vector2 intersectionPos = (obstacle.Intersection.Value - transducerCenter) *displayScale;
|
||||
Vector2 intersectionPos = (obstacle.Intersection.Value - transducerCenter) * displayScale;
|
||||
intersectionPos.Y = -intersectionPos.Y;
|
||||
intersectionPos += center;
|
||||
GUI.DrawRectangle(spriteBatch, intersectionPos - Vector2.One * 2, Vector2.One * 4, GUIStyle.Red);
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace Barotrauma.Items.Components
|
||||
GUI.DrawLine(spriteBatch,
|
||||
new Vector2(debugRayStartPos.X, -debugRayStartPos.Y),
|
||||
new Vector2(debugRayEndPos.X, -debugRayEndPos.Y),
|
||||
Color.Yellow);
|
||||
Color.Yellow, width: 3f);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace Barotrauma.Items.Components
|
||||
resource = ItemPrefab.Prefabs[Tags.FPGACircuit];
|
||||
}
|
||||
|
||||
AddComponentInternal(ICircuitBoxIdentifiable.FindFreeID(Components), prefab, resource, pos, static delegate { });
|
||||
AddComponentInternal(ICircuitBoxIdentifiable.FindFreeID(Components), prefab, resource, pos, Character.Controlled, onItemSpawned: null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace Barotrauma.Items.Components
|
||||
MaxValueFloat = numberInputMax,
|
||||
FloatValue = Math.Clamp(floatSignal, numberInputMin, numberInputMax),
|
||||
DecimalsToDisplay = ciElement.NumberInputDecimalPlaces,
|
||||
valueStep = numberInputStep,
|
||||
ValueStep = numberInputStep,
|
||||
OnValueChanged = (ni) =>
|
||||
{
|
||||
if (GameMain.Client == null)
|
||||
@@ -121,7 +121,7 @@ namespace Barotrauma.Items.Components
|
||||
MinValueInt = numberInputMin,
|
||||
MaxValueInt = numberInputMax,
|
||||
IntValue = Math.Clamp(intSignal, numberInputMin, numberInputMax),
|
||||
valueStep = numberInputStep,
|
||||
ValueStep = numberInputStep,
|
||||
OnValueChanged = (ni) =>
|
||||
{
|
||||
if (GameMain.Client == null)
|
||||
@@ -137,7 +137,8 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.LogError($"Error creating a CustomInterface component: unexpected NumberType \"{(ciElement.NumberType.HasValue ? ciElement.NumberType.Value.ToString() : "none")}\"");
|
||||
DebugConsole.LogError($"Error creating a CustomInterface component: unexpected NumberType \"{(ciElement.NumberType.HasValue ? ciElement.NumberType.Value.ToString() : "none")}\"",
|
||||
contentPackage: item.Prefab.ContentPackage);
|
||||
}
|
||||
if (numberInput != null)
|
||||
{
|
||||
|
||||
@@ -349,8 +349,8 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
GUI.DrawString(spriteBatch, hudPos, texts[0].Value, textColors[0] * alpha, Color.Black * 0.7f * alpha, 2, GUIStyle.SubHeadingFont, ForceUpperCase.No);
|
||||
hudPos.X += 5.0f;
|
||||
hudPos.Y += 24.0f * GameSettings.CurrentConfig.Graphics.TextScale;
|
||||
hudPos.X += 5.0f * GUI.Scale;
|
||||
hudPos.Y += GUIStyle.SubHeadingFont.MeasureString(texts[0].Value).Y;
|
||||
|
||||
hudPos.X = (int)hudPos.X;
|
||||
hudPos.Y = (int)hudPos.Y;
|
||||
@@ -358,7 +358,7 @@ namespace Barotrauma.Items.Components
|
||||
for (int i = 1; i < texts.Count; i++)
|
||||
{
|
||||
GUI.DrawString(spriteBatch, hudPos, texts[i], textColors[i] * alpha, Color.Black * 0.7f * alpha, 2, GUIStyle.SmallFont);
|
||||
hudPos.Y += (int)(18.0f * GameSettings.CurrentConfig.Graphics.TextScale);
|
||||
hudPos.Y += (int)(GUIStyle.SubHeadingFont.MeasureString(texts[i].Value).Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
LocalizedString description = item.Description;
|
||||
if (item.HasTag(Tags.IdCard) || item.HasTag(Tags.DespawnContainer))
|
||||
if (item.HasTag(Tags.IdCardTag) || item.HasTag(Tags.DespawnContainer))
|
||||
{
|
||||
string[] readTags = item.Tags.Split(',');
|
||||
string idName = null;
|
||||
@@ -1505,14 +1505,28 @@ namespace Barotrauma
|
||||
int stackAmount = DraggingItems.Count;
|
||||
if (selectedSlot?.ParentInventory != null)
|
||||
{
|
||||
stackAmount = Math.Min(
|
||||
stackAmount,
|
||||
selectedSlot.ParentInventory.HowManyCanBePut(draggedItem.Prefab, selectedSlot.SlotIndex, draggedItem.Condition));
|
||||
if (selectedSlot.Item?.OwnInventory != null)
|
||||
{
|
||||
int maxAmountPerSlot = 0;
|
||||
for (int i = 0; i < SelectedSlot.Item.OwnInventory.Capacity; i++)
|
||||
{
|
||||
maxAmountPerSlot = Math.Max(
|
||||
maxAmountPerSlot,
|
||||
selectedSlot.Item.OwnInventory.HowManyCanBePut(draggedItem.Prefab, i, draggedItem.Condition, ignoreItemsInSlot: true));
|
||||
}
|
||||
stackAmount = Math.Min(stackAmount, maxAmountPerSlot);
|
||||
}
|
||||
else
|
||||
{
|
||||
stackAmount = Math.Min(
|
||||
stackAmount,
|
||||
selectedSlot.ParentInventory.HowManyCanBePut(draggedItem.Prefab, selectedSlot.SlotIndex, draggedItem.Condition, ignoreItemsInSlot: true));
|
||||
}
|
||||
}
|
||||
Vector2 stackCountPos = itemPos + Vector2.One * iconSize * 0.25f;
|
||||
string stackCountText = "x" + stackAmount;
|
||||
GUIStyle.SmallFont.DrawString(spriteBatch, stackCountText, stackCountPos + Vector2.One, Color.Black);
|
||||
GUIStyle.SmallFont.DrawString(spriteBatch, stackCountText, stackCountPos, GUIStyle.TextColorBright);
|
||||
GUIStyle.SmallFont.DrawString(spriteBatch, stackCountText, stackCountPos, GUIStyle.TextColorBright);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1908,6 +1922,15 @@ namespace Barotrauma
|
||||
foreach (UInt16 id in receivedItemIDs[i])
|
||||
{
|
||||
if (Entity.FindEntityByID(id) is not Item item || slots[i].Contains(item)) { continue; }
|
||||
|
||||
if (Owner is Item thisItem && thisItem.Container == item)
|
||||
{
|
||||
//if this item is inside the item we're trying to contain inside it, we need to drop it (both items can't be inside each other!)
|
||||
//can happen when a player swaps the items to be "the other way around", and we receive a message about the contained item
|
||||
//before the message about the "parent item" being placed in some other inventory (like the player's inventory)
|
||||
thisItem.Drop(null);
|
||||
}
|
||||
|
||||
if (!TryPutItem(item, i, false, false, null, false))
|
||||
{
|
||||
ForceToSlot(item, i);
|
||||
|
||||
@@ -132,9 +132,9 @@ namespace Barotrauma
|
||||
return GetDrawDepth(SpriteDepth + DrawDepthOffset, Sprite);
|
||||
}
|
||||
|
||||
public Color GetSpriteColor(bool withHighlight = false)
|
||||
public Color GetSpriteColor(Color? defaultColor = null, bool withHighlight = false)
|
||||
{
|
||||
Color color = spriteColor;
|
||||
Color color = defaultColor ?? spriteColor;
|
||||
if (Prefab.UseContainedSpriteColor && ownInventory != null)
|
||||
{
|
||||
foreach (Item item in ContainedItems)
|
||||
@@ -333,9 +333,7 @@ namespace Barotrauma
|
||||
else if (!ShowItems) { return; }
|
||||
}
|
||||
|
||||
Color color =
|
||||
overrideColor ??
|
||||
(IsIncludedInSelection && editing ? GUIStyle.Blue : GetSpriteColor(withHighlight: true));
|
||||
Color color = GetSpriteColor(spriteColor);
|
||||
|
||||
bool isWiringMode = editing && SubEditorScreen.TransparentWiringMode && SubEditorScreen.IsWiringMode() && !isWire && parentInventory == null;
|
||||
bool renderTransparent = isWiringMode && GetComponent<ConnectionPanel>() == null;
|
||||
@@ -406,12 +404,14 @@ namespace Barotrauma
|
||||
foreach (var decorativeSprite in Prefab.DecorativeSprites)
|
||||
{
|
||||
if (!spriteAnimState[decorativeSprite].IsActive) { continue; }
|
||||
|
||||
Color decorativeSpriteColor = GetSpriteColor(decorativeSprite.Color);
|
||||
Vector2 offset = decorativeSprite.GetOffset(ref spriteAnimState[decorativeSprite].OffsetState, spriteAnimState[decorativeSprite].RandomOffsetMultiplier, flippedX && Prefab.CanSpriteFlipX ? RotationRad : -RotationRad) * Scale;
|
||||
if (flippedX && Prefab.CanSpriteFlipX) { offset.X = -offset.X; }
|
||||
if (flippedY && Prefab.CanSpriteFlipY) { offset.Y = -offset.Y; }
|
||||
decorativeSprite.Sprite.DrawTiled(spriteBatch,
|
||||
new Vector2(DrawPosition.X + offset.X - rect.Width / 2, -(DrawPosition.Y + offset.Y + rect.Height / 2)),
|
||||
size, color: color,
|
||||
size, color: decorativeSpriteColor,
|
||||
textureScale: Vector2.One * Scale,
|
||||
depth: Math.Min(depth + (decorativeSprite.Sprite.Depth - activeSprite.Depth), 0.999f));
|
||||
}
|
||||
@@ -437,13 +437,15 @@ namespace Barotrauma
|
||||
foreach (var decorativeSprite in Prefab.DecorativeSprites)
|
||||
{
|
||||
if (!spriteAnimState[decorativeSprite].IsActive) { continue; }
|
||||
|
||||
Color decorativeSpriteColor = GetSpriteColor(decorativeSprite.Color);
|
||||
float rot = decorativeSprite.GetRotation(ref spriteAnimState[decorativeSprite].RotationState, spriteAnimState[decorativeSprite].RandomRotationFactor);
|
||||
bool flipX = flippedX && Prefab.CanSpriteFlipX;
|
||||
bool flipY = flippedY && Prefab.CanSpriteFlipY;
|
||||
Vector2 offset = decorativeSprite.GetOffset(ref spriteAnimState[decorativeSprite].OffsetState, spriteAnimState[decorativeSprite].RandomOffsetMultiplier, flipX ^ flipY ? RotationRad : -RotationRad) * Scale;
|
||||
if (flipX) { offset.X = -offset.X; }
|
||||
if (flipY) { offset.Y = -offset.Y; }
|
||||
decorativeSprite.Sprite.Draw(spriteBatch, new Vector2(DrawPosition.X + offset.X, -(DrawPosition.Y + offset.Y)), color,
|
||||
decorativeSprite.Sprite.Draw(spriteBatch, new Vector2(DrawPosition.X + offset.X, -(DrawPosition.Y + offset.Y)), decorativeSpriteColor,
|
||||
RotationRad + rot, decorativeSprite.GetScale(spriteAnimState[decorativeSprite].RandomScaleFactor) * Scale, activeSprite.effects,
|
||||
depth: Math.Min(depth + (decorativeSprite.Sprite.Depth - activeSprite.Depth), 0.999f));
|
||||
}
|
||||
@@ -618,6 +620,13 @@ namespace Barotrauma
|
||||
}
|
||||
return origin;
|
||||
}
|
||||
|
||||
Color GetSpriteColor(Color defaultColor)
|
||||
{
|
||||
return
|
||||
overrideColor ??
|
||||
(IsIncludedInSelection && editing ? GUIStyle.Blue : this.GetSpriteColor(defaultColor: defaultColor, withHighlight: true));
|
||||
}
|
||||
}
|
||||
|
||||
partial void OnCollisionProjSpecific(float impact)
|
||||
@@ -852,7 +861,7 @@ namespace Barotrauma
|
||||
CanBeFocused = true
|
||||
};
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(0.23f, 1.0f), buttonContainer.RectTransform), TextManager.Get("MirrorEntityX"), style: "GUIButtonSmall")
|
||||
var mirrorX = new GUIButton(new RectTransform(new Vector2(0.23f, 1.0f), buttonContainer.RectTransform), TextManager.Get("MirrorEntityX"), style: "GUIButtonSmall")
|
||||
{
|
||||
ToolTip = TextManager.Get("MirrorEntityXToolTip"),
|
||||
Enabled = Prefab.CanFlipX,
|
||||
@@ -863,10 +872,12 @@ namespace Barotrauma
|
||||
me.FlipX(relativeToSub: false);
|
||||
}
|
||||
if (!SelectedList.Contains(this)) { FlipX(relativeToSub: false); }
|
||||
ColorFlipButton(button, FlippedX);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
new GUIButton(new RectTransform(new Vector2(0.23f, 1.0f), buttonContainer.RectTransform), TextManager.Get("MirrorEntityY"), style: "GUIButtonSmall")
|
||||
ColorFlipButton(mirrorX, FlippedX);
|
||||
var mirrorY = new GUIButton(new RectTransform(new Vector2(0.23f, 1.0f), buttonContainer.RectTransform), TextManager.Get("MirrorEntityY"), style: "GUIButtonSmall")
|
||||
{
|
||||
ToolTip = TextManager.Get("MirrorEntityYToolTip"),
|
||||
Enabled = Prefab.CanFlipY,
|
||||
@@ -877,9 +888,11 @@ namespace Barotrauma
|
||||
me.FlipY(relativeToSub: false);
|
||||
}
|
||||
if (!SelectedList.Contains(this)) { FlipY(relativeToSub: false); }
|
||||
ColorFlipButton(button, FlippedY);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
ColorFlipButton(mirrorY, FlippedY);
|
||||
if (Sprite != null)
|
||||
{
|
||||
var reloadTextureButton = new GUIButton(new RectTransform(new Vector2(0.23f, 1.0f), buttonContainer.RectTransform), TextManager.Get("ReloadSprite"), style: "GUIButtonSmall");
|
||||
|
||||
@@ -321,10 +321,8 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ResizeHorizontal)
|
||||
placeSize.X = Math.Max(position.X - placePosition.X, Size.X);
|
||||
if (ResizeVertical)
|
||||
placeSize.Y = Math.Max(placePosition.Y - position.Y, Size.Y);
|
||||
if (ResizeHorizontal) { placeSize.X = Math.Max(position.X - placePosition.X, Size.X); }
|
||||
if (ResizeVertical) { placeSize.Y = Math.Max(placePosition.Y - position.Y, Size.Y); }
|
||||
|
||||
if (PlayerInput.PrimaryMouseButtonReleased())
|
||||
{
|
||||
@@ -369,15 +367,23 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawPlacing(SpriteBatch spriteBatch, Rectangle placeRect, float scale = 1.0f, SpriteEffects spriteEffects = SpriteEffects.None)
|
||||
public override void DrawPlacing(SpriteBatch spriteBatch, Rectangle placeRect, float scale = 1.0f, float rotation = 0.0f, SpriteEffects spriteEffects = SpriteEffects.None)
|
||||
{
|
||||
if (!ResizeHorizontal && !ResizeVertical)
|
||||
{
|
||||
Sprite.Draw(spriteBatch, new Vector2(placeRect.Center.X, -(placeRect.Y - placeRect.Height / 2)), SpriteColor * 0.8f, scale: scale);
|
||||
sprite.Draw(spriteBatch, new Vector2(placeRect.Center.X, -(placeRect.Y - placeRect.Height / 2)), SpriteColor * 0.8f, scale: scale, rotate: rotation);
|
||||
}
|
||||
else
|
||||
{
|
||||
Sprite.DrawTiled(spriteBatch, new Vector2(placeRect.X, -placeRect.Y), placeRect.Size.ToVector2(), SpriteColor * 0.8f);
|
||||
Vector2 position = placeRect.Location.ToVector2();
|
||||
Vector2 placeSize = placeRect.Size.ToVector2();
|
||||
sprite?.DrawTiled(
|
||||
spriteBatch,
|
||||
new Vector2(position.X, -position.Y),
|
||||
placeSize,
|
||||
rotation: rotation,
|
||||
textureScale: Vector2.One * scale,
|
||||
color: SpriteColor * 0.8f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -277,12 +277,21 @@ namespace Barotrauma
|
||||
Rectangle drawRect =
|
||||
Submarine == null ? rect : new Rectangle((int)(Submarine.DrawPosition.X + rect.X), (int)(Submarine.DrawPosition.Y + rect.Y), rect.Width, rect.Height);
|
||||
|
||||
if ((IsSelected || IsHighlighted) && editing)
|
||||
if (editing)
|
||||
{
|
||||
if (IsSelected || IsHighlighted)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2(drawRect.X, -drawRect.Y),
|
||||
new Vector2(rect.Width, rect.Height),
|
||||
(IsHighlighted ? Color.LightBlue * 0.8f : GUIStyle.Red * 0.5f) * alpha, false, 0, (int)Math.Max(5.0f / Screen.Selected.Cam.Zoom, 1.0f));
|
||||
}
|
||||
|
||||
float waterHeight = WaterVolume / rect.Width;
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2(drawRect.X, -drawRect.Y),
|
||||
new Vector2(rect.Width, rect.Height),
|
||||
(IsHighlighted ? Color.LightBlue * 0.8f : GUIStyle.Red * 0.5f) * alpha, false, 0, (int)Math.Max(5.0f / Screen.Selected.Cam.Zoom, 1.0f));
|
||||
new Vector2(drawRect.X, -drawRect.Y + drawRect.Height - waterHeight),
|
||||
new Vector2(drawRect.Width, waterHeight),
|
||||
Color.Blue * 0.25f, isFilled: true);
|
||||
}
|
||||
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
@@ -300,13 +309,27 @@ namespace Barotrauma
|
||||
" - Oxygen: " + ((int)OxygenPercentage), new Vector2(drawRect.X + 5, -drawRect.Y + 5), Color.White);
|
||||
GUIStyle.SmallFont.DrawString(spriteBatch, waterVolume + " / " + Volume, new Vector2(drawRect.X + 5, -drawRect.Y + 20), Color.White);
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(drawRect.Center.X, -drawRect.Y + drawRect.Height / 2, 10, (int)(100 * Math.Min(waterVolume / Volume, 1.0f))), Color.Cyan, true);
|
||||
if (WaterVolume > Volume)
|
||||
if (WaterVolume > 0)
|
||||
{
|
||||
float maxExcessWater = Volume * MaxCompress;
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(drawRect.Center.X, -drawRect.Y + drawRect.Height / 2, 10, (int)(100 * (waterVolume - Volume) / maxExcessWater)), GUIStyle.Red, true);
|
||||
drawProgressBar(50, new Point(0, 0), Math.Min(waterVolume / Volume, 1.0f), Color.Cyan);
|
||||
if (WaterVolume > Volume)
|
||||
{
|
||||
float maxExcessWater = Volume * MaxCompress;
|
||||
drawProgressBar(50, new Point(0, 0), (waterVolume - Volume) / maxExcessWater, GUIStyle.Red);
|
||||
}
|
||||
}
|
||||
if (lethalPressure > 0)
|
||||
{
|
||||
drawProgressBar(50, new Point(20, 0), lethalPressure / 100.0f, Color.Red);
|
||||
}
|
||||
|
||||
void drawProgressBar(int height, Point offset, float fillAmount, Color color)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(drawRect.Center.X - 2 + offset.X, -drawRect.Y - 2 + drawRect.Height / 2 + offset.Y, 14, height+4), Color.Black * 0.8f, depth: 0.01f, isFilled: true);
|
||||
|
||||
int barHeight = (int)(fillAmount * height);
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(drawRect.Center.X + offset.X, -drawRect.Y + drawRect.Height / 2 + height - barHeight + offset.Y, 10, barHeight), color, isFilled: true);
|
||||
}
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(drawRect.Center.X, -drawRect.Y + drawRect.Height / 2, 10, 100), Color.Black);
|
||||
|
||||
foreach (FireSource fs in FireSources)
|
||||
{
|
||||
@@ -732,7 +755,7 @@ namespace Barotrauma
|
||||
|
||||
var newFire = i < FireSources.Count ?
|
||||
FireSources[i] :
|
||||
new FireSource(Submarine == null ? pos : pos + Submarine.Position, null, true);
|
||||
new FireSource(Submarine == null ? pos : pos + Submarine.Position, sourceCharacter: null, isNetworkMessage: true);
|
||||
newFire.Position = pos;
|
||||
newFire.Size = new Vector2(size, newFire.Size.Y);
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Barotrauma
|
||||
{
|
||||
mainElement = mainElement.FirstElement();
|
||||
prefabs.Clear();
|
||||
DebugConsole.NewMessage($"Overriding all background creatures with '{configPath}'", Color.Yellow);
|
||||
DebugConsole.NewMessage($"Overriding all background creatures with '{configPath}'", Color.MediumPurple);
|
||||
}
|
||||
else if (prefabs.Any())
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Barotrauma
|
||||
foreach (InterestingPosition pos in PositionsOfInterest)
|
||||
{
|
||||
Color color = Color.Yellow;
|
||||
if (pos.PositionType == PositionType.Cave)
|
||||
if (pos.PositionType == PositionType.Cave || pos.PositionType == PositionType.AbyssCave)
|
||||
{
|
||||
color = Color.DarkOrange;
|
||||
}
|
||||
@@ -61,6 +61,10 @@ namespace Barotrauma
|
||||
{
|
||||
color = Color.LightGray;
|
||||
}
|
||||
if (!pos.IsValid)
|
||||
{
|
||||
color = Color.Red;
|
||||
}
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, new Vector2(pos.Position.X - 15.0f, -pos.Position.Y - 15.0f), new Vector2(30.0f, 30.0f), color, true);
|
||||
}
|
||||
|
||||
@@ -1318,7 +1318,7 @@ namespace Barotrauma.Lights
|
||||
|
||||
if (LightTextureTargetSize != Vector2.Zero)
|
||||
{
|
||||
LightSprite.DrawTiled(spriteBatch, drawPos, LightTextureTargetSize, color, startOffset: LightTextureOffset, textureScale: LightTextureScale);
|
||||
LightSprite.DrawTiled(spriteBatch, drawPos, LightTextureTargetSize, color: color, startOffset: LightTextureOffset, textureScale: LightTextureScale);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Barotrauma
|
||||
|
||||
Vector2 spriteScale = new Vector2(zoom);
|
||||
|
||||
uiSprite.Sprite.DrawTiled(spriteBatch, topLeft, size, Params.RadiationAreaColor, Vector2.Zero, textureScale: spriteScale);
|
||||
uiSprite.Sprite.DrawTiled(spriteBatch, topLeft, size, color: Params.RadiationAreaColor, startOffset: Vector2.Zero, textureScale: spriteScale);
|
||||
|
||||
Vector2 topRight = topLeft + Vector2.UnitX * size.X;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using Barotrauma.Lights;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -65,9 +66,7 @@ namespace Barotrauma
|
||||
disableSelect = value;
|
||||
if (disableSelect)
|
||||
{
|
||||
startMovingPos = Vector2.Zero;
|
||||
selectionSize = Vector2.Zero;
|
||||
selectionPos = Vector2.Zero;
|
||||
StopSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -494,6 +493,13 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public static void StopSelection()
|
||||
{
|
||||
startMovingPos = Vector2.Zero;
|
||||
selectionSize = Vector2.Zero;
|
||||
selectionPos = Vector2.Zero;
|
||||
}
|
||||
|
||||
public static Vector2 GetNudgeAmount(bool doHold = true)
|
||||
{
|
||||
Vector2 nudgeAmount = Vector2.Zero;
|
||||
@@ -792,12 +798,16 @@ namespace Barotrauma
|
||||
foreach (MapEntity e in SelectedList)
|
||||
{
|
||||
SpriteEffects spriteEffects = SpriteEffects.None;
|
||||
float spriteRotation = 0.0f;
|
||||
float rectangleRotation = 0.0f;
|
||||
switch (e)
|
||||
{
|
||||
case Item item:
|
||||
{
|
||||
if (item.FlippedX && item.Prefab.CanSpriteFlipX) { spriteEffects ^= SpriteEffects.FlipHorizontally; }
|
||||
if (item.flippedY && item.Prefab.CanSpriteFlipY) { spriteEffects ^= SpriteEffects.FlipVertically; }
|
||||
if (item.FlippedY && item.Prefab.CanSpriteFlipY) { spriteEffects ^= SpriteEffects.FlipVertically; }
|
||||
spriteRotation = MathHelper.ToRadians(item.Rotation);
|
||||
rectangleRotation = spriteRotation;
|
||||
var wire = item.GetComponent<Wire>();
|
||||
if (wire != null && wire.Item.body != null && !wire.Item.body.Enabled)
|
||||
{
|
||||
@@ -809,7 +819,10 @@ namespace Barotrauma
|
||||
case Structure structure:
|
||||
{
|
||||
if (structure.FlippedX && structure.Prefab.CanSpriteFlipX) { spriteEffects ^= SpriteEffects.FlipHorizontally; }
|
||||
if (structure.flippedY && structure.Prefab.CanSpriteFlipY) { spriteEffects ^= SpriteEffects.FlipVertically; }
|
||||
if (structure.FlippedY && structure.Prefab.CanSpriteFlipY) { spriteEffects ^= SpriteEffects.FlipVertically; }
|
||||
spriteRotation = MathHelper.ToRadians(structure.Rotation);
|
||||
rectangleRotation = spriteRotation;
|
||||
if (structure.FlippedX != structure.FlippedY) { rectangleRotation = -rectangleRotation; }
|
||||
break;
|
||||
}
|
||||
case WayPoint wayPoint:
|
||||
@@ -831,11 +844,12 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
e.Prefab?.DrawPlacing(spriteBatch,
|
||||
new Rectangle(e.WorldRect.Location + new Point((int)moveAmount.X, (int)-moveAmount.Y), e.WorldRect.Size), e.Scale, spriteEffects);
|
||||
new Rectangle(e.WorldRect.Location + new Point((int)moveAmount.X, (int)-moveAmount.Y), e.WorldRect.Size), e.Scale, spriteRotation, spriteEffects: spriteEffects);
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2(e.WorldRect.X, -e.WorldRect.Y) + moveAmount,
|
||||
new Vector2(e.rect.Width, e.rect.Height),
|
||||
Color.White, false, 0, (int)Math.Max(3.0f / GameScreen.Selected.Cam.Zoom, 2.0f));
|
||||
center: e.WorldRect.Center.ToVector2().FlipY() + moveAmount + new Vector2(0f, e.WorldRect.Height),
|
||||
width: e.WorldRect.Width, height: e.WorldRect.Height,
|
||||
rotation: rectangleRotation, clr: Color.White,
|
||||
depth: 0f, thickness: Math.Max(3.0f / GameScreen.Selected.Cam.Zoom, 2.0f));
|
||||
}
|
||||
|
||||
//stop dragging the "selection rectangle"
|
||||
@@ -877,6 +891,23 @@ namespace Barotrauma
|
||||
spriteBatch.DrawLine(corners[3] + offset, corners[0] - offset, color, thickness);
|
||||
}
|
||||
|
||||
protected static void ColorFlipButton(GUIButton btn, bool flip)
|
||||
{
|
||||
var color = flip ? GUIStyle.Green : Color.White;
|
||||
var hsv = ToolBox.RGBToHSV(color);
|
||||
|
||||
// Boost saturation and reduce value a bit because our default colors are too muted for this button's style
|
||||
var hsvBase = hsv;
|
||||
hsvBase.Y *= 4f;
|
||||
hsvBase.Z *= 0.8f;
|
||||
btn.Color = ToolBox.HSVToRGB(hsvBase.X, hsvBase.Y, hsvBase.Z);
|
||||
btn.SelectedColor = ToolBox.HSVToRGB(hsvBase.X, hsvBase.Y, hsvBase.Z);
|
||||
|
||||
var hsvHover = hsv;
|
||||
hsvHover.Z *= 1.2f;
|
||||
btn.HoverColor = ToolBox.HSVToRGB(hsvHover.X, hsvHover.Y, hsvHover.Z);
|
||||
}
|
||||
|
||||
public static List<MapEntity> FilteredSelectedList { get; private set; } = new List<MapEntity>();
|
||||
|
||||
public static void UpdateEditor(Camera cam, float deltaTime)
|
||||
@@ -1105,6 +1136,25 @@ namespace Barotrauma
|
||||
|
||||
public virtual void DrawEditing(SpriteBatch spriteBatch, Camera cam) { }
|
||||
|
||||
private float RotationRad
|
||||
=> MathHelper.ToRadians(
|
||||
this switch
|
||||
{
|
||||
Structure s => s.Rotation,
|
||||
Item it => it.Rotation,
|
||||
_ => 0.0f
|
||||
});
|
||||
|
||||
private Vector2 GetEditingHandlePos(int x, int y, Camera cam)
|
||||
{
|
||||
Vector2 handleDiff = new Vector2(x * (rect.Width * 0.5f), y * (rect.Height * 0.5f));
|
||||
var rotation = -RotationRad;
|
||||
handleDiff = MathUtils.RotatePoint(handleDiff, rotation);
|
||||
if (FlippedX) { handleDiff = handleDiff.FlipX(); }
|
||||
if (FlippedY) { handleDiff = handleDiff.FlipY(); }
|
||||
return cam.WorldToScreen(Position + handleDiff);
|
||||
}
|
||||
|
||||
float ResizeHandleSize => 10 * GUI.Scale;
|
||||
float ResizeHandleHighlightDistance => 8 * GUI.Scale;
|
||||
|
||||
@@ -1119,9 +1169,10 @@ namespace Barotrauma
|
||||
{
|
||||
for (int y = startY; y < 2; y += 2)
|
||||
{
|
||||
Vector2 handlePos = cam.WorldToScreen(Position + new Vector2(x * (rect.Width * 0.5f), y * (rect.Height * 0.5f)));
|
||||
Vector2 handlePos = GetEditingHandlePos(x, y, cam);
|
||||
|
||||
bool highlighted = Vector2.DistanceSquared(PlayerInput.MousePosition, handlePos) < ResizeHandleHighlightDistance * ResizeHandleHighlightDistance;
|
||||
|
||||
if (highlighted && PlayerInput.PrimaryMouseButtonDown())
|
||||
{
|
||||
selectionPos = Vector2.Zero;
|
||||
@@ -1138,44 +1189,83 @@ namespace Barotrauma
|
||||
{
|
||||
if (prevRect == null)
|
||||
{
|
||||
prevRect = new Rectangle(Rect.Location, Rect.Size);
|
||||
prevRect = Rect;
|
||||
}
|
||||
|
||||
Vector2 placePosition = new Vector2(rect.X, rect.Y);
|
||||
Vector2 placeSize = new Vector2(rect.Width, rect.Height);
|
||||
Vector2 placePosition = prevRect.Value.Location.ToVector2();
|
||||
Vector2 placeSize = prevRect.Value.Size.ToVector2();
|
||||
|
||||
Vector2 mousePos = Submarine.MouseToWorldGrid(cam, Submarine.MainSub, round: true);
|
||||
|
||||
if (PlayerInput.IsShiftDown())
|
||||
static Vector2 flipThenRotate(Vector2 point, Vector2 center, float angle, bool flipX, bool flipY)
|
||||
{
|
||||
mousePos = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
if (flipX) { point = (point - center).FlipX() + center; }
|
||||
if (flipY) { point = (point - center).FlipY() + center; }
|
||||
|
||||
point = MathUtils.RotatePointAroundTarget(point, center, angle);
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
static Vector2 rotateThenFlip(Vector2 point, Vector2 center, float angle, bool flipX, bool flipY)
|
||||
{
|
||||
point = MathUtils.RotatePointAroundTarget(point, center, angle);
|
||||
|
||||
if (flipX) { point = (point - center).FlipX() + center; }
|
||||
if (flipY) { point = (point - center).FlipY() + center; }
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
Vector2 mousePos = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
Vector2 prevPos = placePosition;
|
||||
Vector2 prevOppositeCorner = prevPos + placeSize.FlipY();
|
||||
Vector2 prevCenter = placePosition + placeSize.FlipY() * 0.5f;
|
||||
mousePos = flipThenRotate(mousePos, prevCenter, RotationRad, FlippedX, FlippedY);
|
||||
|
||||
if (!PlayerInput.IsShiftDown())
|
||||
{
|
||||
mousePos = Submarine.VectorToWorldGrid(mousePos, Submarine.MainSub, round: true);
|
||||
}
|
||||
|
||||
if (resizeDirX > 0)
|
||||
{
|
||||
mousePos.X = Math.Max(mousePos.X, rect.X + Submarine.GridSize.X);
|
||||
mousePos.X = Math.Max(mousePos.X, prevRect.Value.X + Submarine.GridSize.X);
|
||||
placeSize.X = mousePos.X - placePosition.X;
|
||||
}
|
||||
else if (resizeDirX < 0)
|
||||
{
|
||||
mousePos.X = Math.Min(mousePos.X, rect.Right - Submarine.GridSize.X);
|
||||
mousePos.X = Math.Min(mousePos.X, prevRect.Value.Right - Submarine.GridSize.X);
|
||||
|
||||
placeSize.X = MathF.Round((placePosition.X + placeSize.X) - mousePos.X);
|
||||
placePosition.X = MathF.Round(mousePos.X);
|
||||
}
|
||||
if (resizeDirY < 0)
|
||||
{
|
||||
mousePos.Y = Math.Min(mousePos.Y, rect.Y - Submarine.GridSize.Y);
|
||||
mousePos.Y = Math.Min(mousePos.Y, prevRect.Value.Y - Submarine.GridSize.Y);
|
||||
placeSize.Y = placePosition.Y - mousePos.Y;
|
||||
}
|
||||
else if (resizeDirY > 0)
|
||||
{
|
||||
mousePos.Y = Math.Max(mousePos.Y, rect.Y - rect.Height + Submarine.GridSize.X);
|
||||
mousePos.Y = Math.Max(mousePos.Y, prevRect.Value.Y - prevRect.Value.Height + Submarine.GridSize.Y);
|
||||
|
||||
placeSize.Y = mousePos.Y - (rect.Y - rect.Height);
|
||||
placeSize.Y = mousePos.Y - (prevRect.Value.Y - prevRect.Value.Height);
|
||||
placePosition.Y = mousePos.Y;
|
||||
}
|
||||
|
||||
Vector2 newPos = placePosition;
|
||||
Vector2 newOppositeCorner = placePosition + placeSize.FlipY();
|
||||
|
||||
Vector2 transformedCornerDiff = rotateThenFlip(newPos-prevPos, Vector2.Zero, -RotationRad, FlippedX, FlippedY);
|
||||
Vector2 transformedOppositeCornerDiff = rotateThenFlip(newOppositeCorner-prevOppositeCorner, Vector2.Zero, -RotationRad, FlippedX, FlippedY);
|
||||
|
||||
Vector2 newPosTransformed = rotateThenFlip(prevPos, prevCenter, -RotationRad, FlippedX, FlippedY)
|
||||
+ transformedCornerDiff;
|
||||
Vector2 newOppositeTransformed = rotateThenFlip(prevOppositeCorner, prevCenter, -RotationRad, FlippedX, FlippedY)
|
||||
+ transformedOppositeCornerDiff;
|
||||
Vector2 newTransformedCenter = (newPosTransformed + newOppositeTransformed) * 0.5f;
|
||||
|
||||
var newDiff = (newOppositeCorner - newPos) * 0.5f;
|
||||
placePosition = newTransformedCenter - newDiff;
|
||||
|
||||
if ((int)placePosition.X != rect.X || (int)placePosition.Y != rect.Y || (int)placeSize.X != rect.Width || (int)placeSize.Y != rect.Height)
|
||||
{
|
||||
Rect = new Rectangle((int)placePosition.X, (int)placePosition.Y, (int)placeSize.X, (int)placeSize.Y);
|
||||
@@ -1210,15 +1300,16 @@ namespace Barotrauma
|
||||
IsHighlighted = true;
|
||||
|
||||
int startX = ResizeHorizontal ? -1 : 0;
|
||||
int StartY = ResizeVertical ? -1 : 0;
|
||||
int startY = ResizeVertical ? -1 : 0;
|
||||
|
||||
for (int x = startX; x < 2; x += 2)
|
||||
{
|
||||
for (int y = StartY; y < 2; y += 2)
|
||||
for (int y = startY; y < 2; y += 2)
|
||||
{
|
||||
Vector2 handlePos = cam.WorldToScreen(Position + new Vector2(x * (rect.Width * 0.5f), y * (rect.Height * 0.5f)));
|
||||
Vector2 handlePos = GetEditingHandlePos(x, y, cam);
|
||||
|
||||
bool highlighted = Vector2.DistanceSquared(PlayerInput.MousePosition, handlePos) < ResizeHandleHighlightDistance * ResizeHandleHighlightDistance;
|
||||
var color = Color.White * (highlighted ? 1.0f : 0.6f);
|
||||
if (highlighted && !PlayerInput.PrimaryMouseButtonHeld())
|
||||
{
|
||||
GUI.MouseCursor = CursorState.Hand;
|
||||
@@ -1226,7 +1317,7 @@ namespace Barotrauma
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
handlePos - new Vector2(ResizeHandleSize / 2),
|
||||
new Vector2(ResizeHandleSize),
|
||||
Color.White * (highlighted ? 1.0f : 0.6f),
|
||||
color,
|
||||
true, 0,
|
||||
(int)Math.Max(1.5f / GameScreen.Selected.Cam.Zoom, 1.0f));
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void DrawPlacing(SpriteBatch spriteBatch, Rectangle drawRect, float scale = 1.0f, SpriteEffects spriteEffects = SpriteEffects.None)
|
||||
public virtual void DrawPlacing(SpriteBatch spriteBatch, Rectangle drawRect, float scale = 1.0f, float rotation = 0.0f, SpriteEffects spriteEffects = SpriteEffects.None)
|
||||
{
|
||||
if (Submarine.MainSub != null)
|
||||
{
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#nullable enable
|
||||
using Barotrauma.Sounds;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Sounds;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -45,7 +44,8 @@ namespace Barotrauma
|
||||
}
|
||||
if (FrequencyMultiplierRange.Y > 4.0f)
|
||||
{
|
||||
DebugConsole.ThrowError($"Loaded frequency range exceeds max value: {FrequencyMultiplierRange} (original string was \"{freqMultAttr}\")");
|
||||
DebugConsole.ThrowError($"Loaded frequency range exceeds max value: {FrequencyMultiplierRange} (original string was \"{freqMultAttr}\")",
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
IgnoreMuffling = element.GetAttributeBool("dontmuffle", false);
|
||||
}
|
||||
@@ -65,7 +65,8 @@ namespace Barotrauma
|
||||
if (filename is null)
|
||||
{
|
||||
string errorMsg = "Error when loading round sound (" + element + ") - file path not set";
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
DebugConsole.ThrowError(errorMsg,
|
||||
contentPackage: element.ContentPackage);
|
||||
GameAnalyticsManager.AddErrorEventOnce("RoundSound.LoadRoundSound:FilePathEmpty" + element.ToString(), GameAnalyticsManager.ErrorSeverity.Error, errorMsg + "\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
return null;
|
||||
}
|
||||
@@ -86,7 +87,8 @@ namespace Barotrauma
|
||||
catch (System.IO.FileNotFoundException e)
|
||||
{
|
||||
string errorMsg = "Failed to load sound file \"" + filename + "\" (file not found).";
|
||||
DebugConsole.ThrowError(errorMsg, e);
|
||||
DebugConsole.ThrowError(errorMsg, e,
|
||||
contentPackage: element.ContentPackage);
|
||||
if (!ContentPackageManager.ModsEnabled)
|
||||
{
|
||||
GameAnalyticsManager.AddErrorEventOnce("RoundSound.LoadRoundSound:FileNotFound" + filename, GameAnalyticsManager.ErrorSeverity.Error, errorMsg + "\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
@@ -96,7 +98,8 @@ namespace Barotrauma
|
||||
catch (System.IO.InvalidDataException e)
|
||||
{
|
||||
string errorMsg = "Failed to load sound file \"" + filename + "\" (invalid data).";
|
||||
DebugConsole.ThrowError(errorMsg, e);
|
||||
DebugConsole.ThrowError(errorMsg, e,
|
||||
contentPackage: element.ContentPackage);
|
||||
GameAnalyticsManager.AddErrorEventOnce("RoundSound.LoadRoundSound:InvalidData" + filename, GameAnalyticsManager.ErrorSeverity.Error, errorMsg + "\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
return null;
|
||||
}
|
||||
@@ -123,7 +126,8 @@ namespace Barotrauma
|
||||
catch (System.IO.FileNotFoundException e)
|
||||
{
|
||||
string errorMsg = "Failed to load sound file \"" + roundSound.Filename + "\".";
|
||||
DebugConsole.ThrowError(errorMsg, e);
|
||||
DebugConsole.ThrowError(errorMsg, e,
|
||||
contentPackage: roundSound.Sound?.XElement?.ContentPackage);
|
||||
GameAnalyticsManager.AddErrorEventOnce("RoundSound.LoadRoundSound:FileNotFound" + roundSound.Filename, GameAnalyticsManager.ErrorSeverity.Error, errorMsg + "\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -150,7 +150,8 @@ namespace Barotrauma
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.01f
|
||||
};
|
||||
new GUIButton(new RectTransform(new Vector2(0.23f, 1.0f), buttonContainer.RectTransform), TextManager.Get("MirrorEntityX"), style: "GUIButtonSmall")
|
||||
|
||||
var mirrorX = new GUIButton(new RectTransform(new Vector2(0.23f, 1.0f), buttonContainer.RectTransform), TextManager.Get("MirrorEntityX"), style: "GUIButtonSmall")
|
||||
{
|
||||
ToolTip = TextManager.Get("MirrorEntityXToolTip"),
|
||||
OnClicked = (button, data) =>
|
||||
@@ -160,10 +161,12 @@ namespace Barotrauma
|
||||
me.FlipX(relativeToSub: false);
|
||||
}
|
||||
if (!SelectedList.Contains(this)) { FlipX(relativeToSub: false); }
|
||||
ColorFlipButton(button, FlippedX);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
new GUIButton(new RectTransform(new Vector2(0.23f, 1.0f), buttonContainer.RectTransform), TextManager.Get("MirrorEntityY"), style: "GUIButtonSmall")
|
||||
ColorFlipButton(mirrorX, FlippedX);
|
||||
var mirrorY = new GUIButton(new RectTransform(new Vector2(0.23f, 1.0f), buttonContainer.RectTransform), TextManager.Get("MirrorEntityY"), style: "GUIButtonSmall")
|
||||
{
|
||||
ToolTip = TextManager.Get("MirrorEntityYToolTip"),
|
||||
OnClicked = (button, data) =>
|
||||
@@ -173,9 +176,11 @@ namespace Barotrauma
|
||||
me.FlipY(relativeToSub: false);
|
||||
}
|
||||
if (!SelectedList.Contains(this)) { FlipY(relativeToSub: false); }
|
||||
ColorFlipButton(button, FlippedY);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
ColorFlipButton(mirrorY, FlippedY);
|
||||
new GUIButton(new RectTransform(new Vector2(0.23f, 1.0f), buttonContainer.RectTransform), TextManager.Get("ReloadSprite"), style: "GUIButtonSmall")
|
||||
{
|
||||
OnClicked = (button, data) =>
|
||||
@@ -357,8 +362,10 @@ namespace Barotrauma
|
||||
|
||||
Prefab.BackgroundSprite.DrawTiled(
|
||||
spriteBatch,
|
||||
new Vector2(rect.X + drawOffset.X, -(rect.Y + drawOffset.Y)),
|
||||
new Vector2(rect.X + rect.Width / 2 + drawOffset.X, -(rect.Y - rect.Height / 2 + drawOffset.Y)),
|
||||
new Vector2(rect.Width, rect.Height),
|
||||
rotation: rotationRad,
|
||||
origin: rect.Size.ToVector2() * new Vector2(0.5f, 0.5f),
|
||||
color: Prefab.BackgroundSpriteColor,
|
||||
textureScale: TextureScale * Scale,
|
||||
startOffset: backGroundOffset,
|
||||
@@ -368,8 +375,10 @@ namespace Barotrauma
|
||||
{
|
||||
Prefab.BackgroundSprite.DrawTiled(
|
||||
spriteBatch,
|
||||
new Vector2(rect.X + drawOffset.X, -(rect.Y + drawOffset.Y)) + dropShadowOffset,
|
||||
new Vector2(rect.X + rect.Width / 2 + drawOffset.X, -(rect.Y - rect.Height / 2 + drawOffset.Y)) + dropShadowOffset,
|
||||
new Vector2(rect.Width, rect.Height),
|
||||
rotation: rotationRad,
|
||||
origin: rect.Size.ToVector2() * new Vector2(0.5f, 0.5f),
|
||||
color: Color.Black * 0.5f,
|
||||
textureScale: TextureScale * Scale,
|
||||
startOffset: backGroundOffset,
|
||||
@@ -385,6 +394,13 @@ namespace Barotrauma
|
||||
SpriteEffects oldEffects = Prefab.Sprite.effects;
|
||||
Prefab.Sprite.effects ^= SpriteEffects;
|
||||
|
||||
Vector2 advanceX = MathUtils.RotatedUnitXRadians(this.rotationRad).FlipY();
|
||||
Vector2 advanceY = advanceX.YX().FlipX();
|
||||
if (FlippedX != FlippedY)
|
||||
{
|
||||
advanceX = advanceX.FlipY();
|
||||
advanceY = advanceY.FlipX();
|
||||
}
|
||||
for (int i = 0; i < Sections.Length; i++)
|
||||
{
|
||||
Rectangle drawSection = Sections[i].rect;
|
||||
@@ -409,7 +425,7 @@ namespace Barotrauma
|
||||
drawSection = new Rectangle(
|
||||
drawSection.X,
|
||||
drawSection.Y,
|
||||
Sections[Sections.Length -1 ].rect.Right - drawSection.X,
|
||||
Sections[Sections.Length - 1].rect.Right - drawSection.X,
|
||||
drawSection.Y - (Sections[Sections.Length - 1].rect.Y - Sections[Sections.Length - 1].rect.Height));
|
||||
i = Sections.Length;
|
||||
}
|
||||
@@ -424,10 +440,18 @@ namespace Barotrauma
|
||||
sectionOffset.X += MathUtils.PositiveModulo((int)-textureOffset.X, Prefab.Sprite.SourceRect.Width);
|
||||
sectionOffset.Y += MathUtils.PositiveModulo((int)-textureOffset.Y, Prefab.Sprite.SourceRect.Height);
|
||||
|
||||
Vector2 pos = new Vector2(drawSection.X, drawSection.Y);
|
||||
pos -= rect.Location.ToVector2();
|
||||
pos = advanceX * pos.X + advanceY * pos.Y;
|
||||
pos += rect.Location.ToVector2();
|
||||
pos = new Vector2(pos.X + rect.Width / 2 + drawOffset.X, -(pos.Y - rect.Height / 2 + drawOffset.Y));
|
||||
|
||||
Prefab.Sprite.DrawTiled(
|
||||
spriteBatch,
|
||||
new Vector2(drawSection.X + drawOffset.X, -(drawSection.Y + drawOffset.Y)),
|
||||
pos,
|
||||
new Vector2(drawSection.Width, drawSection.Height),
|
||||
rotation: rotationRad,
|
||||
origin: rect.Size.ToVector2() * new Vector2(0.5f, 0.5f),
|
||||
color: color,
|
||||
startOffset: sectionOffset,
|
||||
depth: depth,
|
||||
@@ -437,7 +461,7 @@ namespace Barotrauma
|
||||
foreach (var decorativeSprite in Prefab.DecorativeSprites)
|
||||
{
|
||||
if (!spriteAnimState[decorativeSprite].IsActive) { continue; }
|
||||
float rotation = decorativeSprite.GetRotation(ref spriteAnimState[decorativeSprite].RotationState, spriteAnimState[decorativeSprite].RandomRotationFactor);
|
||||
float rotation = decorativeSprite.GetRotation(ref spriteAnimState[decorativeSprite].RotationState, spriteAnimState[decorativeSprite].RandomRotationFactor) + this.rotationRad;
|
||||
Vector2 offset = decorativeSprite.GetOffset(ref spriteAnimState[decorativeSprite].OffsetState, spriteAnimState[decorativeSprite].RandomOffsetMultiplier) * Scale;
|
||||
decorativeSprite.Sprite.Draw(spriteBatch, new Vector2(DrawPosition.X + offset.X, -(DrawPosition.Y + offset.Y)), color,
|
||||
rotation, decorativeSprite.GetScale(spriteAnimState[decorativeSprite].RandomScaleFactor) * Scale, Prefab.Sprite.effects,
|
||||
|
||||
@@ -94,16 +94,21 @@ namespace Barotrauma
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(newRect.X, -newRect.Y - GameMain.GraphicsHeight, newRect.Width, newRect.Height + GameMain.GraphicsHeight * 2), Color.White);
|
||||
}
|
||||
|
||||
public override void DrawPlacing(SpriteBatch spriteBatch, Rectangle placeRect, float scale = 1.0f, SpriteEffects spriteEffects = SpriteEffects.None)
|
||||
public override void DrawPlacing(SpriteBatch spriteBatch, Rectangle placeRect, float scale = 1.0f, float rotation = 0.0f, SpriteEffects spriteEffects = SpriteEffects.None)
|
||||
{
|
||||
SpriteEffects oldEffects = Sprite.effects;
|
||||
Sprite.effects ^= spriteEffects;
|
||||
|
||||
var position = placeRect.Location.ToVector2().FlipY();
|
||||
position += placeRect.Size.ToVector2() * 0.5f;
|
||||
|
||||
Sprite.DrawTiled(
|
||||
spriteBatch,
|
||||
new Vector2(placeRect.X, -placeRect.Y),
|
||||
new Vector2(placeRect.Width, placeRect.Height),
|
||||
color: Color.White * 0.8f,
|
||||
position,
|
||||
placeRect.Size.ToVector2(),
|
||||
color: Color.White * 0.8f,
|
||||
origin: placeRect.Size.ToVector2() * 0.5f,
|
||||
rotation: rotation,
|
||||
textureScale: TextureScale * scale);
|
||||
|
||||
Sprite.effects = oldEffects;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Barotrauma
|
||||
/// <summary>
|
||||
/// Margin applied around the view area when culling entities (i.e. entities that are this far outside the view are still considered visible)
|
||||
/// </summary>
|
||||
private const int CullMargin = 500;
|
||||
private const int CullMargin = 50;
|
||||
/// <summary>
|
||||
/// Update entity culling when any corner of the view has moved more than this
|
||||
/// </summary>
|
||||
@@ -713,18 +713,12 @@ namespace Barotrauma
|
||||
return GameMain.LightManager.Lights.Count(l => l.CastShadows && !l.IsBackground) - disabledItemLightCount;
|
||||
}
|
||||
|
||||
public static Vector2 MouseToWorldGrid(Camera cam, Submarine sub, bool round = false)
|
||||
public static Vector2 MouseToWorldGrid(Camera cam, Submarine sub, Vector2? mousePos = null, bool round = false)
|
||||
{
|
||||
Vector2 position = PlayerInput.MousePosition;
|
||||
Vector2 position = mousePos ?? PlayerInput.MousePosition;
|
||||
position = cam.ScreenToWorld(position);
|
||||
|
||||
Vector2 worldGridPos = VectorToWorldGrid(position, round);
|
||||
|
||||
if (sub != null)
|
||||
{
|
||||
worldGridPos.X += sub.Position.X % GridSize.X;
|
||||
worldGridPos.Y += sub.Position.Y % GridSize.Y;
|
||||
}
|
||||
Vector2 worldGridPos = VectorToWorldGrid(position, sub, round);
|
||||
|
||||
return worldGridPos;
|
||||
}
|
||||
|
||||
@@ -122,12 +122,12 @@ namespace Barotrauma.Networking
|
||||
VoipSound = null;
|
||||
}
|
||||
|
||||
public void SetPermissions(ClientPermissions permissions, IEnumerable<string> permittedConsoleCommands)
|
||||
public void SetPermissions(ClientPermissions permissions, IEnumerable<Identifier> permittedConsoleCommands)
|
||||
{
|
||||
List<DebugConsole.Command> permittedCommands = new List<DebugConsole.Command>();
|
||||
foreach (string commandName in permittedConsoleCommands)
|
||||
foreach (Identifier commandName in permittedConsoleCommands)
|
||||
{
|
||||
var consoleCommand = DebugConsole.Commands.Find(c => c.names.Contains(commandName));
|
||||
var consoleCommand = DebugConsole.Commands.Find(c => c.Names.Contains(commandName));
|
||||
if (consoleCommand != null)
|
||||
{
|
||||
permittedCommands.Add(consoleCommand);
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Barotrauma.Networking
|
||||
public bool LateCampaignJoin = false;
|
||||
|
||||
private ClientPermissions permissions = ClientPermissions.None;
|
||||
private List<string> permittedConsoleCommands = new List<string>();
|
||||
private List<Identifier> permittedConsoleCommands = new List<Identifier>();
|
||||
|
||||
private bool connected;
|
||||
|
||||
@@ -170,9 +170,9 @@ namespace Barotrauma.Networking
|
||||
internal readonly struct PermissionChangedEvent
|
||||
{
|
||||
public readonly ClientPermissions NewPermissions;
|
||||
public readonly ImmutableArray<string> NewPermittedConsoleCommands;
|
||||
public readonly ImmutableArray<Identifier> NewPermittedConsoleCommands;
|
||||
|
||||
public PermissionChangedEvent(ClientPermissions newPermissions, IReadOnlyList<string> newPermittedConsoleCommands)
|
||||
public PermissionChangedEvent(ClientPermissions newPermissions, IReadOnlyList<Identifier> newPermittedConsoleCommands)
|
||||
{
|
||||
NewPermissions = newPermissions;
|
||||
NewPermittedConsoleCommands = newPermittedConsoleCommands.ToImmutableArray();
|
||||
@@ -1211,11 +1211,11 @@ namespace Barotrauma.Networking
|
||||
targetClient?.SetPermissions(permissions, permittedCommands);
|
||||
if (clientId == SessionId)
|
||||
{
|
||||
SetMyPermissions(permissions, permittedCommands.Select(command => command.names[0]));
|
||||
SetMyPermissions(permissions, permittedCommands.Select(command => command.Names[0]));
|
||||
}
|
||||
}
|
||||
|
||||
private void SetMyPermissions(ClientPermissions newPermissions, IEnumerable<string> permittedConsoleCommands)
|
||||
private void SetMyPermissions(ClientPermissions newPermissions, IEnumerable<Identifier> permittedConsoleCommands)
|
||||
{
|
||||
if (!(this.permittedConsoleCommands.Any(c => !permittedConsoleCommands.Contains(c)) ||
|
||||
permittedConsoleCommands.Any(c => !this.permittedConsoleCommands.Contains(c))))
|
||||
@@ -1227,7 +1227,7 @@ namespace Barotrauma.Networking
|
||||
permissions.HasFlag(ClientPermissions.ManageRound) != newPermissions.HasFlag(ClientPermissions.ManageRound);
|
||||
|
||||
permissions = newPermissions;
|
||||
this.permittedConsoleCommands = new List<string>(permittedConsoleCommands);
|
||||
this.permittedConsoleCommands = permittedConsoleCommands.ToList();
|
||||
//don't show the "permissions changed" popup if the client owns the server
|
||||
if (!IsServerOwner)
|
||||
{
|
||||
@@ -1265,10 +1265,10 @@ namespace Barotrauma.Networking
|
||||
var commandsLabel = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), rightColumn.RectTransform),
|
||||
TextManager.Get("PermittedConsoleCommands"), wrap: true, font: GUIStyle.SubHeadingFont);
|
||||
var commandList = new GUIListBox(new RectTransform(new Vector2(1.0f, 1.0f), rightColumn.RectTransform));
|
||||
foreach (string permittedCommand in permittedConsoleCommands)
|
||||
foreach (Identifier permittedCommand in permittedConsoleCommands)
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), commandList.Content.RectTransform, minSize: new Point(0, 15)),
|
||||
permittedCommand, font: GUIStyle.SmallFont)
|
||||
permittedCommand.Value, font: GUIStyle.SmallFont)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
@@ -1348,6 +1348,7 @@ namespace Barotrauma.Networking
|
||||
bool respawnAllowed = inc.ReadBoolean();
|
||||
ServerSettings.AllowDisguises = inc.ReadBoolean();
|
||||
ServerSettings.AllowRewiring = inc.ReadBoolean();
|
||||
ServerSettings.AllowImmediateItemDelivery = inc.ReadBoolean();
|
||||
ServerSettings.AllowFriendlyFire = inc.ReadBoolean();
|
||||
ServerSettings.LockAllDefaultWires = inc.ReadBoolean();
|
||||
ServerSettings.AllowLinkingWifiToChat = inc.ReadBoolean();
|
||||
@@ -2551,18 +2552,18 @@ namespace Barotrauma.Networking
|
||||
return permissions.HasFlag(permission);
|
||||
}
|
||||
|
||||
public bool HasConsoleCommandPermission(string commandName)
|
||||
public bool HasConsoleCommandPermission(Identifier commandName)
|
||||
{
|
||||
if (!permissions.HasFlag(ClientPermissions.ConsoleCommands)) { return false; }
|
||||
|
||||
if (permittedConsoleCommands.Any(c => c.Equals(commandName, StringComparison.OrdinalIgnoreCase))) { return true; }
|
||||
if (permittedConsoleCommands.Contains(commandName)) { return true; }
|
||||
|
||||
//check aliases
|
||||
foreach (DebugConsole.Command command in DebugConsole.Commands)
|
||||
{
|
||||
if (command.names.Contains(commandName))
|
||||
if (command.Names.Contains(commandName))
|
||||
{
|
||||
if (command.names.Intersect(permittedConsoleCommands).Any()) { return true; }
|
||||
if (command.Names.Intersect(permittedConsoleCommands).Any()) { return true; }
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,9 @@ namespace Barotrauma.Networking
|
||||
[Serialize("", IsPropertySaveable.Yes)]
|
||||
public LanguageIdentifier Language { get; set; }
|
||||
|
||||
[Serialize("", IsPropertySaveable.Yes)]
|
||||
public string SelectedSub { get; set; } = string.Empty;
|
||||
|
||||
public Version GameVersion { get; set; } = new Version(0, 0, 0, 0);
|
||||
|
||||
public Option<int> Ping = Option<int>.None();
|
||||
@@ -104,6 +107,8 @@ namespace Barotrauma.Networking
|
||||
|
||||
public ImmutableArray<ContentPackageInfo> ContentPackages;
|
||||
|
||||
public int ContentPackageCount;
|
||||
|
||||
public bool IsModded => ContentPackages.Any(p => !GameMain.VanillaContent.NameMatches(p.Name));
|
||||
|
||||
public ServerInfo(Endpoint endpoint)
|
||||
@@ -309,6 +314,14 @@ namespace Barotrauma.Networking
|
||||
TextManager.Get(GameMode.IsEmpty ? "Unknown" : "GameMode." + GameMode).Fallback(GameMode.Value),
|
||||
textAlignment: Alignment.Right);
|
||||
|
||||
if (!string.IsNullOrEmpty(SelectedSub))
|
||||
{
|
||||
var submarineText = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), content.RectTransform), TextManager.Get("Submarine"));
|
||||
new GUITextBlock(new RectTransform(Vector2.One, submarineText.RectTransform),
|
||||
SelectedSub,
|
||||
textAlignment: Alignment.Right);
|
||||
}
|
||||
|
||||
GUITextBlock playStyleText = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), content.RectTransform), TextManager.Get("serverplaystyle"));
|
||||
new GUITextBlock(new RectTransform(Vector2.One, playStyleText.RectTransform), TextManager.Get("servertag." + playStyle), textAlignment: Alignment.Right);
|
||||
|
||||
@@ -385,6 +398,15 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ContentPackageCount > ContentPackages.Length)
|
||||
{
|
||||
new GUITextBlock(
|
||||
new RectTransform(new Vector2(1.0f, 0.15f), contentPackageList.Content.RectTransform) { MinSize = new Point(0, 15) },
|
||||
TextManager.GetWithVariable("workshopitemdownloadprompttruncated", "[number]", (ContentPackageCount - ContentPackages.Length).ToString()))
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -423,14 +445,16 @@ namespace Barotrauma.Networking
|
||||
AllowSpectating = getBool("allowspectating");
|
||||
AllowRespawn = getBool("allowrespawn");
|
||||
VoipEnabled = getBool("voicechatenabled");
|
||||
|
||||
GameMode = valueGetter("gamemode")?.ToIdentifier() ?? Identifier.Empty;
|
||||
if (float.TryParse(valueGetter("traitors"), NumberStyles.Any, CultureInfo.InvariantCulture, out float traitorProbability)) { TraitorProbability = traitorProbability; }
|
||||
if (Enum.TryParse(valueGetter("playstyle"), out PlayStyle playStyle)) { PlayStyle = playStyle; }
|
||||
Language = valueGetter("language")?.ToLanguageIdentifier() ?? LanguageIdentifier.None;
|
||||
SelectedSub = valueGetter("submarine") ?? string.Empty;
|
||||
|
||||
ContentPackages = ExtractContentPackageInfo(ServerName, valueGetter).ToImmutableArray();
|
||||
|
||||
ContentPackageCount = ContentPackages.Length;
|
||||
if (int.TryParse(valueGetter("packagecount"), out int packageCount)) { ContentPackageCount = packageCount; }
|
||||
|
||||
bool getBool(string key)
|
||||
{
|
||||
string? data = valueGetter(key);
|
||||
|
||||
@@ -936,6 +936,10 @@ namespace Barotrauma.Networking
|
||||
TextManager.Get("ServerSettingsAllowVoteKick"));
|
||||
GetPropertyData(nameof(AllowVoteKick)).AssignGUIComponent(voteKickBox);
|
||||
|
||||
var allowImmediateItemDeliveryBox = new GUITickBox(new RectTransform(new Vector2(0.48f, 0.05f), tickBoxContainer.Content.RectTransform),
|
||||
TextManager.Get("ServerSettingsImmediateItemDelivery"));
|
||||
GetPropertyData(nameof(AllowImmediateItemDelivery)).AssignGUIComponent(allowImmediateItemDeliveryBox);
|
||||
|
||||
GUITextBlock.AutoScaleAndNormalize(tickBoxContainer.Content.Children.Select(c => ((GUITickBox)c).TextBlock));
|
||||
|
||||
tickBoxContainer.RectTransform.MinSize = new Point(0, (int)(tickBoxContainer.Content.Children.First().Rect.Height * 2.0f + tickBoxContainer.Padding.Y + tickBoxContainer.Padding.W));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
#nullable enable
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
@@ -148,7 +149,7 @@ namespace Barotrauma.Particles
|
||||
Prefab = prefab;
|
||||
}
|
||||
|
||||
public void Emit(float deltaTime, Vector2 position, Hull hullGuess = null, float angle = 0.0f, float particleRotation = 0.0f, float velocityMultiplier = 1.0f, float sizeMultiplier = 1.0f, float amountMultiplier = 1.0f, Color? colorMultiplier = null, ParticlePrefab overrideParticle = null, bool mirrorAngle = false, Tuple<Vector2, Vector2> tracerPoints = null)
|
||||
public void Emit(float deltaTime, Vector2 position, Hull? hullGuess = null, float angle = 0.0f, float particleRotation = 0.0f, float velocityMultiplier = 1.0f, float sizeMultiplier = 1.0f, float amountMultiplier = 1.0f, Color? colorMultiplier = null, ParticlePrefab? overrideParticle = null, bool mirrorAngle = false, Tuple<Vector2, Vector2>? tracerPoints = null)
|
||||
{
|
||||
if (GameMain.Client?.MidRoundSyncing ?? false) { return; }
|
||||
|
||||
@@ -191,16 +192,17 @@ namespace Barotrauma.Particles
|
||||
burstEmitTimer = Prefab.Properties.EmitInterval;
|
||||
for (int i = 0; i < Prefab.Properties.ParticleAmount * amountMultiplier; i++)
|
||||
{
|
||||
Emit(position, hullGuess, angle, particleRotation, velocityMultiplier, sizeMultiplier, colorMultiplier, overrideParticle, tracerPoints: tracerPoints);
|
||||
Emit(position, hullGuess, angle, particleRotation, velocityMultiplier, sizeMultiplier, colorMultiplier, overrideParticle, mirrorAngle, tracerPoints: tracerPoints);
|
||||
}
|
||||
}
|
||||
|
||||
private void Emit(Vector2 position, Hull hullGuess, float angle, float particleRotation, float velocityMultiplier, float sizeMultiplier, Color? colorMultiplier = null, ParticlePrefab overrideParticle = null, bool mirrorAngle = false, Tuple<Vector2, Vector2> tracerPoints = null)
|
||||
private void Emit(Vector2 position, Hull? hullGuess, float angle, float particleRotation, float velocityMultiplier, float sizeMultiplier, Color? colorMultiplier = null, ParticlePrefab? overrideParticle = null, bool mirrorAngle = false, Tuple<Vector2, Vector2>? tracerPoints = null)
|
||||
{
|
||||
var particlePrefab = overrideParticle ?? Prefab.ParticlePrefab;
|
||||
if (particlePrefab == null)
|
||||
{
|
||||
DebugConsole.AddWarning($"Could not find the particle prefab \"{Prefab.ParticlePrefabName}\".");
|
||||
DebugConsole.AddWarning($"Could not find the particle prefab \"{Prefab.ParticlePrefabName}\".",
|
||||
contentPackage: Prefab.ContentPackage);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -271,7 +273,7 @@ namespace Barotrauma.Particles
|
||||
{
|
||||
public readonly Identifier ParticlePrefabName;
|
||||
|
||||
public ParticlePrefab ParticlePrefab
|
||||
public ParticlePrefab? ParticlePrefab
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -282,12 +284,16 @@ namespace Barotrauma.Particles
|
||||
|
||||
public readonly ParticleEmitterProperties Properties;
|
||||
|
||||
public bool DrawOnTop => Properties.DrawOnTop || ParticlePrefab.DrawOnTop;
|
||||
public readonly ContentPackage? ContentPackage;
|
||||
|
||||
public bool DrawOnTop => Properties.DrawOnTop || ParticlePrefab is { DrawOnTop: true };
|
||||
|
||||
public ParticleEmitterPrefab(ContentXElement element)
|
||||
{
|
||||
Properties = new ParticleEmitterProperties(element);
|
||||
if (element == null) { throw new ArgumentNullException(nameof(element)); }
|
||||
Properties = new ParticleEmitterProperties(element!);
|
||||
ParticlePrefabName = element.GetAttributeIdentifier("particle", "");
|
||||
ContentPackage = element.ContentPackage;
|
||||
}
|
||||
|
||||
public ParticleEmitterPrefab(ParticlePrefab prefab, ParticleEmitterProperties properties)
|
||||
|
||||
@@ -244,7 +244,8 @@ namespace Barotrauma.Particles
|
||||
|
||||
if (Sprites.Count == 0)
|
||||
{
|
||||
DebugConsole.ThrowError($"Particle prefab \"{Name}\" in the file \"{file}\" has no sprites defined!");
|
||||
DebugConsole.ThrowError($"Particle prefab \"{Name}\" in the file \"{file}\" has no sprites defined!",
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
|
||||
//if velocity change in water is not given, it defaults to the normal velocity change
|
||||
|
||||
@@ -261,6 +261,9 @@ namespace Barotrauma
|
||||
{
|
||||
crashHeader += " " + exception.TargetSite.ToString();
|
||||
}
|
||||
//log the message separately, so the same error messages get grouped as the same error in GA
|
||||
//(the full crash report tends to always have some differences between clients, so they get displayed separately)
|
||||
GameAnalyticsManager.AddErrorEvent(GameAnalyticsManager.ErrorSeverity.Critical, crashHeader);
|
||||
GameAnalyticsManager.AddErrorEvent(GameAnalyticsManager.ErrorSeverity.Critical, crashHeader + "\n\n" + sb.ToString());
|
||||
GameAnalyticsManager.ShutDown();
|
||||
}
|
||||
|
||||
@@ -76,6 +76,8 @@ namespace Barotrauma
|
||||
private GUITextBlock tutorialHeader, tutorialDescription;
|
||||
private GUIListBox tutorialList;
|
||||
|
||||
private GUIComponent versionMismatchWarning;
|
||||
|
||||
#region Creation
|
||||
public MainMenuScreen(GameMain game)
|
||||
{
|
||||
@@ -105,6 +107,28 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
|
||||
versionMismatchWarning = new GUIFrame(new RectTransform(new Vector2(0.7f, 0.065f), Frame.RectTransform) { AbsoluteOffset = new Point(GUI.IntScale(15)) }, style: "InnerFrame", color: GUIStyle.Red)
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
Visible = false
|
||||
};
|
||||
var versionMismatchContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), versionMismatchWarning.RectTransform, Anchor.Center), isHorizontal: true)
|
||||
{
|
||||
RelativeSpacing = 0.05f,
|
||||
};
|
||||
new GUIImage(new RectTransform(new Vector2(1.0f), versionMismatchContent.RectTransform, scaleBasis: ScaleBasis.Smallest), style: "GUINotificationButton")
|
||||
{
|
||||
Color = GUIStyle.Orange
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.85f, 1.0f), versionMismatchContent.RectTransform),
|
||||
TextManager.GetWithVariables("versionmismatchwarning",
|
||||
("[gameversion]", GameMain.Version.ToString()),
|
||||
("[contentversion]", ContentPackageManager.VanillaCorePackage.GameVersion.ToString())),
|
||||
wrap: true)
|
||||
{
|
||||
TextColor = GUIStyle.Orange
|
||||
};
|
||||
|
||||
new GUIImage(new RectTransform(new Vector2(0.4f, 0.25f), Frame.RectTransform, Anchor.BottomRight)
|
||||
{ RelativeOffset = new Vector2(0.08f, 0.05f), AbsoluteOffset = new Point(-8, -8) },
|
||||
style: "TitleText")
|
||||
@@ -587,7 +611,9 @@ namespace Barotrauma
|
||||
|
||||
GameMain.SubEditorScreen?.ClearBackedUpSubInfo();
|
||||
Submarine.Unload();
|
||||
|
||||
|
||||
versionMismatchWarning.Visible = GameMain.Version < ContentPackageManager.VanillaCorePackage.GameVersion;
|
||||
|
||||
ResetButtonStates(null);
|
||||
}
|
||||
|
||||
@@ -663,7 +689,18 @@ namespace Barotrauma
|
||||
.ToArray();
|
||||
foreach (var newServerExe in newServerExes)
|
||||
{
|
||||
serverExecutableDropdown.AddItem($"{newServerExe.ContentPackage.Name} - {Path.GetFileNameWithoutExtension(newServerExe.Path.Value)}", userData: newServerExe);
|
||||
var serverExeEntry = serverExecutableDropdown.AddItem($"{newServerExe.ContentPackage.Name} - {Path.GetFileNameWithoutExtension(newServerExe.Path.Value)}", userData: newServerExe);
|
||||
if (newServerExe.ContentPackage.GameVersion < GameMain.VanillaContent.GameVersion)
|
||||
{
|
||||
serverExeEntry.ToolTip =
|
||||
TextManager.GetWithVariables("versionmismatchwarning",
|
||||
("[gameversion]", newServerExe.ContentPackage.GameVersion.ToString()),
|
||||
("[contentversion]", GameMain.VanillaContent.GameVersion.ToString()));
|
||||
if (serverExeEntry is GUITextBlock serverExeText)
|
||||
{
|
||||
serverExeText.TextColor = GUIStyle.Red;
|
||||
}
|
||||
}
|
||||
}
|
||||
serverExecutableDropdown.ListBox.Content.Children.ForEach(c =>
|
||||
{
|
||||
@@ -1472,34 +1509,58 @@ namespace Barotrauma
|
||||
{
|
||||
OnClicked = (btn, userdata) =>
|
||||
{
|
||||
string name = serverNameBox.Text;
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
serverNameBox.Flash();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isPublicBox.Selected && ForbiddenWordFilter.IsForbidden(name, out string forbiddenWord))
|
||||
{
|
||||
var msgBox = new GUIMessageBox("",
|
||||
TextManager.GetWithVariables("forbiddenservernameverification", ("[forbiddenword]", forbiddenWord), ("[servername]", name)),
|
||||
new LocalizedString[] { TextManager.Get("yes"), TextManager.Get("no") });
|
||||
msgBox.Buttons[0].OnClicked += (_, __) =>
|
||||
{
|
||||
TryStartServer();
|
||||
msgBox.Close();
|
||||
return true;
|
||||
};
|
||||
msgBox.Buttons[1].OnClicked += msgBox.Close;
|
||||
}
|
||||
else
|
||||
{
|
||||
TryStartServer();
|
||||
}
|
||||
|
||||
CheckServerName();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void CheckServerName()
|
||||
{
|
||||
string name = serverNameBox.Text;
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
serverNameBox.Flash();
|
||||
return;
|
||||
}
|
||||
if (isPublicBox.Selected && ForbiddenWordFilter.IsForbidden(name, out string forbiddenWord))
|
||||
{
|
||||
var msgBox = new GUIMessageBox("",
|
||||
TextManager.GetWithVariables("forbiddenservernameverification", ("[forbiddenword]", forbiddenWord), ("[servername]", name)),
|
||||
new LocalizedString[] { TextManager.Get("yes"), TextManager.Get("no") });
|
||||
msgBox.Buttons[0].OnClicked += (_, __) =>
|
||||
{
|
||||
CheckServerExe();
|
||||
msgBox.Close();
|
||||
return true;
|
||||
};
|
||||
msgBox.Buttons[1].OnClicked += msgBox.Close;
|
||||
return;
|
||||
}
|
||||
CheckServerExe();
|
||||
}
|
||||
|
||||
void CheckServerExe()
|
||||
{
|
||||
if (serverExecutableDropdown?.SelectedData is ServerExecutableFile serverExe &&
|
||||
serverExe.ContentPackage.GameVersion < GameMain.VanillaContent.GameVersion)
|
||||
{
|
||||
var msgBox = new GUIMessageBox(string.Empty,
|
||||
TextManager.GetWithVariables("versionmismatchwarning",
|
||||
("[gameversion]", serverExe.ContentPackage.GameVersion.ToString()),
|
||||
("[contentversion]", GameMain.VanillaContent.GameVersion.ToString())) + "\n\n"+
|
||||
TextManager.GetWithVariable("versionmismatch.verifylaunch", "[exename]", serverExe.ContentPackage.Name),
|
||||
new LocalizedString[] { TextManager.Get("yes"), TextManager.Get("no") });
|
||||
msgBox.Buttons[0].OnClicked += (_, __) =>
|
||||
{
|
||||
TryStartServer();
|
||||
msgBox.Close();
|
||||
return true;
|
||||
};
|
||||
msgBox.Buttons[1].OnClicked += msgBox.Close;
|
||||
return;
|
||||
}
|
||||
TryStartServer();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetServerPlayStyle(PlayStyle playStyle)
|
||||
|
||||
@@ -2389,10 +2389,20 @@ namespace Barotrauma
|
||||
options.Add(kickOption);
|
||||
}
|
||||
|
||||
options.Add(new ContextMenuOption("Ban", isEnabled: canBan, onSelected: delegate
|
||||
if (GameMain.Client?.ServerSettings?.BanList?.BannedPlayers?.Any(bp => bp.MatchesClient(client)) ?? false)
|
||||
{
|
||||
GameMain.Client?.CreateKickReasonPrompt(client.Name, true);
|
||||
}));
|
||||
options.Add(new ContextMenuOption("clientpermission.unban", isEnabled: canBan, onSelected: delegate
|
||||
{
|
||||
GameMain.Client?.UnbanPlayer(client.Name);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
options.Add(new ContextMenuOption("Ban", isEnabled: canBan, onSelected: delegate
|
||||
{
|
||||
GameMain.Client?.CreateKickReasonPrompt(client.Name, true);
|
||||
}));
|
||||
}
|
||||
|
||||
GUIContextMenu.CreateContextMenu(null, client.Name, headerColor: clientColor, options.ToArray());
|
||||
}
|
||||
@@ -2591,11 +2601,11 @@ namespace Barotrauma
|
||||
foreach (DebugConsole.Command command in DebugConsole.Commands)
|
||||
{
|
||||
var commandTickBox = new GUITickBox(new RectTransform(new Vector2(0.15f, 0.15f), commandList.Content.RectTransform),
|
||||
command.names[0], font: GUIStyle.SmallFont)
|
||||
command.Names[0].Value, font: GUIStyle.SmallFont)
|
||||
{
|
||||
Selected = selectedClient.PermittedConsoleCommands.Contains(command),
|
||||
Enabled = !myClient,
|
||||
ToolTip = command.help,
|
||||
ToolTip = command.Help,
|
||||
UserData = command
|
||||
};
|
||||
commandTickBox.OnSelected += (GUITickBox tickBox) =>
|
||||
@@ -2630,12 +2640,25 @@ namespace Barotrauma
|
||||
{
|
||||
if (GameMain.Client.HasPermission(ClientPermissions.Ban))
|
||||
{
|
||||
var banButton = new GUIButton(new RectTransform(new Vector2(0.34f, 1.0f), buttonAreaTop.RectTransform),
|
||||
TextManager.Get("Ban"))
|
||||
GUIButton banButton;
|
||||
if (GameMain.Client?.ServerSettings?.BanList?.BannedPlayers?.Any(bp => bp.MatchesClient(selectedClient)) ?? false)
|
||||
{
|
||||
UserData = selectedClient
|
||||
};
|
||||
banButton.OnClicked = (bt, userdata) => { BanPlayer(selectedClient); return true; };
|
||||
banButton = new GUIButton(new RectTransform(new Vector2(0.34f, 1.0f), buttonAreaTop.RectTransform),
|
||||
TextManager.Get("clientpermission.unban"))
|
||||
{
|
||||
UserData = selectedClient
|
||||
};
|
||||
banButton.OnClicked = (bt, userdata) => { GameMain.Client?.UnbanPlayer(selectedClient.Name); return true; };
|
||||
}
|
||||
else
|
||||
{
|
||||
banButton = new GUIButton(new RectTransform(new Vector2(0.34f, 1.0f), buttonAreaTop.RectTransform),
|
||||
TextManager.Get("Ban"))
|
||||
{
|
||||
UserData = selectedClient
|
||||
};
|
||||
banButton.OnClicked = (bt, userdata) => { BanPlayer(selectedClient); return true; };
|
||||
}
|
||||
banButton.OnClicked += ClosePlayerFrame;
|
||||
}
|
||||
|
||||
@@ -3147,12 +3170,12 @@ namespace Barotrauma
|
||||
GUIButton jobButton = null;
|
||||
|
||||
var availableJobs = JobPrefab.Prefabs.Where(jobPrefab =>
|
||||
jobPrefab.MaxNumber > 0 && JobList.Content.Children.All(c => !(c.UserData is JobVariant prefab) || prefab.Prefab != jobPrefab)
|
||||
!jobPrefab.HiddenJob && jobPrefab.MaxNumber > 0 && JobList.Content.Children.All(c => c.UserData is not JobVariant prefab || prefab.Prefab != jobPrefab)
|
||||
).Select(j => new JobVariant(j, 0));
|
||||
|
||||
availableJobs = availableJobs.Concat(
|
||||
JobPrefab.Prefabs.Where(jobPrefab =>
|
||||
jobPrefab.MaxNumber > 0 && JobList.Content.Children.Any(c => (c.UserData is JobVariant prefab) && prefab.Prefab == jobPrefab)
|
||||
!jobPrefab.HiddenJob && jobPrefab.MaxNumber > 0 && JobList.Content.Children.Any(c => (c.UserData is JobVariant prefab) && prefab.Prefab == jobPrefab)
|
||||
).Select(j => (JobVariant)JobList.Content.FindChild(c => (c.UserData is JobVariant prefab) && prefab.Prefab == j).UserData));
|
||||
|
||||
availableJobs = availableJobs.ToList();
|
||||
|
||||
@@ -655,7 +655,7 @@ namespace Barotrauma
|
||||
ScrollBarVisible = true,
|
||||
OnSelected = (btn, obj) =>
|
||||
{
|
||||
if (!(obj is ServerInfo serverInfo)) { return false; }
|
||||
if (obj is not ServerInfo serverInfo) { return false; }
|
||||
|
||||
joinButton.Enabled = true;
|
||||
selectedServer = Option<ServerInfo>.Some(serverInfo);
|
||||
|
||||
@@ -1289,7 +1289,8 @@ namespace Barotrauma
|
||||
if (legacy) { textBlock.TextColor *= 0.6f; }
|
||||
if (name.IsNullOrEmpty())
|
||||
{
|
||||
DebugConsole.AddWarning($"Entity \"{ep.Identifier.Value}\" has no name!");
|
||||
DebugConsole.AddWarning($"Entity \"{ep.Identifier.Value}\" has no name!",
|
||||
contentPackage: ep.ContentPackage);
|
||||
textBlock.Text = frame.ToolTip = ep.Identifier.Value;
|
||||
textBlock.TextColor = GUIStyle.Red;
|
||||
}
|
||||
@@ -2365,49 +2366,58 @@ namespace Barotrauma
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
var beaconSettingsContainer = new GUILayoutGroup(new RectTransform(Vector2.One, subTypeDependentSettingFrame.RectTransform))
|
||||
var extraSettingsContainer = new GUILayoutGroup(new RectTransform(new Vector2(1, 0.5f), subTypeDependentSettingFrame.RectTransform))
|
||||
{
|
||||
CanBeFocused = true,
|
||||
Visible = false,
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
// -------------------
|
||||
|
||||
var beaconMinDifficultyGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), beaconSettingsContainer.RectTransform), isHorizontal: true)
|
||||
var minDifficultyGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), extraSettingsContainer.RectTransform), isHorizontal: true)
|
||||
{
|
||||
Stretch = true
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), beaconMinDifficultyGroup.RectTransform),
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), minDifficultyGroup.RectTransform),
|
||||
TextManager.Get("minleveldifficulty"), textAlignment: Alignment.CenterLeft, wrap: true);
|
||||
var numInput = new GUINumberInput(new RectTransform(new Vector2(0.4f, 1.0f), beaconMinDifficultyGroup.RectTransform), NumberType.Int)
|
||||
var numInput = new GUINumberInput(new RectTransform(new Vector2(0.4f, 1.0f), minDifficultyGroup.RectTransform), NumberType.Int)
|
||||
{
|
||||
IntValue = (int)(MainSub?.Info?.BeaconStationInfo?.MinLevelDifficulty ?? 0),
|
||||
IntValue = (int)(MainSub?.Info?.GetExtraSubmarineInfo?.MinLevelDifficulty ?? 0),
|
||||
MinValueInt = 0,
|
||||
MaxValueInt = 100,
|
||||
OnValueChanged = (numberInput) =>
|
||||
{
|
||||
MainSub.Info.BeaconStationInfo.MinLevelDifficulty = numberInput.IntValue;
|
||||
MainSub.Info.GetExtraSubmarineInfo.MinLevelDifficulty = numberInput.IntValue;
|
||||
}
|
||||
};
|
||||
beaconMinDifficultyGroup.RectTransform.MaxSize = numInput.TextBox.RectTransform.MaxSize;
|
||||
var beaconMaxDifficultyGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), beaconSettingsContainer.RectTransform), isHorizontal: true)
|
||||
minDifficultyGroup.RectTransform.MaxSize = numInput.TextBox.RectTransform.MaxSize;
|
||||
var maxDifficultyGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), extraSettingsContainer.RectTransform), isHorizontal: true)
|
||||
{
|
||||
Stretch = true
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), beaconMaxDifficultyGroup.RectTransform),
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), maxDifficultyGroup.RectTransform),
|
||||
TextManager.Get("maxleveldifficulty"), textAlignment: Alignment.CenterLeft, wrap: true);
|
||||
numInput = new GUINumberInput(new RectTransform(new Vector2(0.4f, 1.0f), beaconMaxDifficultyGroup.RectTransform), NumberType.Int)
|
||||
numInput = new GUINumberInput(new RectTransform(new Vector2(0.4f, 1.0f), maxDifficultyGroup.RectTransform), NumberType.Int)
|
||||
{
|
||||
IntValue = (int)(MainSub?.Info?.BeaconStationInfo?.MaxLevelDifficulty ?? 100),
|
||||
IntValue = (int)(MainSub?.Info?.GetExtraSubmarineInfo?.MaxLevelDifficulty ?? 100),
|
||||
MinValueInt = 0,
|
||||
MaxValueInt = 100,
|
||||
OnValueChanged = (numberInput) =>
|
||||
{
|
||||
MainSub.Info.BeaconStationInfo.MaxLevelDifficulty = numberInput.IntValue;
|
||||
MainSub.Info.GetExtraSubmarineInfo.MaxLevelDifficulty = numberInput.IntValue;
|
||||
}
|
||||
};
|
||||
beaconMaxDifficultyGroup.RectTransform.MaxSize = numInput.TextBox.RectTransform.MaxSize;
|
||||
maxDifficultyGroup.RectTransform.MaxSize = numInput.TextBox.RectTransform.MaxSize;
|
||||
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
var beaconSettingsContainer = new GUILayoutGroup(new RectTransform(Vector2.One, extraSettingsContainer.RectTransform))
|
||||
{
|
||||
CanBeFocused = true,
|
||||
Visible = false,
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
new GUITickBox(new RectTransform(new Vector2(1.0f, 0.25f), beaconSettingsContainer.RectTransform), TextManager.Get("allowdamagedwalls"))
|
||||
{
|
||||
Selected = MainSub?.Info?.BeaconStationInfo?.AllowDamagedWalls ?? true,
|
||||
@@ -2669,8 +2679,13 @@ namespace Barotrauma
|
||||
{
|
||||
MainSub.Info.BeaconStationInfo ??= new BeaconStationInfo(MainSub.Info);
|
||||
}
|
||||
else if (type == SubmarineType.Wreck)
|
||||
{
|
||||
MainSub.Info.WreckInfo ??= new WreckInfo(MainSub.Info);
|
||||
}
|
||||
previewImageButtonHolder.Children.ForEach(c => c.Enabled = MainSub.Info.AllowPreviewImage);
|
||||
outpostSettingsContainer.Visible = type == SubmarineType.OutpostModule;
|
||||
extraSettingsContainer.Visible = type == SubmarineType.BeaconStation || type == SubmarineType.Wreck;
|
||||
beaconSettingsContainer.Visible = type == SubmarineType.BeaconStation;
|
||||
subSettingsContainer.Visible = type == SubmarineType.Player;
|
||||
return true;
|
||||
@@ -4439,6 +4454,7 @@ namespace Barotrauma
|
||||
MapEntity.SelectEntity(itemContainer);
|
||||
dummyCharacter.SelectedItem = itemContainer;
|
||||
FilterEntities(entityFilterBox.Text);
|
||||
MapEntity.StopSelection();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -5556,11 +5572,32 @@ namespace Barotrauma
|
||||
dummyCharacter.Submarine = MainSub;
|
||||
}
|
||||
|
||||
// Deposit item from our "infinite stack" into inventory slots
|
||||
var inv = dummyCharacter?.SelectedItem?.OwnInventory;
|
||||
if (inv?.visualSlots != null && !PlayerInput.IsCtrlDown())
|
||||
if (dummyCharacter?.SelectedItem != null)
|
||||
{
|
||||
var dragginMouse = MouseDragStart != Vector2.Zero && Vector2.Distance(PlayerInput.MousePosition, MouseDragStart) >= GUI.Scale * 20;
|
||||
// Deposit item from our "infinite stack" into inventory slots
|
||||
TryDragItemsToItem(dummyCharacter.SelectedItem);
|
||||
foreach (Item linkedItem in dummyCharacter.SelectedItem.linkedTo.OfType<Item>())
|
||||
{
|
||||
if (linkedItem.OwnInventory?.visualSlots != null)
|
||||
{
|
||||
TryDragItemsToItem(linkedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TryDragItemsToItem(Item item)
|
||||
{
|
||||
foreach (ItemContainer ic in item.GetComponents<ItemContainer>())
|
||||
{
|
||||
TryDragItemsToInventory(ic.Inventory);
|
||||
}
|
||||
}
|
||||
|
||||
void TryDragItemsToInventory(Inventory inv)
|
||||
{
|
||||
if (PlayerInput.IsCtrlDown()) { return; }
|
||||
|
||||
var draggingMouse = MouseDragStart != Vector2.Zero && Vector2.Distance(PlayerInput.MousePosition, MouseDragStart) >= GUI.Scale * 20;
|
||||
|
||||
// So we don't accidentally drag inventory items while doing this
|
||||
if (DraggedItemPrefab != null) { Inventory.DraggingItems.Clear(); }
|
||||
@@ -5568,134 +5605,134 @@ namespace Barotrauma
|
||||
switch (DraggedItemPrefab)
|
||||
{
|
||||
// regular item prefabs
|
||||
case ItemPrefab itemPrefab when PlayerInput.PrimaryMouseButtonClicked() || dragginMouse:
|
||||
{
|
||||
bool spawnedItem = false;
|
||||
for (var i = 0; i < inv.Capacity; i++)
|
||||
case ItemPrefab itemPrefab when PlayerInput.PrimaryMouseButtonClicked() || draggingMouse:
|
||||
{
|
||||
var slot = inv.visualSlots[i];
|
||||
var itemContainer = inv.GetItemAt(i)?.GetComponent<ItemContainer>();
|
||||
|
||||
// check if the slot is empty or if we can place the item into a container, for example an oxygen tank into a diving suit
|
||||
if (Inventory.IsMouseOnSlot(slot))
|
||||
bool spawnedItem = false;
|
||||
for (var i = 0; i < inv.Capacity; i++)
|
||||
{
|
||||
var newItem = new Item(itemPrefab, Vector2.Zero, MainSub);
|
||||
var slot = inv.visualSlots[i];
|
||||
var itemContainer = inv.GetItemAt(i)?.GetComponent<ItemContainer>();
|
||||
|
||||
if (inv.CanBePutInSlot(itemPrefab, i, condition: null))
|
||||
// check if the slot is empty or if we can place the item into a container, for example an oxygen tank into a diving suit
|
||||
if (Inventory.IsMouseOnSlot(slot))
|
||||
{
|
||||
bool placedItem = inv.TryPutItem(newItem, i, false, true, dummyCharacter);
|
||||
spawnedItem |= placedItem;
|
||||
var newItem = new Item(itemPrefab, Vector2.Zero, MainSub);
|
||||
|
||||
if (!placedItem)
|
||||
if (inv.CanBePutInSlot(itemPrefab, i, condition: null))
|
||||
{
|
||||
newItem.Remove();
|
||||
bool placedItem = inv.TryPutItem(newItem, i, false, true, dummyCharacter);
|
||||
spawnedItem |= placedItem;
|
||||
|
||||
if (!placedItem)
|
||||
{
|
||||
newItem.Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (itemContainer != null && itemContainer.Inventory.CanBePut(itemPrefab))
|
||||
{
|
||||
bool placedItem = itemContainer.Inventory.TryPutItem(newItem, dummyCharacter);
|
||||
spawnedItem |= placedItem;
|
||||
|
||||
// try to place the item into the inventory of the item we are hovering over
|
||||
if (!placedItem)
|
||||
else if (itemContainer != null && itemContainer.Inventory.CanBePut(itemPrefab))
|
||||
{
|
||||
newItem.Remove();
|
||||
bool placedItem = itemContainer.Inventory.TryPutItem(newItem, dummyCharacter);
|
||||
spawnedItem |= placedItem;
|
||||
|
||||
// try to place the item into the inventory of the item we are hovering over
|
||||
if (!placedItem)
|
||||
{
|
||||
newItem.Remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.ShowBorderHighlight(GUIStyle.Green, 0.1f, 0.4f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.ShowBorderHighlight(GUIStyle.Green, 0.1f, 0.4f);
|
||||
newItem.Remove();
|
||||
slot.ShowBorderHighlight(GUIStyle.Red, 0.1f, 0.4f);
|
||||
}
|
||||
|
||||
if (!newItem.Removed)
|
||||
{
|
||||
BulkItemBufferInUse = ItemAddMutex;
|
||||
BulkItemBuffer.Add(new AddOrDeleteCommand(new List<MapEntity> { newItem }, false));
|
||||
}
|
||||
|
||||
if (!draggingMouse)
|
||||
{
|
||||
SoundPlayer.PlayUISound(spawnedItem ? GUISoundType.PickItem : GUISoundType.PickItemFail);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newItem.Remove();
|
||||
slot.ShowBorderHighlight(GUIStyle.Red, 0.1f, 0.4f);
|
||||
}
|
||||
|
||||
if (!newItem.Removed)
|
||||
{
|
||||
BulkItemBufferInUse = ItemAddMutex;
|
||||
BulkItemBuffer.Add(new AddOrDeleteCommand(new List<MapEntity> { newItem }, false));
|
||||
}
|
||||
|
||||
if (!dragginMouse)
|
||||
{
|
||||
SoundPlayer.PlayUISound(spawnedItem ? GUISoundType.PickItem : GUISoundType.PickItemFail);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// item assemblies
|
||||
case ItemAssemblyPrefab assemblyPrefab when PlayerInput.PrimaryMouseButtonClicked():
|
||||
{
|
||||
bool spawnedItems = false;
|
||||
for (var i = 0; i < inv.visualSlots.Length; i++)
|
||||
{
|
||||
var slot = inv.visualSlots[i];
|
||||
var item = inv?.GetItemAt(i);
|
||||
var itemContainer = item?.GetComponent<ItemContainer>();
|
||||
if (item == null && Inventory.IsMouseOnSlot(slot))
|
||||
bool spawnedItems = false;
|
||||
for (var i = 0; i < inv.visualSlots.Length; i++)
|
||||
{
|
||||
// load the items
|
||||
var itemInstance = LoadItemAssemblyInventorySafe(assemblyPrefab);
|
||||
|
||||
// counter for items that failed so we so we known that slot remained empty
|
||||
var failedCount = 0;
|
||||
|
||||
for (var j = 0; j < itemInstance.Count(); j++)
|
||||
var slot = inv.visualSlots[i];
|
||||
var item = inv?.GetItemAt(i);
|
||||
var itemContainer = item?.GetComponent<ItemContainer>();
|
||||
if (item == null && Inventory.IsMouseOnSlot(slot))
|
||||
{
|
||||
var newItem = itemInstance[j];
|
||||
var newSpot = i + j - failedCount;
|
||||
// load the items
|
||||
var itemInstance = LoadItemAssemblyInventorySafe(assemblyPrefab);
|
||||
|
||||
// try to find a valid slot to put the items
|
||||
while (inv.visualSlots.Length > newSpot)
|
||||
// counter for items that failed so we so we known that slot remained empty
|
||||
var failedCount = 0;
|
||||
|
||||
for (var j = 0; j < itemInstance.Count; j++)
|
||||
{
|
||||
if (inv.GetItemAt(newSpot) == null) { break; }
|
||||
newSpot++;
|
||||
}
|
||||
var newItem = itemInstance[j];
|
||||
var newSpot = i + j - failedCount;
|
||||
|
||||
// valid slot found
|
||||
if (inv.visualSlots.Length > newSpot)
|
||||
{
|
||||
var placedItem = inv.TryPutItem(newItem, newSpot, false, true, dummyCharacter);
|
||||
spawnedItems |= placedItem;
|
||||
|
||||
if (!placedItem)
|
||||
// try to find a valid slot to put the items
|
||||
while (inv.visualSlots.Length > newSpot)
|
||||
{
|
||||
failedCount++;
|
||||
// delete the included items too so we don't get a popup asking if we want to keep them
|
||||
newItem?.OwnInventory?.DeleteAllItems();
|
||||
newItem.Remove();
|
||||
if (inv.GetItemAt(newSpot) == null) { break; }
|
||||
newSpot++;
|
||||
}
|
||||
|
||||
// valid slot found
|
||||
if (inv.visualSlots.Length > newSpot)
|
||||
{
|
||||
var placedItem = inv.TryPutItem(newItem, newSpot, false, true, dummyCharacter);
|
||||
spawnedItems |= placedItem;
|
||||
|
||||
if (!placedItem)
|
||||
{
|
||||
failedCount++;
|
||||
// delete the included items too so we don't get a popup asking if we want to keep them
|
||||
newItem?.OwnInventory?.DeleteAllItems();
|
||||
newItem.Remove();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var placedItem = inv.TryPutItem(newItem, dummyCharacter);
|
||||
spawnedItems |= placedItem;
|
||||
|
||||
// if our while loop didn't find a valid slot then let the inventory decide where to put it as a last resort
|
||||
if (!placedItem)
|
||||
{
|
||||
// delete the included items too so we don't get a popup asking if we want to keep them
|
||||
newItem?.OwnInventory?.DeleteAllItems();
|
||||
newItem.Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
List<MapEntity> placedEntities = itemInstance.Where(it => !it.Removed).Cast<MapEntity>().ToList();
|
||||
if (placedEntities.Any())
|
||||
{
|
||||
var placedItem = inv.TryPutItem(newItem, dummyCharacter);
|
||||
spawnedItems |= placedItem;
|
||||
|
||||
// if our while loop didn't find a valid slot then let the inventory decide where to put it as a last resort
|
||||
if (!placedItem)
|
||||
{
|
||||
// delete the included items too so we don't get a popup asking if we want to keep them
|
||||
newItem?.OwnInventory?.DeleteAllItems();
|
||||
newItem.Remove();
|
||||
}
|
||||
BulkItemBufferInUse = ItemAddMutex;
|
||||
BulkItemBuffer.Add(new AddOrDeleteCommand(placedEntities, false));
|
||||
}
|
||||
}
|
||||
|
||||
List<MapEntity> placedEntities = itemInstance.Where(it => !it.Removed).Cast<MapEntity>().ToList();
|
||||
if (placedEntities.Any())
|
||||
{
|
||||
BulkItemBufferInUse = ItemAddMutex;
|
||||
BulkItemBuffer.Add(new AddOrDeleteCommand(placedEntities, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SoundPlayer.PlayUISound(spawnedItems ? GUISoundType.PickItem : GUISoundType.PickItemFail);
|
||||
break;
|
||||
}
|
||||
SoundPlayer.PlayUISound(spawnedItems ? GUISoundType.PickItem : GUISoundType.PickItemFail);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -571,16 +571,37 @@ namespace Barotrauma
|
||||
numberInput.MinValueFloat = editableAttribute.MinValueFloat;
|
||||
numberInput.MaxValueFloat = editableAttribute.MaxValueFloat;
|
||||
numberInput.DecimalsToDisplay = editableAttribute.DecimalCount;
|
||||
numberInput.valueStep = editableAttribute.ValueStep;
|
||||
numberInput.ValueStep = editableAttribute.ValueStep;
|
||||
numberInput.ForceShowPlusMinusButtons = editableAttribute.ForceShowPlusMinusButtons;
|
||||
numberInput.FloatValue = value;
|
||||
|
||||
numberInput.OnValueChanged += (numInput) =>
|
||||
numberInput.OnValueChanged += numInput =>
|
||||
{
|
||||
if (SetPropertyValue(property, entity, numInput.FloatValue))
|
||||
{
|
||||
TrySendNetworkUpdate(entity, property);
|
||||
}
|
||||
};
|
||||
|
||||
// Lots of UI boilerplate to handle all(?) cases where the property's setter may be called
|
||||
// and modify the input value (e.g. rotation value wrapping)
|
||||
void HandleSetterModifyingInput(GUINumberInput numInput)
|
||||
{
|
||||
var inputFloatValue = numInput.FloatValue;
|
||||
var resultingFloatValue = property.GetFloatValue(entity);
|
||||
if (!MathUtils.NearlyEqual(resultingFloatValue, inputFloatValue))
|
||||
{
|
||||
numInput.FloatValue = resultingFloatValue;
|
||||
}
|
||||
}
|
||||
bool HandleSetterModifyingInputOnButtonPressed() { HandleSetterModifyingInput(numberInput); return true; }
|
||||
bool HandleSetterModifyingInputOnButtonClicked(GUIButton _, object __) { HandleSetterModifyingInput(numberInput); return true; }
|
||||
|
||||
numberInput.OnValueEntered += HandleSetterModifyingInput;
|
||||
numberInput.PlusButton.OnPressed += HandleSetterModifyingInputOnButtonPressed;
|
||||
numberInput.PlusButton.OnClicked += HandleSetterModifyingInputOnButtonClicked;
|
||||
numberInput.MinusButton.OnPressed += HandleSetterModifyingInputOnButtonPressed;
|
||||
numberInput.MinusButton.OnClicked += HandleSetterModifyingInputOnButtonClicked;
|
||||
refresh += () =>
|
||||
{
|
||||
if (!numberInput.TextBox.Selected) { numberInput.FloatValue = (float)property.GetValue(entity); }
|
||||
@@ -859,7 +880,7 @@ namespace Barotrauma
|
||||
numberInput.MinValueFloat = editableAttribute.MinValueFloat;
|
||||
numberInput.MaxValueFloat = editableAttribute.MaxValueFloat;
|
||||
numberInput.DecimalsToDisplay = editableAttribute.DecimalCount;
|
||||
numberInput.valueStep = editableAttribute.ValueStep;
|
||||
numberInput.ValueStep = editableAttribute.ValueStep;
|
||||
|
||||
if (i == 0)
|
||||
numberInput.FloatValue = value.X;
|
||||
@@ -930,7 +951,7 @@ namespace Barotrauma
|
||||
numberInput.MinValueFloat = editableAttribute.MinValueFloat;
|
||||
numberInput.MaxValueFloat = editableAttribute.MaxValueFloat;
|
||||
numberInput.DecimalsToDisplay = editableAttribute.DecimalCount;
|
||||
numberInput.valueStep = editableAttribute.ValueStep;
|
||||
numberInput.ValueStep = editableAttribute.ValueStep;
|
||||
|
||||
if (i == 0)
|
||||
numberInput.FloatValue = value.X;
|
||||
@@ -1006,7 +1027,7 @@ namespace Barotrauma
|
||||
numberInput.MinValueFloat = editableAttribute.MinValueFloat;
|
||||
numberInput.MaxValueFloat = editableAttribute.MaxValueFloat;
|
||||
numberInput.DecimalsToDisplay = editableAttribute.DecimalCount;
|
||||
numberInput.valueStep = editableAttribute.ValueStep;
|
||||
numberInput.ValueStep = editableAttribute.ValueStep;
|
||||
|
||||
if (i == 0)
|
||||
numberInput.FloatValue = value.X;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Barotrauma.Sounds
|
||||
|
||||
private short[] sampleBuffer = Array.Empty<short>();
|
||||
private short[] muffleBuffer = Array.Empty<short>();
|
||||
public OggSound(SoundManager owner, string filename, bool stream, XElement xElement) : base(owner, filename,
|
||||
public OggSound(SoundManager owner, string filename, bool stream, ContentXElement xElement) : base(owner, filename,
|
||||
stream, true, xElement)
|
||||
{
|
||||
var reader = new VorbisReader(Filename);
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Barotrauma.Sounds
|
||||
|
||||
public readonly string Filename;
|
||||
|
||||
public readonly XElement XElement;
|
||||
public readonly ContentXElement XElement;
|
||||
|
||||
public readonly bool Stream;
|
||||
|
||||
@@ -60,14 +60,14 @@ namespace Barotrauma.Sounds
|
||||
public float BaseNear;
|
||||
public float BaseFar;
|
||||
|
||||
public Sound(SoundManager owner, string filename, bool stream, bool streamsReliably, XElement xElement = null, bool getFullPath = true)
|
||||
public Sound(SoundManager owner, string filename, bool stream, bool streamsReliably, ContentXElement xElement = null, bool getFullPath = true)
|
||||
{
|
||||
Owner = owner;
|
||||
Filename = getFullPath ? Path.GetFullPath(filename.CleanUpPath()).CleanUpPath() : filename;
|
||||
Stream = stream;
|
||||
StreamsReliably = streamsReliably;
|
||||
XElement = xElement;
|
||||
sourcePoolIndex = XElement.GetAttributeEnum("sourcepool", SoundManager.SourcePoolIndex.Default);
|
||||
sourcePoolIndex = XElement?.GetAttributeEnum("sourcepool", SoundManager.SourcePoolIndex.Default) ?? SoundManager.SourcePoolIndex.Default;
|
||||
|
||||
BaseGain = 1.0f;
|
||||
BaseNear = 100.0f;
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Barotrauma
|
||||
|
||||
partial void LoadTexture(ref Vector4 sourceVector, ref bool shouldReturn)
|
||||
{
|
||||
texture = LoadTexture(FilePath.Value, Compress);
|
||||
texture = LoadTexture(FilePath.Value, Compress, contentPackage: SourceElement?.ContentPackage);
|
||||
|
||||
if (texture == null)
|
||||
{
|
||||
@@ -175,7 +175,7 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
texture.Dispose();
|
||||
texture = TextureLoader.FromFile(FilePath.Value, Compress);
|
||||
texture = TextureLoader.FromFile(FilePath.Value, Compress, contentPackage: SourceElement?.ContentPackage);
|
||||
Identifier pathKey = FullPath.ToIdentifier();
|
||||
if (textureRefCounts.ContainsKey(pathKey))
|
||||
{
|
||||
@@ -195,7 +195,7 @@ namespace Barotrauma
|
||||
sourceRect = new Rectangle(0, 0, texture.Width, texture.Height);
|
||||
}
|
||||
|
||||
public static Texture2D LoadTexture(string file, bool compress = true)
|
||||
public static Texture2D LoadTexture(string file, bool compress = true, ContentPackage contentPackage = null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(file))
|
||||
{
|
||||
@@ -221,11 +221,11 @@ namespace Barotrauma
|
||||
if (!ToolBox.IsProperFilenameCase(file))
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Texture file \"" + file + "\" has incorrect case!");
|
||||
DebugConsole.ThrowError("Texture file \"" + file + "\" has incorrect case!", contentPackage: contentPackage);
|
||||
#endif
|
||||
}
|
||||
|
||||
Texture2D newTexture = TextureLoader.FromFile(file, compress);
|
||||
Texture2D newTexture = TextureLoader.FromFile(file, compress, contentPackage: contentPackage);
|
||||
lock (list)
|
||||
{
|
||||
if (!textureRefCounts.TryAdd(fullPath,
|
||||
@@ -284,17 +284,35 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawTiled(ISpriteBatch spriteBatch, Vector2 position, Vector2 targetSize,
|
||||
public void DrawTiled(ISpriteBatch spriteBatch, Vector2 position, Vector2 targetSize, float rotation = 0f, Vector2? origin = null,
|
||||
Color? color = null, Vector2? startOffset = null, Vector2? textureScale = null, float? depth = null)
|
||||
{
|
||||
if (Texture == null) { return; }
|
||||
|
||||
bool flipHorizontal = (effects & SpriteEffects.FlipHorizontally) != 0;
|
||||
bool flipVertical = (effects & SpriteEffects.FlipVertically) != 0;
|
||||
|
||||
float addedRotation = rotation + this.rotation;
|
||||
if (flipHorizontal != flipVertical) { addedRotation = -addedRotation; }
|
||||
|
||||
Vector2 advanceX = addedRotation == 0.0f ? Vector2.UnitX : new Vector2((float)Math.Cos(addedRotation), (float)Math.Sin(addedRotation));
|
||||
Vector2 advanceY = new Vector2(-advanceX.Y, advanceX.X);
|
||||
|
||||
//Init optional values
|
||||
Vector2 drawOffset = startOffset ?? Vector2.Zero;
|
||||
Vector2 scale = textureScale ?? Vector2.One;
|
||||
Color drawColor = color ?? Color.White;
|
||||
Vector2 transformedOrigin = origin ?? Vector2.Zero;
|
||||
|
||||
bool flipHorizontal = (effects & SpriteEffects.FlipHorizontally) != 0;
|
||||
bool flipVertical = (effects & SpriteEffects.FlipVertically) != 0;
|
||||
transformedOrigin = advanceX * transformedOrigin.X + advanceY * transformedOrigin.Y;
|
||||
|
||||
void drawSection(Vector2 slicePos, Rectangle sliceRect)
|
||||
{
|
||||
Vector2 transformedPos = slicePos - position;
|
||||
transformedPos = advanceX * transformedPos.X + advanceY * transformedPos.Y;
|
||||
transformedPos += position - transformedOrigin;
|
||||
spriteBatch.Draw(texture, transformedPos, sliceRect, drawColor, addedRotation, Vector2.Zero, scale, effects, depth ?? this.depth);
|
||||
}
|
||||
|
||||
//wrap the drawOffset inside the sourceRect
|
||||
drawOffset.X = (drawOffset.X / scale.X) % sourceRect.Width;
|
||||
@@ -368,8 +386,8 @@ namespace Barotrauma
|
||||
{
|
||||
slicePos.Y += flippedDrawOffset.Y;
|
||||
}
|
||||
|
||||
spriteBatch.Draw(texture, slicePos, sliceRect, drawColor, rotation, Vector2.Zero, scale, effects, depth ?? this.depth);
|
||||
|
||||
drawSection(slicePos, sliceRect);
|
||||
currDrawPosition.X = slicePos.X + sliceWidth;
|
||||
}
|
||||
}
|
||||
@@ -416,7 +434,7 @@ namespace Barotrauma
|
||||
sliceRect.Y = SourceRect.Y;
|
||||
sliceRect.Height = (int)(sliceHeight / scale.Y);
|
||||
|
||||
spriteBatch.Draw(texture, slicePos, sliceRect, drawColor, rotation, Vector2.Zero, scale, effects, depth ?? this.depth);
|
||||
drawSection(slicePos, sliceRect);
|
||||
|
||||
currDrawPosition.Y = slicePos.Y + sliceHeight;
|
||||
}
|
||||
@@ -433,8 +451,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
spriteBatch.Draw(texture, currDrawPosition,
|
||||
texPerspective, drawColor, rotation, Vector2.Zero, scale, effects, depth ?? this.depth);
|
||||
drawSection(currDrawPosition, texPerspective);
|
||||
|
||||
currDrawPosition.Y += texPerspective.Height * scale.Y;
|
||||
}
|
||||
|
||||
@@ -120,6 +120,10 @@ namespace Barotrauma.Steam
|
||||
currentLobby?.SetData("playstyle", serverSettings.PlayStyle.ToString());
|
||||
currentLobby?.SetData("gamemode", GameMain.NetLobbyScreen?.SelectedMode?.Identifier.Value ?? "");
|
||||
currentLobby?.SetData("language", serverSettings.Language.ToString());
|
||||
if (GameMain.NetLobbyScreen?.SelectedSub != null)
|
||||
{
|
||||
currentLobby?.SetData("submarine", GameMain.NetLobbyScreen.SelectedSub.Name);
|
||||
}
|
||||
|
||||
DebugConsole.Log("Lobby updated!");
|
||||
}
|
||||
|
||||
@@ -151,13 +151,13 @@ namespace Barotrauma
|
||||
output[outputOffset + 10] = (byte)((g2_565 << 5) | b2_565);
|
||||
}
|
||||
|
||||
public static Texture2D FromFile(string path, bool compress = true, bool mipmap = false)
|
||||
public static Texture2D FromFile(string path, bool compress = true, bool mipmap = false, ContentPackage contentPackage = null)
|
||||
{
|
||||
using FileStream fileStream = File.OpenRead(path);
|
||||
return FromStream(fileStream, path, compress, mipmap);
|
||||
return FromStream(fileStream, path, compress, mipmap, contentPackage);
|
||||
}
|
||||
|
||||
public static Texture2D FromStream(System.IO.Stream stream, string path = null, bool compress = true, bool mipmap = false)
|
||||
public static Texture2D FromStream(System.IO.Stream stream, string path = null, bool compress = true, bool mipmap = false, ContentPackage contentPackage = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -176,7 +176,8 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.AddWarning($"Could not compress a texture because the dimensions aren't a multiple of 4 (path: {path ?? "null"}, size: {width}x{height})");
|
||||
DebugConsole.AddWarning($"Could not compress a texture because the dimensions aren't a multiple of 4 (path: {path ?? "null"}, size: {width}x{height})",
|
||||
contentPackage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<RootNamespace>Barotrauma</RootNamespace>
|
||||
<Authors>FakeFish, Undertow Games</Authors>
|
||||
<Product>Barotrauma</Product>
|
||||
<Version>1.1.18.1</Version>
|
||||
<Version>1.2.1.0</Version>
|
||||
<Copyright>Copyright © FakeFish 2018-2023</Copyright>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<AssemblyName>Barotrauma</AssemblyName>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<RootNamespace>Barotrauma</RootNamespace>
|
||||
<Authors>FakeFish, Undertow Games</Authors>
|
||||
<Product>Barotrauma</Product>
|
||||
<Version>1.1.18.1</Version>
|
||||
<Version>1.2.1.0</Version>
|
||||
<Copyright>Copyright © FakeFish 2018-2023</Copyright>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<AssemblyName>Barotrauma</AssemblyName>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<RootNamespace>Barotrauma</RootNamespace>
|
||||
<Authors>FakeFish, Undertow Games</Authors>
|
||||
<Product>Barotrauma</Product>
|
||||
<Version>1.1.18.1</Version>
|
||||
<Version>1.2.1.0</Version>
|
||||
<Copyright>Copyright © FakeFish 2018-2023</Copyright>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<AssemblyName>Barotrauma</AssemblyName>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<RootNamespace>Barotrauma</RootNamespace>
|
||||
<Authors>FakeFish, Undertow Games</Authors>
|
||||
<Product>Barotrauma Dedicated Server</Product>
|
||||
<Version>1.1.18.1</Version>
|
||||
<Version>1.2.1.0</Version>
|
||||
<Copyright>Copyright © FakeFish 2018-2023</Copyright>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<AssemblyName>DedicatedServer</AssemblyName>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<RootNamespace>Barotrauma</RootNamespace>
|
||||
<Authors>FakeFish, Undertow Games</Authors>
|
||||
<Product>Barotrauma Dedicated Server</Product>
|
||||
<Version>1.1.18.1</Version>
|
||||
<Version>1.2.1.0</Version>
|
||||
<Copyright>Copyright © FakeFish 2018-2023</Copyright>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<AssemblyName>DedicatedServer</AssemblyName>
|
||||
|
||||
@@ -34,8 +34,8 @@ namespace Barotrauma
|
||||
{
|
||||
if (!CheatsEnabled && IsCheat)
|
||||
{
|
||||
NewMessage("Client \"" + client.Name + "\" attempted to use the command \"" + names[0] + "\". Cheats must be enabled using \"enablecheats\" before the command can be used.", Color.Red);
|
||||
GameMain.Server.SendConsoleMessage("You need to enable cheats using the command \"enablecheats\" before you can use the command \"" + names[0] + "\".", client, Color.Red);
|
||||
NewMessage("Client \"" + client.Name + "\" attempted to use the command \"" + Names[0] + "\". Cheats must be enabled using \"enablecheats\" before the command can be used.", Color.Red);
|
||||
GameMain.Server.SendConsoleMessage("You need to enable cheats using the command \"enablecheats\" before you can use the command \"" + Names[0] + "\".", client, Color.Red);
|
||||
|
||||
#if USE_STEAM
|
||||
NewMessage("Enabling cheats will disable Steam achievements during this play session.", Color.Red);
|
||||
@@ -317,7 +317,7 @@ namespace Barotrauma
|
||||
|
||||
private static void AssignOnClientRequestExecute(string names, Action<Client, Vector2, string[]> onClientRequestExecute)
|
||||
{
|
||||
var matchingCommand = commands.Find(c => c.names.Intersect(names.Split('|')).Count() > 0);
|
||||
var matchingCommand = commands.Find(c => c.Names.Intersect(names.Split('|').ToIdentifiers()).Any());
|
||||
if (matchingCommand == null)
|
||||
{
|
||||
throw new Exception("AssignOnClientRequestExecute failed. Command matching the name(s) \"" + names + "\" not found.");
|
||||
@@ -654,8 +654,10 @@ namespace Barotrauma
|
||||
|
||||
ShowQuestionPrompt("Console command permissions to grant to \"" + client.Name + "\"? You may enter multiple commands separated with a space, or \"all\" to allow using any console command.", (commandsStr) =>
|
||||
{
|
||||
string[] splitCommands = commandsStr.Split(' ');
|
||||
bool giveAll = splitCommands.Length > 0 && splitCommands[0].Equals("all", StringComparison.OrdinalIgnoreCase);
|
||||
Identifier[] splitCommands = commandsStr.Split(' ')
|
||||
.Select(s => s.Trim())
|
||||
.ToIdentifiers().ToArray();
|
||||
bool giveAll = splitCommands.Length > 0 && splitCommands[0] == "all";
|
||||
|
||||
List<Command> grantedCommands = new List<Command>();
|
||||
if (giveAll)
|
||||
@@ -664,13 +666,12 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < splitCommands.Length; i++)
|
||||
foreach (Identifier command in splitCommands)
|
||||
{
|
||||
splitCommands[i] = splitCommands[i].Trim().ToLowerInvariant();
|
||||
Command matchingCommand = commands.Find(c => c.names.Contains(splitCommands[i]));
|
||||
Command matchingCommand = commands.Find(c => c.Names.Contains(command));
|
||||
if (matchingCommand == null)
|
||||
{
|
||||
ThrowError("Could not find the command \"" + splitCommands[i] + "\"!");
|
||||
ThrowError("Could not find the command \"" + command + "\"!");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -688,7 +689,7 @@ namespace Barotrauma
|
||||
}
|
||||
else if (grantedCommands.Count > 0)
|
||||
{
|
||||
NewMessage("Gave the client \"" + client.Name + "\" the permission to use console commands " + string.Join(", ", grantedCommands.Select(c => c.names[0])) + ".", Color.White);
|
||||
NewMessage("Gave the client \"" + client.Name + "\" the permission to use console commands " + string.Join(", ", grantedCommands.Select(c => c.Names[0])) + ".", Color.White);
|
||||
}
|
||||
|
||||
}, args, 1);
|
||||
@@ -717,22 +718,23 @@ namespace Barotrauma
|
||||
|
||||
ShowQuestionPrompt("Console command permissions to revoke from \"" + client.Name + "\"? You may enter multiple commands separated with a space.", (commandsStr) =>
|
||||
{
|
||||
string[] splitCommands = commandsStr.Split(' ');
|
||||
Identifier[] splitCommands = commandsStr.Split(' ')
|
||||
.Select(s => s.Trim())
|
||||
.ToIdentifiers().ToArray();
|
||||
List<Command> revokedCommands = new List<Command>();
|
||||
bool revokeAll = splitCommands.Length > 0 && splitCommands[0].Equals("all", StringComparison.OrdinalIgnoreCase);
|
||||
bool revokeAll = splitCommands.Length > 0 && splitCommands[0] == "all";
|
||||
if (revokeAll)
|
||||
{
|
||||
revokedCommands.AddRange(commands);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < splitCommands.Length; i++)
|
||||
foreach (Identifier command in splitCommands)
|
||||
{
|
||||
splitCommands[i] = splitCommands[i].Trim().ToLowerInvariant();
|
||||
Command matchingCommand = commands.Find(c => c.names.Contains(splitCommands[i]));
|
||||
Command matchingCommand = commands.Find(c => c.Names.Contains(command));
|
||||
if (matchingCommand == null)
|
||||
{
|
||||
ThrowError("Could not find the command \"" + splitCommands[i] + "\"!");
|
||||
ThrowError("Could not find the command \"" + command + "\"!");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -749,7 +751,7 @@ namespace Barotrauma
|
||||
}
|
||||
else if (revokedCommands.Any())
|
||||
{
|
||||
NewMessage("Revoked \"" + client.Name + "\"'s permission to use the console commands " + string.Join(", ", revokedCommands.Select(c => c.names[0])) + ".", Color.White);
|
||||
NewMessage("Revoked \"" + client.Name + "\"'s permission to use the console commands " + string.Join(", ", revokedCommands.Select(c => c.Names[0])) + ".", Color.White);
|
||||
}
|
||||
}, args, 1);
|
||||
});
|
||||
@@ -793,7 +795,7 @@ namespace Barotrauma
|
||||
NewMessage("Permitted console commands:", Color.White);
|
||||
foreach (Command permittedCommand in client.PermittedConsoleCommands)
|
||||
{
|
||||
NewMessage(" - " + permittedCommand.names[0], Color.White);
|
||||
NewMessage(" - " + permittedCommand.Names[0], Color.White);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1156,6 +1158,23 @@ namespace Barotrauma
|
||||
}
|
||||
);
|
||||
|
||||
commands.Add(new Command("debugjobassignment", "debugjobassignment: Shows information about how jobs were assigned for the most recent round.", (string[] args) =>
|
||||
{
|
||||
if (GameMain.Server == null) { return; }
|
||||
foreach (var debugMsg in GameMain.Server.JobAssignmentDebugLog)
|
||||
{
|
||||
NewMessage(debugMsg, Color.Cyan);
|
||||
}
|
||||
}));
|
||||
AssignOnClientRequestExecute("debugjobassignment", (Client client, Vector2 cursorWorldPos, string[] args) =>
|
||||
{
|
||||
if (GameMain.Server == null) { return; }
|
||||
foreach (var debugMsg in GameMain.Server.JobAssignmentDebugLog)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage(debugMsg, client);
|
||||
}
|
||||
});
|
||||
|
||||
commands.Add(new Command("setpassword|setserverpassword|password", "setpassword [password]: Changes the password of the server that's being hosted.", (string[] args) =>
|
||||
{
|
||||
if (GameMain.Server == null) { return; }
|
||||
@@ -1432,7 +1451,6 @@ namespace Barotrauma
|
||||
GameMain.Server.PrintSenderTransters();
|
||||
}));
|
||||
|
||||
|
||||
commands.Add(new Command("forcelocationtypechange", "", (string[] args) =>
|
||||
{
|
||||
if (GameMain.Server == null || GameMain.GameSession?.Campaign == null) { return; }
|
||||
@@ -1568,6 +1586,19 @@ namespace Barotrauma
|
||||
GameMain.Server.SendChatMessage(ToolBox.RandomSeed(msgLength), ChatMessageType.Default);
|
||||
}
|
||||
}));
|
||||
|
||||
commands.Add(new Command("multiclienttestmode", "Makes the server assign campaign characters based on the name of the client and the character, as opposed to just checking the account ID or address. Useful for testing the campaign with multiple clients running locally.", (string[] args) =>
|
||||
{
|
||||
CharacterCampaignData.RequireClientNameMatch = !CharacterCampaignData.RequireClientNameMatch;
|
||||
if (CharacterCampaignData.RequireClientNameMatch)
|
||||
{
|
||||
NewMessage("Enabled RequireClientNameMatch (clients' names must match their campaign character)");
|
||||
}
|
||||
else
|
||||
{
|
||||
NewMessage("Disabled RequireClientNameMatch");
|
||||
}
|
||||
}));
|
||||
#endif
|
||||
|
||||
AssignOnClientRequestExecute(
|
||||
@@ -1751,17 +1782,32 @@ namespace Barotrauma
|
||||
{
|
||||
Submarine.MainSub.SetPosition(Level.Loaded.StartPosition - Vector2.UnitY * Submarine.MainSub.Borders.Height);
|
||||
}
|
||||
else
|
||||
else if (args[0].Equals("end", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Submarine.MainSub.SetPosition(Level.Loaded.EndPosition - Vector2.UnitY * Submarine.MainSub.Borders.Height);
|
||||
}
|
||||
else if (args[0].Equals("endoutpost", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Submarine.MainSub.SetPosition(Level.Loaded.EndExitPosition - Vector2.UnitY * Submarine.MainSub.Borders.Height);
|
||||
var submarineDockingPort = DockingPort.List.FirstOrDefault(d => d.Item.Submarine == Submarine.MainSub);
|
||||
if (Level.Loaded?.EndOutpost == null)
|
||||
{
|
||||
NewMessage("Can't teleport the sub to the end outpost (no outpost at the end of the level).", Color.Red);
|
||||
return;
|
||||
}
|
||||
var outpostDockingPort = DockingPort.List.FirstOrDefault(d => d.Item.Submarine == Level.Loaded.EndOutpost);
|
||||
if (submarineDockingPort != null && outpostDockingPort != null)
|
||||
{
|
||||
submarineDockingPort.Dock(outpostDockingPort);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
AssignOnClientRequestExecute("togglecampaignteleport",
|
||||
(Client client, Vector2 cursorWorldPos, string[] args) =>
|
||||
{
|
||||
if (!(GameMain.GameSession?.Campaign is MultiPlayerCampaign mpCampaign))
|
||||
if (GameMain.GameSession?.Campaign is not MultiPlayerCampaign mpCampaign)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("No campaign active.", client, Color.Red);
|
||||
return;
|
||||
@@ -2171,21 +2217,21 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
List<Command> grantedCommands = new List<Command>();
|
||||
string[] splitCommands = args.Skip(1).ToArray();
|
||||
bool giveAll = splitCommands.Length > 0 && splitCommands[0].Equals("all", StringComparison.OrdinalIgnoreCase);
|
||||
Identifier[] splitCommands = args.Skip(1)
|
||||
.Select(s => s.Trim()).ToIdentifiers().ToArray();
|
||||
bool giveAll = splitCommands.Length > 0 && splitCommands[0] == "all";
|
||||
if (giveAll)
|
||||
{
|
||||
grantedCommands.AddRange(commands);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < splitCommands.Length; i++)
|
||||
foreach (Identifier command in splitCommands)
|
||||
{
|
||||
splitCommands[i] = splitCommands[i].Trim().ToLowerInvariant();
|
||||
Command matchingCommand = commands.Find(c => c.names.Contains(splitCommands[i]));
|
||||
Command matchingCommand = commands.Find(c => c.Names.Contains(command));
|
||||
if (matchingCommand == null)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Could not find the command \"" + splitCommands[i] + "\"!", senderClient, Color.Red);
|
||||
GameMain.Server.SendConsoleMessage("Could not find the command \"" + command + "\"!", senderClient, Color.Red);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2204,7 +2250,7 @@ namespace Barotrauma
|
||||
}
|
||||
else if (grantedCommands.Count > 0)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Gave the client \"" + client.Name + "\" the permission to use console commands " + string.Join(", ", grantedCommands.Select(c => c.names[0])) + ".", senderClient);
|
||||
GameMain.Server.SendConsoleMessage("Gave the client \"" + client.Name + "\" the permission to use console commands " + string.Join(", ", grantedCommands.Select(c => c.Names[0])) + ".", senderClient);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -2227,21 +2273,21 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
List<Command> revokedCommands = new List<Command>();
|
||||
string[] splitCommands = args.Skip(1).ToArray();
|
||||
bool revokeAll = splitCommands.Length > 0 && splitCommands[0].Equals("all", StringComparison.OrdinalIgnoreCase);
|
||||
Identifier[] splitCommands = args.Skip(1)
|
||||
.Select(s => s.Trim()).ToIdentifiers().ToArray();
|
||||
bool revokeAll = splitCommands.Length > 0 && splitCommands[0] == "all";
|
||||
if (revokeAll)
|
||||
{
|
||||
revokedCommands.AddRange(commands);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < splitCommands.Length; i++)
|
||||
foreach (Identifier command in splitCommands)
|
||||
{
|
||||
splitCommands[i] = splitCommands[i].Trim().ToLowerInvariant();
|
||||
Command matchingCommand = commands.Find(c => c.names.Contains(splitCommands[i]));
|
||||
Command matchingCommand = commands.Find(c => c.Names.Contains(command));
|
||||
if (matchingCommand == null)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Could not find the command \"" + splitCommands[i] + "\"!", senderClient, Color.Red);
|
||||
GameMain.Server.SendConsoleMessage("Could not find the command \"" + command + "\"!", senderClient, Color.Red);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2256,14 +2302,14 @@ namespace Barotrauma
|
||||
client.RemovePermission(ClientPermissions.ConsoleCommands);
|
||||
}
|
||||
GameMain.Server.UpdateClientPermissions(client);
|
||||
GameMain.Server.SendConsoleMessage("Revoked \"" + client.Name + "\"'s permission to use the console commands " + string.Join(", ", revokedCommands.Select(c => c.names[0])) + ".", senderClient);
|
||||
GameMain.Server.SendConsoleMessage("Revoked \"" + client.Name + "\"'s permission to use the console commands " + string.Join(", ", revokedCommands.Select(c => c.Names[0])) + ".", senderClient);
|
||||
if (revokeAll)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Revoked \"" + client.Name + "\"'s permission to use console commands.", senderClient);
|
||||
}
|
||||
else if (revokedCommands.Count > 0)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Revoked \"" + client.Name + "\"'s permission to use the console commands " + string.Join(", ", revokedCommands.Select(c => c.names[0])) + ".", senderClient);
|
||||
GameMain.Server.SendConsoleMessage("Revoked \"" + client.Name + "\"'s permission to use the console commands " + string.Join(", ", revokedCommands.Select(c => c.Names[0])) + ".", senderClient);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -2308,7 +2354,7 @@ namespace Barotrauma
|
||||
GameMain.Server.SendConsoleMessage("Permitted console commands:", senderClient);
|
||||
foreach (Command permittedCommand in client.PermittedConsoleCommands)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage(" - " + permittedCommand.names[0], senderClient);
|
||||
GameMain.Server.SendConsoleMessage(" - " + permittedCommand.Names[0], senderClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2585,10 +2631,10 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
string[] splitCommand = ToolBox.SplitCommand(command);
|
||||
Command matchingCommand = commands.Find(c => c.names.Contains(splitCommand[0].ToLowerInvariant()));
|
||||
Command matchingCommand = commands.Find(c => c.Names.Contains(splitCommand[0].ToIdentifier()));
|
||||
if (matchingCommand != null && !client.PermittedConsoleCommands.Contains(matchingCommand) && client.Connection != GameMain.Server.OwnerConnection)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("You are not permitted to use the command\"" + matchingCommand.names[0] + "\"!", client, Color.Red);
|
||||
GameMain.Server.SendConsoleMessage("You are not permitted to use the command\"" + matchingCommand.Names[0] + "\"!", client, Color.Red);
|
||||
GameServer.Log(GameServer.ClientLogName(client) + " attempted to execute the console command \"" + command + "\" without a permission to use the command.", ServerLog.MessageType.ConsoleUsage);
|
||||
return;
|
||||
}
|
||||
@@ -2612,14 +2658,14 @@ namespace Barotrauma
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ThrowError("Executing the command \"" + matchingCommand.names[0] + "\" by request from \"" + GameServer.ClientLogName(client) + "\" failed.", e);
|
||||
ThrowError("Executing the command \"" + matchingCommand.Names[0] + "\" by request from \"" + GameServer.ClientLogName(client) + "\" failed.", e);
|
||||
}
|
||||
}
|
||||
|
||||
static partial void ShowHelpMessage(Command command)
|
||||
{
|
||||
NewMessage(command.names[0], Color.Cyan);
|
||||
NewMessage(command.help, Color.Gray);
|
||||
NewMessage(command.Names[0].Value, Color.Cyan);
|
||||
NewMessage(command.Help, Color.Gray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ partial class EventLogAction : EventAction
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.AddWarning($"{target} is not a valid target for an EventLogAction. The target should be a character.");
|
||||
DebugConsole.AddWarning($"{target} is not a valid target for an EventLogAction. The target should be a character.",
|
||||
ParentEvent.Prefab.ContentPackage);
|
||||
}
|
||||
}
|
||||
if (eventLog.TryAddEntry(ParentEvent.Prefab.Identifier, Id, displayText, targetClients) && ShowInServerLog)
|
||||
|
||||
@@ -118,26 +118,13 @@ namespace Barotrauma
|
||||
|
||||
private void CheckContentPackage()
|
||||
{
|
||||
//TODO: reimplement using only core package?
|
||||
/*foreach (ContentPackage contentPackage in Config.AllEnabledPackages)
|
||||
if (Version < VanillaContent.GameVersion)
|
||||
{
|
||||
var exePaths = contentPackage.GetFilesOfType(ContentType.ServerExecutable);
|
||||
if (exePaths.Count() > 0 && AppDomain.CurrentDomain.FriendlyName != exePaths.First())
|
||||
{
|
||||
DebugConsole.NewMessage(AppDomain.CurrentDomain.FriendlyName);
|
||||
DebugConsole.ShowQuestionPrompt(TextManager.GetWithVariables("IncorrectExe", new string[2] { "[selectedpackage]", "[exename]" }, new string[2] { contentPackage.Name, exePaths.First() }),
|
||||
(option) =>
|
||||
{
|
||||
if (option.ToLower() == "y" || option.ToLower() == "yes")
|
||||
{
|
||||
string fullPath = Path.GetFullPath(exePaths.First());
|
||||
ToolBox.OpenFileWithShell(fullPath);
|
||||
ShouldRun = false;
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
DebugConsole.ThrowError(
|
||||
TextManager.GetWithVariables("versionmismatchwarning",
|
||||
("[gameversion]", Version.ToString()),
|
||||
("[contentversion]", VanillaContent.GameVersion.ToString())));
|
||||
}
|
||||
}
|
||||
|
||||
public void StartServer()
|
||||
|
||||
@@ -2,27 +2,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Barotrauma.Networking;
|
||||
using System.Text;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class CargoManager
|
||||
{
|
||||
public void SellBackPurchasedItems(Identifier storeIdentifier, List<PurchasedItem> itemsToSell, Client client)
|
||||
{
|
||||
// Check all the prices before starting the transaction to make sure the modifiers stay the same for the whole transaction
|
||||
var buyValues = GetBuyValuesAtCurrentLocation(storeIdentifier, itemsToSell.Select(i => i.ItemPrefab));
|
||||
var store = Location.GetStore(storeIdentifier);
|
||||
if (store == null) { return; }
|
||||
var storeSpecificItems = GetPurchasedItems(storeIdentifier);
|
||||
foreach (var item in itemsToSell)
|
||||
{
|
||||
var itemValue = item.Quantity * buyValues[item.ItemPrefab];
|
||||
store.Balance -= itemValue;
|
||||
campaign.GetWallet(client).Give(itemValue);
|
||||
storeSpecificItems?.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void BuyBackSoldItems(Identifier storeIdentifier, List<SoldItem> itemsToBuy, Client client)
|
||||
{
|
||||
var store = Location.GetStore(storeIdentifier);
|
||||
@@ -80,6 +65,21 @@ namespace Barotrauma
|
||||
OnSoldItemsChanged?.Invoke(this);
|
||||
}
|
||||
|
||||
public void LogNewItemPurchases(Identifier storeIdentifier, List<PurchasedItem> newItems, Client client)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int price = 0;
|
||||
Dictionary<ItemPrefab, int> buyValues = GetBuyValuesAtCurrentLocation(storeIdentifier, newItems.Select(i => i.ItemPrefab));
|
||||
foreach (PurchasedItem item in newItems)
|
||||
{
|
||||
int itemValue = item.Quantity * buyValues[item.ItemPrefab];
|
||||
GameAnalyticsManager.AddMoneySpentEvent(itemValue, GameAnalyticsManager.MoneySink.Store, item.ItemPrefab.Identifier.Value);
|
||||
sb.Append($"\n - {item.ItemPrefab.Name} x{item.Quantity}");
|
||||
price += itemValue;
|
||||
}
|
||||
GameServer.Log($"{NetworkMember.ClientLogName(client, client?.Name ?? "Unknown")} purchased {newItems.Count} item(s) for {TextManager.FormatCurrency(price)}{sb.ToString()}", ServerLog.MessageType.Money);
|
||||
}
|
||||
|
||||
public void ClearSoldItemsProjSpecific()
|
||||
{
|
||||
SoldItems.Clear();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.Networking;
|
||||
using Barotrauma.Networking;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -27,6 +26,15 @@ namespace Barotrauma
|
||||
AnyOneAllowedToManageCampaign(permissions);
|
||||
}
|
||||
|
||||
public static bool AllowImmediateItemDelivery(Client client)
|
||||
{
|
||||
if (client == null || GameMain.Server == null) { return false; }
|
||||
return
|
||||
GameMain.Server.ServerSettings.AllowImmediateItemDelivery ||
|
||||
client.HasPermission(ClientPermissions.ManageCampaign) ||
|
||||
client.Connection == GameMain.Server.OwnerConnection;
|
||||
}
|
||||
|
||||
public static bool AllowedToManageWallets(Client client)
|
||||
{
|
||||
return AllowedToManageCampaign(client, ClientPermissions.ManageMoney);
|
||||
|
||||
@@ -6,6 +6,14 @@ namespace Barotrauma
|
||||
{
|
||||
partial class CharacterCampaignData
|
||||
{
|
||||
#if DEBUG
|
||||
/// <summary>
|
||||
/// If enabled, client names must match the name of the character. Useful for testing the campaign with multiple clients running locally:
|
||||
/// without this, the clients would all get assigned the same character due to all of them having the same AccountId or Address.
|
||||
/// </summary>
|
||||
public static bool RequireClientNameMatch = false;
|
||||
#endif
|
||||
|
||||
public bool HasSpawned;
|
||||
|
||||
public bool HasItemData
|
||||
@@ -76,7 +84,7 @@ namespace Barotrauma
|
||||
{
|
||||
case "character":
|
||||
case "characterinfo":
|
||||
CharacterInfo = new CharacterInfo(subElement);
|
||||
CharacterInfo = new CharacterInfo(new ContentXElement(contentPackage: null, subElement));
|
||||
break;
|
||||
case "inventory":
|
||||
itemData = subElement;
|
||||
@@ -103,6 +111,12 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
#if DEBUG
|
||||
if (RequireClientNameMatch)
|
||||
{
|
||||
return ClientAddress == client.Connection.Endpoint.Address && client.Name == Name;
|
||||
}
|
||||
#endif
|
||||
return ClientAddress == client.Connection.Endpoint.Address;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -806,7 +806,7 @@ namespace Barotrauma
|
||||
UInt16 itemToRemoveID = msg.ReadUInt16();
|
||||
Identifier itemToInstallIdentifier = msg.ReadIdentifier();
|
||||
ItemPrefab itemToInstall = itemToInstallIdentifier.IsEmpty ? null : ItemPrefab.Find(string.Empty, itemToInstallIdentifier);
|
||||
if (!(Entity.FindEntityByID(itemToRemoveID) is Item itemToRemove)) { continue; }
|
||||
if (Entity.FindEntityByID(itemToRemoveID) is not Item itemToRemove) { continue; }
|
||||
purchasedItemSwaps.Add(new PurchasedItemSwap(itemToRemove, itemToInstall));
|
||||
}
|
||||
|
||||
@@ -894,7 +894,7 @@ namespace Barotrauma
|
||||
int availableQuantity = map.CurrentLocation.Stores[store.Key].Stock.Find(s => s.ItemPrefab == item.ItemPrefab)?.Quantity ?? 0;
|
||||
int alreadyPurchasedQuantity =
|
||||
CargoManager.GetBuyCrateItem(store.Key, item.ItemPrefab)?.Quantity ?? 0 +
|
||||
CargoManager.GetPurchasedItem(store.Key, item.ItemPrefab)?.Quantity ?? 0;
|
||||
CargoManager.GetPurchasedItemCount(store.Key, item.ItemPrefab);
|
||||
item.Quantity = MathHelper.Clamp(item.Quantity, 0, availableQuantity - alreadyPurchasedQuantity);
|
||||
CargoManager.ModifyItemQuantityInBuyCrate(store.Key, item.ItemPrefab, item.Quantity, sender);
|
||||
}
|
||||
@@ -905,9 +905,41 @@ namespace Barotrauma
|
||||
{
|
||||
prevPurchasedItems.Add(kvp.Key, new List<PurchasedItem>(kvp.Value));
|
||||
}
|
||||
foreach (var kvp in prevPurchasedItems)
|
||||
|
||||
foreach (var storeId in purchasedItems.Keys)
|
||||
{
|
||||
CargoManager.SellBackPurchasedItems(kvp.Key, kvp.Value, sender);
|
||||
DebugConsole.Log($"Purchased items ({storeId}):\n");
|
||||
if (prevPurchasedItems.TryGetValue(storeId, out var alreadyPurchased))
|
||||
{
|
||||
var delivered = alreadyPurchased.Where(it => it.Delivered);
|
||||
var notDelivered = alreadyPurchased.Where(it => !it.Delivered);
|
||||
if (delivered.Any())
|
||||
{
|
||||
DebugConsole.Log($" Already delivered:\n" + string.Concat(delivered.Select(it => $" - {it.ItemPrefab.Name} (x{it.Quantity})")));
|
||||
}
|
||||
if (notDelivered.Any())
|
||||
{
|
||||
DebugConsole.Log($" Already purchased:\n" + string.Concat(notDelivered.Where(it => !it.Delivered).Select(it => $" - {it.ItemPrefab.Name} (x{it.Quantity})")));
|
||||
}
|
||||
}
|
||||
DebugConsole.Log($" New purchases:");
|
||||
foreach (var purchasedItem in purchasedItems[storeId])
|
||||
{
|
||||
if (purchasedItem.Delivered) { continue; }
|
||||
int quantity = purchasedItem.Quantity;
|
||||
if (alreadyPurchased != null)
|
||||
{
|
||||
quantity -= alreadyPurchased.Where(it => it.DeliverImmediately == purchasedItem.DeliverImmediately && it.ItemPrefab == purchasedItem.ItemPrefab).Sum(it => it.Quantity);
|
||||
}
|
||||
if (quantity > 0)
|
||||
{
|
||||
DebugConsole.Log($" - {purchasedItem.ItemPrefab.Name} (x{quantity})");
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var storeId in soldItems.Keys)
|
||||
{
|
||||
DebugConsole.Log($"Sold items:\n" + string.Concat(soldItems[storeId].Select(it => $" - {it.ItemPrefab.Name}")));
|
||||
}
|
||||
|
||||
foreach (var kvp in purchasedItems)
|
||||
@@ -916,17 +948,23 @@ namespace Barotrauma
|
||||
var purchasedItemList = kvp.Value;
|
||||
foreach (var purchasedItem in purchasedItemList)
|
||||
{
|
||||
int desiredQuantity = purchasedItem.Quantity;
|
||||
if (prevPurchasedItems.TryGetValue(storeId, out var alreadyPurchasedList) &&
|
||||
alreadyPurchasedList.FirstOrDefault(p => p.ItemPrefab == purchasedItem.ItemPrefab) is { } alreadyPurchased)
|
||||
{
|
||||
desiredQuantity -= alreadyPurchased.Quantity;
|
||||
}
|
||||
int availableQuantity = map.CurrentLocation.Stores[storeId].Stock.Find(s => s.ItemPrefab == purchasedItem.ItemPrefab)?.Quantity ?? 0;
|
||||
purchasedItem.Quantity = Math.Min(purchasedItem.Quantity, availableQuantity);
|
||||
}
|
||||
CargoManager.PurchaseItems(storeId, purchasedItemList, false, sender);
|
||||
purchasedItem.Quantity = Math.Min(desiredQuantity, availableQuantity);
|
||||
}
|
||||
CargoManager.PurchaseItems(storeId, purchasedItemList, removeFromCrate: false, client: sender);
|
||||
}
|
||||
|
||||
foreach (var (storeIdentifier, items) in CargoManager.PurchasedItems)
|
||||
{
|
||||
if (!prevPurchasedItems.ContainsKey(storeIdentifier))
|
||||
{
|
||||
CargoManager.OnNewItemsPurchased(storeIdentifier, items, sender);
|
||||
CargoManager.LogNewItemPurchases(storeIdentifier, items, sender);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -941,7 +979,6 @@ namespace Barotrauma
|
||||
newItems.Add(item);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (matching.Quantity < item.Quantity)
|
||||
{
|
||||
newItems.Add(new PurchasedItem(item.ItemPrefab, item.Quantity - matching.Quantity, sender));
|
||||
@@ -950,7 +987,7 @@ namespace Barotrauma
|
||||
|
||||
if (newItems.Any())
|
||||
{
|
||||
CargoManager.OnNewItemsPurchased(storeIdentifier, newItems, sender);
|
||||
CargoManager.LogNewItemPurchases(storeIdentifier, newItems, sender);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1015,7 +1052,7 @@ namespace Barotrauma
|
||||
UpgradeManager.PurchaseUpgrade(prefab, category, client: sender);
|
||||
|
||||
// unstable logging
|
||||
int price = prefab.Price.GetBuyPrice(UpgradeManager.GetUpgradeLevel(prefab, category), Map?.CurrentLocation, characterList);
|
||||
int price = prefab.Price.GetBuyPrice(prefab, UpgradeManager.GetUpgradeLevel(prefab, category), Map?.CurrentLocation, characterList);
|
||||
int level = UpgradeManager.GetUpgradeLevel(prefab, category);
|
||||
GameServer.Log($"SERVER: Purchased level {level} {category.Identifier}.{prefab.Identifier} for {price}", ServerLog.MessageType.ServerMessage);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#nullable enable
|
||||
|
||||
using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
@@ -138,7 +138,7 @@ namespace Barotrauma.Items.Components
|
||||
return;
|
||||
}
|
||||
|
||||
bool result = AddComponentInternal(id, prefab, resource.Prefab, data.Position, it =>
|
||||
bool result = AddComponentInternal(id, prefab, resource.Prefab, data.Position, c.Character, it =>
|
||||
{
|
||||
CreateServerEvent(new CircuitBoxServerCreateComponentEvent(it.ID, resource.Prefab.UintIdentifier, id, data.Position));
|
||||
});
|
||||
@@ -304,7 +304,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private void ThrowError(string message, Client c)
|
||||
{
|
||||
DebugConsole.ThrowError(message);
|
||||
DebugConsole.ThrowError(message,
|
||||
contentPackage: item.Prefab.ContentPackage);
|
||||
SendToClient(CircuitBoxOpcode.Error, new CircuitBoxErrorEvent(message), c);
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,8 @@ namespace Barotrauma
|
||||
(pickable.IsAttached && !pickable.PickingDone) ||
|
||||
item.AllowedSlots.None())
|
||||
{
|
||||
DebugConsole.AddWarning($"Client {c.Name} tried to pick up a non-pickable item \"{item}\" (parent inventory: {item.ParentInventory?.Owner.ToString() ?? "null"})");
|
||||
DebugConsole.AddWarning($"Client {c.Name} tried to pick up a non-pickable item \"{item}\" (parent inventory: {item.ParentInventory?.Owner.ToString() ?? "null"})",
|
||||
item.Prefab.ContentPackage);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace Barotrauma
|
||||
out NetworkFireSource[] newFireSources);
|
||||
|
||||
if (!c.HasPermission(ClientPermissions.ConsoleCommands) ||
|
||||
!c.PermittedConsoleCommands.Any(command => command.names.Contains("fire") || command.names.Contains("editfire")))
|
||||
!c.PermittedConsoleCommands.Any(command => command.Names.Contains("fire".ToIdentifier()) || command.Names.Contains("editfire".ToIdentifier())))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -138,7 +138,7 @@ namespace Barotrauma
|
||||
|
||||
var newFire = i < FireSources.Count ?
|
||||
FireSources[i] :
|
||||
new FireSource(Submarine == null ? pos : pos + Submarine.Position, null, true);
|
||||
new FireSource(Submarine == null ? pos : pos + Submarine.Position, sourceCharacter: null, isNetworkMessage: true);
|
||||
newFire.Position = pos;
|
||||
newFire.Size = new Vector2(size, newFire.Size.Y);
|
||||
|
||||
|
||||
@@ -80,58 +80,10 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
c.LastSentChatMessages.RemoveRange(0, c.LastSentChatMessages.Count - 10);
|
||||
}
|
||||
|
||||
float similarity = 0.0f;
|
||||
for (int i = 0; i < c.LastSentChatMessages.Count; i++)
|
||||
{
|
||||
float closeFactor = 1.0f / (c.LastSentChatMessages.Count - i);
|
||||
|
||||
if (string.IsNullOrEmpty(txt))
|
||||
{
|
||||
similarity += closeFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
int levenshteinDist = ToolBox.LevenshteinDistance(txt, c.LastSentChatMessages[i]);
|
||||
similarity += Math.Max((txt.Length - levenshteinDist) / (float)txt.Length * closeFactor, 0.0f);
|
||||
}
|
||||
}
|
||||
//order/report messages can be sent a little faster than normal messages without triggering the spam filter
|
||||
if (orderMsg != null)
|
||||
{
|
||||
similarity *= 0.25f;
|
||||
}
|
||||
|
||||
bool isSpamExempt = RateLimiter.IsExempt(c);
|
||||
|
||||
if (similarity + c.ChatSpamSpeed > 5.0f && !isSpamExempt)
|
||||
{
|
||||
GameMain.Server.KarmaManager.OnSpamFilterTriggered(c);
|
||||
|
||||
c.ChatSpamCount++;
|
||||
if (c.ChatSpamCount > 3)
|
||||
{
|
||||
//kick for spamming too much
|
||||
GameMain.Server.KickClient(c, TextManager.Get("SpamFilterKicked").Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatMessage denyMsg = Create("", TextManager.Get("SpamFilterBlocked").Value, ChatMessageType.Server, null);
|
||||
c.ChatSpamTimer = 10.0f;
|
||||
GameMain.Server.SendDirectChatMessage(denyMsg, c);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
c.ChatSpamSpeed += similarity + 0.5f;
|
||||
|
||||
if (c.ChatSpamTimer > 0.0f && !isSpamExempt)
|
||||
{
|
||||
ChatMessage denyMsg = Create("", TextManager.Get("SpamFilterBlocked").Value, ChatMessageType.Server, null);
|
||||
c.ChatSpamTimer = 10.0f;
|
||||
GameMain.Server.SendDirectChatMessage(denyMsg, c);
|
||||
return;
|
||||
}
|
||||
//order/report messages can be sent a little faster than normal messages without triggering the spam filter;
|
||||
float similarityMultiplier = orderMsg != null ? 0.25f : 1.0f;
|
||||
HandleSpamFilter(c, txt, out bool flaggedAsSpam, similarityMultiplier);
|
||||
if (flaggedAsSpam) { return; }
|
||||
|
||||
if (type == ChatMessageType.Order)
|
||||
{
|
||||
@@ -177,6 +129,65 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increase the client's chat spam speed and check whether the spam filter should kick in
|
||||
/// </summary>
|
||||
public static void HandleSpamFilter(Client c, string messageText, out bool flaggedAsSpam, float similarityMultiplier = 1.0f)
|
||||
{
|
||||
float similarity = 0.0f;
|
||||
for (int i = 0; i < c.LastSentChatMessages.Count; i++)
|
||||
{
|
||||
float closeFactor = 1.0f / (c.LastSentChatMessages.Count - i);
|
||||
|
||||
if (string.IsNullOrEmpty(messageText))
|
||||
{
|
||||
similarity += closeFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
int levenshteinDist = ToolBox.LevenshteinDistance(messageText, c.LastSentChatMessages[i]);
|
||||
similarity += Math.Max((messageText.Length - levenshteinDist) / (float)messageText.Length * closeFactor, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
similarity *= similarityMultiplier;
|
||||
|
||||
bool isSpamExempt = RateLimiter.IsExempt(c);
|
||||
|
||||
if (similarity + c.ChatSpamSpeed > 5.0f && !isSpamExempt)
|
||||
{
|
||||
GameMain.Server.KarmaManager.OnSpamFilterTriggered(c);
|
||||
|
||||
c.ChatSpamCount++;
|
||||
if (c.ChatSpamCount > 3)
|
||||
{
|
||||
//kick for spamming too much
|
||||
GameMain.Server.KickClient(c, TextManager.Get("SpamFilterKicked").Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatMessage denyMsg = Create("", TextManager.Get("SpamFilterBlocked").Value, ChatMessageType.Server, null);
|
||||
c.ChatSpamTimer = 10.0f;
|
||||
GameMain.Server.SendDirectChatMessage(denyMsg, c);
|
||||
}
|
||||
flaggedAsSpam = true;
|
||||
return;
|
||||
}
|
||||
|
||||
c.ChatSpamSpeed += similarity + 0.5f;
|
||||
|
||||
if (c.ChatSpamTimer > 0.0f && !isSpamExempt)
|
||||
{
|
||||
ChatMessage denyMsg = Create("", TextManager.Get("SpamFilterBlocked").Value, ChatMessageType.Server, null);
|
||||
c.ChatSpamTimer = 10.0f;
|
||||
GameMain.Server.SendDirectChatMessage(denyMsg, c);
|
||||
flaggedAsSpam = true;
|
||||
return;
|
||||
}
|
||||
|
||||
flaggedAsSpam = false;
|
||||
}
|
||||
|
||||
public int EstimateLengthBytesServer(Client c)
|
||||
{
|
||||
int length = 1 + //(byte)ServerNetObject.CHAT_MESSAGE
|
||||
|
||||
@@ -369,6 +369,9 @@ namespace Barotrauma.Networking
|
||||
if (!character.ClientDisconnected) { continue; }
|
||||
|
||||
Client owner = connectedClients.Find(c => (c.Character == null || c.Character == character) && character.IsClientOwner(c));
|
||||
bool canOwnerTakeControl =
|
||||
owner != null && owner.InGame && !owner.NeedsMidRoundSync &&
|
||||
(!ServerSettings.AllowSpectating || !owner.SpectateOnly);
|
||||
if (!character.IsDead)
|
||||
{
|
||||
character.KillDisconnectedTimer += deltaTime;
|
||||
@@ -379,18 +382,19 @@ namespace Barotrauma.Networking
|
||||
character.Kill(CauseOfDeathType.Disconnected, null);
|
||||
continue;
|
||||
}
|
||||
if (owner != null && owner.InGame && !owner.NeedsMidRoundSync &&
|
||||
(!ServerSettings.AllowSpectating || !owner.SpectateOnly))
|
||||
if (canOwnerTakeControl)
|
||||
{
|
||||
SetClientCharacter(owner, character);
|
||||
}
|
||||
}
|
||||
else if (owner != null &&
|
||||
else if (canOwnerTakeControl &&
|
||||
character.CauseOfDeath?.Type == CauseOfDeathType.Disconnected &&
|
||||
character.CharacterHealth.VitalityDisregardingDeath > 0)
|
||||
{
|
||||
//create network event immediately to ensure the character is revived client-side
|
||||
//before the client gains control of it (normally status events are created periodically)
|
||||
character.Revive(removeAfflictions: false, createNetworkEvent: true);
|
||||
SetClientCharacter(owner, character);
|
||||
character.Revive(removeAfflictions: false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2534,7 +2538,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
spawnList.Add(new PurchasedItem(kvp.Key, kvp.Value, buyer: null));
|
||||
}
|
||||
CargoManager.CreateItems(spawnList, sub, cargoManager: null);
|
||||
CargoManager.DeliverItemsToSub(spawnList, sub, cargoManager: null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2581,6 +2585,7 @@ namespace Barotrauma.Networking
|
||||
msg.WriteBoolean(ServerSettings.AllowRespawn && missionAllowRespawn);
|
||||
msg.WriteBoolean(ServerSettings.AllowDisguises);
|
||||
msg.WriteBoolean(ServerSettings.AllowRewiring);
|
||||
msg.WriteBoolean(ServerSettings.AllowImmediateItemDelivery);
|
||||
msg.WriteBoolean(ServerSettings.AllowFriendlyFire);
|
||||
msg.WriteBoolean(ServerSettings.LockAllDefaultWires);
|
||||
msg.WriteBoolean(ServerSettings.AllowLinkingWifiToChat);
|
||||
@@ -3706,8 +3711,12 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
|
||||
public readonly List<string> JobAssignmentDebugLog = new List<string>();
|
||||
|
||||
public void AssignJobs(List<Client> unassigned)
|
||||
{
|
||||
JobAssignmentDebugLog.Clear();
|
||||
|
||||
var jobList = JobPrefab.Prefabs.ToList();
|
||||
unassigned = new List<Client>(unassigned);
|
||||
unassigned = unassigned.OrderBy(sp => Rand.Int(int.MaxValue)).ToList();
|
||||
@@ -3729,10 +3738,11 @@ namespace Barotrauma.Networking
|
||||
//remove already assigned clients from unassigned
|
||||
unassigned.RemoveAll(u => campaignAssigned.ContainsKey(u));
|
||||
//add up to assigned client count
|
||||
foreach (KeyValuePair<Client, Job> clientJob in campaignAssigned)
|
||||
foreach ((Client client, Job job) in campaignAssigned)
|
||||
{
|
||||
assignedClientCount[clientJob.Value.Prefab]++;
|
||||
clientJob.Key.AssignedJob = new JobVariant(clientJob.Value.Prefab, clientJob.Value.Variant);
|
||||
assignedClientCount[job.Prefab]++;
|
||||
client.AssignedJob = new JobVariant(job.Prefab, job.Variant);
|
||||
JobAssignmentDebugLog.Add($"Client {client.Name} has an existing campaign character, keeping the job {job.Name}.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3751,6 +3761,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (unassigned[i].JobPreferences.Count == 0) { continue; }
|
||||
if (!unassigned[i].JobPreferences.Any() || !unassigned[i].JobPreferences[0].Prefab.AllowAlways) { continue; }
|
||||
JobAssignmentDebugLog.Add($"Client {unassigned[i].Name} has {unassigned[i].JobPreferences[0].Prefab.Name} as their first preference, assigning it because the job is always allowed.");
|
||||
unassigned[i].AssignedJob = unassigned[i].JobPreferences[0];
|
||||
unassigned.RemoveAt(i);
|
||||
}
|
||||
@@ -3769,6 +3780,7 @@ namespace Barotrauma.Networking
|
||||
Client client = FindClientWithJobPreference(unassigned, jobPrefab, forceAssign: false);
|
||||
if (client != null)
|
||||
{
|
||||
JobAssignmentDebugLog.Add($"At least {jobPrefab.MinNumber} {jobPrefab.Name} required. Assigning {client.Name} as a {jobPrefab.Name} (has the job in their preferences).");
|
||||
AssignJob(client, jobPrefab);
|
||||
}
|
||||
}
|
||||
@@ -3780,7 +3792,11 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (unassigned.Count == 0) { break; }
|
||||
if (jobPrefab.MinNumber < 1 || assignedClientCount[jobPrefab] >= jobPrefab.MinNumber) { continue; }
|
||||
AssignJob(FindClientWithJobPreference(unassigned, jobPrefab, forceAssign: true), jobPrefab);
|
||||
var client = FindClientWithJobPreference(unassigned, jobPrefab, forceAssign: true);
|
||||
JobAssignmentDebugLog.Add(
|
||||
$"At least {jobPrefab.MinNumber} {jobPrefab.Name} required. "+
|
||||
$"A random client needs to be assigned because no one has the job in their preferences. Assigning {client.Name} as a {jobPrefab.Name}.");
|
||||
AssignJob(client, jobPrefab);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3798,32 +3814,6 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
|
||||
List<WayPoint> availableSpawnPoints = WayPoint.WayPointList.FindAll(wp =>
|
||||
wp.SpawnType == SpawnType.Human &&
|
||||
wp.Submarine != null && wp.Submarine.TeamID == teamID);
|
||||
|
||||
/*bool canAssign = false;
|
||||
do
|
||||
{
|
||||
canAssign = false;
|
||||
foreach (WayPoint spawnPoint in unassignedSpawnPoints)
|
||||
{
|
||||
if (unassigned.Count == 0) { break; }
|
||||
|
||||
JobPrefab job = spawnPoint.AssignedJob ?? JobPrefab.List.Values.GetRandom();
|
||||
if (assignedClientCount[job] >= job.MaxNumber) { continue; }
|
||||
|
||||
Client assignedClient = FindClientWithJobPreference(unassigned, job, true);
|
||||
if (assignedClient != null)
|
||||
{
|
||||
assignedClient.AssignedJob = job;
|
||||
assignedClientCount[job]++;
|
||||
unassigned.Remove(assignedClient);
|
||||
canAssign = true;
|
||||
}
|
||||
}
|
||||
} while (unassigned.Count > 0 && canAssign);*/
|
||||
|
||||
// Attempt to give the clients a job they have in their job preferences.
|
||||
// First evaluate all the primary preferences, then all the secondary etc.
|
||||
for (int preferenceIndex = 0; preferenceIndex < 3; preferenceIndex++)
|
||||
@@ -3834,12 +3824,17 @@ namespace Barotrauma.Networking
|
||||
if (preferenceIndex >= client.JobPreferences.Count) { continue; }
|
||||
var preferredJob = client.JobPreferences[preferenceIndex];
|
||||
JobPrefab jobPrefab = preferredJob.Prefab;
|
||||
if (assignedClientCount[jobPrefab] >= jobPrefab.MaxNumber || client.Karma < jobPrefab.MinKarma)
|
||||
if (assignedClientCount[jobPrefab] >= jobPrefab.MaxNumber)
|
||||
{
|
||||
//can't assign this job if maximum number has reached or the clien't karma is too low
|
||||
JobAssignmentDebugLog.Add($"{client.Name} has {jobPrefab.Name} as their {preferenceIndex + 1}. preference. Cannot assign, maximum number of the job has been reached.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (client.Karma < jobPrefab.MinKarma)
|
||||
{
|
||||
JobAssignmentDebugLog.Add($"{client.Name} has {jobPrefab.Name} as their {preferenceIndex + 1}. preference. Cannot assign, karma too low ({client.Karma} < {jobPrefab.MinKarma}).");
|
||||
continue;
|
||||
}
|
||||
JobAssignmentDebugLog.Add($"{client.Name} has {jobPrefab.Name} as their {preferenceIndex + 1}. preference. Assigning {client.Name} as a {jobPrefab.Name}.");
|
||||
client.AssignedJob = preferredJob;
|
||||
assignedClientCount[jobPrefab]++;
|
||||
unassigned.RemoveAt(i);
|
||||
@@ -3855,7 +3850,9 @@ namespace Barotrauma.Networking
|
||||
//all jobs taken, give a random job
|
||||
if (remainingJobs.Count == 0)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to assign a suitable job for \"" + c.Name + "\" (all jobs already have the maximum numbers of players). Assigning a random job...");
|
||||
string errorMsg = $"Failed to assign a suitable job for \"{c.Name}\" (all jobs already have the maximum numbers of players). Assigning a random job...";
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
JobAssignmentDebugLog.Add(errorMsg);
|
||||
int jobIndex = Rand.Range(0, jobList.Count);
|
||||
int skips = 0;
|
||||
while (c.Karma < jobList[jobIndex].MinKarma)
|
||||
@@ -3871,19 +3868,20 @@ namespace Barotrauma.Networking
|
||||
assignedClientCount[c.AssignedJob.Prefab]++;
|
||||
}
|
||||
//if one of the client's preferences is still available, give them that job
|
||||
else if (c.JobPreferences.Any(jp => remainingJobs.Contains(jp.Prefab)))
|
||||
else if (c.JobPreferences.FirstOrDefault(jp => remainingJobs.Contains(jp.Prefab)) is { } remainingJob)
|
||||
{
|
||||
foreach (JobVariant preferredJob in c.JobPreferences)
|
||||
{
|
||||
c.AssignedJob = preferredJob;
|
||||
assignedClientCount[preferredJob.Prefab]++;
|
||||
break;
|
||||
}
|
||||
JobAssignmentDebugLog.Add(
|
||||
$"{c.Name} has {remainingJob.Prefab.Name} as their {c.JobPreferences.IndexOf(remainingJob) + 1}. preference, and it is still available."+
|
||||
$" Assigning {c.Name} as a {remainingJob.Prefab.Name}.");
|
||||
c.AssignedJob = remainingJob;
|
||||
assignedClientCount[remainingJob.Prefab]++;
|
||||
}
|
||||
else //none of the client's preferred jobs available, choose a random job
|
||||
{
|
||||
c.AssignedJob = new JobVariant(remainingJobs[Rand.Range(0, remainingJobs.Count)], 0);
|
||||
assignedClientCount[c.AssignedJob.Prefab]++;
|
||||
JobAssignmentDebugLog.Add(
|
||||
$"No suitable jobs available for {c.Name} (karma {c.Karma}). Assigning a random job: {c.AssignedJob.Prefab.Name}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,7 +611,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
foreach (DebugConsole.Command command in clientPermission.PermittedCommands)
|
||||
{
|
||||
clientElement.Add(new XElement("command", new XAttribute("name", command.names[0])));
|
||||
clientElement.Add(new XElement("command", new XAttribute("name", command.Names[0])));
|
||||
}
|
||||
}
|
||||
doc.Root.Add(clientElement);
|
||||
|
||||
@@ -345,9 +345,15 @@ namespace Barotrauma
|
||||
sender.SetVote(voteType, client);
|
||||
if (client?.Character != null)
|
||||
{
|
||||
GameMain.Server.SendChatMessage(
|
||||
TextManager.GetWithVariable("traitor.blamebutton.dialog", "[name]", client.Character.DisplayName).Value,
|
||||
ChatMessageType.Radio, senderClient: sender, senderCharacter: sender.Character);
|
||||
string msg = TextManager.GetWithVariable("traitor.blamebutton.dialog", "[name]", client.Character.DisplayName).Value;
|
||||
ChatMessage.HandleSpamFilter(sender, msg, out bool flaggedAsSpam);
|
||||
if (!flaggedAsSpam)
|
||||
{
|
||||
GameMain.Server.SendChatMessage(
|
||||
msg,
|
||||
ChatMessageType.Radio, senderClient: sender, senderCharacter: sender.Character);
|
||||
sender.LastSentChatMessages.Add(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -58,15 +58,20 @@ namespace Barotrauma.Steam
|
||||
Steamworks.SteamServer.SetKey("message", server.ServerSettings.ServerMessageText);
|
||||
Steamworks.SteamServer.SetKey("version", GameMain.Version.ToString());
|
||||
Steamworks.SteamServer.SetKey("playercount", server.ConnectedClients.Count.ToString());
|
||||
|
||||
//a2s seems to break if too much data is added (seems to be related to MTU?)
|
||||
//let's restrict the number of packages to 10, clients can use packagecount to tell when the list has been truncated
|
||||
const int MaxPackagesToList = 10;
|
||||
int index = 0;
|
||||
foreach (var contentPackage in contentPackages)
|
||||
foreach (var contentPackage in contentPackages.Take(MaxPackagesToList))
|
||||
{
|
||||
string ugcIdStr = contentPackage.UgcId.TryUnwrap(out var ugcId) ? ugcId.StringRepresentation : string.Empty;
|
||||
Steamworks.SteamServer.SetKey(
|
||||
$"contentpackage{index}",
|
||||
contentPackage.Name+","+ contentPackage.Hash.StringRepresentation + "," + ugcIdStr);
|
||||
$"contentpackage{index}",
|
||||
contentPackage.Name + "," + contentPackage.Hash.StringRepresentation + "," + ugcIdStr);
|
||||
index++;
|
||||
}
|
||||
Steamworks.SteamServer.SetKey("packagecount", contentPackages.Count().ToString());
|
||||
Steamworks.SteamServer.SetKey("modeselectionmode", server.ServerSettings.ModeSelectionMode.ToString());
|
||||
Steamworks.SteamServer.SetKey("subselectionmode", server.ServerSettings.SubSelectionMode.ToString());
|
||||
Steamworks.SteamServer.SetKey("voicechatenabled", server.ServerSettings.VoiceChatEnabled.ToString());
|
||||
@@ -79,6 +84,10 @@ namespace Barotrauma.Steam
|
||||
Steamworks.SteamServer.SetKey("gamemode", server.ServerSettings.GameModeIdentifier.Value);
|
||||
Steamworks.SteamServer.SetKey("playstyle", server.ServerSettings.PlayStyle.ToString());
|
||||
Steamworks.SteamServer.SetKey("language", server.ServerSettings.Language.ToString());
|
||||
if (GameMain.NetLobbyScreen?.SelectedSub != null)
|
||||
{
|
||||
Steamworks.SteamServer.SetKey("submarine", GameMain.NetLobbyScreen.SelectedSub.Name);
|
||||
}
|
||||
|
||||
Steamworks.SteamServer.DedicatedServer = true;
|
||||
|
||||
|
||||
@@ -224,7 +224,8 @@ namespace Barotrauma
|
||||
var selectedTraitor = SelectRandomTraitor();
|
||||
if (selectedTraitor == null)
|
||||
{
|
||||
DebugConsole.ThrowError($"Could not find a suitable traitor for the event \"{selectedPrefab.Identifier}\".");
|
||||
DebugConsole.ThrowError($"Could not find a suitable traitor for the event \"{selectedPrefab.Identifier}\".",
|
||||
contentPackage: selectedPrefab.ContentPackage);
|
||||
return false;
|
||||
}
|
||||
CreateTraitorEvent(eventManager, selectedPrefab, selectedTraitor);
|
||||
@@ -263,7 +264,8 @@ namespace Barotrauma
|
||||
{
|
||||
DebugConsole.ThrowError(
|
||||
$"Error in traitor event {traitorEvent.Prefab.Identifier}. Not enough players to choose {amountToChoose} secondary traitors."+
|
||||
$"Make sure the {nameof(traitorEvent.Prefab.MinPlayerCount)} of the event is high enough to support to desired amount of secondary traitors.");
|
||||
$"Make sure the {nameof(traitorEvent.Prefab.MinPlayerCount)} of the event is high enough to support to desired amount of secondary traitors.",
|
||||
contentPackage: traitorEvent.Prefab.ContentPackage);
|
||||
amountToChoose = viableTraitors.Count;
|
||||
}
|
||||
|
||||
@@ -352,7 +354,8 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.ThrowError($"Failed to create an instance of the traitor event prefab \"{selectedPrefab.Identifier}\"!");
|
||||
DebugConsole.ThrowError($"Failed to create an instance of the traitor event prefab \"{selectedPrefab.Identifier}\"!",
|
||||
contentPackage: selectedPrefab.ContentPackage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,7 +368,8 @@ namespace Barotrauma
|
||||
var traitor = SelectRandomTraitor();
|
||||
if (traitor == null)
|
||||
{
|
||||
DebugConsole.ThrowError($"Could not find a suitable traitor for the event \"{traitorEventPrefab.Identifier}\".");
|
||||
DebugConsole.ThrowError($"Could not find a suitable traitor for the event \"{traitorEventPrefab.Identifier}\".",
|
||||
contentPackage: traitorEventPrefab.ContentPackage);
|
||||
return;
|
||||
}
|
||||
CreateTraitorEvent(eventManager, traitorEventPrefab, traitor);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<RootNamespace>Barotrauma</RootNamespace>
|
||||
<Authors>FakeFish, Undertow Games</Authors>
|
||||
<Product>Barotrauma Dedicated Server</Product>
|
||||
<Version>1.1.18.1</Version>
|
||||
<Version>1.2.1.0</Version>
|
||||
<Copyright>Copyright © FakeFish 2018-2023</Copyright>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<AssemblyName>DedicatedServer</AssemblyName>
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
StartingBalanceAmount="High"
|
||||
StartItemSet="easy"
|
||||
MaxMissionCount="3"
|
||||
Difficulty="Easy"/>
|
||||
Difficulty="Easy"
|
||||
MinStolenItemInspectionProbability="0.2"
|
||||
MaxStolenItemInspectionProbability="0.9"/>
|
||||
<CampaignSettings
|
||||
presetname="Normal"
|
||||
TutorialEnabled="true"
|
||||
@@ -20,7 +22,9 @@
|
||||
StartingBalanceAmount="Medium"
|
||||
StartItemSet="normal"
|
||||
MaxMissionCount="2"
|
||||
Difficulty="Medium"/>
|
||||
Difficulty="Medium"
|
||||
MinStolenItemInspectionProbability="0.3"
|
||||
MaxStolenItemInspectionProbability="0.9"/>
|
||||
<CampaignSettings
|
||||
presetname="Hard"
|
||||
TutorialEnabled="false"
|
||||
@@ -28,5 +32,7 @@
|
||||
StartingBalanceAmount="Low"
|
||||
StartItemSet="hard"
|
||||
MaxMissionCount="1"
|
||||
Difficulty="Hard"/>
|
||||
Difficulty="Hard"
|
||||
MinStolenItemInspectionProbability="0.4"
|
||||
MaxStolenItemInspectionProbability="1.0"/>
|
||||
</CampaignSettingPresets>
|
||||
@@ -262,7 +262,8 @@ namespace Barotrauma
|
||||
|
||||
if (aiElements.Count == 0)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in file \"" + c.Params.File + "\" - no AI element found.");
|
||||
DebugConsole.ThrowError("Error in file \"" + c.Params.File + "\" - no AI element found.",
|
||||
contentPackage: c.Prefab?.ContentPackage);
|
||||
outsideSteering = new SteeringManager(this);
|
||||
insideSteering = new IndoorsSteeringManager(this, false, false);
|
||||
return;
|
||||
@@ -330,7 +331,8 @@ namespace Barotrauma
|
||||
_aiParams = Character.Params.AI;
|
||||
if (_aiParams == null)
|
||||
{
|
||||
DebugConsole.ThrowError($"No AI Params defined for {Character.SpeciesName}. AI disabled.");
|
||||
DebugConsole.ThrowError($"No AI Params defined for {Character.SpeciesName}. AI disabled.",
|
||||
contentPackage: Character.Prefab.ContentPackage);
|
||||
Enabled = false;
|
||||
_aiParams = new CharacterParams.AIParams(null, Character.Params);
|
||||
}
|
||||
@@ -2503,7 +2505,8 @@ namespace Barotrauma
|
||||
Limb mouthLimb = Character.AnimController.GetLimb(LimbType.Head);
|
||||
if (mouthLimb == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Character \"" + Character.SpeciesName + "\" failed to eat a target (No head limb defined)");
|
||||
DebugConsole.ThrowError("Character \"" + Character.SpeciesName + "\" failed to eat a target (No head limb defined)",
|
||||
contentPackage: Character.Prefab.ContentPackage);
|
||||
State = AIState.Idle;
|
||||
return;
|
||||
}
|
||||
@@ -2540,7 +2543,11 @@ namespace Barotrauma
|
||||
item.body.LinearVelocity -= velocity * 0.25f;
|
||||
bool wasBroken = item.Condition <= 0.0f;
|
||||
item.LastEatenTime = (float)Timing.TotalTimeUnpaused;
|
||||
item.AddDamage(Character, item.WorldPosition, new Attack(0.0f, 0.0f, 0.0f, 0.0f, 0.02f * Character.Params.EatingSpeed), deltaTime);
|
||||
item.AddDamage(Character,
|
||||
item.WorldPosition,
|
||||
new Attack(0.0f, 0.0f, 0.0f, 0.0f, 0.02f * Character.Params.EatingSpeed),
|
||||
impulseDirection: Vector2.Zero,
|
||||
deltaTime);
|
||||
Character.ApplyStatusEffects(ActionType.OnEating, deltaTime);
|
||||
if (item.Condition <= 0.0f)
|
||||
{
|
||||
|
||||
@@ -167,10 +167,6 @@ namespace Barotrauma
|
||||
|
||||
public HumanAIController(Character c) : base(c)
|
||||
{
|
||||
if (!c.IsHuman)
|
||||
{
|
||||
throw new Exception($"Tried to create a human ai controller for a non-human: {c.SpeciesName}!");
|
||||
}
|
||||
insideSteering = new IndoorsSteeringManager(this, true, false);
|
||||
outsideSteering = new SteeringManager(this);
|
||||
objectiveManager = new AIObjectiveManager(c);
|
||||
@@ -1800,7 +1796,7 @@ namespace Barotrauma
|
||||
if (!TriggerSecurity(otherHumanAI, combatMode))
|
||||
{
|
||||
// Else call the others
|
||||
foreach (Character security in Character.CharacterList.Where(c => c.TeamID == otherCharacter.TeamID).OrderByDescending(c => Vector2.DistanceSquared(character.WorldPosition, c.WorldPosition)))
|
||||
foreach (Character security in Character.CharacterList.Where(c => c.TeamID == otherCharacter.TeamID).OrderBy(c => Vector2.DistanceSquared(character.WorldPosition, c.WorldPosition)))
|
||||
{
|
||||
if (!TriggerSecurity(security.AIController as HumanAIController, combatMode))
|
||||
{
|
||||
@@ -1861,16 +1857,11 @@ namespace Barotrauma
|
||||
}
|
||||
if (!someoneSpoke)
|
||||
{
|
||||
if (!item.StolenDuringRound &&
|
||||
Level.Loaded?.Type == LevelData.LevelType.Outpost &&
|
||||
GameMain.GameSession?.Campaign?.Map?.CurrentLocation != null)
|
||||
if (!item.StolenDuringRound)
|
||||
{
|
||||
var reputationLoss = MathHelper.Clamp(
|
||||
(item.Prefab.GetMinPrice() ?? 0) * Reputation.ReputationLossPerStolenItemPrice,
|
||||
Reputation.MinReputationLossPerStolenItem, Reputation.MaxReputationLossPerStolenItem);
|
||||
GameMain.GameSession.Campaign.Map.CurrentLocation.Reputation?.AddReputation(-reputationLoss);
|
||||
ApplyStealingReputationLoss(item);
|
||||
item.StolenDuringRound = true;
|
||||
}
|
||||
item.StolenDuringRound = true;
|
||||
otherCharacter.Speak(TextManager.Get("dialogstealwarning").Value, null, Rand.Range(0.5f, 1.0f), "thief".ToIdentifier(), 10.0f);
|
||||
someoneSpoke = true;
|
||||
#if CLIENT
|
||||
@@ -1881,7 +1872,7 @@ namespace Barotrauma
|
||||
if (!TriggerSecurity(otherHumanAI))
|
||||
{
|
||||
// Else call the others
|
||||
foreach (Character security in Character.CharacterList.Where(c => c.TeamID == otherCharacter.TeamID).OrderByDescending(c => Vector2.DistanceSquared(thief.WorldPosition, c.WorldPosition)))
|
||||
foreach (Character security in Character.CharacterList.Where(c => c.TeamID == otherCharacter.TeamID).OrderBy(c => Vector2.DistanceSquared(thief.WorldPosition, c.WorldPosition)))
|
||||
{
|
||||
if (TriggerSecurity(security.AIController as HumanAIController))
|
||||
{
|
||||
@@ -1902,6 +1893,10 @@ namespace Barotrauma
|
||||
if (humanAI == null) { return false; }
|
||||
if (!humanAI.Character.IsSecurity) { return false; }
|
||||
if (humanAI.ObjectiveManager.IsCurrentObjective<AIObjectiveCombat>()) { return false; }
|
||||
if (humanAI.ObjectiveManager.GetObjective<AIObjectiveFindThieves>() is { } findThieves)
|
||||
{
|
||||
findThieves.InspectEveryone();
|
||||
}
|
||||
humanAI.AddCombatObjective(AIObjectiveCombat.CombatMode.Arrest, thief, delay: GetReactionTime(),
|
||||
abortCondition: obj => thief.Inventory.FindItem(it => it != null && it.StolenDuringRound, true) == null,
|
||||
onAbort: () =>
|
||||
@@ -1919,6 +1914,18 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public static void ApplyStealingReputationLoss(Item item)
|
||||
{
|
||||
if (Level.Loaded?.Type == LevelData.LevelType.Outpost &&
|
||||
GameMain.GameSession?.Campaign?.Map?.CurrentLocation != null)
|
||||
{
|
||||
var reputationLoss = MathHelper.Clamp(
|
||||
(item.Prefab.GetMinPrice() ?? 0) * Reputation.ReputationLossPerStolenItemPrice,
|
||||
Reputation.MinReputationLossPerStolenItem, Reputation.MaxReputationLossPerStolenItem);
|
||||
GameMain.GameSession.Campaign.Map.CurrentLocation.Reputation?.AddReputation(-reputationLoss);
|
||||
}
|
||||
}
|
||||
|
||||
// 0.225 - 0.375
|
||||
private static float GetReactionTime() => reactionTime * Rand.Range(0.75f, 1.25f);
|
||||
|
||||
|
||||
@@ -197,17 +197,6 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method allows multiple subobjectives of same type. Use with caution.
|
||||
/// </summary>
|
||||
public void AddSubObjectiveInQueue(AIObjective objective)
|
||||
{
|
||||
if (!subObjectives.Contains(objective))
|
||||
{
|
||||
subObjectives.Add(objective);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveSubObjective<T>(ref T objective) where T : AIObjective
|
||||
{
|
||||
if (objective != null)
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class AIObjectiveCheckStolenItems : AIObjective
|
||||
{
|
||||
public override Identifier Identifier { get; set; } = "check stolen items".ToIdentifier();
|
||||
public override bool AllowOutsideSubmarine => false;
|
||||
public override bool AllowInAnySub => false;
|
||||
|
||||
public float FindStolenItemsProbability = 1.0f;
|
||||
|
||||
enum State
|
||||
{
|
||||
GotoTarget,
|
||||
Inspect,
|
||||
Warn,
|
||||
Done
|
||||
}
|
||||
|
||||
private float inspectDelay;
|
||||
private float warnDelay;
|
||||
|
||||
private State currentState;
|
||||
|
||||
public readonly Character TargetCharacter;
|
||||
|
||||
private AIObjectiveGoTo? goToObjective;
|
||||
|
||||
private readonly List<Item> stolenItems = new List<Item>();
|
||||
|
||||
public AIObjectiveCheckStolenItems(Character character, Character targetCharacter, AIObjectiveManager objectiveManager, float priorityModifier = 1) :
|
||||
base(character, objectiveManager, priorityModifier)
|
||||
{
|
||||
TargetCharacter = targetCharacter;
|
||||
inspectDelay = 5.0f;
|
||||
warnDelay = 5.0f;
|
||||
}
|
||||
|
||||
public override bool IsLoop
|
||||
{
|
||||
get => false;
|
||||
set => throw new Exception("Trying to set the value for IsLoop from: " + Environment.StackTrace.CleanupStackTrace());
|
||||
}
|
||||
|
||||
protected override bool CheckObjectiveSpecific() => false;
|
||||
|
||||
protected override float GetPriority()
|
||||
{
|
||||
if (!Abandon && !IsCompleted && objectiveManager.IsOrder(this))
|
||||
{
|
||||
Priority = objectiveManager.GetOrderPriority(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
Priority = AIObjectiveManager.LowestOrderPriority - 1;
|
||||
}
|
||||
return Priority;
|
||||
}
|
||||
|
||||
public void ForceComplete()
|
||||
{
|
||||
IsCompleted = true;
|
||||
}
|
||||
|
||||
protected override void Act(float deltaTime)
|
||||
{
|
||||
switch (currentState)
|
||||
{
|
||||
case State.GotoTarget:
|
||||
TryAddSubObjective(ref goToObjective,
|
||||
constructor: () =>
|
||||
{
|
||||
return new AIObjectiveGoTo(TargetCharacter, character, objectiveManager, repeat: false)
|
||||
{
|
||||
SpeakIfFails = false
|
||||
};
|
||||
},
|
||||
onCompleted: () =>
|
||||
{
|
||||
RemoveSubObjective(ref goToObjective);
|
||||
currentState = State.Inspect;
|
||||
stolenItems.Clear();
|
||||
TargetCharacter.Inventory.FindAllItems(it => it.SpawnedInCurrentOutpost && !it.AllowStealing, recursive: true, stolenItems);
|
||||
character.Speak(TextManager.Get("dialogcheckstolenitems").Value);
|
||||
},
|
||||
onAbandon: () =>
|
||||
{
|
||||
Abandon = true;
|
||||
});
|
||||
break;
|
||||
case State.Inspect:
|
||||
Inspect(deltaTime);
|
||||
break;
|
||||
case State.Warn:
|
||||
Warn(deltaTime);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void Inspect(float deltaTime)
|
||||
{
|
||||
if (inspectDelay > 0.0f)
|
||||
{
|
||||
character.SelectCharacter(TargetCharacter);
|
||||
inspectDelay -= deltaTime;
|
||||
return;
|
||||
}
|
||||
|
||||
if (stolenItems.Any() &&
|
||||
Rand.Range(0.0f, 1.0f, Rand.RandSync.Unsynced) < FindStolenItemsProbability)
|
||||
{
|
||||
character.Speak(TextManager.Get("dialogcheckstolenitems.warn").Value);
|
||||
currentState = State.Warn;
|
||||
}
|
||||
else
|
||||
{
|
||||
character.Speak(TextManager.Get("dialogcheckstolenitems.nostolenitems").Value);
|
||||
currentState = State.Done;
|
||||
IsCompleted = true;
|
||||
}
|
||||
character.DeselectCharacter();
|
||||
}
|
||||
|
||||
private void Warn(float deltaTime)
|
||||
{
|
||||
if (warnDelay > 0.0f)
|
||||
{
|
||||
warnDelay -= deltaTime;
|
||||
return;
|
||||
}
|
||||
var stolenItemsOnCharacter = stolenItems.Where(it => it.GetRootInventoryOwner() == TargetCharacter);
|
||||
if (stolenItemsOnCharacter.Any())
|
||||
{
|
||||
character.Speak(TextManager.Get("dialogcheckstolenitems.arrest").Value);
|
||||
HumanAIController.AddCombatObjective(AIObjectiveCombat.CombatMode.Arrest, TargetCharacter);
|
||||
foreach (var stolenItem in stolenItemsOnCharacter)
|
||||
{
|
||||
HumanAIController.ApplyStealingReputationLoss(stolenItem);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
character.Speak(TextManager.Get("dialogcheckstolenitems.comply").Value);
|
||||
}
|
||||
foreach (var item in stolenItems)
|
||||
{
|
||||
HumanAIController.ObjectiveManager.AddObjective(new AIObjectiveGetItem(character, item, objectiveManager, equip: false)
|
||||
{
|
||||
BasePriority = 10
|
||||
});
|
||||
}
|
||||
currentState = State.Done;
|
||||
IsCompleted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
#nullable enable
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class AIObjectiveFindThieves : AIObjectiveLoop<Character>
|
||||
{
|
||||
public override Identifier Identifier { get; set; } = "find thieves".ToIdentifier();
|
||||
protected override float IgnoreListClearInterval => 30;
|
||||
public override bool IgnoreUnsafeHulls => true;
|
||||
|
||||
protected override float TargetUpdateTimeMultiplier => 1.0f;
|
||||
|
||||
const float DefaultInspectDistance = 200.0f;
|
||||
|
||||
/// <summary>
|
||||
/// How close the NPC must be to the target to the inspect them? You can use high values to make the NPC
|
||||
/// systematically go through targets no matter where they are, and low values to check targets they happen to come across.
|
||||
/// </summary>
|
||||
public float InspectDistance = DefaultInspectDistance;
|
||||
|
||||
private float? overrideInspectProbability;
|
||||
/// <summary>
|
||||
/// Chance of inspecting a valid target. The NPC won't try to inspect that target again for <see cref="inspectionInterval"/>
|
||||
/// regardless if the target is inspected or not.
|
||||
/// </summary>
|
||||
public float InspectProbability
|
||||
{
|
||||
get
|
||||
{
|
||||
if (overrideInspectProbability.HasValue)
|
||||
{
|
||||
return overrideInspectProbability.Value;
|
||||
}
|
||||
if (GameMain.GameSession?.Campaign is { } campaign)
|
||||
{
|
||||
if (campaign.Map?.CurrentLocation?.Reputation is { } reputation)
|
||||
{
|
||||
return MathHelper.Lerp(
|
||||
campaign.Settings.MaxStolenItemInspectionProbability,
|
||||
campaign.Settings.MinStolenItemInspectionProbability,
|
||||
reputation.NormalizedValue);
|
||||
}
|
||||
}
|
||||
|
||||
return 0.2f;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When did the character last inspect whether some other character has stolen items on them?
|
||||
/// </summary>
|
||||
private static readonly Dictionary<Character, double> lastInspectionTimes = new Dictionary<Character, double>();
|
||||
|
||||
private readonly float inspectionInterval = 120.0f;
|
||||
|
||||
public AIObjectiveFindThieves(Character character, AIObjectiveManager objectiveManager, float priorityModifier = 1)
|
||||
: base(character, objectiveManager, priorityModifier) { }
|
||||
|
||||
protected override bool Filter(Character target)
|
||||
{
|
||||
if (!IsValidTarget(target, character)) { return false; }
|
||||
if (Vector2.DistanceSquared(target.WorldPosition, character.WorldPosition) > InspectDistance * InspectDistance) { return false; }
|
||||
if (lastInspectionTimes.TryGetValue(target, out double lastInspectionTime))
|
||||
{
|
||||
if (Timing.TotalTime < lastInspectionTime + inspectionInterval)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override IEnumerable<Character> GetList() => Character.CharacterList;
|
||||
|
||||
protected override float TargetEvaluation()
|
||||
{
|
||||
return subObjectives.Any() ? 50 : 0;
|
||||
}
|
||||
|
||||
public void InspectEveryone()
|
||||
{
|
||||
lastInspectionTimes.Clear();
|
||||
overrideInspectProbability = 1.0f;
|
||||
InspectDistance = DefaultInspectDistance * 2;
|
||||
}
|
||||
|
||||
protected override AIObjective ObjectiveConstructor(Character target)
|
||||
{
|
||||
var checkStolenItemsObjective = new AIObjectiveCheckStolenItems(character, target, objectiveManager);
|
||||
if (Rand.Range(0.0f, 1.0f, Rand.RandSync.Unsynced) >= InspectProbability)
|
||||
{
|
||||
checkStolenItemsObjective.ForceComplete();
|
||||
lastInspectionTimes[target] = Timing.TotalTime;
|
||||
}
|
||||
return checkStolenItemsObjective;
|
||||
}
|
||||
|
||||
private float checkVisibleStolenItemsTimer;
|
||||
private const float CheckVisibleStolenItemsInterval = 5.0f;
|
||||
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
base.Update(deltaTime);
|
||||
if (checkVisibleStolenItemsTimer > 0.0f)
|
||||
{
|
||||
checkVisibleStolenItemsTimer -= deltaTime;
|
||||
return;
|
||||
}
|
||||
foreach (var target in Character.CharacterList)
|
||||
{
|
||||
if (!IsValidTarget(target, character)) { continue; }
|
||||
//if we spot someone wearing or holding stolen items, immediately check them (with 100% chance of spotting the stolen items)
|
||||
if (target.Inventory.AllItems.Any(it => it.SpawnedInCurrentOutpost && !it.AllowStealing && target.HasEquippedItem(it)) &&
|
||||
character.CanSeeTarget(target))
|
||||
{
|
||||
AIObjectiveCheckStolenItems? existingObjective =
|
||||
objectiveManager.GetActiveObjectives<AIObjectiveCheckStolenItems>().FirstOrDefault(o => o.TargetCharacter == target);
|
||||
if (existingObjective == null)
|
||||
{
|
||||
objectiveManager.AddObjective(new AIObjectiveCheckStolenItems(character, target, objectiveManager));
|
||||
lastInspectionTimes[target] = Timing.TotalTime;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
checkVisibleStolenItemsTimer = CheckVisibleStolenItemsInterval;
|
||||
}
|
||||
|
||||
private bool IsValidTarget(Character target, Character character)
|
||||
{
|
||||
if (target == null || target.Removed) { return false; }
|
||||
if (target.IsIncapacitated) { return false; }
|
||||
if (target == character) { return false; }
|
||||
if (target.Submarine == null) { return false; }
|
||||
if (character.Submarine == null) { return false; }
|
||||
if (target.CurrentHull == null) { return false; }
|
||||
if (target.Submarine != character.Submarine) { return false; }
|
||||
//only player's crew can steal, ignore other teams
|
||||
if (!target.IsOnPlayerTeam) { return false; }
|
||||
if (target.IsArrested) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnObjectiveCompleted(AIObjective objective, Character target)
|
||||
{
|
||||
lastInspectionTimes[target] = Timing.TotalTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,7 +178,7 @@ namespace Barotrauma
|
||||
if (!objectiveManager.IsOrder(this))
|
||||
{
|
||||
// Battery or pump states cannot currently be reported (not implemented) and therefore we must ignore them -> the bots always know if they require attention.
|
||||
bool ignore = this is AIObjectiveChargeBatteries || this is AIObjectivePumpWater;
|
||||
bool ignore = this is AIObjectiveChargeBatteries || this is AIObjectivePumpWater || this is AIObjectiveFindThieves;
|
||||
if (!ignore && !ReportedTargets.Contains(target)) { continue; }
|
||||
}
|
||||
if (!Filter(target)) { continue; }
|
||||
|
||||
@@ -142,6 +142,7 @@ namespace Barotrauma
|
||||
prevIdleObjective.PreferredOutpostModuleTypes.ForEach(t => newIdleObjective.PreferredOutpostModuleTypes.Add(t));
|
||||
}
|
||||
AddObjective(newIdleObjective);
|
||||
|
||||
int objectiveCount = Objectives.Count;
|
||||
foreach (var autonomousObjective in character.Info.Job.Prefab.AutonomousObjectives)
|
||||
{
|
||||
@@ -549,6 +550,9 @@ namespace Barotrauma
|
||||
case "escapehandcuffs":
|
||||
newObjective = new AIObjectiveEscapeHandcuffs(character, this, priorityModifier: priorityModifier);
|
||||
break;
|
||||
case "findthieves":
|
||||
newObjective = new AIObjectiveFindThieves(character, this, priorityModifier: priorityModifier);
|
||||
break;
|
||||
case "prepareforexpedition":
|
||||
newObjective = new AIObjectivePrepare(character, this, order.GetTargetItems(order.Option), order.RequireItems)
|
||||
{
|
||||
|
||||
@@ -441,7 +441,8 @@ namespace Barotrauma
|
||||
}
|
||||
catch (NotImplementedException e)
|
||||
{
|
||||
DebugConsole.LogError($"Error creating a new Order instance: unexpected target type \"{targetType}\".\n{e.StackTrace.CleanupStackTrace()}");
|
||||
DebugConsole.LogError($"Error creating a new Order instance: unexpected target type \"{targetType}\".\n{e.StackTrace.CleanupStackTrace()}",
|
||||
contentPackage: ContentPackage);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,7 +552,8 @@ namespace Barotrauma
|
||||
#if DEBUG
|
||||
if (handlePos[i].LengthSquared() > ArmLength)
|
||||
{
|
||||
DebugConsole.AddWarning($"Aim position for the item {item.Name} may be incorrect (further than the length of the character's arm)");
|
||||
DebugConsole.AddWarning($"Aim position for the item {item.Name} may be incorrect (further than the length of the character's arm)",
|
||||
item.Prefab.ContentPackage);
|
||||
}
|
||||
#endif
|
||||
HandIK(
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace Barotrauma
|
||||
|
||||
private readonly float movementLerp;
|
||||
|
||||
private float cprAnimTimer,cprPump;
|
||||
private float cprAnimTimer, cprPumpTimer;
|
||||
|
||||
private float fallingProneAnimTimer;
|
||||
const float FallingProneAnimDuration = 1.0f;
|
||||
@@ -243,14 +243,17 @@ namespace Barotrauma
|
||||
if (MainLimb == null) { return; }
|
||||
|
||||
levitatingCollider = !IsHanging;
|
||||
if ((character.SelectedItem?.GetComponent<Controller>()?.ControlCharacterPose ?? false) ||
|
||||
(character.SelectedSecondaryItem?.GetComponent<Controller>()?.ControlCharacterPose ?? false) ||
|
||||
character.SelectedSecondaryItem?.GetComponent<Ladder>() != null ||
|
||||
(ForceSelectAnimationType != AnimationType.Crouch && ForceSelectAnimationType != AnimationType.NotDefined))
|
||||
if (onGround && character.CanMove)
|
||||
{
|
||||
Crouching = false;
|
||||
if ((character.SelectedItem?.GetComponent<Controller>()?.ControlCharacterPose ?? false) ||
|
||||
(character.SelectedSecondaryItem?.GetComponent<Controller>()?.ControlCharacterPose ?? false) ||
|
||||
character.SelectedSecondaryItem?.GetComponent<Ladder>() != null ||
|
||||
(ForceSelectAnimationType != AnimationType.Crouch && ForceSelectAnimationType != AnimationType.NotDefined))
|
||||
{
|
||||
Crouching = false;
|
||||
}
|
||||
ColliderIndex = Crouching && !swimming ? 1 : 0;
|
||||
}
|
||||
ColliderIndex = Crouching && !swimming ? 1 : 0;
|
||||
|
||||
//stun (= disable the animations) if the ragdoll receives a large enough impact
|
||||
if (strongestImpact > 0.0f)
|
||||
@@ -276,7 +279,7 @@ namespace Barotrauma
|
||||
|
||||
if (!character.CanMove)
|
||||
{
|
||||
if (fallingProneAnimTimer < FallingProneAnimDuration)
|
||||
if (fallingProneAnimTimer < FallingProneAnimDuration && onGround)
|
||||
{
|
||||
fallingProneAnimTimer += deltaTime;
|
||||
UpdateFallingProne(1.0f);
|
||||
@@ -285,7 +288,12 @@ namespace Barotrauma
|
||||
Collider.FarseerBody.FixedRotation = false;
|
||||
if (GameMain.NetworkMember == null || !GameMain.NetworkMember.IsClient)
|
||||
{
|
||||
Collider.Enabled = false;
|
||||
if (Collider.Enabled)
|
||||
{
|
||||
//deactivating the collider -> make the main limb inherit the collider's velocity because it'll control the movement now
|
||||
MainLimb.body.LinearVelocity = Collider.LinearVelocity;
|
||||
Collider.Enabled = false;
|
||||
}
|
||||
Collider.LinearVelocity = MainLimb.LinearVelocity;
|
||||
Collider.SetTransformIgnoreContacts(MainLimb.SimPosition, MainLimb.Rotation);
|
||||
//reset pull joints to prevent the character from "hanging" mid-air if pull joints had been active when the character was still moving
|
||||
@@ -386,6 +394,12 @@ namespace Barotrauma
|
||||
DragCharacter(character.SelectedCharacter, deltaTime);
|
||||
}
|
||||
|
||||
if (Anim != Animation.CPR)
|
||||
{
|
||||
cprAnimTimer = 0.0f;
|
||||
cprPumpTimer = 0.0f;
|
||||
}
|
||||
|
||||
switch (Anim)
|
||||
{
|
||||
case Animation.Climbing:
|
||||
@@ -648,14 +662,6 @@ namespace Barotrauma
|
||||
|
||||
if (!onGround)
|
||||
{
|
||||
Vector2 move = torso.PullJointWorldAnchorB - torso.SimPosition;
|
||||
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
if (limb.IsSevered) { continue; }
|
||||
MoveLimb(limb, limb.SimPosition + move, 15.0f, true);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1318,14 +1324,14 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateFallingProne(float strength)
|
||||
void UpdateFallingProne(float strength, bool moveHands = true, bool moveTorso = true, bool moveLegs = true)
|
||||
{
|
||||
if (strength <= 0.0f) { return; }
|
||||
|
||||
Limb head = GetLimb(LimbType.Head);
|
||||
Limb torso = GetLimb(LimbType.Torso);
|
||||
|
||||
if (head != null && head.LinearVelocity.LengthSquared() > 1.0f && !head.IsSevered)
|
||||
if (moveHands && head != null && head.LinearVelocity.LengthSquared() > 1.0f && !head.IsSevered)
|
||||
{
|
||||
//if the head is moving, try to protect it with the hands
|
||||
Limb leftHand = GetLimb(LimbType.LeftHand);
|
||||
@@ -1347,7 +1353,7 @@ namespace Barotrauma
|
||||
|
||||
//make the torso tip over
|
||||
//otherwise it tends to just drop straight down, pinning the characters legs in a weird pose
|
||||
if (!InWater)
|
||||
if (moveTorso && !InWater)
|
||||
{
|
||||
//prefer tipping over in the same direction the torso is rotating
|
||||
//or moving
|
||||
@@ -1358,27 +1364,30 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
//attempt to make legs stay in a straight line with the torso to prevent the character from doing a split
|
||||
for (int i = 0; i < 2; i++)
|
||||
if (moveLegs)
|
||||
{
|
||||
var thigh = i == 0 ? GetLimb(LimbType.LeftThigh) : GetLimb(LimbType.RightThigh);
|
||||
if (thigh == null) { continue; }
|
||||
if (thigh.IsSevered) { continue; }
|
||||
float thighDiff = Math.Abs(MathUtils.GetShortestAngle(torso.Rotation, thigh.Rotation));
|
||||
float diff = torso.Rotation - thigh.Rotation;
|
||||
if (MathUtils.IsValid(diff))
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
float thighTorque = thighDiff * thigh.Mass * Math.Sign(diff) * 5.0f;
|
||||
thigh.body.ApplyTorque(thighTorque * strength);
|
||||
}
|
||||
var thigh = i == 0 ? GetLimb(LimbType.LeftThigh) : GetLimb(LimbType.RightThigh);
|
||||
if (thigh == null) { continue; }
|
||||
if (thigh.IsSevered) { continue; }
|
||||
float thighDiff = Math.Abs(MathUtils.GetShortestAngle(torso.Rotation, thigh.Rotation));
|
||||
float diff = torso.Rotation - thigh.Rotation;
|
||||
if (MathUtils.IsValid(diff))
|
||||
{
|
||||
float thighTorque = thighDiff * thigh.Mass * Math.Sign(diff) * 5.0f;
|
||||
thigh.body.ApplyTorque(thighTorque * strength);
|
||||
}
|
||||
|
||||
var leg = i == 0 ? GetLimb(LimbType.LeftLeg) : GetLimb(LimbType.RightLeg);
|
||||
if (leg == null || leg.IsSevered) { continue; }
|
||||
float legDiff = Math.Abs(MathUtils.GetShortestAngle(torso.Rotation, leg.Rotation));
|
||||
diff = torso.Rotation - leg.Rotation;
|
||||
if (MathUtils.IsValid(diff))
|
||||
{
|
||||
float legTorque = legDiff * leg.Mass * Math.Sign(diff) * 5.0f;
|
||||
leg.body.ApplyTorque(legTorque * strength);
|
||||
var leg = i == 0 ? GetLimb(LimbType.LeftLeg) : GetLimb(LimbType.RightLeg);
|
||||
if (leg == null || leg.IsSevered) { continue; }
|
||||
float legDiff = Math.Abs(MathUtils.GetShortestAngle(torso.Rotation, leg.Rotation));
|
||||
diff = torso.Rotation - leg.Rotation;
|
||||
if (MathUtils.IsValid(diff))
|
||||
{
|
||||
float legTorque = legDiff * leg.Mass * Math.Sign(diff) * 5.0f;
|
||||
leg.body.ApplyTorque(legTorque * strength);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1398,7 +1407,8 @@ namespace Barotrauma
|
||||
|
||||
Crouching = true;
|
||||
|
||||
Vector2 diff = target.SimPosition - character.SimPosition;
|
||||
Vector2 offset = Vector2.UnitX * -Dir * 0.75f;
|
||||
Vector2 diff = (target.SimPosition + offset) - character.SimPosition;
|
||||
Limb targetHead = target.AnimController.GetLimb(LimbType.Head);
|
||||
Limb targetTorso = target.AnimController.GetLimb(LimbType.Torso);
|
||||
if (targetTorso == null)
|
||||
@@ -1412,7 +1422,23 @@ namespace Barotrauma
|
||||
|
||||
Vector2 headDiff = targetHead == null ? diff : targetHead.SimPosition - character.SimPosition;
|
||||
targetMovement = new Vector2(diff.X, 0.0f);
|
||||
const float CloseEnough = 0.1f;
|
||||
if (Math.Abs(targetMovement.X) < CloseEnough)
|
||||
{
|
||||
targetMovement.X = 0.0f;
|
||||
}
|
||||
|
||||
TargetDir = headDiff.X > 0.0f ? Direction.Right : Direction.Left;
|
||||
//if the target's in some weird pose, we may not be able to flip it so it's facing up,
|
||||
//so let's only try it once so we don't end up constantly flipping it
|
||||
if (cprAnimTimer <= 0.0f && target.AnimController.Direction == TargetDir)
|
||||
{
|
||||
target.AnimController.Flip();
|
||||
}
|
||||
(target.AnimController as HumanoidAnimController)?.UpdateFallingProne(strength: 1.0f, moveHands: false, moveTorso: false);
|
||||
|
||||
head.Disabled = true;
|
||||
torso.Disabled = true;
|
||||
|
||||
UpdateStanding();
|
||||
|
||||
@@ -1443,73 +1469,64 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
//pump for 15 seconds (cprAnimTimer 0-15), then do mouth-to-mouth for 2 seconds (cprAnimTimer 15-17)
|
||||
if (cprAnimTimer > 15.0f && targetHead != null && head != null)
|
||||
//Serverside code
|
||||
if (GameMain.NetworkMember is not { IsClient: true })
|
||||
{
|
||||
float yPos = (float)Math.Sin(cprAnimTimer) * 0.2f;
|
||||
head.PullJointWorldAnchorB = new Vector2(targetHead.SimPosition.X, targetHead.SimPosition.Y + 0.3f + yPos);
|
||||
if (target.Oxygen < -10.0f)
|
||||
{
|
||||
//stabilize the oxygen level but don't allow it to go positive and revive the character yet
|
||||
float stabilizationAmount = skill * CPRSettings.Active.StabilizationPerSkill;
|
||||
stabilizationAmount = MathHelper.Clamp(stabilizationAmount, CPRSettings.Active.StabilizationMin, CPRSettings.Active.StabilizationMax);
|
||||
character.Oxygen -= 1.0f / stabilizationAmount * deltaTime; //Worse skill = more oxygen required
|
||||
if (character.Oxygen > 0.0f) { target.Oxygen += stabilizationAmount * deltaTime; } //we didn't suffocate yet did we
|
||||
}
|
||||
}
|
||||
|
||||
if (targetHead != null && head != null)
|
||||
{
|
||||
head.PullJointWorldAnchorB = new Vector2(targetHead.SimPosition.X, targetHead.SimPosition.Y + 0.8f);
|
||||
head.PullJointEnabled = true;
|
||||
torso.PullJointWorldAnchorB = new Vector2(torso.SimPosition.X, colliderPos.Y + (TorsoPosition.Value - 0.2f));
|
||||
torso.PullJointEnabled = true;
|
||||
|
||||
//Serverside code
|
||||
if (GameMain.NetworkMember is not { IsClient: true })
|
||||
{
|
||||
if (target.Oxygen < -10.0f)
|
||||
{
|
||||
//stabilize the oxygen level but don't allow it to go positive and revive the character yet
|
||||
float stabilizationAmount = skill * CPRSettings.Active.StabilizationPerSkill;
|
||||
stabilizationAmount = MathHelper.Clamp(stabilizationAmount, CPRSettings.Active.StabilizationMin, CPRSettings.Active.StabilizationMax);
|
||||
character.Oxygen -= 1.0f / stabilizationAmount * deltaTime; //Worse skill = more oxygen required
|
||||
if (character.Oxygen > 0.0f) { target.Oxygen += stabilizationAmount * deltaTime; } //we didn't suffocate yet did we
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
torso.PullJointWorldAnchorB = new Vector2(torso.SimPosition.X, colliderPos.Y + (TorsoPosition.Value - 0.1f));
|
||||
torso.PullJointEnabled = true;
|
||||
|
||||
if (cprPumpTimer >= 1)
|
||||
{
|
||||
if (targetHead != null && head != null)
|
||||
torso.body.ApplyLinearImpulse(new Vector2(0, -20f), maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
|
||||
targetTorso.body.ApplyLinearImpulse(new Vector2(0, -20f), maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
|
||||
cprPumpTimer = 0;
|
||||
|
||||
if (skill < CPRSettings.Active.DamageSkillThreshold)
|
||||
{
|
||||
head.PullJointWorldAnchorB = new Vector2(targetHead.SimPosition.X, targetHead.SimPosition.Y + 0.8f);
|
||||
head.PullJointEnabled = true;
|
||||
target.LastDamageSource = null;
|
||||
target.DamageLimb(
|
||||
targetTorso.WorldPosition, targetTorso,
|
||||
new[] { CPRSettings.Active.InsufficientSkillAffliction.Instantiate((CPRSettings.Active.DamageSkillThreshold - skill) * CPRSettings.Active.DamageSkillMultiplier, source: character) },
|
||||
stun: 0.0f,
|
||||
playSound: true,
|
||||
attackImpulse: Vector2.Zero,
|
||||
attacker: null);
|
||||
}
|
||||
|
||||
torso.PullJointWorldAnchorB = new Vector2(torso.SimPosition.X, colliderPos.Y + (TorsoPosition.Value - 0.1f));
|
||||
torso.PullJointEnabled = true;
|
||||
|
||||
if (cprPump >= 1)
|
||||
//need to CPR for at least a couple of seconds before the target can be revived
|
||||
//(reviving the target when the CPR has barely started looks strange)
|
||||
if (cprAnimTimer > 2.0f && GameMain.NetworkMember is not { IsClient: true })
|
||||
{
|
||||
torso.body.ApplyLinearImpulse(new Vector2(0, -20f), maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
|
||||
targetTorso.body.ApplyLinearImpulse(new Vector2(0, -20f), maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
|
||||
cprPump = 0;
|
||||
float reviveChance = skill * CPRSettings.Active.ReviveChancePerSkill;
|
||||
reviveChance = (float)Math.Pow(reviveChance, CPRSettings.Active.ReviveChanceExponent);
|
||||
reviveChance = MathHelper.Clamp(reviveChance, CPRSettings.Active.ReviveChanceMin, CPRSettings.Active.ReviveChanceMax);
|
||||
reviveChance *= 1f + cprBoost;
|
||||
|
||||
if (skill < CPRSettings.Active.DamageSkillThreshold)
|
||||
if (Rand.Range(0.0f, 1.0f, Rand.RandSync.ServerAndClient) <= reviveChance)
|
||||
{
|
||||
target.LastDamageSource = null;
|
||||
target.DamageLimb(
|
||||
targetTorso.WorldPosition, targetTorso,
|
||||
new[] { CPRSettings.Active.InsufficientSkillAffliction.Instantiate((CPRSettings.Active.DamageSkillThreshold - skill) * CPRSettings.Active.DamageSkillMultiplier, source: character) },
|
||||
0.0f, true, 0.0f, attacker: null);
|
||||
}
|
||||
if (GameMain.NetworkMember == null || !GameMain.NetworkMember.IsClient) //Serverside code
|
||||
{
|
||||
float reviveChance = skill * CPRSettings.Active.ReviveChancePerSkill;
|
||||
reviveChance = (float)Math.Pow(reviveChance, CPRSettings.Active.ReviveChanceExponent);
|
||||
reviveChance = MathHelper.Clamp(reviveChance, CPRSettings.Active.ReviveChanceMin, CPRSettings.Active.ReviveChanceMax);
|
||||
|
||||
reviveChance *= 1f + cprBoost;
|
||||
|
||||
if (Rand.Range(0.0f, 1.0f, Rand.RandSync.ServerAndClient) <= reviveChance)
|
||||
{
|
||||
//increase oxygen and clamp it above zero
|
||||
// -> the character should be revived if there are no major afflictions in addition to lack of oxygen
|
||||
target.Oxygen = Math.Max(target.Oxygen + 10.0f, 10.0f);
|
||||
}
|
||||
//increase oxygen and clamp it above zero
|
||||
// -> the character should be revived if there are no major afflictions in addition to lack of oxygen
|
||||
target.Oxygen = Math.Max(target.Oxygen + 10.0f, 10.0f);
|
||||
}
|
||||
}
|
||||
cprPump += deltaTime;
|
||||
}
|
||||
|
||||
cprAnimTimer = (cprAnimTimer + deltaTime) % 17;
|
||||
cprPumpTimer += deltaTime;
|
||||
cprAnimTimer += deltaTime;
|
||||
|
||||
//got the character back into a non-critical state, increase medical skill
|
||||
//BUT only if it has been more than 10 seconds since the character revived someone
|
||||
|
||||
@@ -437,7 +437,18 @@ namespace Barotrauma
|
||||
foreach (var huskAppendage in mainElement.GetChildElements("huskappendage"))
|
||||
{
|
||||
if (!inEditor && huskAppendage.GetAttributeBool("onlyfromafflictions", false)) { continue; }
|
||||
AfflictionHusk.AttachHuskAppendage(character, huskAppendage.GetAttributeIdentifier("affliction", Identifier.Empty), huskAppendage, ragdoll: this);
|
||||
|
||||
Identifier afflictionIdentifier = huskAppendage.GetAttributeIdentifier("affliction", Identifier.Empty);
|
||||
if (!AfflictionPrefab.Prefabs.TryGet(afflictionIdentifier, out AfflictionPrefab affliction) ||
|
||||
affliction is not AfflictionPrefabHusk matchingAffliction)
|
||||
{
|
||||
DebugConsole.ThrowError($"Could not find an affliction of type 'huskinfection' that matches the affliction '{afflictionIdentifier}'!",
|
||||
contentPackage: huskAppendage.ContentPackage);
|
||||
}
|
||||
else
|
||||
{
|
||||
AfflictionHusk.AttachHuskAppendage(character, matchingAffliction, huskAppendage, ragdoll: this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Barotrauma.Items.Components;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Items.Components;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
{
|
||||
public enum HitDetection
|
||||
{
|
||||
Distance,
|
||||
@@ -391,7 +392,8 @@ namespace Barotrauma
|
||||
element.GetAttribute("burndamage") != null ||
|
||||
element.GetAttribute("bleedingdamage") != null)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in Attack (" + parentDebugName + ") - Define damage as afflictions instead of using the damage attribute (e.g. <Affliction identifier=\"internaldamage\" strength=\"10\" />).");
|
||||
DebugConsole.ThrowError("Error in Attack (" + parentDebugName + ") - Define damage as afflictions instead of using the damage attribute (e.g. <Affliction identifier=\"internaldamage\" strength=\"10\" />).",
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
|
||||
//if level wall damage is not defined, default to the structure damage
|
||||
@@ -414,12 +416,14 @@ namespace Barotrauma
|
||||
AfflictionPrefab afflictionPrefab;
|
||||
if (subElement.GetAttribute("name") != null)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in Attack (" + parentDebugName + ") - define afflictions using identifiers instead of names.");
|
||||
DebugConsole.ThrowError("Error in Attack (" + parentDebugName + ") - define afflictions using identifiers instead of names.",
|
||||
contentPackage: element.ContentPackage);
|
||||
string afflictionName = subElement.GetAttributeString("name", "").ToLowerInvariant();
|
||||
afflictionPrefab = AfflictionPrefab.List.FirstOrDefault(ap => ap.Name.Equals(afflictionName, System.StringComparison.OrdinalIgnoreCase));
|
||||
if (afflictionPrefab == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in Attack (" + parentDebugName + ") - Affliction prefab \"" + afflictionName + "\" not found.");
|
||||
DebugConsole.ThrowError("Error in Attack (" + parentDebugName + ") - Affliction prefab \"" + afflictionName + "\" not found.",
|
||||
contentPackage: element.ContentPackage);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -428,7 +432,8 @@ namespace Barotrauma
|
||||
Identifier afflictionIdentifier = subElement.GetAttributeIdentifier("identifier", "");
|
||||
if (!AfflictionPrefab.Prefabs.TryGet(afflictionIdentifier, out afflictionPrefab))
|
||||
{
|
||||
DebugConsole.ThrowError("Error in Attack (" + parentDebugName + ") - Affliction prefab \"" + afflictionIdentifier + "\" not found.");
|
||||
DebugConsole.ThrowError("Error in Attack (" + parentDebugName + ") - Affliction prefab \"" + afflictionIdentifier + "\" not found.",
|
||||
contentPackage: element.ContentPackage);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -441,7 +446,7 @@ namespace Barotrauma
|
||||
}
|
||||
partial void InitProjSpecific(ContentXElement element);
|
||||
|
||||
public void ReloadAfflictions(XElement element, string parentDebugName)
|
||||
public void ReloadAfflictions(ContentXElement element, string parentDebugName)
|
||||
{
|
||||
Afflictions.Clear();
|
||||
foreach (var subElement in element.GetChildElements("affliction"))
|
||||
@@ -450,13 +455,14 @@ namespace Barotrauma
|
||||
Identifier afflictionIdentifier = subElement.GetAttributeIdentifier("identifier", "");
|
||||
if (!AfflictionPrefab.Prefabs.TryGet(afflictionIdentifier, out AfflictionPrefab afflictionPrefab))
|
||||
{
|
||||
DebugConsole.ThrowError($"Error in an Attack defined in \"{parentDebugName}\" - could not find an affliction with the identifier \"{afflictionIdentifier}\".");
|
||||
DebugConsole.ThrowError($"Error in an Attack defined in \"{parentDebugName}\" - could not find an affliction with the identifier \"{afflictionIdentifier}\".",
|
||||
contentPackage: element.ContentPackage);
|
||||
continue;
|
||||
}
|
||||
affliction = afflictionPrefab.Instantiate(0.0f);
|
||||
affliction.Deserialize(subElement);
|
||||
//backwards compatibility
|
||||
if (subElement.Attribute("amount") != null && subElement.Attribute("strength") == null)
|
||||
if (subElement.GetAttribute("amount") != null && subElement.GetAttribute("strength") == null)
|
||||
{
|
||||
affliction.Strength = subElement.GetAttributeFloat("amount", 0.0f);
|
||||
}
|
||||
@@ -465,7 +471,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void Serialize(XElement element)
|
||||
public void Serialize(ContentXElement element)
|
||||
{
|
||||
SerializableProperty.SerializeProperties(this, element, true);
|
||||
foreach (var affliction in Afflictions)
|
||||
@@ -477,7 +483,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void Deserialize(XElement element, string parentDebugName)
|
||||
public void Deserialize(ContentXElement element, string parentDebugName)
|
||||
{
|
||||
SerializableProperties = SerializableProperty.DeserializeProperties(this, element);
|
||||
ReloadAfflictions(element, parentDebugName);
|
||||
@@ -497,8 +503,9 @@ namespace Barotrauma
|
||||
SetUser(attacker);
|
||||
|
||||
DamageParticles(deltaTime, worldPosition);
|
||||
|
||||
var attackResult = target?.AddDamage(attacker, worldPosition, this, deltaTime, playSound) ?? new AttackResult();
|
||||
|
||||
Vector2 impulseDirection = GetImpulseDirection(target as ISpatialEntity, worldPosition, SourceItem);
|
||||
var attackResult = target?.AddDamage(attacker, worldPosition, this, impulseDirection, deltaTime, playSound) ?? new AttackResult();
|
||||
var conditionalEffectType = attackResult.Damage > 0.0f ? ActionType.OnSuccess : ActionType.OnFailure;
|
||||
var additionalEffectType = ActionType.OnUse;
|
||||
if (targetCharacter != null && targetCharacter.IsDead)
|
||||
@@ -606,7 +613,7 @@ namespace Barotrauma
|
||||
float penetration = Penetration;
|
||||
|
||||
RangedWeapon weapon =
|
||||
SourceItem?.GetComponent<RangedWeapon>() ??
|
||||
SourceItem?.GetComponent<RangedWeapon>() ??
|
||||
SourceItem?.GetComponent<Projectile>()?.Launcher?.GetComponent<RangedWeapon>();
|
||||
float? penetrationValue = weapon?.Penetration;
|
||||
if (penetrationValue.HasValue)
|
||||
@@ -614,7 +621,8 @@ namespace Barotrauma
|
||||
penetration += penetrationValue.Value;
|
||||
}
|
||||
|
||||
var attackResult = targetLimb.character.ApplyAttack(attacker, worldPosition, this, deltaTime, playSound, targetLimb, penetration);
|
||||
Vector2 impulseDirection = GetImpulseDirection(targetLimb, worldPosition, SourceItem);
|
||||
var attackResult = targetLimb.character.ApplyAttack(attacker, worldPosition, this, deltaTime, impulseDirection, playSound, targetLimb, penetration);
|
||||
var conditionalEffectType = attackResult.Damage > 0.0f ? ActionType.OnSuccess : ActionType.OnFailure;
|
||||
|
||||
foreach (StatusEffect effect in statusEffects)
|
||||
@@ -666,6 +674,34 @@ namespace Barotrauma
|
||||
return attackResult;
|
||||
}
|
||||
|
||||
private Vector2 GetImpulseDirection(ISpatialEntity target, Vector2 sourceWorldPosition, Item sourceItem)
|
||||
{
|
||||
Vector2 impulseDirection = Vector2.Zero;
|
||||
if (target != null)
|
||||
{
|
||||
impulseDirection = target.WorldPosition - sourceWorldPosition;
|
||||
}
|
||||
|
||||
if (sourceItem?.body != null && sourceItem.body.Enabled && sourceItem.body.LinearVelocity.LengthSquared() > 0.0f)
|
||||
{
|
||||
impulseDirection = sourceItem.body.LinearVelocity;
|
||||
}
|
||||
else
|
||||
{
|
||||
var projectileComponent = sourceItem?.GetComponent<Projectile>();
|
||||
if (projectileComponent != null)
|
||||
{
|
||||
impulseDirection = new Vector2(MathF.Cos(SourceItem.Rotation), MathF.Sin(SourceItem.Rotation));
|
||||
}
|
||||
}
|
||||
|
||||
if (impulseDirection.LengthSquared() > 0.0001f)
|
||||
{
|
||||
impulseDirection = Vector2.Normalize(impulseDirection);
|
||||
}
|
||||
return impulseDirection;
|
||||
}
|
||||
|
||||
public float AttackTimer { get; private set; }
|
||||
public float CoolDownTimer { get; set; }
|
||||
public float CurrentRandomCoolDown { get; private set; }
|
||||
|
||||
@@ -1098,6 +1098,15 @@ namespace Barotrauma
|
||||
set { CharacterHealth.Unkillable = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is the health interface available on this character? Can be used by status effects
|
||||
/// </summary>
|
||||
public bool UseHealthWindow
|
||||
{
|
||||
get { return CharacterHealth.UseHealthWindow; }
|
||||
set { CharacterHealth.UseHealthWindow = value; }
|
||||
}
|
||||
|
||||
public CampaignMode.InteractionType CampaignInteractionType;
|
||||
public Identifier MerchantIdentifier;
|
||||
|
||||
@@ -1223,19 +1232,15 @@ namespace Barotrauma
|
||||
public static Character Create(CharacterPrefab prefab, Vector2 position, string seed, CharacterInfo characterInfo = null, ushort id = Entity.NullEntityID, bool isRemotePlayer = false, bool hasAi = true, bool createNetworkEvent = true, RagdollParams ragdoll = null, bool spawnInitialItems = true)
|
||||
{
|
||||
Character newCharacter = null;
|
||||
if (prefab.Identifier != CharacterPrefab.HumanSpeciesName)
|
||||
if (prefab.Identifier != CharacterPrefab.HumanSpeciesName || hasAi)
|
||||
{
|
||||
var aiCharacter = new AICharacter(prefab, position, seed, characterInfo, id, isRemotePlayer, ragdoll, spawnInitialItems);
|
||||
var ai = new EnemyAIController(aiCharacter, seed);
|
||||
|
||||
var ai = (prefab.Identifier == CharacterPrefab.HumanSpeciesName || aiCharacter.Params.UseHumanAI) ?
|
||||
new HumanAIController(aiCharacter) as AIController :
|
||||
new EnemyAIController(aiCharacter, seed);
|
||||
aiCharacter.SetAI(ai);
|
||||
newCharacter = aiCharacter;
|
||||
}
|
||||
else if (hasAi)
|
||||
{
|
||||
var aiCharacter = new AICharacter(prefab, position, seed, characterInfo, id, isRemotePlayer, ragdoll, spawnInitialItems);
|
||||
var ai = new HumanAIController(aiCharacter);
|
||||
aiCharacter.SetAI(ai);
|
||||
newCharacter = aiCharacter;
|
||||
newCharacter = aiCharacter;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1282,7 +1287,8 @@ namespace Barotrauma
|
||||
{
|
||||
if (!VariantOf.IsEmpty)
|
||||
{
|
||||
DebugConsole.ThrowError("The variant system does not yet support humans, sorry. It does support other humanoids though!");
|
||||
DebugConsole.ThrowError("The variant system does not yet support humans, sorry. It does support other humanoids though!",
|
||||
contentPackage: Prefab.ContentPackage);
|
||||
}
|
||||
if (characterInfo == null)
|
||||
{
|
||||
@@ -1406,7 +1412,8 @@ namespace Barotrauma
|
||||
if (matchingAffliction == null || nonHuskedSpeciesName.IsEmpty)
|
||||
{
|
||||
DebugConsole.ThrowError($"Cannot find a husk infection that matches {speciesName}! Please make sure that the speciesname is added as 'targets' in the husk affliction prefab definition!\n"
|
||||
+ "Note that all the infected speciesnames and files must stick the following pattern: [nonhuskedspeciesname][huskedspeciesname]. E.g. Humanhusk, Crawlerhusk, or Humancustomhusk, or Crawlerzombie. Not \"Customhumanhusk!\" or \"Zombiecrawler\"");
|
||||
+ "Note that all the infected speciesnames and files must stick the following pattern: [nonhuskedspeciesname][huskedspeciesname]. E.g. Humanhusk, Crawlerhusk, or Humancustomhusk, or Crawlerzombie. Not \"Customhumanhusk!\" or \"Zombiecrawler\"",
|
||||
contentPackage: Prefab.ContentPackage);
|
||||
// Crashes if we fail to create a ragdoll -> Let's just use some ragdoll so that the user sees the error msg.
|
||||
nonHuskedSpeciesName = IsHumanoid ? CharacterPrefab.HumanSpeciesName : "crawler".ToIdentifier();
|
||||
speciesName = nonHuskedSpeciesName;
|
||||
@@ -2407,6 +2414,11 @@ namespace Barotrauma
|
||||
}
|
||||
else if (body.UserData is Item item)
|
||||
{
|
||||
if (item.GetComponent<Door>() is { HasWindow: true } door)
|
||||
{
|
||||
if (door.IsPositionOnWindow(ConvertUnits.ToDisplayUnits(Submarine.LastPickedPosition))) { return false; }
|
||||
}
|
||||
|
||||
return item != target;
|
||||
}
|
||||
return true;
|
||||
@@ -2768,9 +2780,17 @@ namespace Barotrauma
|
||||
if (!item.Prefab.InteractThroughWalls && Screen.Selected != GameMain.SubEditorScreen && !insideTrigger)
|
||||
{
|
||||
var body = Submarine.CheckVisibility(SimPosition, itemPosition, ignoreLevel: true);
|
||||
if (body != null && body.UserData as Item != item && (body.UserData as ItemComponent)?.Item != item && Submarine.LastPickedFixture?.UserData as Item != item)
|
||||
{
|
||||
return false;
|
||||
if (body != null)
|
||||
{
|
||||
var otherItem = body.UserData as Item ?? (body.UserData as ItemComponent)?.Item;
|
||||
if (otherItem != item &&
|
||||
(body.UserData as ItemComponent)?.Item != item &&
|
||||
/*allow interacting through open doors (e.g. duct blocks' colliders stay active despite being open)*/
|
||||
otherItem?.GetComponent<Door>() is not { IsOpen: true } &&
|
||||
Submarine.LastPickedFixture?.UserData as Item != item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2797,7 +2817,12 @@ namespace Barotrauma
|
||||
public void DeselectCharacter()
|
||||
{
|
||||
if (SelectedCharacter == null) { return; }
|
||||
SelectedCharacter.AnimController?.ResetPullJoints();
|
||||
if (!SelectedCharacter.AllowInput)
|
||||
{
|
||||
//we cannot reset the pull joints if the target is conscious (moving on its own),
|
||||
//that'd interfere with its animations
|
||||
SelectedCharacter.AnimController?.ResetPullJoints();
|
||||
}
|
||||
SelectedCharacter = null;
|
||||
}
|
||||
|
||||
@@ -3301,10 +3326,7 @@ namespace Barotrauma
|
||||
IsRagdolled = IsKeyDown(InputType.Ragdoll); //Handle this here instead of Control because we can stop being ragdolled ourselves
|
||||
if (wasRagdolled != IsRagdolled) { ragdollingLockTimer = 0.2f; }
|
||||
}
|
||||
if (IsRagdolled)
|
||||
{
|
||||
SetInput(InputType.Ragdoll, false, true);
|
||||
}
|
||||
SetInput(InputType.Ragdoll, false, IsRagdolled);
|
||||
}
|
||||
if (!wasRagdolled && IsRagdolled)
|
||||
{
|
||||
@@ -3980,15 +4002,15 @@ namespace Barotrauma
|
||||
CharacterHealth.SetAllDamage(damageAmount, bleedingDamageAmount, burnDamageAmount);
|
||||
}
|
||||
|
||||
public AttackResult AddDamage(Character attacker, Vector2 worldPosition, Attack attack, float deltaTime, bool playSound = true)
|
||||
public AttackResult AddDamage(Character attacker, Vector2 worldPosition, Attack attack, Vector2 impulseDirection, float deltaTime, bool playSound = true)
|
||||
{
|
||||
return ApplyAttack(attacker, worldPosition, attack, deltaTime, playSound, null);
|
||||
return ApplyAttack(attacker, worldPosition, attack, deltaTime, impulseDirection, playSound);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply the specified attack to this character. If the targetLimb is not specified, the limb closest to worldPosition will receive the damage.
|
||||
/// </summary>
|
||||
public AttackResult ApplyAttack(Character attacker, Vector2 worldPosition, Attack attack, float deltaTime, bool playSound = false, Limb targetLimb = null, float penetration = 0f)
|
||||
public AttackResult ApplyAttack(Character attacker, Vector2 worldPosition, Attack attack, float deltaTime, Vector2 impulseDirection, bool playSound = false, Limb targetLimb = null, float penetration = 0f)
|
||||
{
|
||||
if (Removed)
|
||||
{
|
||||
@@ -4000,7 +4022,16 @@ namespace Barotrauma
|
||||
|
||||
Limb limbHit = targetLimb;
|
||||
|
||||
float attackImpulse = attack.TargetImpulse + attack.TargetForce * attack.ImpactMultiplier * deltaTime;
|
||||
float impulseMagnitude = (attack.TargetImpulse + attack.TargetForce * attack.ImpactMultiplier) * deltaTime;
|
||||
|
||||
Vector2 attackImpulse = Vector2.Zero;
|
||||
if (Math.Abs(impulseMagnitude) > 0.0f)
|
||||
{
|
||||
impulseDirection = impulseDirection.LengthSquared() > 0.0001f ?
|
||||
Vector2.Normalize(impulseDirection) :
|
||||
Vector2.UnitX;
|
||||
attackImpulse = impulseDirection * impulseMagnitude;
|
||||
}
|
||||
|
||||
AbilityAttackData attackData = new AbilityAttackData(attack, this, attacker);
|
||||
IEnumerable<Affliction> attackAfflictions;
|
||||
@@ -4129,12 +4160,12 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public AttackResult AddDamage(Vector2 worldPosition, IEnumerable<Affliction> afflictions, float stun, bool playSound, float attackImpulse = 0.0f, Character attacker = null, float damageMultiplier = 1f)
|
||||
public AttackResult AddDamage(Vector2 worldPosition, IEnumerable<Affliction> afflictions, float stun, bool playSound, Vector2? attackImpulse = null, Character attacker = null, float damageMultiplier = 1f)
|
||||
{
|
||||
return AddDamage(worldPosition, afflictions, stun, playSound, attackImpulse, out _, attacker, damageMultiplier: damageMultiplier);
|
||||
return AddDamage(worldPosition, afflictions, stun, playSound, attackImpulse ?? Vector2.Zero, out _, attacker, damageMultiplier: damageMultiplier);
|
||||
}
|
||||
|
||||
public AttackResult AddDamage(Vector2 worldPosition, IEnumerable<Affliction> afflictions, float stun, bool playSound, float attackImpulse, out Limb hitLimb, Character attacker = null, float damageMultiplier = 1)
|
||||
public AttackResult AddDamage(Vector2 worldPosition, IEnumerable<Affliction> afflictions, float stun, bool playSound, Vector2 attackImpulse, out Limb hitLimb, Character attacker = null, float damageMultiplier = 1)
|
||||
{
|
||||
hitLimb = null;
|
||||
|
||||
@@ -4167,7 +4198,7 @@ namespace Barotrauma
|
||||
CreatureMetrics.RecordKill(target.SpeciesName);
|
||||
}
|
||||
|
||||
public AttackResult DamageLimb(Vector2 worldPosition, Limb hitLimb, IEnumerable<Affliction> afflictions, float stun, bool playSound, float attackImpulse, Character attacker = null, float damageMultiplier = 1, bool allowStacking = true, float penetration = 0f, bool shouldImplode = false)
|
||||
public AttackResult DamageLimb(Vector2 worldPosition, Limb hitLimb, IEnumerable<Affliction> afflictions, float stun, bool playSound, Vector2 attackImpulse, Character attacker = null, float damageMultiplier = 1, bool allowStacking = true, float penetration = 0f, bool shouldImplode = false)
|
||||
{
|
||||
if (Removed) { return new AttackResult(); }
|
||||
|
||||
@@ -4200,18 +4231,17 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
Vector2 dir = hitLimb.WorldPosition - worldPosition;
|
||||
if (Math.Abs(attackImpulse) > 0.0f)
|
||||
if (attackImpulse.LengthSquared() > 0.0f)
|
||||
{
|
||||
Vector2 diff = dir;
|
||||
if (diff == Vector2.Zero) { diff = Rand.Vector(1.0f); }
|
||||
Vector2 impulse = Vector2.Normalize(diff) * attackImpulse;
|
||||
Vector2 hitPos = hitLimb.SimPosition + ConvertUnits.ToSimUnits(diff);
|
||||
hitLimb.body.ApplyLinearImpulse(impulse, hitPos, maxVelocity: NetConfig.MaxPhysicsBodyVelocity * 0.5f);
|
||||
hitLimb.body.ApplyLinearImpulse(attackImpulse, hitPos, maxVelocity: NetConfig.MaxPhysicsBodyVelocity * 0.5f);
|
||||
var mainLimb = hitLimb.character.AnimController.MainLimb;
|
||||
if (hitLimb != mainLimb)
|
||||
{
|
||||
// Always add force to mainlimb
|
||||
mainLimb.body.ApplyLinearImpulse(impulse, hitPos, maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
|
||||
mainLimb.body.ApplyLinearImpulse(attackImpulse, hitPos, maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
|
||||
}
|
||||
}
|
||||
bool wasDead = IsDead;
|
||||
@@ -4656,7 +4686,7 @@ namespace Barotrauma
|
||||
}
|
||||
partial void KillProjSpecific(CauseOfDeathType causeOfDeath, Affliction causeOfDeathAffliction, bool log);
|
||||
|
||||
public void Revive(bool removeAfflictions = true)
|
||||
public void Revive(bool removeAfflictions = true, bool createNetworkEvent = false)
|
||||
{
|
||||
if (Removed)
|
||||
{
|
||||
@@ -4705,7 +4735,11 @@ namespace Barotrauma
|
||||
limb.IsSevered = false;
|
||||
}
|
||||
|
||||
GameMain.GameSession?.ReviveCharacter(this);
|
||||
GameMain.GameSession?.ReviveCharacter(this);
|
||||
if (createNetworkEvent && GameMain.NetworkMember is { IsServer: true })
|
||||
{
|
||||
GameMain.NetworkMember.CreateEntityEvent(this, new CharacterStatusEventData());
|
||||
}
|
||||
}
|
||||
|
||||
public override void Remove()
|
||||
@@ -4986,7 +5020,9 @@ namespace Barotrauma
|
||||
float maxDistance = 1000f;
|
||||
foreach (var hull in adjacentHulls)
|
||||
{
|
||||
if (hull.ConnectedGaps.Any(g => g.Open > 0.9f && g.linkedTo.Contains(CurrentHull) &&
|
||||
if (hull.ConnectedGaps.Any(g =>
|
||||
(g.Open > 0.9f || g.ConnectedDoor is { HasWindow: true }) &&
|
||||
g.linkedTo.Contains(CurrentHull) &&
|
||||
Vector2.DistanceSquared(g.WorldPosition, WorldPosition) < Math.Pow(maxDistance / 2, 2)))
|
||||
{
|
||||
if (Vector2.DistanceSquared(hull.WorldPosition, WorldPosition) < Math.Pow(maxDistance, 2))
|
||||
@@ -5005,7 +5041,7 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
if (h.ConnectedGaps.Any(g =>
|
||||
g.Open > 0.9f &&
|
||||
(g.Open > 0.9f || g.ConnectedDoor is { HasWindow: true }) &&
|
||||
Vector2.DistanceSquared(g.WorldPosition, WorldPosition) < Math.Pow(maxDistance / 2, 2) &&
|
||||
CanSeeTarget(g)))
|
||||
{
|
||||
@@ -5027,7 +5063,7 @@ namespace Barotrauma
|
||||
public bool IsEngineer => HasJob("engineer");
|
||||
public bool IsMechanic => HasJob("mechanic");
|
||||
public bool IsMedic => HasJob("medicaldoctor");
|
||||
public bool IsSecurity => HasJob("securityofficer") || HasJob("vipsecurityofficer");
|
||||
public bool IsSecurity => HasJob("securityofficer") || HasJob("vipsecurityofficer") || HasJob("outpostsecurityofficer");
|
||||
public bool IsAssistant => HasJob("assistant");
|
||||
public bool IsWatchman => HasJob("watchman");
|
||||
public bool IsVip => HasJob("prisoner");
|
||||
|
||||
@@ -767,7 +767,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
// Used for loading the data
|
||||
public CharacterInfo(XElement infoElement, Identifier npcIdentifier = default)
|
||||
public CharacterInfo(ContentXElement infoElement, Identifier npcIdentifier = default)
|
||||
{
|
||||
ID = idCounter;
|
||||
idCounter++;
|
||||
@@ -1311,12 +1311,12 @@ namespace Barotrauma
|
||||
OnExperienceChanged(prevAmount, ExperiencePoints);
|
||||
}
|
||||
|
||||
const int BaseExperienceRequired = -50;
|
||||
const int BaseExperienceRequired = 450;
|
||||
const int AddedExperienceRequiredPerLevel = 500;
|
||||
|
||||
public int GetTotalTalentPoints()
|
||||
{
|
||||
return GetCurrentLevel() + AdditionalTalentPoints - 1;
|
||||
return GetCurrentLevel() + AdditionalTalentPoints;
|
||||
}
|
||||
|
||||
public int GetAvailableTalentPoints()
|
||||
@@ -1342,16 +1342,19 @@ namespace Barotrauma
|
||||
return experienceRequired + ExperienceRequiredPerLevel(level);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// How much more experience does the character need to reach the specified level?
|
||||
/// </summary>
|
||||
public int GetExperienceRequiredForLevel(int level)
|
||||
{
|
||||
int currentLevel = GetCurrentLevel(out int experienceRequired);
|
||||
int currentLevel = GetCurrentLevel();
|
||||
if (currentLevel >= level) { return 0; }
|
||||
int required = experienceRequired;
|
||||
for (int i = currentLevel + 1; i <= level; i++)
|
||||
int required = 0;
|
||||
for (int i = 0; i < level; i++)
|
||||
{
|
||||
required += ExperienceRequiredPerLevel(i);
|
||||
}
|
||||
return required;
|
||||
return required - ExperiencePoints;
|
||||
}
|
||||
|
||||
public int GetCurrentLevel()
|
||||
@@ -1361,7 +1364,7 @@ namespace Barotrauma
|
||||
|
||||
private int GetCurrentLevel(out int experienceRequired)
|
||||
{
|
||||
int level = 1;
|
||||
int level = 0;
|
||||
experienceRequired = 0;
|
||||
while (experienceRequired + ExperienceRequiredPerLevel(level) <= ExperiencePoints)
|
||||
{
|
||||
|
||||
@@ -95,7 +95,8 @@ namespace Barotrauma
|
||||
name = ParseName(mainElement, file);
|
||||
if (name == Identifier.Empty)
|
||||
{
|
||||
DebugConsole.ThrowError($"No species name defined for: {file.Path}");
|
||||
DebugConsole.ThrowError($"No species name defined for: {file.Path}",
|
||||
contentPackage: file.ContentPackage);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -75,7 +75,8 @@ namespace Barotrauma
|
||||
HuskPrefab = prefab as AfflictionPrefabHusk;
|
||||
if (HuskPrefab == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in husk affliction definition: the prefab is of wrong type!");
|
||||
DebugConsole.ThrowError("Error in husk affliction definition: the prefab is of wrong type!",
|
||||
contentPackage: prefab.ContentPackage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +198,7 @@ namespace Barotrauma
|
||||
huskInfection.Add(AfflictionPrefab.InternalDamage.Instantiate(random * 10 * deltaTime / limbCount));
|
||||
character.LastDamageSource = null;
|
||||
float force = applyForce ? random * 0.5f * limb.Mass : 0;
|
||||
character.DamageLimb(limb.WorldPosition, limb, huskInfection, 0, false, force);
|
||||
character.DamageLimb(limb.WorldPosition, limb, huskInfection, 0, false, Rand.Vector(force));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +206,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (huskAppendage == null && character.Params.UseHuskAppendage)
|
||||
{
|
||||
huskAppendage = AttachHuskAppendage(character, Prefab.Identifier);
|
||||
huskAppendage = AttachHuskAppendage(character, Prefab as AfflictionPrefabHusk);
|
||||
}
|
||||
|
||||
if (Prefab is AfflictionPrefabHusk { NeedsAir: false })
|
||||
@@ -285,13 +286,14 @@ namespace Barotrauma
|
||||
|
||||
if (prefab == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to turn character \"" + character.Name + "\" into a husk - husk config file not found.");
|
||||
DebugConsole.ThrowError("Failed to turn character \"" + character.Name + "\" into a husk - husk config file not found.",
|
||||
contentPackage: Prefab.ContentPackage);
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
XElement parentElement = new XElement("CharacterInfo");
|
||||
XElement infoElement = character.Info?.Save(parentElement);
|
||||
CharacterInfo huskCharacterInfo = infoElement == null ? null : new CharacterInfo(infoElement);
|
||||
CharacterInfo huskCharacterInfo = infoElement == null ? null : new CharacterInfo(new ContentXElement(Prefab.ContentPackage, infoElement));
|
||||
|
||||
if (huskCharacterInfo != null)
|
||||
{
|
||||
@@ -371,31 +373,28 @@ namespace Barotrauma
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
public static List<Limb> AttachHuskAppendage(Character character, Identifier afflictionIdentifier, ContentXElement appendageDefinition = null, Ragdoll ragdoll = null)
|
||||
public static List<Limb> AttachHuskAppendage(Character character, AfflictionPrefabHusk matchingAffliction, ContentXElement appendageDefinition = null, Ragdoll ragdoll = null)
|
||||
{
|
||||
var appendage = new List<Limb>();
|
||||
if (!(AfflictionPrefab.List.FirstOrDefault(ap => ap.Identifier == afflictionIdentifier) is AfflictionPrefabHusk matchingAffliction))
|
||||
{
|
||||
DebugConsole.ThrowError($"Could not find an affliction of type 'huskinfection' that matches the affliction '{afflictionIdentifier}'!");
|
||||
return appendage;
|
||||
}
|
||||
Identifier nonhuskedSpeciesName = GetNonHuskedSpeciesName(character.SpeciesName, matchingAffliction);
|
||||
Identifier huskedSpeciesName = GetHuskedSpeciesName(nonhuskedSpeciesName, matchingAffliction);
|
||||
CharacterPrefab huskPrefab = CharacterPrefab.FindBySpeciesName(huskedSpeciesName);
|
||||
if (huskPrefab?.ConfigElement == null)
|
||||
{
|
||||
DebugConsole.ThrowError($"Failed to find the config file for the husk infected species with the species name '{huskedSpeciesName}'!");
|
||||
DebugConsole.ThrowError($"Failed to find the config file for the husk infected species with the species name '{huskedSpeciesName}'!",
|
||||
contentPackage: matchingAffliction.ContentPackage);
|
||||
return appendage;
|
||||
}
|
||||
var mainElement = huskPrefab.ConfigElement;
|
||||
var element = appendageDefinition;
|
||||
if (element == null)
|
||||
{
|
||||
element = mainElement.GetChildElements("huskappendage").FirstOrDefault(e => e.GetAttributeIdentifier("affliction", Identifier.Empty) == afflictionIdentifier);
|
||||
element = mainElement.GetChildElements("huskappendage").FirstOrDefault(e => e.GetAttributeIdentifier("affliction", Identifier.Empty) == matchingAffliction.Identifier);
|
||||
}
|
||||
if (element == null)
|
||||
{
|
||||
DebugConsole.ThrowError($"Error in '{huskPrefab.FilePath}': Failed to find a huskappendage that matches the affliction with an identifier '{afflictionIdentifier}'!");
|
||||
DebugConsole.ThrowError($"Error in '{huskPrefab.FilePath}': Failed to find a huskappendage that matches the affliction with an identifier '{matchingAffliction.Identifier}'!",
|
||||
contentPackage: matchingAffliction.ContentPackage);
|
||||
return appendage;
|
||||
}
|
||||
ContentPath pathToAppendage = element.GetAttributeContentPath("path") ?? ContentPath.Empty;
|
||||
|
||||
@@ -170,11 +170,13 @@ namespace Barotrauma
|
||||
|
||||
if (DormantThreshold > ActiveThreshold)
|
||||
{
|
||||
DebugConsole.ThrowError($"Error in \"{Identifier}\": {nameof(DormantThreshold)} is greater than {nameof(ActiveThreshold)} ({DormantThreshold} > {ActiveThreshold})");
|
||||
DebugConsole.ThrowError($"Error in \"{Identifier}\": {nameof(DormantThreshold)} is greater than {nameof(ActiveThreshold)} ({DormantThreshold} > {ActiveThreshold})",
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
if (ActiveThreshold > TransitionThreshold)
|
||||
{
|
||||
DebugConsole.ThrowError($"Error in \"{Identifier}\": {nameof(ActiveThreshold)} is greater than {nameof(TransitionThreshold)} ({ActiveThreshold} > {TransitionThreshold})");
|
||||
DebugConsole.ThrowError($"Error in \"{Identifier}\": {nameof(ActiveThreshold)} is greater than {nameof(TransitionThreshold)} ({ActiveThreshold} > {TransitionThreshold})",
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
|
||||
TransformThresholdOnDeath = element.GetAttributeFloat("transformthresholdondeath", ActiveThreshold);
|
||||
@@ -440,13 +442,15 @@ namespace Barotrauma
|
||||
AbilityFlags flagType = subElement.GetAttributeEnum("flagtype", AbilityFlags.None);
|
||||
if (flagType is AbilityFlags.None)
|
||||
{
|
||||
DebugConsole.ThrowError($"Error in affliction \"{parentDebugName}\" - invalid ability flag type \"{subElement.GetAttributeString("flagtype", "")}\".");
|
||||
DebugConsole.ThrowError($"Error in affliction \"{parentDebugName}\" - invalid ability flag type \"{subElement.GetAttributeString("flagtype", "")}\".",
|
||||
contentPackage: element.ContentPackage);
|
||||
continue;
|
||||
}
|
||||
AfflictionAbilityFlags |= flagType;
|
||||
break;
|
||||
case "affliction":
|
||||
DebugConsole.AddWarning($"Error in affliction \"{parentDebugName}\" - additional afflictions caused by the affliction should be configured inside status effects.");
|
||||
DebugConsole.AddWarning($"Error in affliction \"{parentDebugName}\" - additional afflictions caused by the affliction should be configured inside status effects.",
|
||||
contentPackage: element.ContentPackage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -537,14 +541,16 @@ namespace Barotrauma
|
||||
}
|
||||
else if (TextTag.IsEmpty)
|
||||
{
|
||||
DebugConsole.ThrowError($"Error in affliction \"{affliction.Identifier}\" - no text defined for one of the descriptions.");
|
||||
DebugConsole.ThrowError($"Error in affliction \"{affliction.Identifier}\" - no text defined for one of the descriptions.",
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
|
||||
MinStrength = element.GetAttributeFloat(nameof(MinStrength), 0.0f);
|
||||
MaxStrength = element.GetAttributeFloat(nameof(MaxStrength), 100.0f);
|
||||
if (MinStrength >= MaxStrength)
|
||||
{
|
||||
DebugConsole.ThrowError($"Error in affliction \"{affliction.Identifier}\" - max strength is not larger than min.");
|
||||
DebugConsole.ThrowError($"Error in affliction \"{affliction.Identifier}\" - max strength is not larger than min.",
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
Target = element.GetAttributeEnum(nameof(Target), TargetType.Any);
|
||||
}
|
||||
@@ -953,7 +959,8 @@ namespace Barotrauma
|
||||
AfflictionOverlay = new Sprite(subElement);
|
||||
break;
|
||||
case "statvalue":
|
||||
DebugConsole.ThrowError($"Error in affliction \"{Identifier}\" - stat values should be configured inside the affliction's effects.");
|
||||
DebugConsole.ThrowError($"Error in affliction \"{Identifier}\" - stat values should be configured inside the affliction's effects.",
|
||||
contentPackage: element.ContentPackage);
|
||||
break;
|
||||
case "effect":
|
||||
case "periodiceffect":
|
||||
@@ -962,7 +969,8 @@ namespace Barotrauma
|
||||
descriptions.Add(new Description(subElement, this));
|
||||
break;
|
||||
default:
|
||||
DebugConsole.AddWarning($"Unrecognized element in affliction \"{Identifier}\" ({subElement.Name})");
|
||||
DebugConsole.AddWarning($"Unrecognized element in affliction \"{Identifier}\" ({subElement.Name})",
|
||||
contentPackage: element.ContentPackage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1046,7 +1054,8 @@ namespace Barotrauma
|
||||
var b = effects[j];
|
||||
if (a.MinStrength < b.MaxStrength && b.MinStrength < a.MaxStrength)
|
||||
{
|
||||
DebugConsole.AddWarning($"Affliction \"{Identifier}\" contains effects with overlapping strength ranges. Only one effect can be active at a time, meaning one of the effects won't work.");
|
||||
DebugConsole.AddWarning($"Affliction \"{Identifier}\" contains effects with overlapping strength ranges. Only one effect can be active at a time, meaning one of the effects won't work.",
|
||||
ContentPackage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,8 @@ namespace Barotrauma
|
||||
case "vitalitymultiplier":
|
||||
if (subElement.GetAttribute("name") != null)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in character health config (" + characterHealth.Character.Name + ") - define vitality multipliers using affliction identifiers or types instead of names.");
|
||||
DebugConsole.ThrowError("Error in character health config (" + characterHealth.Character.Name + ") - define vitality multipliers using affliction identifiers or types instead of names.",
|
||||
contentPackage: element.ContentPackage);
|
||||
continue;
|
||||
}
|
||||
var vitalityMultipliers = subElement.GetAttributeIdentifierArray("identifier", null) ?? subElement.GetAttributeIdentifierArray("identifiers", null);
|
||||
@@ -61,7 +62,8 @@ namespace Barotrauma
|
||||
VitalityMultipliers.Add(vitalityMultiplier, multiplier);
|
||||
if (AfflictionPrefab.Prefabs.None(p => p.Identifier == vitalityMultiplier))
|
||||
{
|
||||
DebugConsole.AddWarning($"Potentially incorrectly defined vitality multiplier in \"{characterHealth.Character.Name}\". Could not find any afflictions with the identifier \"{vitalityMultiplier}\". Did you mean to define the afflictions by type instead?");
|
||||
DebugConsole.AddWarning($"Potentially incorrectly defined vitality multiplier in \"{characterHealth.Character.Name}\". Could not find any afflictions with the identifier \"{vitalityMultiplier}\". Did you mean to define the afflictions by type instead?",
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,13 +76,15 @@ namespace Barotrauma
|
||||
VitalityTypeMultipliers.Add(vitalityTypeMultiplier, multiplier);
|
||||
if (AfflictionPrefab.Prefabs.None(p => p.AfflictionType == vitalityTypeMultiplier))
|
||||
{
|
||||
DebugConsole.AddWarning($"Potentially incorrectly defined vitality multiplier in \"{characterHealth.Character.Name}\". Could not find any afflictions of the type \"{vitalityTypeMultiplier}\". Did you mean to define the afflictions by identifier instead?");
|
||||
DebugConsole.AddWarning($"Potentially incorrectly defined vitality multiplier in \"{characterHealth.Character.Name}\". Could not find any afflictions of the type \"{vitalityTypeMultiplier}\". Did you mean to define the afflictions by identifier instead?",
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (vitalityMultipliers == null && VitalityTypeMultipliers == null)
|
||||
{
|
||||
DebugConsole.ThrowError($"Error in character health config {characterHealth.Character.Name}: affliction identifier(s) or type(s) not defined in the \"VitalityMultiplier\" elements!");
|
||||
DebugConsole.ThrowError($"Error in character health config {characterHealth.Character.Name}: affliction identifier(s) or type(s) not defined in the \"VitalityMultiplier\" elements!",
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -148,11 +152,6 @@ namespace Barotrauma
|
||||
return minVitality;
|
||||
}
|
||||
return vitality;
|
||||
|
||||
}
|
||||
private set
|
||||
{
|
||||
vitality = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +253,7 @@ namespace Barotrauma
|
||||
public CharacterHealth(Character character)
|
||||
{
|
||||
this.Character = character;
|
||||
Vitality = 100.0f;
|
||||
vitality = 100.0f;
|
||||
|
||||
DoesBleed = true;
|
||||
UseHealthWindow = false;
|
||||
@@ -271,7 +270,7 @@ namespace Barotrauma
|
||||
this.Character = character;
|
||||
InitIrremovableAfflictions();
|
||||
|
||||
Vitality = UnmodifiedMaxVitality;
|
||||
vitality = UnmodifiedMaxVitality;
|
||||
|
||||
minVitality = character.IsHuman ? -100.0f : 0.0f;
|
||||
|
||||
@@ -971,7 +970,7 @@ namespace Barotrauma
|
||||
|
||||
public void CalculateVitality()
|
||||
{
|
||||
Vitality = MaxVitality;
|
||||
vitality = MaxVitality;
|
||||
IsParalyzed = false;
|
||||
if (Unkillable || Character.GodMode) { return; }
|
||||
|
||||
@@ -984,7 +983,7 @@ namespace Barotrauma
|
||||
{
|
||||
vitalityDecrease *= GetVitalityMultiplier(affliction, limbHealth);
|
||||
}
|
||||
Vitality -= vitalityDecrease;
|
||||
vitality -= vitalityDecrease;
|
||||
affliction.CalculateDamagePerSecond(vitalityDecrease);
|
||||
|
||||
if (affliction.Strength >= affliction.Prefab.MaxStrength &&
|
||||
|
||||
@@ -79,12 +79,13 @@ namespace Barotrauma
|
||||
|
||||
public ref readonly ImmutableArray<Identifier> ParsedAfflictionTypes => ref parsedAfflictionTypes;
|
||||
|
||||
public DamageModifier(XElement element, string parentDebugName, bool checkErrors = true)
|
||||
public DamageModifier(ContentXElement element, string parentDebugName, bool checkErrors = true)
|
||||
{
|
||||
Deserialize(element);
|
||||
if (element.Attribute("afflictionnames") != null)
|
||||
if (element.GetAttribute("afflictionnames") != null)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in DamageModifier config (" + parentDebugName + ") - define afflictions using identifiers or types instead of names.");
|
||||
DebugConsole.ThrowError("Error in DamageModifier config (" + parentDebugName + ") - define afflictions using identifiers or types instead of names.",
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
if (checkErrors)
|
||||
{
|
||||
@@ -108,12 +109,12 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
static void createWarningOrError(string msg)
|
||||
void createWarningOrError(string msg)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError(msg);
|
||||
DebugConsole.ThrowError(msg, contentPackage: element.ContentPackage);
|
||||
#else
|
||||
DebugConsole.AddWarning(msg);
|
||||
DebugConsole.AddWarning(msg, contentPackage: element.ContentPackage);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,8 +117,8 @@ namespace Barotrauma
|
||||
public XElement Element { get; protected set; }
|
||||
|
||||
|
||||
public readonly List<(XElement element, float commonness)> ItemSets = new List<(XElement element, float commonness)>();
|
||||
public readonly List<(XElement element, float commonness)> CustomCharacterInfos = new List<(XElement element, float commonness)>();
|
||||
public readonly List<(ContentXElement element, float commonness)> ItemSets = new List<(ContentXElement element, float commonness)>();
|
||||
public readonly List<(ContentXElement element, float commonness)> CustomCharacterInfos = new List<(ContentXElement element, float commonness)>();
|
||||
|
||||
public readonly Identifier NpcSetIdentifier;
|
||||
|
||||
@@ -196,7 +196,7 @@ namespace Barotrauma
|
||||
var spawnItems = ToolBox.SelectWeightedRandom(ItemSets, it => it.commonness, randSync).element;
|
||||
if (spawnItems != null)
|
||||
{
|
||||
foreach (XElement itemElement in spawnItems.GetChildElements("item"))
|
||||
foreach (ContentXElement itemElement in spawnItems.GetChildElements("item"))
|
||||
{
|
||||
int amount = itemElement.GetAttributeInt("amount", 1);
|
||||
for (int i = 0; i < amount; i++)
|
||||
@@ -239,14 +239,15 @@ namespace Barotrauma
|
||||
return characterInfo;
|
||||
}
|
||||
|
||||
public static void InitializeItem(Character character, XElement itemElement, Submarine submarine, HumanPrefab humanPrefab, WayPoint spawnPoint = null, Item parentItem = null, bool createNetworkEvents = true)
|
||||
public static void InitializeItem(Character character, ContentXElement itemElement, Submarine submarine, HumanPrefab humanPrefab, WayPoint spawnPoint = null, Item parentItem = null, bool createNetworkEvents = true)
|
||||
{
|
||||
ItemPrefab itemPrefab;
|
||||
string itemIdentifier = itemElement.GetAttributeString("identifier", "");
|
||||
itemPrefab = MapEntityPrefab.FindByIdentifier(itemIdentifier.ToIdentifier()) as ItemPrefab;
|
||||
if (itemPrefab == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Tried to spawn \"" + humanPrefab?.Identifier + "\" with the item \"" + itemIdentifier + "\". Matching item prefab not found.");
|
||||
DebugConsole.ThrowError("Tried to spawn \"" + humanPrefab?.Identifier + "\" with the item \"" + itemIdentifier + "\". Matching item prefab not found.",
|
||||
contentPackage: itemElement?.ContentPackage);
|
||||
return;
|
||||
}
|
||||
Item item = new Item(itemPrefab, character.Position, null);
|
||||
@@ -301,7 +302,7 @@ namespace Barotrauma
|
||||
wifiComponent.TeamID = character.TeamID;
|
||||
}
|
||||
parentItem?.Combine(item, user: null);
|
||||
foreach (XElement childItemElement in itemElement.Elements())
|
||||
foreach (ContentXElement childItemElement in itemElement.Elements())
|
||||
{
|
||||
int amount = childItemElement.GetAttributeInt("amount", 1);
|
||||
for (int i = 0; i < amount; i++)
|
||||
|
||||
@@ -47,13 +47,14 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public Job(XElement element)
|
||||
public Job(ContentXElement element)
|
||||
{
|
||||
Identifier identifier = element.GetAttributeIdentifier("identifier", "");
|
||||
JobPrefab p;
|
||||
if (!JobPrefab.Prefabs.ContainsKey(identifier))
|
||||
{
|
||||
DebugConsole.ThrowError($"Could not find the job {identifier}. Giving the character a random job.");
|
||||
DebugConsole.ThrowError($"Could not find the job {identifier}. Giving the character a random job.",
|
||||
contentPackage: element.ContentPackage);
|
||||
p = JobPrefab.Random(Rand.RandSync.Unsynced);
|
||||
}
|
||||
else
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user