Unstable v0.19.1.0
This commit is contained in:
@@ -191,7 +191,6 @@ namespace Barotrauma
|
||||
if (unlockPathEventPrefab != null)
|
||||
{
|
||||
var newEvent = unlockPathEventPrefab.CreateInstance();
|
||||
newEvent.Init();
|
||||
ActiveEvents.Add(newEvent);
|
||||
}
|
||||
else
|
||||
@@ -223,6 +222,7 @@ namespace Barotrauma
|
||||
PreloadContent(GetFilesToPreload());
|
||||
|
||||
roundDuration = 0.0f;
|
||||
eventsInitialized = false;
|
||||
isCrewAway = false;
|
||||
crewAwayDuration = 0.0f;
|
||||
crewAwayResetTimer = 0.0f;
|
||||
@@ -460,7 +460,6 @@ namespace Barotrauma
|
||||
|
||||
var newEvent = eventPrefab.CreateInstance();
|
||||
if (newEvent == null) { continue; }
|
||||
newEvent.Init(eventSet);
|
||||
if (i < spawnPosFilter.Count) { newEvent.SpawnPosFilter = spawnPosFilter[i]; }
|
||||
DebugConsole.NewMessage($"Initialized event {newEvent}", debugOnly: true);
|
||||
if (!selectedEvents.ContainsKey(eventSet))
|
||||
@@ -490,8 +489,6 @@ namespace Barotrauma
|
||||
var eventPrefab = ToolBox.SelectWeightedRandom(eventPrefabs.Where(isPrefabSuitable), e => e.Commonness, rand);
|
||||
var newEvent = eventPrefab.CreateInstance();
|
||||
if (newEvent == null) { continue; }
|
||||
newEvent.Init(eventSet);
|
||||
DebugConsole.NewMessage($"Initialized event {newEvent}", debugOnly: true);
|
||||
if (!selectedEvents.ContainsKey(eventSet))
|
||||
{
|
||||
selectedEvents.Add(eventSet, new List<Event>());
|
||||
@@ -614,12 +611,25 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool eventsInitialized;
|
||||
|
||||
public void Update(float deltaTime)
|
||||
{
|
||||
if (!Enabled || level == null) { return; }
|
||||
if (GameMain.GameSession.Campaign?.DisableEvents ?? false) { return; }
|
||||
|
||||
if (!eventsInitialized)
|
||||
{
|
||||
foreach (var eventSet in selectedEvents.Keys)
|
||||
{
|
||||
foreach (var ev in selectedEvents[eventSet])
|
||||
{
|
||||
ev.Init(eventSet);
|
||||
}
|
||||
}
|
||||
eventsInitialized = true;
|
||||
}
|
||||
|
||||
//clients only calculate the intensity but don't create any events
|
||||
//(the intensity is used for controlling the background music)
|
||||
CalculateCurrentIntensity(deltaTime);
|
||||
|
||||
@@ -100,7 +100,8 @@ namespace Barotrauma
|
||||
if (!connectedSubs.Contains(item.Submarine)) { continue; }
|
||||
if (item.GetComponent<PowerTransfer>() != null ||
|
||||
item.GetComponent<PowerContainer>() != null ||
|
||||
item.GetComponent<Reactor>() != null)
|
||||
item.GetComponent<Reactor>() != null ||
|
||||
item.GetComponent<Sonar>() != null)
|
||||
{
|
||||
item.InvulnerableToDamage = true;
|
||||
}
|
||||
|
||||
@@ -125,8 +125,7 @@ namespace Barotrauma
|
||||
var file = CharacterPrefab.FindBySpeciesName(SpeciesName)?.ContentFile;
|
||||
if (file == null)
|
||||
{
|
||||
DebugConsole.ThrowError($"Failed to find config file for species \"{SpeciesName}\". Content package: \"{prefab.ConfigElement?.ContentPackage?.Name ?? "unknown"}\".");
|
||||
disallowed = true;
|
||||
DebugConsole.ThrowError($"Failed to find config file for species \"{SpeciesName}\"");
|
||||
yield break;
|
||||
}
|
||||
else
|
||||
@@ -147,6 +146,32 @@ namespace Barotrauma
|
||||
{
|
||||
DebugConsole.NewMessage("Initialized MonsterEvent (" + SpeciesName + ")", Color.White);
|
||||
}
|
||||
|
||||
monsters = new List<Character>();
|
||||
|
||||
//+1 because Range returns an integer less than the max value
|
||||
int amount = Rand.Range(MinAmount, MaxAmount + 1);
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
string seed = Level.Loaded.Seed + i.ToString();
|
||||
Character createdCharacter = Character.Create(SpeciesName, Vector2.Zero, seed, characterInfo: null, isRemotePlayer: false, hasAi: true, createNetworkEvent: true, throwErrorIfNotFound: false);
|
||||
if (createdCharacter == null)
|
||||
{
|
||||
DebugConsole.AddWarning($"Error in MonsterEvent: failed to spawn the character \"{SpeciesName}\". Content package: \"{prefab.ConfigElement?.ContentPackage?.Name ?? "unknown"}\".");
|
||||
disallowed = true;
|
||||
continue;
|
||||
}
|
||||
if (GameMain.GameSession.IsCurrentLocationRadiated())
|
||||
{
|
||||
AfflictionPrefab radiationPrefab = AfflictionPrefab.RadiationSickness;
|
||||
Affliction affliction = new Affliction(radiationPrefab, radiationPrefab.MaxStrength);
|
||||
createdCharacter?.CharacterHealth.ApplyAffliction(null, affliction);
|
||||
// TODO test multiplayer
|
||||
createdCharacter?.Kill(CauseOfDeathType.Affliction, affliction, log: false);
|
||||
}
|
||||
createdCharacter.DisabledByEvent = true;
|
||||
monsters.Add(createdCharacter);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Level.InterestingPosition> GetAvailableSpawnPositions()
|
||||
@@ -487,9 +512,6 @@ namespace Barotrauma
|
||||
|
||||
spawnPending = false;
|
||||
|
||||
//+1 because Range returns an integer less than the max value
|
||||
int amount = Rand.Range(MinAmount, MaxAmount + 1);
|
||||
monsters = new List<Character>();
|
||||
float scatterAmount = scatter;
|
||||
if (SpawnPosType.HasFlag(Level.PositionType.SidePath))
|
||||
{
|
||||
@@ -508,9 +530,9 @@ namespace Barotrauma
|
||||
scatterAmount = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < amount; i++)
|
||||
int i = 0;
|
||||
foreach (Character monster in monsters)
|
||||
{
|
||||
string seed = Level.Loaded.Seed + i.ToString();
|
||||
CoroutineManager.Invoke(() =>
|
||||
{
|
||||
//round ended before the coroutine finished
|
||||
@@ -533,45 +555,33 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
Character createdCharacter = Character.Create(SpeciesName, pos, seed, characterInfo: null, isRemotePlayer: false, hasAi: true, createNetworkEvent: true, throwErrorIfNotFound: false);
|
||||
if (createdCharacter == null)
|
||||
{
|
||||
DebugConsole.AddWarning($"Error in MonsterEvent: failed to spawn the character \"{SpeciesName}\". Content package: \"{prefab.ConfigElement?.ContentPackage?.Name ?? "unknown"}\".");
|
||||
disallowed = true;
|
||||
return;
|
||||
}
|
||||
monster.Enabled = true;
|
||||
monster.DisabledByEvent = false;
|
||||
monster.AnimController.SetPosition(FarseerPhysics.ConvertUnits.ToSimUnits(pos));
|
||||
|
||||
var eventManager = GameMain.GameSession.EventManager;
|
||||
if (eventManager != null)
|
||||
{
|
||||
if (SpawnPosType.HasFlag(Level.PositionType.MainPath) || SpawnPosType.HasFlag(Level.PositionType.SidePath))
|
||||
{
|
||||
eventManager.CumulativeMonsterStrengthMain += createdCharacter.Params.AI.CombatStrength;
|
||||
eventManager.CumulativeMonsterStrengthMain += monster.Params.AI.CombatStrength;
|
||||
eventManager.AddTimeStamp(this);
|
||||
}
|
||||
else if (SpawnPosType.HasFlag(Level.PositionType.Ruin))
|
||||
{
|
||||
eventManager.CumulativeMonsterStrengthRuins += createdCharacter.Params.AI.CombatStrength;
|
||||
eventManager.CumulativeMonsterStrengthRuins += monster.Params.AI.CombatStrength;
|
||||
}
|
||||
else if (SpawnPosType.HasFlag(Level.PositionType.Wreck))
|
||||
{
|
||||
eventManager.CumulativeMonsterStrengthWrecks += createdCharacter.Params.AI.CombatStrength;
|
||||
eventManager.CumulativeMonsterStrengthWrecks += monster.Params.AI.CombatStrength;
|
||||
}
|
||||
else if (SpawnPosType.HasFlag(Level.PositionType.Cave))
|
||||
{
|
||||
eventManager.CumulativeMonsterStrengthCaves += createdCharacter.Params.AI.CombatStrength;
|
||||
eventManager.CumulativeMonsterStrengthCaves += monster.Params.AI.CombatStrength;
|
||||
}
|
||||
}
|
||||
if (GameMain.GameSession.IsCurrentLocationRadiated())
|
||||
{
|
||||
AfflictionPrefab radiationPrefab = AfflictionPrefab.RadiationSickness;
|
||||
Affliction affliction = new Affliction(radiationPrefab, radiationPrefab.MaxStrength);
|
||||
createdCharacter?.CharacterHealth.ApplyAffliction(null, affliction);
|
||||
// TODO test multiplayer
|
||||
createdCharacter?.Kill(CauseOfDeathType.Affliction, affliction, log: false);
|
||||
}
|
||||
monsters.Add(createdCharacter);
|
||||
|
||||
if (monsters.Count == amount)
|
||||
if (monster == monsters.Last())
|
||||
{
|
||||
spawnReady = true;
|
||||
//this will do nothing if the monsters have no swarm behavior defined,
|
||||
@@ -587,6 +597,7 @@ namespace Barotrauma
|
||||
value: Timing.TotalTime - GameMain.GameSession.RoundStartTime);
|
||||
}
|
||||
}, delayBetweenSpawns * i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user