Merge remote-tracking branch 'upstream/master' into develop

This commit is contained in:
EvilFactory
2024-12-11 10:44:53 -03:00
257 changed files with 4793 additions and 1653 deletions
@@ -510,6 +510,17 @@ namespace Barotrauma
}
return false;
}
//can't sell items in hidden inventories
Item rootContainer = item.Container;
while (rootContainer != null)
{
if (rootContainer.OwnInventory?.Container is { } containerComponent)
{
if (!containerComponent.DrawInventory) { return false; }
if (!containerComponent.IsAccessible()) { return false; }
}
rootContainer = rootContainer.Container;
}
if (item.OwnInventory?.Container is ItemContainer itemContainer)
{
var containedItems = item.ContainedItems;
@@ -672,7 +683,8 @@ namespace Barotrauma
{
foreach (Item containedItem in character.Inventory.AllItemsMod)
{
if (containedItem.OwnInventory != null &&
//only put into containers that draw the inventory (not ones with a hidden inventory like circuit boxes!)
if (containedItem.OwnInventory?.Container is { DrawInventory: true } &&
containedItem.OwnInventory.TryPutItem(item, user: null, item.AllowedSlots))
{
break;
@@ -703,14 +715,23 @@ namespace Barotrauma
public static void ItemSpawned(Item item)
{
Submarine sub = item.Submarine ?? item.RootContainer?.Submarine;
if (sub != null)
CharacterTeamType teamID = CharacterTeamType.Team1;
if (item.ParentInventory?.Owner is Character character)
{
foreach (WifiComponent wifiComponent in item.GetComponents<WifiComponent>())
teamID = character.TeamID;
}
else
{
Submarine sub = item.Submarine ?? item.RootContainer?.Submarine;
if (sub != null)
{
wifiComponent.TeamID = sub.TeamID;
teamID = sub.TeamID;
}
}
foreach (WifiComponent wifiComponent in item.GetComponents<WifiComponent>())
{
wifiComponent.TeamID = teamID;
}
}
private readonly List<(PurchasedItem purchaseInfo, IdCard idCard)> purchasedIDCards = new List<(PurchasedItem purchaseInfo, IdCard idCard)>();
@@ -81,6 +81,7 @@ namespace Barotrauma
// Ignore orders work a bit differently since the "unignore" order counters the "ignore" order
var isUnignoreOrder = order.Identifier == Tags.UnignoreThis;
var isIgnoreOrder = order.Identifier == Tags.IgnoreThis;
var orderPrefab = !isUnignoreOrder ? order.Prefab : OrderPrefab.Prefabs[Tags.IgnoreThis];
ActiveOrder existingOrder = ActiveOrders.Find(o =>
o.Order.Prefab == orderPrefab && MatchesTarget(o.Order.TargetEntity, order.TargetEntity) &&
@@ -96,6 +97,14 @@ namespace Barotrauma
else
{
ActiveOrders.Remove(existingOrder);
if (isIgnoreOrder && order.TargetEntity is Item targetItem)
{
foreach (var stackedItem in targetItem.GetStackedItems())
{
ActiveOrders.RemoveAll(o => o.Order.Prefab == orderPrefab && o.Order.TargetEntity == stackedItem);
stackedItem.OrderedToBeIgnored = false;
}
}
return true;
}
}
@@ -124,7 +133,18 @@ namespace Barotrauma
}
}
}
ActiveOrders.Add(new ActiveOrder(order, fadeOutTime));
if (isIgnoreOrder && order.TargetEntity is Item targetItem)
{
foreach (var stackedItem in targetItem.GetStackedItems())
{
ActiveOrders.Add(new ActiveOrder(order.WithTargetEntity(stackedItem), fadeOutTime));
stackedItem.OrderedToBeIgnored = true;
}
}
else
{
ActiveOrders.Add(new ActiveOrder(order, fadeOutTime));
}
#if CLIENT
HintManager.OnActiveOrderAdded(order);
#endif
@@ -554,7 +574,7 @@ namespace Barotrauma
public static IEnumerable<Character> GetCharactersSortedForOrder(Order order, IEnumerable<Character> characters, Character controlledCharacter, bool includeSelf, IEnumerable<Character> extraCharacters = null)
{
var filteredCharacters = characters.Where(c => controlledCharacter == null || ((includeSelf || c != controlledCharacter) && c.TeamID == controlledCharacter.TeamID));
var filteredCharacters = characters.Where(c => c.Info != null && (controlledCharacter == null || ((includeSelf || c != controlledCharacter) && c.TeamID == controlledCharacter.TeamID)));
if (extraCharacters != null)
{
filteredCharacters = filteredCharacters.Union(extraCharacters);
@@ -18,6 +18,7 @@ namespace Barotrauma
string FilePath,
Option<SerializableDateTime> SaveTime,
string SubmarineName,
RespawnMode RespawnMode,
ImmutableArray<string> EnabledContentPackageNames) : INetSerializableStruct;
public const int MaxMoney = int.MaxValue / 2; //about 1 billion
@@ -33,6 +34,20 @@ namespace Barotrauma
public enum InteractionType { None, Talk, Examine, Map, Crew, Store, Upgrade, PurchaseSub, MedicalClinic, Cargo }
/// <summary>
/// Should the interaction be disabled if the character's faction is hostile towards the players?
/// </summary>
public static bool HostileFactionDisablesInteraction(InteractionType interactionType)
{
return
interactionType != InteractionType.None &&
//allow interacting with stores, otherwise you could get softlocked
//(no way to get enough resources from a hostile outpost to make it to the next one?)
interactionType != InteractionType.Store &&
//examining is triggered by events, and there may be events that are intended to allow interaction with a hostile NPC.
interactionType != InteractionType.Examine;
}
public static bool BlocksInteraction(InteractionType interactionType)
{
return interactionType != InteractionType.None && interactionType != InteractionType.Cargo;
@@ -1099,6 +1114,7 @@ namespace Barotrauma
private void NPCInteract(Character npc, Character interactor)
{
if (!npc.AllowCustomInteract) { return; }
if (npc.AIController is HumanAIController humanAi && !humanAi.AllowCampaignInteraction()) { return; }
NPCInteractProjSpecific(npc, interactor);
string coroutineName = "DoCharacterWait." + (npc?.ID ?? Entity.NullEntityID);
if (!CoroutineManager.IsCoroutineRunning(coroutineName))
@@ -140,13 +140,14 @@ namespace Barotrauma
private static readonly Dictionary<string, MultiplierSettings> _multiplierSettings = new Dictionary<string, MultiplierSettings>
{
{ "default", new MultiplierSettings { Min = 0.2f, Max = 2.0f, Step = 0.1f } },
{ nameof(CrewVitalityMultiplier), new MultiplierSettings { Min = 0.5f, Max = 2.0f, Step = 0.1f } },
{ nameof(NonCrewVitalityMultiplier),new MultiplierSettings { Min = 0.5f, Max = 3.0f, Step = 0.1f } },
{ nameof(MissionRewardMultiplier), new MultiplierSettings { Min = 0.5f, Max = 2.0f, Step = 0.1f } },
{ nameof(RepairFailMultiplier), new MultiplierSettings { Min = 0.5f, Max = 5.0f, Step = 0.5f } },
{ nameof(ShopPriceMultiplier), new MultiplierSettings { Min = 0.1f, Max = 3.0f, Step = 0.1f } },
{ nameof(ShipyardPriceMultiplier), new MultiplierSettings { Min = 0.1f, Max = 3.0f, Step = 0.1f } }
{ "default", new MultiplierSettings { Min = 0.2f, Max = 2.0f, Step = 0.1f } },
{ nameof(CrewVitalityMultiplier), new MultiplierSettings { Min = 0.5f, Max = 2.0f, Step = 0.1f } },
{ nameof(NonCrewVitalityMultiplier), new MultiplierSettings { Min = 0.5f, Max = 3.0f, Step = 0.1f } },
{ nameof(MissionRewardMultiplier), new MultiplierSettings { Min = 0.5f, Max = 2.0f, Step = 0.1f } },
{ nameof(ExperienceRewardMultiplier), new MultiplierSettings { Min = 0.5f, Max = 2.0f, Step = 0.1f } },
{ nameof(RepairFailMultiplier), new MultiplierSettings { Min = 0.5f, Max = 5.0f, Step = 0.5f } },
{ nameof(ShopPriceMultiplier), new MultiplierSettings { Min = 0.1f, Max = 3.0f, Step = 0.1f } },
{ nameof(ShipyardPriceMultiplier), new MultiplierSettings { Min = 0.1f, Max = 3.0f, Step = 0.1f } }
// Add overrides for default values here
};
@@ -165,6 +166,9 @@ namespace Barotrauma
[Serialize(1.0f, IsPropertySaveable.Yes), NetworkSerialize]
public float MissionRewardMultiplier { get; set; }
[Serialize(1.0f, IsPropertySaveable.Yes), NetworkSerialize]
public float ExperienceRewardMultiplier { get; set; }
[Serialize(1.0f, IsPropertySaveable.Yes), NetworkSerialize]
public float ShopPriceMultiplier { get; set; }
@@ -482,6 +482,7 @@ namespace Barotrauma
{
Random rand = new MTRandom(ToolBox.StringToInt(levelSeed));
LocationType locationType = LocationType.Prefabs
.OrderBy(lt => lt.UintIdentifier)
.Where(lt => missionPrefab.AllowedLocationTypes.Any(m => m == lt.Identifier))
.GetRandom(rand)!;
dummyLocations = CreateDummyLocations(levelSeed, locationType);
@@ -1573,13 +1574,15 @@ namespace Barotrauma
if (kvp.Key.TryUnwrap(out AccountId? accountId))
{
permadeathsElement.Add(
new XElement("account"),
new XElement("account",
new XAttribute("id", accountId.StringRepresentation),
new XAttribute("permadeathcount", kvp.Value));
new XAttribute("permadeathcount", kvp.Value)));
}
}
rootElement.Add(permadeathsElement);
rootElement.Add(new XAttribute("respawnmode", GameMain.NetworkMember?.ServerSettings?.RespawnMode ?? RespawnMode.None));
((CampaignMode)GameMode).Save(doc.Root, isSavingOnLoading);
doc.SaveSafe(filePath, throwExceptions: true);