v1.5.7.0 (Summer Update)

This commit is contained in:
Regalis11
2024-06-18 16:49:51 +03:00
parent 4a63dacbce
commit 230d1b6e78
263 changed files with 7792 additions and 2845 deletions
@@ -1,4 +1,4 @@
using Barotrauma.Extensions;
using Barotrauma.Extensions;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
@@ -30,7 +30,7 @@ namespace Barotrauma
{
if (TargetTag.IsEmpty)
{
DebugConsole.LogError($"CheckConditionalAction error: {GetEventName()} uses a CheckConditionalAction with no target tag! This will cause the check to automatically succeed.",
DebugConsole.LogError($"CheckConditionalAction error: {GetEventDebugName()} uses a CheckConditionalAction with no target tag! This will cause the check to automatically succeed.",
contentPackage: parentEvent.Prefab.ContentPackage);
}
var conditionalElements = element.GetChildElements("Conditional");
@@ -52,7 +52,7 @@ namespace Barotrauma
if (Conditionals.None())
{
DebugConsole.LogError($"CheckConditionalAction error: {GetEventName()} uses a CheckConditionalAction with no valid PropertyConditional! This will cause the check to automatically succeed.",
DebugConsole.LogError($"CheckConditionalAction error: {GetEventDebugName()} uses a CheckConditionalAction with no valid PropertyConditional! This will cause the check to automatically succeed.",
contentPackage: parentEvent.Prefab.ContentPackage);
}
@@ -67,11 +67,6 @@ namespace Barotrauma
}
}
private string GetEventName()
{
return ParentEvent?.Prefab?.Identifier is { IsEmpty: false } identifier ? $"the event \"{identifier}\"" : "an unknown event";
}
protected override bool? DetermineSuccess()
{
IEnumerable<ISerializableEntity> targets = null;
@@ -82,7 +77,7 @@ namespace Barotrauma
if (targets.None())
{
DebugConsole.LogError($"{nameof(CheckConditionalAction)} error: {GetEventName()} uses a {nameof(CheckConditionalAction)} but no valid target was found for tag \"{TargetTag}\"! This will cause the check to automatically succeed.",
DebugConsole.LogError($"{nameof(CheckConditionalAction)} error: {GetEventDebugName()} uses a {nameof(CheckConditionalAction)} but no valid target was found for tag \"{TargetTag}\"! This will cause the check to automatically succeed.",
contentPackage: ParentEvent.Prefab.ContentPackage);
}
@@ -0,0 +1,35 @@
#nullable enable
namespace Barotrauma;
/// <summary>
/// Check whether the difficulty of the current level is within some specific range.
/// </summary>
class CheckDifficultyAction : BinaryOptionAction
{
[Serialize(0.0f, IsPropertySaveable.Yes, description: "Minimum difficulty of the current level for the check to succeed.")]
public float MinDifficulty { get; set; }
[Serialize(100.0f, IsPropertySaveable.Yes, description: "Maximum difficulty of the current level for the check to succeed.")]
public float MaxDifficulty { get; set; }
public CheckDifficultyAction(ScriptedEvent parentEvent, ContentXElement element) : base(parentEvent, element)
{
if (MaxDifficulty <= MinDifficulty)
{
DebugConsole.LogError($"Potential error in event {GetEventDebugName()}: maximum difficulty ({MaxDifficulty}) is not larger than minimum difficulty ({MinDifficulty}) in {nameof(CheckDifficultyAction)}.",
contentPackage: parentEvent.Prefab.ContentPackage);
}
}
protected override bool? DetermineSuccess()
{
if (Level.Loaded == null) { return false; }
return Level.Loaded.Difficulty >= MinDifficulty && Level.Loaded.Difficulty <= MaxDifficulty;
}
public override string ToDebugString()
{
return $"{ToolBox.GetDebugSymbol(DetermineFinished())} {nameof(CheckDifficultyAction)} -> (min: {MinDifficulty}, max: {MaxDifficulty}" +
$" Succeeded: {(succeeded.HasValue ? succeeded.Value.ToString() : "not determined").ColorizeObject()})";
}
}
@@ -1,4 +1,4 @@
using Barotrauma.Extensions;
using Barotrauma.Extensions;
using Barotrauma.Items.Components;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
@@ -36,6 +36,9 @@ namespace Barotrauma
[Serialize(false, IsPropertySaveable.Yes, description: "Does the item need to be equipped for the check to succeed?")]
public bool RequireEquipped { get; set; }
[Serialize(false, IsPropertySaveable.Yes, description: "Does the item need to be worn for the check to succeed?")]
public bool RequireWorn { get; set; }
[Serialize(true, IsPropertySaveable.Yes, description: "If enabled, the doesn't need to be directly inside the container/character we're checking, but can be nested inside multiple containers (e.g. in a toolbelt in a character's inventory).")]
public bool Recursive { get; set; }
@@ -256,6 +259,19 @@ namespace Barotrauma
if (character == null) { return false; }
return character.HasEquippedItem(item);
}
if (RequireWorn)
{
if (character == null) { return false; }
foreach (var wearable in item.GetComponents<Wearable>())
{
foreach (var allowedSlot in wearable.AllowedSlots)
{
if (allowedSlot == InvSlotType.Any) { continue; }
if (character.HasEquippedItem(item, allowedSlot)) { return true; }
}
}
return false;
}
return true;
}
@@ -1,4 +1,4 @@
using Barotrauma.Extensions;
using Barotrauma.Extensions;
using Barotrauma.Networking;
using Microsoft.Xna.Framework;
using System;
@@ -134,6 +134,10 @@ namespace Barotrauma
else
{
text = TextManager.Get(Text).Fallback(Text);
if (text.Value.IsNullOrEmpty())
{
text = text.Fallback(Text);
}
}
return ParentEvent.ReplaceVariablesInEventText(text);
}
@@ -0,0 +1,55 @@
#nullable enable
namespace Barotrauma;
/// <summary>
/// Can be used to disconnect wires and break devices and walls in beacon stations. Useful if you want the beacon to be in tact by default, and use events to determine whether it should be e.g. manned by bandits, or destroyed and infested by monsters.
/// </summary>
class DamageBeaconStationAction : EventAction
{
[Serialize(0.0f, IsPropertySaveable.Yes, description: "Probability of disconnecting wires (0.5 = 50% chance of disconnecting any given wire, 1 = all wires disconnected).")]
public float DisconnectWireProbability { get; set; }
[Serialize(0.0f, IsPropertySaveable.Yes, description: "Probability of a wall sections leaking (0.5 = 50% creating a leak on any given wall section, 1 = all walls leak).")]
public float DamageWallProbability { get; set; }
[Serialize(0.0f, IsPropertySaveable.Yes, description: "Probability of devices being damaged (0.5 = 50% chance of damaging any given devices, 1 = all devices are damaged).")]
public float DamageDeviceProbability { get; set; }
private bool isFinished;
public DamageBeaconStationAction(ScriptedEvent parentEvent, ContentXElement element) : base(parentEvent, element)
{
if (DisconnectWireProbability <= 0.0f && DamageWallProbability <= 0.0f && DamageDeviceProbability <= 0.0f)
{
DebugConsole.LogError($"Potential error in event {GetEventDebugName()}: {DisconnectWireProbability}, {DamageWallProbability} and {DamageDeviceProbability} are all set to 0 in {nameof(DamageBeaconStationAction)}, and the action will do nothing.",
contentPackage: parentEvent.Prefab.ContentPackage);
}
}
public override bool IsFinished(ref string goToLabel) => isFinished;
public override void Reset()
{
isFinished = false;
}
public override void Update(float deltaTime)
{
if (isFinished) { return; }
if (Level.Loaded != null)
{
Level.Loaded.DisconnectBeaconStationWires(DisconnectWireProbability);
Level.Loaded.DamageBeaconStationWalls(DamageWallProbability);
Level.Loaded.DamageBeaconStationDevices(DamageDeviceProbability);
}
isFinished = true;
}
public override string ToDebugString()
{
return $"{ToolBox.GetDebugSymbol(isFinished)} {nameof(DamageBeaconStationAction)}";
}
}
@@ -198,6 +198,12 @@ namespace Barotrauma
}
}
protected string GetEventDebugName()
{
return ParentEvent?.Prefab?.Identifier is { IsEmpty: false } identifier ? $"the event \"{identifier}\"" : "an unknown event";
}
/// <summary>
/// Rich test to display in debugdraw
/// </summary>
@@ -1,4 +1,4 @@
using Barotrauma.Extensions;
using Barotrauma.Extensions;
using Barotrauma.Items.Components;
using System.Collections.Generic;
using System.Linq;
@@ -31,6 +31,9 @@ namespace Barotrauma
[Serialize(-1, IsPropertySaveable.Yes, description: "Maximum number of NPCs the action can target. For example, you could only make a specific number of security officers man a periscope.")]
public int MaxTargets { get; set; }
[Serialize(100, IsPropertySaveable.Yes, description: "Priority of operating the item (0-100). Higher values will make the AI prefer operating the item over other orders (priority 60-70) or e.g. reacting to emergencies (priority 90).")]
public int Priority { get; set; }
[Serialize(true, IsPropertySaveable.Yes, description: "The event actions reset when a GoTo action makes the event jump to a different point. Should the NPC stop operating the item when the event resets?")]
public bool AbandonOnReset { get; set; }
@@ -72,7 +75,7 @@ namespace Barotrauma
{
var newObjective = new AIObjectiveOperateItem(itemComponent, npc, humanAiController.ObjectiveManager, OrderOption, RequireEquip)
{
OverridePriority = 100.0f
OverridePriority = Priority
};
humanAiController.ObjectiveManager.AddObjective(newObjective);
humanAiController.ObjectiveManager.WaitTimer = 0.0f;
@@ -68,6 +68,7 @@ namespace Barotrauma
("bot", v => TagBots(playerCrewOnly: false)),
("crew", v => TagCrew()),
("humanprefabidentifier", TagHumansByIdentifier),
("humanprefabtag", TagHumansByTag),
("jobidentifier", TagHumansByJobIdentifier),
("structureidentifier", TagStructuresByIdentifier),
("structurespecialtag", TagStructuresBySpecialTag),
@@ -153,6 +154,11 @@ namespace Barotrauma
AddTarget(Tag, Character.CharacterList.Where(c => c.HumanPrefab?.Identifier == identifier));
}
private void TagHumansByTag(Identifier tag)
{
AddTarget(Tag, Character.CharacterList.Where(c => c.HumanPrefab != null && c.HumanPrefab.GetTags().Contains(tag)));
}
private void TagHumansByJobIdentifier(Identifier jobIdentifier)
{
AddTarget(Tag, Character.CharacterList.Where(c => c.HasJob(jobIdentifier)));
@@ -217,6 +223,7 @@ namespace Barotrauma
private bool IsValidItem(Item it)
{
return
!it.IsLayerHidden && /*items in hidden layers are treated as if they didn't exist, regardless if hidden items should be allowed*/
(!it.HiddenInGame || AllowHiddenItems) &&
ModuleTagMatches(it) &&
//if the item has just spawned, it may be in a hull but not moved into the coordinate space of the hull yet