Build 0.20.12.0

This commit is contained in:
Markus Isberg
2022-12-09 20:08:36 +02:00
parent a10cc13566
commit 6f788fb8b4
24 changed files with 203 additions and 456 deletions
@@ -915,7 +915,7 @@ namespace Barotrauma
else
{
// Wander around outside or swimming
steeringManager.SteeringWander();
steeringManager.SteeringWander(avoidWanderingOutsideLevel: true);
if (Character.AnimController.InWater)
{
SteeringManager.SteeringAvoid(deltaTime, lookAheadDistance: avoidLookAheadDistance, weight: 5);
@@ -1860,7 +1860,7 @@ namespace Barotrauma
{
if (Character.CurrentHull == null && !canAttack)
{
SteeringManager.SteeringWander();
SteeringManager.SteeringWander(avoidWanderingOutsideLevel: true);
SteeringManager.SteeringAvoid(deltaTime, lookAheadDistance: avoidLookAheadDistance, weight: 5);
}
else
@@ -3831,7 +3831,7 @@ namespace Barotrauma
}
else
{
SteeringManager.SteeringWander();
SteeringManager.SteeringWander(avoidWanderingOutsideLevel: Character.CurrentHull == null);
if (Character.CurrentHull == null)
{
SteeringManager.SteeringAvoid(deltaTime, lookAheadDistance: avoidLookAheadDistance, weight: 5);
@@ -43,9 +43,9 @@ namespace Barotrauma
steering += DoSteeringSeek(targetSimPos, weight);
}
public void SteeringWander(float weight = 1)
public void SteeringWander(float weight = 1, bool avoidWanderingOutsideLevel = false)
{
steering += DoSteeringWander(weight);
steering += DoSteeringWander(weight, avoidWanderingOutsideLevel);
}
public void SteeringAvoid(float deltaTime, float lookAheadDistance, float weight = 1)
@@ -119,7 +119,7 @@ namespace Barotrauma
//return newSteering;
}
protected virtual Vector2 DoSteeringWander(float weight)
protected virtual Vector2 DoSteeringWander(float weight, bool avoidWanderingOutsideLevel)
{
Vector2 circleCenter = (host.Steering == Vector2.Zero) ? Vector2.UnitY : host.Steering;
circleCenter = Vector2.Normalize(circleCenter) * CircleDistance;
@@ -127,19 +127,35 @@ namespace Barotrauma
Vector2 displacement = new Vector2(
(float)Math.Cos(wanderAngle),
(float)Math.Sin(wanderAngle));
displacement = displacement * CircleRadius;
displacement *= CircleRadius;
float angleChange = 1.5f;
wanderAngle += Rand.Range(0.0f, 1.0f) * angleChange - angleChange * 0.5f;
Vector2 newSteering = circleCenter + displacement;
if (avoidWanderingOutsideLevel && Level.Loaded != null)
{
float margin = 5000.0f;
if (host.WorldPosition.X < -margin)
{
// Too far left
newSteering.X += (-margin - host.WorldPosition.X) * weight / margin;
}
else if (host.WorldPosition.X > Level.Loaded.Size.X - margin)
{
// Too far right
newSteering.X -= (host.WorldPosition.X - (Level.Loaded.Size.X - margin)) * weight / margin;
}
}
float steeringSpeed = (newSteering + host.Steering).Length();
if (steeringSpeed > weight)
{
newSteering = Vector2.Normalize(newSteering) * weight;
}
return newSteering;
}
@@ -377,6 +377,7 @@ namespace Barotrauma
public readonly bool HealableInMedicalClinic;
public readonly float HealCostMultiplier;
public readonly int BaseHealCost;
public readonly bool ShowBarInHealthMenu;
public readonly LocalizedString CauseOfDeathDescription, SelfCauseOfDeathDescription;
@@ -473,6 +474,8 @@ namespace Barotrauma
IsBuff = element.GetAttributeBool(nameof(IsBuff), false);
AffectMachines = element.GetAttributeBool(nameof(AffectMachines), true);
ShowBarInHealthMenu = element.GetAttributeBool("showbarinhealthmenu", true);
HealableInMedicalClinic = element.GetAttributeBool("healableinmedicalclinic",
!IsBuff &&
AfflictionType != "geneticmaterialbuff" &&
@@ -10,12 +10,15 @@ namespace Barotrauma.Abilities
private readonly bool inSameRoom;
private readonly ImmutableHashSet<Identifier> jobIdentifiers;
public override bool AllowClientSimulation { get; }
public CharacterAbilityApplyStatusEffectsToAllies(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement) : base(characterAbilityGroup, abilityElement)
{
allowSelf = abilityElement.GetAttributeBool("allowself", true);
maxDistance = abilityElement.GetAttributeFloat("maxdistance", float.MaxValue);
inSameRoom = abilityElement.GetAttributeBool("insameroom", false);
jobIdentifiers = abilityElement.GetAttributeIdentifierImmutableHashSet("jobs", ImmutableHashSet<Identifier>.Empty);
AllowClientSimulation = abilityElement.GetAttributeBool("allowclientsimulation", true);
}
@@ -327,7 +327,7 @@ namespace Barotrauma
{
if (levelData == null)
{
throw new ArgumentException("Current location was null.");
throw new ArgumentException("Level data was null.");
}
extraMissions.Clear();
@@ -267,11 +267,14 @@ namespace Barotrauma.Items.Components
projectile.Launcher = item;
projectile.Shoot(character, character.AnimController.AimSourceSimPos, barrelPos, rotation + spread, ignoredBodies: ignoredBodies.ToList(), createNetworkEvent: false, damageMultiplier, LaunchImpulse);
projectile.Item.GetComponent<Rope>()?.Attach(Item, projectile.Item);
if (i == 0)
if (projectile.Item.body != null)
{
Item.body.ApplyLinearImpulse(new Vector2((float)Math.Cos(projectile.Item.body.Rotation), (float)Math.Sin(projectile.Item.body.Rotation)) * Item.body.Mass * -50.0f, maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
if (i == 0)
{
Item.body.ApplyLinearImpulse(new Vector2((float)Math.Cos(projectile.Item.body.Rotation), (float)Math.Sin(projectile.Item.body.Rotation)) * Item.body.Mass * -50.0f, maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
}
projectile.Item.body.ApplyTorque(projectile.Item.body.Mass * degreeOfFailure * Rand.Range(-10.0f, 10.0f));
}
projectile.Item.body.ApplyTorque(projectile.Item.body.Mass * degreeOfFailure * Rand.Range(-10.0f, 10.0f));
Item.RemoveContained(projectile.Item);
}
LastProjectile = projectile;
@@ -260,6 +260,8 @@ namespace Barotrauma.Items.Components
}
}
public readonly bool InheritStatusEffects;
public ItemComponent(Item item, ContentXElement element)
{
this.item = item;
@@ -320,6 +322,7 @@ namespace Barotrauma.Items.Components
string inheritStatusEffectsFrom = element.GetAttributeString("inheritstatuseffectsfrom", "");
if (!string.IsNullOrEmpty(inheritStatusEffectsFrom))
{
InheritStatusEffects = true;
var component = item.Components.Find(ic => ic.Name.Equals(inheritStatusEffectsFrom, StringComparison.OrdinalIgnoreCase));
if (component == null)
{
@@ -266,37 +266,43 @@ namespace Barotrauma.Items.Components
if (!subElement.Name.ToString().Equals("attack", StringComparison.OrdinalIgnoreCase)) { continue; }
Attack = new Attack(subElement, item.Name + ", Projectile", item);
}
if (item.body == null)
{
DebugConsole.ThrowError($"Error in projectile definition ({item.Name}): No body defined!");
return;
}
InitProjSpecific(element);
}
partial void InitProjSpecific(ContentXElement element);
public override void OnItemLoaded()
{
if (item.body != null)
if (item.body == null) { return; }
if (Attack != null && Attack.DamageRange <= 0.0f)
{
if (Attack != null && Attack.DamageRange <= 0.0f)
switch (item.body.BodyShape)
{
switch (item.body.BodyShape)
{
case PhysicsBody.Shape.Circle:
Attack.DamageRange = item.body.radius;
break;
case PhysicsBody.Shape.Capsule:
Attack.DamageRange = item.body.height / 2 + item.body.radius;
break;
case PhysicsBody.Shape.Rectangle:
Attack.DamageRange = new Vector2(item.body.width / 2.0f, item.body.height / 2.0f).Length();
break;
}
Attack.DamageRange = ConvertUnits.ToDisplayUnits(Attack.DamageRange);
case PhysicsBody.Shape.Circle:
Attack.DamageRange = item.body.radius;
break;
case PhysicsBody.Shape.Capsule:
Attack.DamageRange = item.body.height / 2 + item.body.radius;
break;
case PhysicsBody.Shape.Rectangle:
Attack.DamageRange = new Vector2(item.body.width / 2.0f, item.body.height / 2.0f).Length();
break;
}
originalCollisionCategories = item.body.CollisionCategories;
originalCollisionTargets = item.body.CollidesWith;
Attack.DamageRange = ConvertUnits.ToDisplayUnits(Attack.DamageRange);
}
originalCollisionCategories = item.body.CollisionCategories;
originalCollisionTargets = item.body.CollidesWith;
}
private void Launch(Character user, Vector2 simPosition, float rotation, float damageMultiplier = 1f, float launchImpulseModifier = 0f)
{
if (Item.body == null) { return; }
Item.body.ResetDynamics();
Item.SetTransform(simPosition, rotation);
if (Attack != null)
@@ -354,6 +360,7 @@ namespace Barotrauma.Items.Components
public bool Use(Character character = null, float launchImpulseModifier = 0f)
{
if (character != null && !characterUsable) { return false; }
if (item.body == null) { return false; }
for (int i = 0; i < HitScanCount; i++)
{
@@ -1074,6 +1081,7 @@ namespace Barotrauma.Items.Components
private void DisableProjectileCollisions()
{
if (item?.body?.FarseerBody == null) { return; }
item.body.FarseerBody.OnCollision -= OnProjectileCollision;
if (originalCollisionCategories != Category.None && originalCollisionTargets != Category.None)
{
@@ -639,16 +639,7 @@ namespace Barotrauma.Items.Components
ItemContainer projectileContainer = projectiles.First().Item.Container?.GetComponent<ItemContainer>();
if (projectileContainer != null && projectileContainer.Item != item)
{
//Use root container (e.g. loader) too in case it needs to react to firing somehow
var rootContainer = projectileContainer.Item.GetRootContainer();
if (rootContainer != null && rootContainer != projectileContainer.Item)
{
rootContainer.Use(deltaTime, null);
}
else
{
projectileContainer.Item.Use(deltaTime, null);
}
projectileContainer?.Item.Use(deltaTime, null);
}
}
else
@@ -1020,12 +1020,15 @@ namespace Barotrauma
}
if (ic.statusEffectLists == null) { continue; }
if (statusEffectLists == null)
if (ic.InheritStatusEffects)
{
statusEffectLists = new Dictionary<ActionType, List<StatusEffect>>();
// Inherited status effects are added when the ItemComponent is initialized at ItemComponent.cs:332.
// Don't create duplicate effects here.
continue;
}
statusEffectLists ??= new Dictionary<ActionType, List<StatusEffect>>();
//go through all the status effects of the component
//and add them to the corresponding statuseffect list
foreach (List<StatusEffect> componentEffectList in ic.statusEffectLists.Values)
@@ -1291,7 +1291,7 @@ namespace Barotrauma
{
var characters = GameSession.GetSessionCrewCharacters(CharacterType.Both);
if (!characters.Any()) { return 0; }
return characters.Sum(c => (int)c.GetStatValue(StatTypes.ExtraSpecialSalesCount));
return characters.Max(static c => (int)c.GetStatValue(StatTypes.ExtraSpecialSalesCount));
}
public bool CanHaveSubsForSale()