mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-16 15:22:27 +02:00
* Added new ComponentEventBus, combined it with IEventBus. * Removed all traces of IEntity from ComponentDependencies. Removed IEntityManager dependency from ComponentManager. * Added entity create/delete events to IEntityManager. * ComponentEvents now use EntitySystemMessages instead of their custom ComponentEvent class. * Component events are now just overloads of entity events. * Removed obsolete EntitySystemMessage, now everything uses the base EntityEventArgs. * Add a bool argument for if the message should be broadcast as well as directed. Fix ordering and init issues of events in EntityManager. * Changed names from Component/Entity events to Directed/Broadcast. * Fix bugs and unit tests.
91 lines
2.5 KiB
C#
91 lines
2.5 KiB
C#
using System;
|
|
using Robust.Shared.Physics;
|
|
using Robust.Shared.Physics.Collision;
|
|
using Robust.Shared.Physics.Dynamics;
|
|
using Robust.Shared.Serialization;
|
|
|
|
namespace Robust.Shared.GameObjects
|
|
{
|
|
/// <summary>
|
|
/// Called every tick for colliding bodies. Called once per pair.
|
|
/// </summary>
|
|
public sealed class CollisionMessage : EntityEventArgs
|
|
{
|
|
public readonly IPhysBody BodyA;
|
|
public readonly IPhysBody BodyB;
|
|
public readonly float FrameTime;
|
|
public readonly Manifold Manifold;
|
|
|
|
public CollisionMessage(IPhysBody bodyA, IPhysBody bodyB, float frameTime, Manifold manifold)
|
|
{
|
|
BodyA = bodyA;
|
|
BodyB = bodyB;
|
|
FrameTime = frameTime;
|
|
Manifold = manifold;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called once when a collision starts
|
|
/// </summary>
|
|
public interface IStartCollide
|
|
{
|
|
/// <summary>
|
|
/// We'll pass in both our body and the other body to save the behaviors having to get these components themselves.
|
|
/// </summary>
|
|
void CollideWith(IPhysBody ourBody, IPhysBody otherBody, in Manifold manifold);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called once when a collision ends.
|
|
/// </summary>
|
|
public interface IEndCollide
|
|
{
|
|
/// <summary>
|
|
/// Run behaviour after all other collision behaviors have run.
|
|
/// </summary>
|
|
/// <param name="ourBody"></param>
|
|
/// <param name="otherBody"></param>
|
|
/// <param name="manifold"></param>
|
|
void CollideWith(IPhysBody ourBody, IPhysBody otherBody, in Manifold manifold);
|
|
}
|
|
|
|
public interface ICollideSpecial
|
|
{
|
|
bool PreventCollide(IPhysBody collidedwith);
|
|
}
|
|
|
|
[Serializable, NetSerializable]
|
|
public enum BodyStatus: byte
|
|
{
|
|
OnGround,
|
|
InAir
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sent whenever a <see cref="IPhysBody"/> is changed.
|
|
/// </summary>
|
|
public sealed class PhysicsUpdateMessage : EntityEventArgs
|
|
{
|
|
public PhysicsComponent Component { get; }
|
|
|
|
public PhysicsUpdateMessage(PhysicsComponent component)
|
|
{
|
|
Component = component;
|
|
}
|
|
}
|
|
|
|
public sealed class FixtureUpdateMessage : EntityEventArgs
|
|
{
|
|
public PhysicsComponent Body { get; }
|
|
|
|
public Fixture Fixture { get; }
|
|
|
|
public FixtureUpdateMessage(PhysicsComponent body, Fixture fixture)
|
|
{
|
|
Body = body;
|
|
Fixture = fixture;
|
|
}
|
|
}
|
|
}
|