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
@@ -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