v1.1.18.0 (Treacherous Tides Update)

This commit is contained in:
Regalis11
2023-10-19 17:18:51 +03:00
parent 12e43d95ef
commit 34ffc520cc
20 changed files with 179 additions and 43 deletions
@@ -21,9 +21,11 @@ namespace Barotrauma.Items.Components
Vector2 simPosition = new Vector2(msg.ReadSingle(), msg.ReadSingle());
float rotation = msg.ReadSingle();
spreadIndex = msg.ReadByte();
ushort submarineID = msg.ReadUInt16();
if (User != null)
{
Shoot(User, simPosition, simPosition, rotation, ignoredBodies: User.AnimController.Limbs.Where(l => !l.IsSevered).Select(l => l.body.FarseerBody).ToList(), createNetworkEvent: false);
item.Submarine = Entity.FindEntityByID(submarineID) as Submarine;
}
else
{
@@ -57,13 +57,6 @@ namespace Barotrauma.Items.Components
private readonly List<ParticleEmitter> particleEmitters = new List<ParticleEmitter>();
private readonly List<ParticleEmitter> particleEmitterCharges = new List<ParticleEmitter>();
[Editable, Serialize("0,0,0,0", IsPropertySaveable.Yes, description: "Optional screen tint color when the item is being operated (R,G,B,A).")]
public Color HudTint
{
get;
private set;
}
[Serialize(false, IsPropertySaveable.No, description: "Should the charge of the connected batteries/supercapacitors be shown at the top of the screen when operating the item.")]
public bool ShowChargeIndicator
{
@@ -163,10 +163,22 @@ namespace Barotrauma
{
if (SelectedAny)
{
SubEditorScreen.StoreCommand(new AddOrDeleteCommand(new List<MapEntity>(SelectedList), true));
if (SelectedList.Any(static t => t is Item it && it.GetComponent<CircuitBox>() is not null))
{
GUI.AskForConfirmation(SubEditorScreen.CircuitBoxDeletionWarningHeader, SubEditorScreen.CircuitBoxDeletionWarningBody, onConfirm: Delete);
}
else
{
Delete();
}
void Delete()
{
SubEditorScreen.StoreCommand(new AddOrDeleteCommand(new List<MapEntity>(SelectedList), true));
SelectedList.ForEach(static e => { if (!e.Removed) { e.Remove(); } });
SelectedList.Clear();
}
}
SelectedList.ForEach(e => { if (!e.Removed) { e.Remove(); } });
SelectedList.Clear();
}
if (PlayerInput.IsCtrlDown())
@@ -60,6 +60,7 @@ namespace Barotrauma
}
Sprite sprite = iconSprites[SpawnType.ToString()];
Sprite sprite2 = null;
if (spawnType == SpawnType.Human && AssignedJob?.Icon != null)
{
sprite = iconSprites["Path"];
@@ -67,17 +68,29 @@ namespace Barotrauma
else if (ConnectedDoor != null)
{
sprite = iconSprites["Door"];
if (ConnectedDoor.IsHorizontal && Ladders == null)
if (Ladders != null)
{
sprite2 = iconSprites["Ladder"];
}
else if (ConnectedDoor.IsHorizontal)
{
//connected to a hatch but not ladders, something's probably off here
clr = Color.Yellow;
}
if (!Submarine.RectContains(ConnectedDoor.Item.WorldRect, WorldPosition))
{
clr = Color.Red;
}
}
else if (Ladders != null)
{
sprite = iconSprites["Ladder"];
}
sprite.Draw(spriteBatch, drawPos, clr, scale: iconSize / (float)sprite.SourceRect.Width, depth: 0.001f);
sprite.RelativeOrigin = Vector2.One * 0.5f;
float spriteScale = iconSize / (float)sprite.SourceRect.Width;
sprite.Draw(spriteBatch, drawPos, clr, origin: sprite.size / 2, scale: spriteScale, depth: 0.001f);
sprite2?.Draw(spriteBatch, drawPos + sprite.size * spriteScale * 0.5f, clr, origin: sprite2.size / 2, scale: spriteScale, depth: 0.001f);
if (spawnType == SpawnType.Human && AssignedJob?.Icon != null)
{
AssignedJob.Icon.Draw(spriteBatch, drawPos, AssignedJob.UIColor, scale: iconSize / (float)AssignedJob.Icon.SourceRect.Width * 0.8f, depth: 0.0f);
@@ -273,6 +273,11 @@ namespace Barotrauma
GUIStyle.SubHeadingFont.DrawString(spriteBatch, Name, HeaderRectangle.Location.ToVector2() + (HeaderRectangle.Size.ToVector2() / 2) - (headerSize / 2), fontColor);
}
public void AddConnection(NodeConnectionType connectionType)
{
Connections.Add(new EventEditorNodeConnection(this, connectionType));
}
public virtual void AddOption()
{
Connections.Add(new EventEditorNodeConnection(this, NodeConnectionType.Option));
@@ -16,6 +16,9 @@ namespace Barotrauma
{
class SubEditorScreen : EditorScreen
{
public const string CircuitBoxDeletionWarningHeader = "Selection contains circuit boxes",
CircuitBoxDeletionWarningBody = "Are you sure you want to delete the selection? Any wiring inside circuit boxes will be lost and cannot be recovered.";
public const int MaxStructures = 2000;
public const int MaxWalls = 500;
public const int MaxItems = 5000;
@@ -3915,18 +3918,31 @@ namespace Barotrauma
new ContextMenuOption("editor.cut", isEnabled: hasTargets, onSelected: () => MapEntity.Cut(targets)),
new ContextMenuOption("editor.copytoclipboard", isEnabled: hasTargets, onSelected: () => MapEntity.Copy(targets)),
new ContextMenuOption("editor.paste", isEnabled: MapEntity.CopiedList.Any(), onSelected: () => MapEntity.Paste(cam.ScreenToWorld(PlayerInput.MousePosition))),
new ContextMenuOption("delete", isEnabled: hasTargets, onSelected: delegate
{
StoreCommand(new AddOrDeleteCommand(targets, true));
foreach (var me in targets)
{
if (!me.Removed) { me.Remove(); }
}
}),
new ContextMenuOption("delete", isEnabled: hasTargets, onSelected: () => RemoveEntitiesWithPossibleWarning(targets)),
new ContextMenuOption(TextManager.Get("editortip.shiftforextraoptions") + '\n' + TextManager.Get("editortip.altforruler"), isEnabled: false, onSelected: null));
}
}
public static void RemoveEntitiesWithPossibleWarning(List<MapEntity> targets)
{
if (targets.Any(static t => t is Item it && it.GetComponent<CircuitBox>() is not null))
{
GUI.AskForConfirmation(CircuitBoxDeletionWarningHeader, CircuitBoxDeletionWarningBody, onConfirm: Delete);
return;
}
Delete();
void Delete()
{
StoreCommand(new AddOrDeleteCommand(targets, true));
foreach (var me in targets)
{
if (!me.Removed) { me.Remove(); }
}
}
}
private void MoveToLayer(string layer, List<MapEntity> content)
{
layer ??= string.Empty;
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using Barotrauma.Items.Components;
@@ -131,7 +132,7 @@ namespace Barotrauma
{
foreach (MapEntity receiver in receivers)
{
if (receiver is Item it && it.ParentInventory != null)
if (receiver is Item { ParentInventory: not null } it)
{
PreviousInventories.Add(new InventorySlotItem(it.ParentInventory.FindIndex(it), it), it.ParentInventory);
}
@@ -192,14 +193,35 @@ namespace Barotrauma
public override void Execute()
{
DeleteUndelete(true);
ContainedItemsCommand?.ForEach(cmd => cmd.Execute());
var items = DeleteUndelete(true);
ContainedItemsCommand?.ForEach(static cmd => cmd.Execute());
CircuitBoxWorkaround(items);
}
public override void UnExecute()
{
DeleteUndelete(false);
ContainedItemsCommand?.ForEach(cmd => cmd.UnExecute());
var items = DeleteUndelete(false);
ContainedItemsCommand?.ForEach(static cmd => cmd.UnExecute());
CircuitBoxWorkaround(items);
}
// FIXME Temporary workaround for circuit boxes throwing console errors and breaking completely when undoing a deletion
private static void CircuitBoxWorkaround(Option<ImmutableArray<MapEntity>> entitiesOption)
{
if (!entitiesOption.TryUnwrap(out var entities)) { return; }
foreach (var entity in entities)
{
if (entity is not Item it) { continue; }
if (it.GetComponent<CircuitBox>() is not null)
{
foreach (var container in it.GetComponents<ItemContainer>())
{
container.Inventory.DeleteAllItems();
}
}
}
}
public override void Cleanup()
@@ -215,10 +237,10 @@ namespace Barotrauma
CloneList?.Clear();
Receivers.Clear();
PreviousInventories?.Clear();
ContainedItemsCommand?.ForEach(cmd => cmd.Cleanup());
ContainedItemsCommand?.ForEach(static cmd => cmd.Cleanup());
}
private void DeleteUndelete(bool redo)
private Option<ImmutableArray<MapEntity>> DeleteUndelete(bool redo)
{
bool wasDeleted = WasDeleted;
@@ -227,13 +249,14 @@ namespace Barotrauma
if (wasDeleted)
{
Debug.Assert(Receivers.All(entity => entity.GetReplacementOrThis().Removed), "Tried to redo a deletion but some items were not deleted");
Debug.Assert(Receivers.All(static entity => entity.GetReplacementOrThis().Removed), "Tried to redo a deletion but some items were not deleted");
List<MapEntity> clones = MapEntity.Clone(CloneList);
int length = Math.Min(Receivers.Count, clones.Count);
for (int i = 0; i < length; i++)
{
MapEntity clone = clones[i], receiver = Receivers[i];
MapEntity clone = clones[i],
receiver = Receivers[i];
if (receiver.GetReplacementOrThis() is Item item && clone is Item cloneItem)
{
@@ -245,7 +268,7 @@ namespace Barotrauma
{
case null:
continue;
case ItemContainer newContainer when newContainer.Inventory != null && ic is ItemContainer itemContainer && itemContainer.Inventory != null:
case ItemContainer { Inventory: not null } newContainer when ic is ItemContainer { Inventory: not null } itemContainer:
itemContainer.Inventory.GetReplacementOrThiS().ReplacedBy = newContainer.Inventory;
goto default;
default:
@@ -260,7 +283,8 @@ namespace Barotrauma
for (int i = 0; i < length; i++)
{
MapEntity clone = clones[i], receiver = Receivers[i];
MapEntity clone = clones[i],
receiver = Receivers[i];
if (clone is Item it)
{
@@ -278,6 +302,8 @@ namespace Barotrauma
{
clone.Submarine = Submarine.MainSub;
}
return Option.Some(clones.ToImmutableArray());
}
else
{
@@ -289,6 +315,8 @@ namespace Barotrauma
receiver.Remove();
}
}
return Option.None;
}
}