Unstable 1.2.1.0

This commit is contained in:
Markus Isberg
2023-11-10 17:45:19 +02:00
parent 2ea58c58a7
commit 8a2e2ea0ae
268 changed files with 4076 additions and 1843 deletions
@@ -382,22 +382,28 @@ namespace Barotrauma
currentLocation.DeselectMission(mission);
}
}
if (levelData.HasBeaconStation && !levelData.IsBeaconActive)
if (levelData.HasBeaconStation && !levelData.IsBeaconActive && Missions.None(m => m.Prefab.Type == MissionType.Beacon))
{
var beaconMissionPrefabs = MissionPrefab.Prefabs.Where(m => m.Tags.Contains("beaconnoreward")).OrderBy(m => m.UintIdentifier);
var beaconMissionPrefabs = MissionPrefab.Prefabs.Where(m => m.IsSideObjective && m.Type == MissionType.Beacon);
if (beaconMissionPrefabs.Any())
{
Random rand = new MTRandom(ToolBox.StringToInt(levelData.Seed));
var beaconMissionPrefab = ToolBox.SelectWeightedRandom(beaconMissionPrefabs, p => (float)p.Commonness, rand);
if (!Missions.Any(m => m.Prefab.Type == beaconMissionPrefab.Type))
var filteredMissions = beaconMissionPrefabs.Where(m => levelData.Difficulty >= m.MinLevelDifficulty && levelData.Difficulty <= m.MaxLevelDifficulty);
if (filteredMissions.None())
{
extraMissions.Add(beaconMissionPrefab.Instantiate(Map.SelectedConnection.Locations, Submarine.MainSub));
DebugConsole.AddWarning($"No suitable beacon mission found matching the level difficulty {levelData.Difficulty}. Ignoring the restriction.");
}
else
{
beaconMissionPrefabs = filteredMissions;
}
Random rand = new MTRandom(ToolBox.StringToInt(levelData.Seed));
var beaconMissionPrefab = ToolBox.SelectWeightedRandom(beaconMissionPrefabs, p => p.Commonness, rand);
extraMissions.Add(beaconMissionPrefab.Instantiate(Map.SelectedConnection.Locations, Submarine.MainSub));
}
}
if (levelData.HasHuntingGrounds)
{
var huntingGroundsMissionPrefabs = MissionPrefab.Prefabs.Where(m => m.Tags.Contains("huntinggrounds")).OrderBy(m => m.UintIdentifier);
var huntingGroundsMissionPrefabs = MissionPrefab.Prefabs.Where(m => m.IsSideObjective && m.Tags.Contains("huntinggrounds")).OrderBy(m => m.UintIdentifier);
if (!huntingGroundsMissionPrefabs.Any())
{
DebugConsole.AddWarning("Could not find a hunting grounds mission for the level. No mission with the tag \"huntinggrounds\" found.");
@@ -862,6 +868,16 @@ namespace Barotrauma
}
}
//remove ID cards left in duffel bags
foreach (var item in Item.ItemList.ToList())
{
if (item.HasTag(Tags.IdCardTag) &&
(item.Container?.HasTag(Tags.DespawnContainer) ?? false))
{
item.Remove();
}
}
foreach (CharacterInfo ci in CrewManager.CharacterInfos.ToList())
{
if (ci.CauseOfDeath != null)
@@ -1353,6 +1369,7 @@ namespace Barotrauma
if (item.HiddenInGame) { continue; }
if (!connectedSubs.Contains(item.Submarine)) { continue; }
if (item.Prefab.DontTransferBetweenSubs) { continue; }
if (AnyParentInventoryDisableTransfer(item)) { continue; }
var rootOwner = item.GetRootInventoryOwner();
if (rootOwner is Character) { continue; }
if (rootOwner is Item ownerItem && (ownerItem.NonInteractable || item.NonPlayerTeamInteractable || ownerItem.HiddenInGame)) { continue; }
@@ -1362,6 +1379,15 @@ namespace Barotrauma
if (item.Components.Any(c => c is Wire w && w.Connections.Any(c => c != null))) { continue; }
itemsToTransfer.Add((item, item.Container));
item.Submarine = null;
static bool AnyParentInventoryDisableTransfer(Item item)
{
if (item.ParentInventory?.Owner is not Item parentOwner) { return false; }
return HasProblematicComponent(parentOwner) || AnyParentInventoryDisableTransfer(parentOwner);
static bool HasProblematicComponent(Item it)
=> it.Components.Any(static c => c.DontTransferInventoryBetweenSubs);
}
}
foreach (var (item, container) in itemsToTransfer)
{
@@ -1369,8 +1395,15 @@ namespace Barotrauma
{
// Drop the item if it's not inside another item set to be transferred.
item.Drop(null, createNetworkEvent: false, setTransform: false);
//dropping items sets the sub, set it back to null
item.Submarine = null;
foreach (var itemContainer in item.GetComponents<ItemContainer>())
{
itemContainer.Inventory.FindAllItems((_) => true, recursive: true).ForEach(it => it.Submarine = null);
}
}
}
System.Diagnostics.Debug.Assert(itemsToTransfer.None(it => it.item.Submarine != null), "Item that was set to be transferred was not removed from the sub!");
currentSub.Info.NoItems = true;
}
// Serialize the current sub
@@ -1408,6 +1441,7 @@ namespace Barotrauma
{
newContainer = newSub.FindContainerFor(item, onlyPrimary: true, checkTransferConditions: true, allowConnectedSubs: true);
}
string newContainerName = newContainer == null ? "(null)" : $"{newContainer.Prefab.Identifier} ({newContainer.Tags})";
if (item.Container == null && (newContainer == null || !newContainer.OwnInventory.TryPutItem(item, user: null, createNetworkEvent: false)))
{
var cargoContainer = CargoManager.GetOrCreateCargoContainerFor(item.Prefab, spawnHull, ref availableContainers);
@@ -1416,13 +1450,16 @@ namespace Barotrauma
Vector2 simPos = ConvertUnits.ToSimUnits(CargoManager.GetCargoPos(spawnHull, item.Prefab));
item.SetTransform(simPos, 0.0f, findNewHull: false, setPrevTransform: false);
}
else if (cargoContainer.Item.Submarine is Submarine containerSub)
else
{
// Use the item's sub in case the sub consists of multiple linked subs.
item.Submarine = containerSub;
if (cargoContainer.Item.Submarine is Submarine containerSub)
{
// Use the item's sub in case the sub consists of multiple linked subs.
item.Submarine = containerSub;
}
newContainerName = cargoContainer.Item.Prefab.Identifier.ToString();
}
}
string newContainerName = newContainer == null ? "(null)" : $"{newContainer.Prefab.Identifier} ({newContainer.Tags})";
string msg = "Item transfer log error.";
if (oldContainer != null)
{
@@ -83,6 +83,12 @@ namespace Barotrauma
}
}
[Serialize(0.2f, IsPropertySaveable.Yes, description: "How likely it is for security to inspect player characters for stolen items when your reputation is high?")]
public float MinStolenItemInspectionProbability { get; set; }
[Serialize(0.9f, IsPropertySaveable.Yes, description: "How likely it is for security to inspect player characters for stolen items when your reputation is low?")]
public float MaxStolenItemInspectionProbability { get; set; }
public const int DefaultMaxMissionCount = 2;
public const int MaxMissionCountLimit = 10;
public const int MinMissionCountLimit = 1;
@@ -319,6 +319,7 @@ namespace Barotrauma
foreach (var item in storeItems.Value)
{
msg.WriteIdentifier(item.ItemPrefabIdentifier);
msg.WriteBoolean(item.DeliverImmediately);
msg.WriteRangedInteger(item.Quantity, 0, CargoManager.MaxQuantity);
}
}
@@ -336,8 +337,12 @@ namespace Barotrauma
for (int j = 0; j < itemCount; j++)
{
Identifier itemId = msg.ReadIdentifier();
bool deliverImmediately = msg.ReadBoolean();
#if SERVER
if (!AllowImmediateItemDelivery(sender)) { deliverImmediately = false; }
#endif
int quantity = msg.ReadRangedInteger(0, CargoManager.MaxQuantity);
items[storeId].Add(new PurchasedItem(itemId, quantity, sender));
items[storeId].Add(new PurchasedItem(itemId, quantity, sender) { DeliverImmediately = deliverImmediately });
}
}
return items;