Release v0.15.12.0
This commit is contained in:
@@ -3,7 +3,6 @@ using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Metadata;
|
||||
|
||||
namespace Barotrauma.Particles
|
||||
{
|
||||
@@ -16,6 +15,8 @@ namespace Barotrauma.Particles
|
||||
public delegate void OnChangeHullHandler(Vector2 position, Hull currentHull);
|
||||
public OnChangeHullHandler OnChangeHull;
|
||||
|
||||
public OnChangeHullHandler OnCollision;
|
||||
|
||||
private Vector2 position;
|
||||
private Vector2 prevPosition;
|
||||
|
||||
@@ -166,6 +167,7 @@ namespace Barotrauma.Particles
|
||||
HighQualityCollisionDetection = false;
|
||||
|
||||
OnChangeHull = null;
|
||||
OnCollision = null;
|
||||
|
||||
subEmitters.Clear();
|
||||
hasSubEmitters = false;
|
||||
@@ -340,12 +342,20 @@ namespace Barotrauma.Particles
|
||||
Vector2 collisionNormal = Vector2.Zero;
|
||||
if (velocity.Y < 0.0f && position.Y - prefab.CollisionRadius * size.Y < hullRect.Y - hullRect.Height)
|
||||
{
|
||||
if (prefab.DeleteOnCollision) { return UpdateResult.Delete; }
|
||||
if (prefab.DeleteOnCollision)
|
||||
{
|
||||
OnCollision?.Invoke(position, currentHull);
|
||||
return UpdateResult.Delete;
|
||||
}
|
||||
collisionNormal = new Vector2(0.0f, 1.0f);
|
||||
}
|
||||
else if (velocity.Y > 0.0f && position.Y + prefab.CollisionRadius * size.Y > hullRect.Y)
|
||||
{
|
||||
if (prefab.DeleteOnCollision) { return UpdateResult.Delete; }
|
||||
if (prefab.DeleteOnCollision)
|
||||
{
|
||||
OnCollision?.Invoke(position, currentHull);
|
||||
return UpdateResult.Delete;
|
||||
}
|
||||
collisionNormal = new Vector2(0.0f, -1.0f);
|
||||
}
|
||||
|
||||
@@ -368,6 +378,7 @@ namespace Barotrauma.Particles
|
||||
handleCollision(gapFound, collisionNormal);
|
||||
}
|
||||
|
||||
collisionNormal = Vector2.Zero;
|
||||
if (velocity.X < 0.0f && position.X - prefab.CollisionRadius * size.X < hullRect.X)
|
||||
{
|
||||
if (prefab.DeleteOnCollision) { return UpdateResult.Delete; }
|
||||
@@ -487,6 +498,8 @@ namespace Barotrauma.Particles
|
||||
velocity.Y = Math.Sign(collisionNormal.Y) * Math.Abs(velocity.Y) * prefab.Restitution;
|
||||
}
|
||||
|
||||
OnCollision?.Invoke(position, currentHull);
|
||||
|
||||
velocity += subVel;
|
||||
}
|
||||
|
||||
@@ -523,6 +536,8 @@ namespace Barotrauma.Particles
|
||||
velocity.Y *= (1.0f - prefab.Friction);
|
||||
}
|
||||
|
||||
OnCollision?.Invoke(position, currentHull);
|
||||
|
||||
velocity *= prefab.Restitution;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user