mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Raise collision events by-ref (#3201)
This commit is contained in:
@@ -16,6 +16,7 @@ using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
|
||||
@@ -57,9 +57,11 @@ using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Dynamics.Contacts;
|
||||
using Robust.Shared.Physics.Dynamics.Joints;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Robust.Client.Debugging
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Reflection;
|
||||
|
||||
namespace Robust.Client.GameObjects
|
||||
|
||||
@@ -11,6 +11,7 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
@@ -5,6 +5,7 @@ using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Robust.Client.GameObjects
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Robust.Client.Physics
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Dynamics.Joints;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Robust.Client.Physics
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using Robust.Shared;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
|
||||
namespace Robust.Client.Physics
|
||||
|
||||
@@ -2,6 +2,7 @@ using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Robust.Client.Physics
|
||||
|
||||
@@ -8,6 +8,7 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Client.Placement
|
||||
|
||||
@@ -6,6 +6,7 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Robust.Server.Console.Commands;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Robust.Server.Console.Commands;
|
||||
|
||||
|
||||
@@ -30,8 +30,10 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Dynamics.Joints;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Robust.Server.Console.Commands
|
||||
|
||||
@@ -6,6 +6,8 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Robust.Server.GameObjects
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Reflection;
|
||||
|
||||
namespace Robust.Server.GameObjects
|
||||
|
||||
@@ -17,6 +17,7 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Network.Messages;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -226,7 +227,7 @@ internal sealed partial class PVSSystem : EntitySystem
|
||||
// we just discard it.
|
||||
_visSetPool.Return(overflowEnts);
|
||||
}
|
||||
|
||||
|
||||
if (sessionData.SentEntities.TryGetValue(ackedTick, out var ackedData))
|
||||
ProcessAckedTick(sessionData, ackedData, ackedTick, lastAckedTick);
|
||||
}
|
||||
@@ -691,7 +692,7 @@ internal sealed partial class PVSSystem : EntitySystem
|
||||
|
||||
if (visibleEnts.Count != 0)
|
||||
throw new Exception("Encountered non-empty object inside of _visSetPool. Was the same object returned to the pool more than once?");
|
||||
|
||||
|
||||
var deletions = _entityPvsCollection.GetDeletedIndices(fromTick);
|
||||
|
||||
foreach (var i in chunkIndices)
|
||||
@@ -754,7 +755,7 @@ internal sealed partial class PVSSystem : EntitySystem
|
||||
var entFromTick = entered ? lastSeen.GetValueOrDefault(uid) : fromTick;
|
||||
var state = GetEntityState(session, uid, entFromTick, mQuery.GetComponent(uid));
|
||||
|
||||
if (entered || !state.Empty)
|
||||
if (entered || !state.Empty)
|
||||
entityStates.Add(state);
|
||||
}
|
||||
|
||||
@@ -808,7 +809,7 @@ internal sealed partial class PVSSystem : EntitySystem
|
||||
foreach (var uid in lastSent.Keys)
|
||||
{
|
||||
if (!visibleEnts.ContainsKey(uid))
|
||||
leftView.Add(uid);
|
||||
leftView.Add(uid);
|
||||
}
|
||||
|
||||
return leftView.Count > 0 ? leftView : null;
|
||||
@@ -901,7 +902,7 @@ internal sealed partial class PVSSystem : EntitySystem
|
||||
// the budget. Chances are the packet will arrive in a nice and orderly fashion, and the client will stick to
|
||||
// their requested budget. However this can cause issues if a packet gets dropped, because a player may create
|
||||
// 2x or more times the normal entity creation budget.
|
||||
//
|
||||
//
|
||||
// The fix for that would be to just also give the PVS budget a client-side aspect that controls entity creation
|
||||
// rate.
|
||||
if (enteredSinceLastSent)
|
||||
|
||||
@@ -15,7 +15,9 @@ using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Robust.Server.Physics
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -3,6 +3,7 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Dynamics.Joints;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Robust.Server.Physics
|
||||
{
|
||||
|
||||
@@ -3,6 +3,8 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -2,7 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Robust.Shared.Containers
|
||||
|
||||
@@ -9,6 +9,7 @@ using Robust.Shared.Utility;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Robust.Shared.Log;
|
||||
using System.Diagnostics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
#if EXCEPTION_TOLERANCE
|
||||
using Robust.Shared.Exceptions;
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Robust.Shared.GameObjects
|
||||
{
|
||||
public sealed class CollideOnAnchorSystem : EntitySystem
|
||||
|
||||
@@ -2,6 +2,8 @@ using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Robust.Shared.GameObjects
|
||||
{
|
||||
|
||||
@@ -8,7 +8,9 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Robust.Shared.GameObjects
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Robust.Shared.Map
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Robust.Shared.Map
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -6,6 +6,7 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Shared.Map;
|
||||
|
||||
@@ -2,7 +2,7 @@ using System.Collections.Generic;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
|
||||
namespace Robust.Shared.Physics.Broadphase
|
||||
namespace Robust.Shared.Physics.BroadPhase
|
||||
{
|
||||
public sealed class DynamicTreeBroadPhase : IBroadPhase
|
||||
{
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using System;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Robust.Shared.GameObjects
|
||||
namespace Robust.Shared.Physics.Components
|
||||
{
|
||||
// TODO: Move to content
|
||||
[Serializable, NetSerializable]
|
||||
public enum BodyStatus: byte
|
||||
{
|
||||
@@ -24,19 +24,20 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Dynamics.Contacts;
|
||||
using Robust.Shared.Physics.Events;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Robust.Shared.GameObjects
|
||||
namespace Robust.Shared.Physics.Components
|
||||
{
|
||||
[ComponentReference(typeof(ILookupWorldBox2Component))]
|
||||
[ComponentReference(typeof(IPhysBody))]
|
||||
@@ -808,85 +809,10 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to prevent bodies from colliding; may lie depending on joints.
|
||||
/// </summary>
|
||||
/// <param name="other"></param>
|
||||
/// <returns></returns>
|
||||
internal bool ShouldCollide(PhysicsComponent other)
|
||||
{
|
||||
if ((_bodyType & (BodyType.Kinematic | BodyType.Static)) != 0 &&
|
||||
(other._bodyType & (BodyType.Kinematic | BodyType.Static)) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Does a joint prevent collision?
|
||||
// if one of them doesn't have jointcomp then they can't share a common joint.
|
||||
// otherwise, only need to iterate over the joints of one component as they both store the same joint.
|
||||
if (_entMan.TryGetComponent(Owner, out JointComponent? jointComponentA) &&
|
||||
_entMan.TryGetComponent(other.Owner, out JointComponent? jointComponentB))
|
||||
{
|
||||
var aUid = jointComponentA.Owner;
|
||||
var bUid = jointComponentB.Owner;
|
||||
|
||||
foreach (var (_, joint) in jointComponentA.Joints)
|
||||
{
|
||||
// Check if either: the joint even allows collisions OR the other body on the joint is actually the other body we're checking.
|
||||
if (!joint.CollideConnected &&
|
||||
((aUid == joint.BodyAUid &&
|
||||
bUid == joint.BodyBUid) ||
|
||||
(bUid == joint.BodyAUid &&
|
||||
aUid == joint.BodyBUid))) return false;
|
||||
}
|
||||
}
|
||||
|
||||
var preventCollideMessage = new PreventCollideEvent(this, other);
|
||||
_entMan.EventBus.RaiseLocalEvent(Owner, preventCollideMessage, true);
|
||||
|
||||
if (preventCollideMessage.Cancelled) return false;
|
||||
|
||||
preventCollideMessage = new PreventCollideEvent(other, this);
|
||||
_entMan.EventBus.RaiseLocalEvent(other.Owner, preventCollideMessage, true);
|
||||
|
||||
if (preventCollideMessage.Cancelled) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// View variables conveniences properties.
|
||||
[ViewVariables]
|
||||
private Vector2 _mapLinearVelocity => _entMan.EntitySysManager.GetEntitySystem<SharedPhysicsSystem>().GetMapLinearVelocity(Owner, this);
|
||||
[ViewVariables]
|
||||
private float _mapAngularVelocity => _entMan.EntitySysManager.GetEntitySystem<SharedPhysicsSystem>().GetMapAngularVelocity(Owner, this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Directed event raised when an entity's physics BodyType changes.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public readonly struct PhysicsBodyTypeChangedEvent
|
||||
{
|
||||
public readonly EntityUid Entity;
|
||||
|
||||
/// <summary>
|
||||
/// New BodyType of the entity.
|
||||
/// </summary>
|
||||
public readonly BodyType New;
|
||||
|
||||
/// <summary>
|
||||
/// Old BodyType of the entity.
|
||||
/// </summary>
|
||||
public readonly BodyType Old;
|
||||
|
||||
public readonly PhysicsComponent Component;
|
||||
|
||||
public PhysicsBodyTypeChangedEvent(EntityUid entity, BodyType newType, BodyType oldType, PhysicsComponent component)
|
||||
{
|
||||
Entity = entity;
|
||||
New = newType;
|
||||
Old = oldType;
|
||||
Component = component;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Dynamics.Joints;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Robust.Shared.GameObjects
|
||||
namespace Robust.Shared.Physics.Components
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class PhysicsComponentState : ComponentState
|
||||
@@ -5,6 +5,7 @@ using Prometheus;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Robust.Shared.Physics.Controllers
|
||||
|
||||
@@ -39,7 +39,10 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Collision;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics.Contacts;
|
||||
using Robust.Shared.Physics.Events;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Shared.Physics.Dynamics
|
||||
@@ -48,6 +51,7 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IPhysicsManager _physicsManager = default!;
|
||||
private SharedPhysicsSystem _physics = default!;
|
||||
private SharedTransformSystem _transform = default!;
|
||||
|
||||
internal MapId MapId { get; set; }
|
||||
@@ -159,7 +163,8 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
public void Initialize()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
_transform = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<SharedTransformSystem>();
|
||||
_physics = _entityManager.EntitySysManager.GetEntitySystem<SharedPhysicsSystem>();
|
||||
_transform = _entityManager.EntitySysManager.GetEntitySystem<SharedTransformSystem>();
|
||||
var configManager = IoCManager.Resolve<IConfigurationManager>();
|
||||
configManager.OnValueChanged(CVars.ContactMultithreadThreshold, OnContactMultithreadThreshold, true);
|
||||
configManager.OnValueChanged(CVars.ContactMinimumThreads, OnContactMinimumThreads, true);
|
||||
@@ -243,7 +248,7 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
DebugTools.Assert(!fixtureB.Contacts.ContainsKey(fixtureA));
|
||||
|
||||
// Does a joint override collision? Is at least one body dynamic?
|
||||
if (!bodyB.ShouldCollide(bodyA))
|
||||
if (!_physics.ShouldCollide(bodyB, bodyA))
|
||||
return;
|
||||
|
||||
// Call the factory.
|
||||
@@ -293,8 +298,10 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
|
||||
if (contact.IsTouching)
|
||||
{
|
||||
_entityManager.EventBus.RaiseLocalEvent(bodyA.Owner, new EndCollideEvent(fixtureA, fixtureB), true);
|
||||
_entityManager.EventBus.RaiseLocalEvent(bodyB.Owner, new EndCollideEvent(fixtureB, fixtureA), true);
|
||||
var ev1 = new EndCollideEvent(fixtureA, fixtureB);
|
||||
var ev2 = new EndCollideEvent(fixtureB, fixtureA);
|
||||
_entityManager.EventBus.RaiseLocalEvent(bodyA.Owner, ref ev1);
|
||||
_entityManager.EventBus.RaiseLocalEvent(bodyB.Owner, ref ev2);
|
||||
}
|
||||
|
||||
if (contact.Manifold.PointCount > 0 && contact.FixtureA?.Hard == true && contact.FixtureB?.Hard == true)
|
||||
@@ -364,7 +371,7 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
if ((contact.Flags & ContactFlags.Filter) != 0x0)
|
||||
{
|
||||
// Should these bodies collide?
|
||||
if (bodyB.ShouldCollide(bodyA) == false)
|
||||
if (_physics.ShouldCollide(bodyB, bodyA) == false)
|
||||
{
|
||||
node = node.Next;
|
||||
Destroy(contact);
|
||||
@@ -497,8 +504,11 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
var bodyB = fixtureB.Body;
|
||||
var worldPoint = Transform.Mul(_physicsManager.EnsureTransform(bodyA), contact.Manifold.LocalPoint);
|
||||
|
||||
_entityManager.EventBus.RaiseLocalEvent(bodyA.Owner, new StartCollideEvent(fixtureA, fixtureB, worldPoint), true);
|
||||
_entityManager.EventBus.RaiseLocalEvent(bodyB.Owner, new StartCollideEvent(fixtureB, fixtureA, worldPoint), true);
|
||||
var ev1 = new StartCollideEvent(fixtureA, fixtureB, worldPoint);
|
||||
var ev2 = new StartCollideEvent(fixtureB, fixtureA, worldPoint);
|
||||
|
||||
_entityManager.EventBus.RaiseLocalEvent(bodyA.Owner, ref ev1, true);
|
||||
_entityManager.EventBus.RaiseLocalEvent(bodyB.Owner, ref ev2, true);
|
||||
break;
|
||||
}
|
||||
case ContactStatus.Touching:
|
||||
@@ -515,8 +525,11 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
var bodyA = fixtureA.Body;
|
||||
var bodyB = fixtureB.Body;
|
||||
|
||||
_entityManager.EventBus.RaiseLocalEvent(bodyA.Owner, new EndCollideEvent(fixtureA, fixtureB), true);
|
||||
_entityManager.EventBus.RaiseLocalEvent(bodyB.Owner, new EndCollideEvent(fixtureB, fixtureA), true);
|
||||
var ev1 = new EndCollideEvent(fixtureA, fixtureB);
|
||||
var ev2 = new EndCollideEvent(fixtureB, fixtureA);
|
||||
|
||||
_entityManager.EventBus.RaiseLocalEvent(bodyA.Owner, ref ev1);
|
||||
_entityManager.EventBus.RaiseLocalEvent(bodyB.Owner, ref ev2);
|
||||
break;
|
||||
}
|
||||
case ContactStatus.NoContact:
|
||||
@@ -606,60 +619,8 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PostSolve()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#region Collide Events Classes
|
||||
|
||||
public abstract class CollideEvent : EntityEventArgs
|
||||
{
|
||||
public Fixture OurFixture { get; }
|
||||
public Fixture OtherFixture { get; }
|
||||
|
||||
public CollideEvent(Fixture ourFixture, Fixture otherFixture)
|
||||
{
|
||||
OurFixture = ourFixture;
|
||||
OtherFixture = otherFixture;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class StartCollideEvent : CollideEvent
|
||||
{
|
||||
public Vector2 WorldPoint;
|
||||
|
||||
public StartCollideEvent(Fixture ourFixture, Fixture otherFixture, Vector2 worldPoint)
|
||||
: base(ourFixture, otherFixture)
|
||||
{
|
||||
WorldPoint = worldPoint;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class EndCollideEvent : CollideEvent
|
||||
{
|
||||
public EndCollideEvent(Fixture ourFixture, Fixture otherFixture)
|
||||
: base(ourFixture, otherFixture)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class PreventCollideEvent : CancellableEntityEventArgs
|
||||
{
|
||||
public IPhysBody BodyA;
|
||||
public IPhysBody BodyB;
|
||||
|
||||
public PreventCollideEvent(IPhysBody ourBody, IPhysBody otherBody)
|
||||
{
|
||||
BodyA = ourBody;
|
||||
BodyB = otherBody;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
internal enum ContactStatus : byte
|
||||
{
|
||||
NoContact = 0,
|
||||
|
||||
@@ -34,6 +34,7 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Collision;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Robust.Shared.Physics.Dynamics.Contacts
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@ using System.Threading.Tasks;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Collision;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Shared.Physics.Dynamics.Contacts
|
||||
|
||||
@@ -26,7 +26,9 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics.Contacts;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
|
||||
@@ -29,6 +29,7 @@ using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -25,6 +25,7 @@ using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -26,6 +26,8 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Robust.Shared.Physics.Dynamics.Joints
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@ using System;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -25,6 +25,7 @@ using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ using System;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics.Contacts;
|
||||
using Robust.Shared.Physics.Dynamics.Joints;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -28,8 +28,9 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Dynamics.Contacts;
|
||||
using Robust.Shared.Physics.Dynamics.Joints;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Utility;
|
||||
using PhysicsComponent = Robust.Shared.GameObjects.PhysicsComponent;
|
||||
using PhysicsComponent = Robust.Shared.Physics.Components.PhysicsComponent;
|
||||
|
||||
namespace Robust.Shared.Physics.Dynamics
|
||||
{
|
||||
@@ -344,8 +345,6 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
|
||||
SolveIslands(frameTime, dtRatio, invDt, prediction);
|
||||
Cleanup(frameTime);
|
||||
|
||||
ContactManager.PostSolve();
|
||||
}
|
||||
|
||||
protected virtual void Cleanup(float frameTime)
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
namespace Robust.Shared.GameObjects
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Robust.Shared.Physics.Events
|
||||
{
|
||||
[ByRefEvent]
|
||||
public readonly struct CollisionChangeEvent
|
||||
17
Robust.Shared/Physics/Events/EndCollideEvent.cs
Normal file
17
Robust.Shared/Physics/Events/EndCollideEvent.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
|
||||
namespace Robust.Shared.Physics.Events;
|
||||
|
||||
[ByRefEvent]
|
||||
public readonly struct EndCollideEvent
|
||||
{
|
||||
public readonly Fixture OurFixture;
|
||||
public readonly Fixture OtherFixture;
|
||||
|
||||
public EndCollideEvent(Fixture ourFixture, Fixture otherFixture)
|
||||
{
|
||||
OurFixture = ourFixture;
|
||||
OtherFixture = otherFixture;
|
||||
}
|
||||
}
|
||||
33
Robust.Shared/Physics/Events/PhysicsBodyTypeChangedEvent.cs
Normal file
33
Robust.Shared/Physics/Events/PhysicsBodyTypeChangedEvent.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Robust.Shared.Physics.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Directed event raised when an entity's physics BodyType changes.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public readonly struct PhysicsBodyTypeChangedEvent
|
||||
{
|
||||
public readonly EntityUid Entity;
|
||||
|
||||
/// <summary>
|
||||
/// New BodyType of the entity.
|
||||
/// </summary>
|
||||
public readonly BodyType New;
|
||||
|
||||
/// <summary>
|
||||
/// Old BodyType of the entity.
|
||||
/// </summary>
|
||||
public readonly BodyType Old;
|
||||
|
||||
public readonly PhysicsComponent Component;
|
||||
|
||||
public PhysicsBodyTypeChangedEvent(EntityUid entity, BodyType newType, BodyType oldType, PhysicsComponent component)
|
||||
{
|
||||
Entity = entity;
|
||||
New = newType;
|
||||
Old = oldType;
|
||||
Component = component;
|
||||
}
|
||||
}
|
||||
18
Robust.Shared/Physics/Events/PreventCollideEvent.cs
Normal file
18
Robust.Shared/Physics/Events/PreventCollideEvent.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Robust.Shared.Physics.Events;
|
||||
|
||||
[ByRefEvent]
|
||||
public struct PreventCollideEvent
|
||||
{
|
||||
public PhysicsComponent BodyA;
|
||||
public PhysicsComponent BodyB;
|
||||
public bool Cancelled = false;
|
||||
|
||||
public PreventCollideEvent(PhysicsComponent ourBody, PhysicsComponent otherBody)
|
||||
{
|
||||
BodyA = ourBody;
|
||||
BodyB = otherBody;
|
||||
}
|
||||
}
|
||||
18
Robust.Shared/Physics/Events/StartCollideEvent.cs
Normal file
18
Robust.Shared/Physics/Events/StartCollideEvent.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
|
||||
namespace Robust.Shared.Physics.Events;
|
||||
|
||||
[ByRefEvent]
|
||||
public readonly struct StartCollideEvent
|
||||
{
|
||||
public readonly Fixture OurFixture;
|
||||
public readonly Fixture OtherFixture;
|
||||
|
||||
public StartCollideEvent(Fixture ourFixture, Fixture otherFixture, Vector2 worldPoint)
|
||||
{
|
||||
OurFixture = ourFixture;
|
||||
OtherFixture = otherFixture;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Broadphase;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Dynamics.Contacts;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Robust.Shared.Physics
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Robust.Shared.Physics
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Robust.Shared.Physics
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Shared.Physics
|
||||
namespace Robust.Shared.Physics.Systems
|
||||
{
|
||||
public partial class FixtureSystem
|
||||
{
|
||||
@@ -7,11 +7,12 @@ using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Shared.Physics
|
||||
namespace Robust.Shared.Physics.Systems
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages physics fixtures.
|
||||
@@ -1,20 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Broadphase;
|
||||
using Robust.Shared.Physics.BroadPhase;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Dynamics.Contacts;
|
||||
using Robust.Shared.Physics.Events;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Shared.Physics
|
||||
namespace Robust.Shared.Physics.Systems
|
||||
{
|
||||
public abstract class SharedBroadphaseSystem : EntitySystem
|
||||
{
|
||||
@@ -1,21 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics.Contacts;
|
||||
using Robust.Shared.Physics.Dynamics.Joints;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Shared.Physics
|
||||
namespace Robust.Shared.Physics.Systems
|
||||
{
|
||||
// These exist as a means to defer joint additions / removals so we can use HandleComponentState gracefully without
|
||||
// exploding for modifying components.
|
||||
@@ -1,14 +1,16 @@
|
||||
using System;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Events;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Shared.GameObjects;
|
||||
namespace Robust.Shared.Physics.Systems;
|
||||
|
||||
public partial class SharedPhysicsSystem
|
||||
{
|
||||
@@ -0,0 +1,54 @@
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Events;
|
||||
|
||||
namespace Robust.Shared.Physics.Systems;
|
||||
|
||||
public abstract partial class SharedPhysicsSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to prevent bodies from colliding; may lie depending on joints.
|
||||
/// </summary>
|
||||
/// <param name="other"></param>
|
||||
/// <returns></returns>
|
||||
internal bool ShouldCollide(PhysicsComponent body, PhysicsComponent other)
|
||||
{
|
||||
if ((body.BodyType & (BodyType.Kinematic | BodyType.Static)) != 0 &&
|
||||
(other.BodyType & (BodyType.Kinematic | BodyType.Static)) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Does a joint prevent collision?
|
||||
// if one of them doesn't have jointcomp then they can't share a common joint.
|
||||
// otherwise, only need to iterate over the joints of one component as they both store the same joint.
|
||||
if (TryComp(body.Owner, out JointComponent? jointComponentA) &&
|
||||
TryComp(other.Owner, out JointComponent? jointComponentB))
|
||||
{
|
||||
var aUid = jointComponentA.Owner;
|
||||
var bUid = jointComponentB.Owner;
|
||||
|
||||
foreach (var (_, joint) in jointComponentA.Joints)
|
||||
{
|
||||
// Check if either: the joint even allows collisions OR the other body on the joint is actually the other body we're checking.
|
||||
if (!joint.CollideConnected &&
|
||||
((aUid == joint.BodyAUid &&
|
||||
bUid == joint.BodyBUid) ||
|
||||
(bUid == joint.BodyAUid &&
|
||||
aUid == joint.BodyBUid))) return false;
|
||||
}
|
||||
}
|
||||
|
||||
var preventCollideMessage = new PreventCollideEvent(body, other);
|
||||
RaiseLocalEvent(body.Owner, ref preventCollideMessage);
|
||||
|
||||
if (preventCollideMessage.Cancelled) return false;
|
||||
|
||||
preventCollideMessage = new PreventCollideEvent(other, body);
|
||||
RaiseLocalEvent(other.Owner, ref preventCollideMessage);
|
||||
|
||||
if (preventCollideMessage.Cancelled) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Shared.GameObjects;
|
||||
namespace Robust.Shared.Physics.Systems;
|
||||
|
||||
public abstract partial class SharedPhysicsSystem
|
||||
{
|
||||
@@ -1,14 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Robust.Shared.Debugging;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Debugging;
|
||||
|
||||
namespace Robust.Shared.GameObjects
|
||||
namespace Robust.Shared.Physics.Systems
|
||||
{
|
||||
/*
|
||||
* Handles all of the public query methods for physics.
|
||||
@@ -84,7 +84,7 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
if (other.Fixture.Body.Deleted || other.Fixture.Body == body) return true;
|
||||
if ((proxy.Fixture.CollisionMask & other.Fixture.CollisionLayer) == 0x0) return true;
|
||||
if (!body.ShouldCollide(other.Fixture.Body)) return true;
|
||||
if (!ShouldCollide(body, other.Fixture.Body)) return true;
|
||||
|
||||
state.entities.Add(other.Fixture.Body);
|
||||
return true;
|
||||
@@ -1,10 +1,11 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Robust.Shared.GameObjects;
|
||||
namespace Robust.Shared.Physics.Systems;
|
||||
|
||||
public abstract partial class SharedPhysicsSystem
|
||||
{
|
||||
@@ -3,17 +3,19 @@ using System.Collections.Generic;
|
||||
using Prometheus;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Events;
|
||||
using Robust.Shared.Utility;
|
||||
using DependencyAttribute = Robust.Shared.IoC.DependencyAttribute;
|
||||
|
||||
namespace Robust.Shared.GameObjects
|
||||
namespace Robust.Shared.Physics.Systems
|
||||
{
|
||||
public abstract partial class SharedPhysicsSystem : EntitySystem
|
||||
{
|
||||
@@ -10,7 +10,6 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Broadphase;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.Manager;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
@@ -26,6 +26,8 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Profiling;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Reflection;
|
||||
|
||||
@@ -6,6 +6,7 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.UnitTesting.Server;
|
||||
|
||||
// ReSharper disable AccessToStaticMemberViaDerivedType
|
||||
|
||||
@@ -5,6 +5,7 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Robust.UnitTesting.Shared.Map
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Robust.UnitTesting.Shared.Map
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.UnitTesting.Server;
|
||||
|
||||
namespace Robust.UnitTesting.Shared.Physics;
|
||||
|
||||
@@ -4,6 +4,7 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Robust.UnitTesting.Shared.Physics
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@ using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Robust.UnitTesting.Shared.Physics;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using NUnit.Framework;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Robust.UnitTesting.Shared.Physics
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Robust.UnitTesting.Shared.Physics;
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Robust.UnitTesting.Shared.Physics;
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics.Joints;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Robust.UnitTesting.Shared.Physics;
|
||||
|
||||
|
||||
@@ -8,8 +8,10 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Dynamics.Joints;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Reflection;
|
||||
using Robust.UnitTesting.Server;
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Robust.UnitTesting.Shared.Physics
|
||||
{
|
||||
|
||||
@@ -7,7 +7,9 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Robust.UnitTesting.Shared.Physics
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.UnitTesting.Server;
|
||||
|
||||
|
||||
@@ -33,7 +33,9 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Robust.UnitTesting.Shared.Physics
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user