v1.6.17.0 (Unto the Breach update)

This commit is contained in:
Regalis11
2024-10-22 17:29:04 +03:00
parent e74b3cdb17
commit 6e6c17e100
417 changed files with 17166 additions and 5870 deletions
@@ -178,12 +178,21 @@ namespace Barotrauma
{
float minDistance = level.Size.X * 0.2f;
bool allowAtStart = prefab.AllowAtStart;
bool allowAtEnd = prefab.AllowAtEnd;
if (GameMain.GameSession?.GameMode is PvPMode)
{
//in PvP mode, the object must be allowed at both the start and end to be placed at either end
//since the 2nd team starts at the end of the level, it'd be unfair to allow e.g. ballast flora to spawn at the end of the level but not the start
allowAtEnd = allowAtStart = allowAtEnd && allowAtStart;
}
suitableSpawnPositions.Add(prefab,
availableSpawnPositions.Where(sp =>
sp.SpawnPosTypes.Any(type => prefab.SpawnPos.HasFlag(type)) &&
sp.Length >= prefab.MinSurfaceWidth &&
(prefab.AllowAtStart || !level.IsCloseToStart(sp.GraphEdge.Center, minDistance)) &&
(prefab.AllowAtEnd || !level.IsCloseToEnd(sp.GraphEdge.Center, minDistance)) &&
(allowAtStart || !level.IsCloseToStart(sp.GraphEdge.Center, minDistance)) &&
(allowAtEnd || !level.IsCloseToEnd(sp.GraphEdge.Center, minDistance)) &&
(sp.Alignment == Alignment.Any || prefab.Alignment.HasFlag(sp.Alignment))).ToList());
spawnPositionWeights.Add(prefab,
@@ -6,7 +6,9 @@ using FarseerPhysics.Dynamics.Contacts;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Barotrauma.Items.Components;
namespace Barotrauma
{
@@ -55,6 +57,8 @@ namespace Barotrauma
private readonly HashSet<Entity> triggerers = new HashSet<Entity>();
private readonly TriggererType triggeredBy;
private readonly Identifier triggerSpeciesOrGroup;
private readonly PropertyConditional.LogicalComparison conditionals;
private readonly float randomTriggerInterval;
private readonly float randomTriggerProbability;
@@ -255,7 +259,16 @@ namespace Barotrauma
string triggeredByStr = element.GetAttributeString("triggeredby", "Character");
if (!Enum.TryParse(triggeredByStr, out triggeredBy))
{
DebugConsole.ThrowError("Error in LevelTrigger config: \"" + triggeredByStr + "\" is not a valid triggerer type.");
Identifier speciesOrGroup = triggeredByStr.ToIdentifier();
if (CharacterPrefab.Prefabs.Any(p => p.MatchesSpeciesNameOrGroup(speciesOrGroup)))
{
triggerSpeciesOrGroup = speciesOrGroup;
triggeredBy = TriggererType.Character;
}
else
{
DebugConsole.ThrowError("Error in LevelTrigger config: \"" + triggeredByStr + "\" is not a valid triggerer type.");
}
}
if (PhysicsBody != null)
{
@@ -293,6 +306,8 @@ namespace Barotrauma
break;
}
}
conditionals = PropertyConditional.LoadConditionals(element);
forceFluctuationTimer = Rand.Range(0.0f, ForceFluctuationInterval);
randomTriggerTimer = Rand.Range(0.0f, randomTriggerInterval);
@@ -341,7 +356,7 @@ namespace Barotrauma
{
Entity entity = GetEntity(fixtureB);
if (entity == null) { return false; }
if (!IsTriggeredByEntity(entity, triggeredBy, mustBeOutside: true)) { return false; }
if (!IsTriggeredByEntity(entity, triggeredBy, triggerSpeciesOrGroup: triggerSpeciesOrGroup, conditionals: conditionals, mustBeOutside: true)) { return false; }
if (!triggerers.Contains(entity))
{
if (!IsTriggered)
@@ -354,12 +369,22 @@ namespace Barotrauma
return true;
}
public static bool IsTriggeredByEntity(Entity entity, TriggererType triggeredBy, bool mustBeOutside = false, (bool mustBe, Submarine sub) mustBeOnSpecificSub = default)
public static bool IsTriggeredByEntity(
Entity entity,
TriggererType triggeredBy,
Identifier triggerSpeciesOrGroup,
PropertyConditional.LogicalComparison conditionals,
(bool mustBe, Submarine sub) mustBeOnSpecificSub = default,
bool mustBeOutside = false)
{
if (entity is Character character)
{
if (mustBeOutside && character.CurrentHull != null) { return false; }
if (mustBeOnSpecificSub.mustBe && character.Submarine != mustBeOnSpecificSub.sub) { return false; }
if (!triggerSpeciesOrGroup.IsEmpty)
{
if (character.SpeciesName != triggerSpeciesOrGroup && character.Group != triggerSpeciesOrGroup) { return false; }
}
if (character.IsHuman)
{
if (!triggeredBy.HasFlag(TriggererType.Human)) { return false; }
@@ -379,6 +404,10 @@ namespace Barotrauma
{
if (!triggeredBy.HasFlag(TriggererType.Submarine)) { return false; }
}
if (conditionals != null && entity is ISerializableEntity serializableEntity)
{
if (!PropertyConditional.CheckConditionals(serializableEntity, conditionals.Conditionals, conditionals.LogicalOperator)) { return false; }
}
return true;
}
@@ -497,7 +526,7 @@ namespace Barotrauma
triggeredTimer = stayTriggeredDelay;
if (!wasAlreadyTriggered)
{
if (!IsTriggeredByEntity(triggerer, triggeredBy, mustBeOutside: true)) { return; }
if (!IsTriggeredByEntity(triggerer, triggeredBy, triggerSpeciesOrGroup, conditionals, mustBeOutside: true)) { return; }
if (!triggerers.Contains(triggerer))
{
if (!IsTriggered)
@@ -652,13 +681,20 @@ namespace Barotrauma
}
}
public static void ApplyStatusEffects(List<StatusEffect> statusEffects, Vector2 worldPosition, Entity triggerer, float deltaTime, List<ISerializableEntity> targets)
public static void ApplyStatusEffects(List<StatusEffect> statusEffects, Vector2 worldPosition, Entity triggerer, float deltaTime, List<ISerializableEntity> targets, Item targetItem = null)
{
foreach (StatusEffect effect in statusEffects)
{
if (effect.type == ActionType.OnBroken) { return; }
Vector2? position = null;
if (effect.HasTargetType(StatusEffect.TargetType.This)) { position = worldPosition; }
if (effect.HasTargetType(StatusEffect.TargetType.This))
{
position = worldPosition;
if (targetItem != null)
{
effect.Apply(effect.type, deltaTime, triggerer, targetItem.AllPropertyObjects, position);
}
}
if (triggerer is Character character)
{
effect.Apply(effect.type, deltaTime, triggerer, character, position);
@@ -728,6 +764,8 @@ namespace Barotrauma
if (distFactor < 0.0f) return;
}
if (MathUtils.NearlyEqual(currentForceFluctuation, 0.0f)) { return; }
switch (ForceMode)
{
case TriggerForceMode.Force: