Unstable 1.8.4.0

This commit is contained in:
Markus Isberg
2025-03-12 12:56:27 +00:00
parent a4c3e868e4
commit a4a3427e4e
627 changed files with 29860 additions and 10018 deletions
@@ -1,4 +1,4 @@
#nullable enable
#nullable enable
using System;
using System.Linq;
@@ -70,6 +70,19 @@ namespace Barotrauma.Items.Components
[Editable, Serialize(false, IsPropertySaveable.Yes, "")]
public bool PreloadCharacter { get; set; }
[Editable, Serialize(false, IsPropertySaveable.Yes, "Should the \"spawn monsters\" setting affect this item in the PvP mode?")]
public bool AffectedByPvPSpawnMonstersSetting { get; set; }
/// <summary>
/// Implemented as a property and checked on the fly instead of disabling the component,
/// because the signals sent by the component might be necessary even if it can't spawn anything.
/// </summary>
private bool DisabledByByPvPSpawnMonstersSetting =>
!SpeciesName.IsNullOrEmpty() &&
AffectedByPvPSpawnMonstersSetting &&
GameMain.GameSession?.GameMode is PvPMode &&
GameMain.NetworkMember is { ServerSettings.PvPSpawnMonsters: false };
private float spawnTimer;
private float? spawnTimerGoal;
@@ -114,15 +127,24 @@ namespace Barotrauma.Items.Components
public override void Update(float deltaTime, Camera cam)
{
if (PreloadCharacter && !Screen.Selected.IsEditor && !preloadInitiated)
if (DisabledByByPvPSpawnMonstersSetting)
{
SpawnCharacter(Vector2.Zero, onSpawn: (Character c) =>
CanSpawn = false;
//in most cases we could probably just disable the component here and return,
//but the state_out signal might be needed for something even if the spawning is disabled
}
else
{
if (PreloadCharacter && !Screen.Selected.IsEditor && !preloadInitiated)
{
preloadedCharacter = c;
c.DisabledByEvent = true;
});
preloadInitiated = true;
return;
SpawnCharacter(Vector2.Zero, onSpawn: (Character c) =>
{
preloadedCharacter = c;
c.DisabledByEvent = true;
});
preloadInitiated = true;
return;
}
}
base.Update(deltaTime, cam);
@@ -182,7 +204,7 @@ namespace Barotrauma.Items.Components
private bool CanSpawnMore()
{
if (!CanSpawn) { return false; }
if (!CanSpawn || DisabledByByPvPSpawnMonstersSetting) { return false; }
if (MaximumAmount > 0 && spawnedAmount >= MaximumAmount) { return false; }
if (OnlySpawnWhenCrewInRange)
@@ -300,7 +322,7 @@ namespace Barotrauma.Items.Components
}
else if (!string.IsNullOrWhiteSpace(ItemIdentifier))
{
Identifier[] allItems = ItemIdentifier.Split(',').Select(s => s.Trim()).ToIdentifiers().ToArray();
Identifier[] allItems = ItemIdentifier.ToIdentifiers().ToArray();
Identifier itemIdentifier = allItems.GetRandomUnsynced();
ItemPrefab? prefab = ItemPrefab.Find(null, itemIdentifier);
if (prefab is null) { return; }
@@ -320,7 +342,7 @@ namespace Barotrauma.Items.Components
{
if (!string.IsNullOrWhiteSpace(SpeciesName))
{
Identifier[] allSpecies = SpeciesName.Split(',').Select(s => s.Trim()).ToIdentifiers().ToArray();
Identifier[] allSpecies = SpeciesName.ToIdentifiers().ToArray();
Identifier species = allSpecies.GetRandomUnsynced();
Entity.Spawner?.AddCharacterToSpawnQueue(species, pos, onSpawn);
}