(bf212a41f) v0.9.2.0 pre-release test version

This commit is contained in:
Joonas Rikkonen
2019-07-27 21:06:07 +03:00
parent afa2137bd2
commit 0f63da27b2
154 changed files with 3959 additions and 1428 deletions
@@ -113,6 +113,13 @@ namespace Barotrauma.Items.Components
set;
}
[Serialize(1, false)]
public int HitScanCount
{
get;
set;
}
[Serialize(false, false)]
public bool RemoveOnHit
{
@@ -120,6 +127,13 @@ namespace Barotrauma.Items.Components
set;
}
[Serialize(0.0f, false)]
public float Spread
{
get;
set;
}
public Projectile(Item item, XElement element)
: base (item, element)
{
@@ -154,17 +168,25 @@ namespace Barotrauma.Items.Components
public override bool Use(float deltaTime, Character character = null)
{
if (character != null && !characterUsable) return false;
if (character != null && !characterUsable) { return false; }
Vector2 launchDir = new Vector2((float)Math.Cos(item.body.Rotation), (float)Math.Sin(item.body.Rotation));
if (Hitscan)
for (int i = 0; i < HitScanCount; i++)
{
DoHitscan(launchDir);
}
else
{
Launch(launchDir * launchImpulse * item.body.Mass);
float launchAngle = item.body.Rotation + MathHelper.ToRadians(Rand.Range(-Spread, Spread));
Vector2 launchDir = new Vector2((float)Math.Cos(launchAngle), (float)Math.Sin(launchAngle));
if (Hitscan)
{
Vector2 prevSimpos = item.SimPosition;
DoHitscan(launchDir);
if (i < HitScanCount - 1)
{
item.SetTransform(prevSimpos, item.body.Rotation);
}
}
else
{
Launch(launchDir * launchImpulse * item.body.Mass);
}
}
User = character;
@@ -306,6 +328,9 @@ namespace Barotrauma.Items.Components
!fixture.CollisionCategories.HasFlag(Physics.CollisionWall) &&
!fixture.CollisionCategories.HasFlag(Physics.CollisionLevel)) return true;
fixture.Body.GetTransform(out FarseerPhysics.Common.Transform transform);
if (!fixture.Shape.TestPoint(ref transform, ref rayStart)) { return true; }
hits.Add(new HitscanResult(fixture, rayStart, -dir, 0.0f));
return true;
}, ref aabb);