@@ -11,13 +11,14 @@ namespace Content.Client.GameObjects.Components.Movement
|
|||||||
{
|
{
|
||||||
base.HandleComponentState(curState, nextState);
|
base.HandleComponentState(curState, nextState);
|
||||||
|
|
||||||
if (curState is not ClimbModeComponentState climbModeState)
|
if (curState is not ClimbModeComponentState climbModeState || Body == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IsClimbing = climbModeState.Climbing;
|
IsClimbing = climbModeState.Climbing;
|
||||||
OwnerIsTransitioning = climbModeState.IsTransitioning;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool IsClimbing { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#nullable enable
|
||||||
|
using Content.Shared.GameObjects.Components.Movement;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Map;
|
||||||
|
|
||||||
|
namespace Content.Client.GameObjects.Components.Movement
|
||||||
|
{
|
||||||
|
[RegisterComponent]
|
||||||
|
[ComponentReference(typeof(IMoverComponent))]
|
||||||
|
public class PlayerInputMoverComponent : SharedPlayerInputMoverComponent
|
||||||
|
{
|
||||||
|
public override EntityCoordinates LastPosition { get; set; }
|
||||||
|
public override float StepSoundDistance { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using Content.Shared.GameObjects;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
|
||||||
|
namespace Content.Client.GameObjects.Components.Projectiles
|
||||||
|
{
|
||||||
|
[RegisterComponent]
|
||||||
|
public class ThrownItemComponent : ProjectileComponent
|
||||||
|
{
|
||||||
|
public override string Name => "ThrownItem";
|
||||||
|
public override uint? NetID => ContentNetIDs.THROWN_ITEM;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,6 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
|
|
||||||
namespace Content.Client.GameObjects.Components.Suspicion
|
namespace Content.Client.GameObjects.Components.Suspicion
|
||||||
{
|
{
|
||||||
@@ -63,7 +62,7 @@ namespace Content.Client.GameObjects.Components.Suspicion
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ally.TryGetComponent(out IPhysBody physics))
|
if (!ally.TryGetComponent(out IPhysicsComponent physics))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -83,7 +82,7 @@ namespace Content.Client.GameObjects.Components.Suspicion
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var worldBox = physics.GetWorldAABB();
|
var worldBox = physics.WorldAABB;
|
||||||
|
|
||||||
// if not on screen, or too small, continue
|
// if not on screen, or too small, continue
|
||||||
if (!worldBox.Intersects(in viewport) || worldBox.IsEmpty())
|
if (!worldBox.Intersects(in viewport) || worldBox.IsEmpty())
|
||||||
@@ -91,7 +90,7 @@ namespace Content.Client.GameObjects.Components.Suspicion
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var screenCoordinates = _eyeManager.WorldToScreen(physics.GetWorldAABB().TopLeft + (0, 0.5f));
|
var screenCoordinates = _eyeManager.WorldToScreen(physics.WorldAABB.TopLeft + (0, 0.5f));
|
||||||
DrawString(screen, _font, screenCoordinates, _traitorText, Color.OrangeRed);
|
DrawString(screen, _font, screenCoordinates, _traitorText, Color.OrangeRed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
43
Content.Client/GameObjects/EntitySystems/MoverSystem.cs
Normal file
43
Content.Client/GameObjects/EntitySystems/MoverSystem.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#nullable enable
|
||||||
|
using Content.Shared.GameObjects.Components.Movement;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
using Robust.Client.Physics;
|
||||||
|
using Robust.Client.Player;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
|
||||||
|
namespace Content.Client.GameObjects.EntitySystems
|
||||||
|
{
|
||||||
|
[UsedImplicitly]
|
||||||
|
public class MoverSystem : SharedMoverSystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
UpdatesBefore.Add(typeof(PhysicsSystem));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void FrameUpdate(float frameTime)
|
||||||
|
{
|
||||||
|
var playerEnt = _playerManager.LocalPlayer?.ControlledEntity;
|
||||||
|
|
||||||
|
if (playerEnt == null || !playerEnt.TryGetComponent(out IMoverComponent? mover) || !playerEnt.TryGetComponent(out IPhysicsComponent? physics))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
physics.Predict = true;
|
||||||
|
|
||||||
|
UpdateKinematics(playerEnt.Transform, mover, physics);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update(float frameTime)
|
||||||
|
{
|
||||||
|
FrameUpdate(frameTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -85,22 +85,13 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
foreach (var snapGridComponent in grid.GetSnapGridCell(position, SnapGridOffset.Center))
|
foreach (var snapGridComponent in grid.GetSnapGridCell(position, SnapGridOffset.Center))
|
||||||
{
|
{
|
||||||
var entity = snapGridComponent.Owner;
|
var entity = snapGridComponent.Owner;
|
||||||
if (!entity.TryGetComponent(out SubFloorHideComponent subFloorComponent))
|
if (!entity.TryGetComponent(out SubFloorHideComponent subFloorComponent) ||
|
||||||
|
!entity.TryGetComponent(out ISpriteComponent spriteComponent))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var enabled = EnableAll || !subFloorComponent.Running || tileDef.IsSubFloor;
|
spriteComponent.Visible = EnableAll || !subFloorComponent.Running || tileDef.IsSubFloor;
|
||||||
|
|
||||||
if (entity.TryGetComponent(out ISpriteComponent spriteComponent))
|
|
||||||
{
|
|
||||||
spriteComponent.Visible = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity.TryGetComponent(out PhysicsComponent physicsComponent))
|
|
||||||
{
|
|
||||||
physicsComponent.CanCollide = enabled;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
#nullable enable
|
|
||||||
using Content.Shared.GameObjects.Components.Movement;
|
|
||||||
using Content.Shared.Physics.Controllers;
|
|
||||||
using Robust.Client.Player;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Physics.Dynamics;
|
|
||||||
|
|
||||||
namespace Content.Client.Physics.Controllers
|
|
||||||
{
|
|
||||||
public sealed class MoverController : SharedMoverController
|
|
||||||
{
|
|
||||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
|
||||||
|
|
||||||
public override void UpdateBeforeSolve(bool prediction, float frameTime)
|
|
||||||
{
|
|
||||||
base.UpdateBeforeSolve(prediction, frameTime);
|
|
||||||
|
|
||||||
var player = _playerManager.LocalPlayer?.ControlledEntity;
|
|
||||||
if (player == null ||
|
|
||||||
!player.TryGetComponent(out IMoverComponent? mover) ||
|
|
||||||
!player.TryGetComponent(out PhysicsComponent? body)) return;
|
|
||||||
|
|
||||||
body.Predict = true; // TODO: equal prediction instead of true?
|
|
||||||
|
|
||||||
// Server-side should just be handled on its own so we'll just do this shizznit
|
|
||||||
if (player.TryGetComponent(out IMobMoverComponent? mobMover))
|
|
||||||
{
|
|
||||||
HandleMobMovement(mover, body, mobMover);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
HandleKinematicMovement(mover, body);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -20,10 +20,9 @@ namespace Content.IntegrationTests.Tests.Doors
|
|||||||
components:
|
components:
|
||||||
- type: Physics
|
- type: Physics
|
||||||
anchored: false
|
anchored: false
|
||||||
fixtures:
|
shapes:
|
||||||
- shape:
|
- !type:PhysShapeAabb
|
||||||
!type:PhysShapeAabb
|
bounds: ""-0.49,-0.49,0.49,0.49""
|
||||||
bounds: ""-0.49,-0.49,0.49,0.49""
|
|
||||||
layer:
|
layer:
|
||||||
- Impassable
|
- Impassable
|
||||||
|
|
||||||
@@ -34,10 +33,9 @@ namespace Content.IntegrationTests.Tests.Doors
|
|||||||
- type: Door
|
- type: Door
|
||||||
- type: Airlock
|
- type: Airlock
|
||||||
- type: Physics
|
- type: Physics
|
||||||
fixtures:
|
shapes:
|
||||||
- shape:
|
- !type:PhysShapeAabb
|
||||||
!type:PhysShapeAabb
|
bounds: ""-0.49,-0.49,0.49,0.49""
|
||||||
bounds: ""-0.49,-0.49,0.49,0.49""
|
|
||||||
mask:
|
mask:
|
||||||
- Impassable
|
- Impassable
|
||||||
";
|
";
|
||||||
@@ -113,9 +111,9 @@ namespace Content.IntegrationTests.Tests.Doors
|
|||||||
var mapManager = server.ResolveDependency<IMapManager>();
|
var mapManager = server.ResolveDependency<IMapManager>();
|
||||||
var entityManager = server.ResolveDependency<IEntityManager>();
|
var entityManager = server.ResolveDependency<IEntityManager>();
|
||||||
|
|
||||||
IPhysBody physBody = null;
|
|
||||||
IEntity physicsDummy = null;
|
IEntity physicsDummy = null;
|
||||||
IEntity airlock = null;
|
IEntity airlock = null;
|
||||||
|
TestController controller = null;
|
||||||
ServerDoorComponent doorComponent = null;
|
ServerDoorComponent doorComponent = null;
|
||||||
|
|
||||||
var physicsDummyStartingX = -1;
|
var physicsDummyStartingX = -1;
|
||||||
@@ -130,7 +128,9 @@ namespace Content.IntegrationTests.Tests.Doors
|
|||||||
|
|
||||||
airlock = entityManager.SpawnEntity("AirlockDummy", new MapCoordinates((0, 0), mapId));
|
airlock = entityManager.SpawnEntity("AirlockDummy", new MapCoordinates((0, 0), mapId));
|
||||||
|
|
||||||
Assert.True(physicsDummy.TryGetComponent(out physBody));
|
Assert.True(physicsDummy.TryGetComponent(out IPhysicsComponent physics));
|
||||||
|
|
||||||
|
controller = physics.EnsureController<TestController>();
|
||||||
|
|
||||||
Assert.True(airlock.TryGetComponent(out doorComponent));
|
Assert.True(airlock.TryGetComponent(out doorComponent));
|
||||||
Assert.That(doorComponent.State, Is.EqualTo(SharedDoorComponent.DoorState.Closed));
|
Assert.That(doorComponent.State, Is.EqualTo(SharedDoorComponent.DoorState.Closed));
|
||||||
@@ -139,13 +139,12 @@ namespace Content.IntegrationTests.Tests.Doors
|
|||||||
await server.WaitIdleAsync();
|
await server.WaitIdleAsync();
|
||||||
|
|
||||||
// Push the human towards the airlock
|
// Push the human towards the airlock
|
||||||
Assert.That(physBody != null);
|
controller.LinearVelocity = (0.5f, 0);
|
||||||
physBody.LinearVelocity = (0.5f, 0);
|
|
||||||
|
|
||||||
for (var i = 0; i < 240; i += 10)
|
for (var i = 0; i < 240; i += 10)
|
||||||
{
|
{
|
||||||
// Keep the airlock awake so they collide
|
// Keep the airlock awake so they collide
|
||||||
airlock.GetComponent<IPhysBody>().WakeBody();
|
airlock.GetComponent<IPhysicsComponent>().WakeBody();
|
||||||
|
|
||||||
// Ensure that it is still closed
|
// Ensure that it is still closed
|
||||||
Assert.That(doorComponent.State, Is.EqualTo(SharedDoorComponent.DoorState.Closed));
|
Assert.That(doorComponent.State, Is.EqualTo(SharedDoorComponent.DoorState.Closed));
|
||||||
@@ -160,5 +159,7 @@ namespace Content.IntegrationTests.Tests.Doors
|
|||||||
// Blocked by the airlock
|
// Blocked by the airlock
|
||||||
Assert.That(physicsDummy.Transform.MapPosition.X, Is.Negative.Or.Zero);
|
Assert.That(physicsDummy.Transform.MapPosition.X, Is.Negative.Or.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class TestController : VirtualController { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using NUnit.Framework;
|
|||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
|
|
||||||
namespace Content.IntegrationTests.Tests.GameObjects.Components.Movement
|
namespace Content.IntegrationTests.Tests.GameObjects.Components.Movement
|
||||||
{
|
{
|
||||||
@@ -60,12 +59,15 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Movement
|
|||||||
// Now let's make the player enter a climbing transitioning state.
|
// Now let's make the player enter a climbing transitioning state.
|
||||||
climbing.IsClimbing = true;
|
climbing.IsClimbing = true;
|
||||||
climbing.TryMoveTo(human.Transform.WorldPosition, table.Transform.WorldPosition);
|
climbing.TryMoveTo(human.Transform.WorldPosition, table.Transform.WorldPosition);
|
||||||
var body = human.GetComponent<IPhysBody>();
|
var body = human.GetComponent<IPhysicsComponent>();
|
||||||
// TODO: Check it's climbing
|
|
||||||
|
Assert.That(body.HasController<ClimbController>(), "Player has no ClimbController");
|
||||||
|
|
||||||
// Force the player out of climb state. It should immediately remove the ClimbController.
|
// Force the player out of climb state. It should immediately remove the ClimbController.
|
||||||
climbing.IsClimbing = false;
|
climbing.IsClimbing = false;
|
||||||
|
|
||||||
|
Assert.That(!body.HasController<ClimbController>(), "Player wrongly has a ClimbController");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await server.WaitIdleAsync();
|
await server.WaitIdleAsync();
|
||||||
|
|||||||
79
Content.IntegrationTests/Tests/Pulling/PullTest.cs
Normal file
79
Content.IntegrationTests/Tests/Pulling/PullTest.cs
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
using System.Threading.Tasks;
|
||||||
|
using Content.Server.GameObjects.Components.Pulling;
|
||||||
|
using Content.Shared.GameObjects.Components.Pulling;
|
||||||
|
using Content.Shared.Physics.Pull;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Map;
|
||||||
|
|
||||||
|
namespace Content.IntegrationTests.Tests.Pulling
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
[TestOf(typeof(SharedPullableComponent))]
|
||||||
|
[TestOf(typeof(SharedPullerComponent))]
|
||||||
|
[TestOf(typeof(PullController))]
|
||||||
|
public class PullTest : ContentIntegrationTest
|
||||||
|
{
|
||||||
|
private const string Prototypes = @"
|
||||||
|
- type: entity
|
||||||
|
name: PullTestPullerDummy
|
||||||
|
id: PullTestPullerDummy
|
||||||
|
components:
|
||||||
|
- type: Puller
|
||||||
|
- type: Physics
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
name: PullTestPullableDummy
|
||||||
|
id: PullTestPullableDummy
|
||||||
|
components:
|
||||||
|
- type: Pullable
|
||||||
|
- type: Physics
|
||||||
|
";
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task AnchoredNoPullTest()
|
||||||
|
{
|
||||||
|
var options = new ServerContentIntegrationOption {ExtraPrototypes = Prototypes};
|
||||||
|
var server = StartServerDummyTicker(options);
|
||||||
|
|
||||||
|
await server.WaitIdleAsync();
|
||||||
|
|
||||||
|
var mapManager = server.ResolveDependency<IMapManager>();
|
||||||
|
var entityManager = server.ResolveDependency<IEntityManager>();
|
||||||
|
|
||||||
|
await server.WaitAssertion(() =>
|
||||||
|
{
|
||||||
|
mapManager.CreateNewMapEntity(MapId.Nullspace);
|
||||||
|
|
||||||
|
var pullerEntity = entityManager.SpawnEntity("PullTestPullerDummy", MapCoordinates.Nullspace);
|
||||||
|
var pullableEntity = entityManager.SpawnEntity("PullTestPullableDummy", MapCoordinates.Nullspace);
|
||||||
|
|
||||||
|
var puller = pullerEntity.GetComponent<SharedPullerComponent>();
|
||||||
|
var pullable = pullableEntity.GetComponent<PullableComponent>();
|
||||||
|
var pullablePhysics = pullableEntity.GetComponent<PhysicsComponent>();
|
||||||
|
|
||||||
|
pullablePhysics.Anchored = false;
|
||||||
|
|
||||||
|
Assert.That(pullable.TryStartPull(puller.Owner));
|
||||||
|
Assert.That(pullable.Puller, Is.EqualTo(puller.Owner));
|
||||||
|
Assert.That(pullable.BeingPulled);
|
||||||
|
|
||||||
|
Assert.That(puller.Pulling, Is.EqualTo(pullable.Owner));
|
||||||
|
|
||||||
|
Assert.That(pullable.TryStopPull);
|
||||||
|
Assert.That(pullable.Puller, Is.Null);
|
||||||
|
Assert.That(pullable.BeingPulled, Is.False);
|
||||||
|
|
||||||
|
Assert.That(puller.Pulling, Is.Null);
|
||||||
|
|
||||||
|
pullablePhysics.Anchored = true;
|
||||||
|
|
||||||
|
Assert.That(pullable.TryStartPull(puller.Owner), Is.False);
|
||||||
|
Assert.That(pullable.Puller, Is.Null);
|
||||||
|
Assert.That(pullable.BeingPulled, Is.False);
|
||||||
|
|
||||||
|
Assert.That(puller.Pulling, Is.Null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,6 @@ using Content.Shared.Utility;
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Physics.Broadphase;
|
|
||||||
|
|
||||||
namespace Content.IntegrationTests.Tests.Utility
|
namespace Content.IntegrationTests.Tests.Utility
|
||||||
{
|
{
|
||||||
@@ -21,10 +20,9 @@ namespace Content.IntegrationTests.Tests.Utility
|
|||||||
name: {BlockerDummyId}
|
name: {BlockerDummyId}
|
||||||
components:
|
components:
|
||||||
- type: Physics
|
- type: Physics
|
||||||
fixtures:
|
shapes:
|
||||||
- shape:
|
- !type:PhysShapeAabb
|
||||||
!type:PhysShapeAabb
|
bounds: ""-0.49,-0.49,0.49,0.49""
|
||||||
bounds: ""-0.49,-0.49,0.49,0.49""
|
|
||||||
mask:
|
mask:
|
||||||
- Impassable
|
- Impassable
|
||||||
";
|
";
|
||||||
@@ -39,7 +37,6 @@ namespace Content.IntegrationTests.Tests.Utility
|
|||||||
|
|
||||||
var sMapManager = server.ResolveDependency<IMapManager>();
|
var sMapManager = server.ResolveDependency<IMapManager>();
|
||||||
var sEntityManager = server.ResolveDependency<IEntityManager>();
|
var sEntityManager = server.ResolveDependency<IEntityManager>();
|
||||||
var broady = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<SharedBroadPhaseSystem>();
|
|
||||||
|
|
||||||
await server.WaitAssertion(() =>
|
await server.WaitAssertion(() =>
|
||||||
{
|
{
|
||||||
@@ -61,7 +58,6 @@ namespace Content.IntegrationTests.Tests.Utility
|
|||||||
|
|
||||||
// Spawn a blocker with an Impassable mask
|
// Spawn a blocker with an Impassable mask
|
||||||
sEntityManager.SpawnEntity(BlockerDummyId, entityCoordinates);
|
sEntityManager.SpawnEntity(BlockerDummyId, entityCoordinates);
|
||||||
broady.Update(0.016f);
|
|
||||||
|
|
||||||
// Cannot spawn something with an Impassable layer
|
// Cannot spawn something with an Impassable layer
|
||||||
Assert.Null(sEntityManager.SpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.Impassable));
|
Assert.Null(sEntityManager.SpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.Impassable));
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ using Robust.Shared.IoC;
|
|||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Physics.Broadphase;
|
|
||||||
|
|
||||||
namespace Content.Server.AI.Utils
|
namespace Content.Server.AI.Utils
|
||||||
{
|
{
|
||||||
@@ -41,7 +40,7 @@ namespace Content.Server.AI.Utils
|
|||||||
angle.ToVec(),
|
angle.ToVec(),
|
||||||
(int)(CollisionGroup.Opaque | CollisionGroup.Impassable | CollisionGroup.MobImpassable));
|
(int)(CollisionGroup.Opaque | CollisionGroup.Impassable | CollisionGroup.MobImpassable));
|
||||||
|
|
||||||
var rayCastResults = EntitySystem.Get<SharedBroadPhaseSystem>().IntersectRay(owner.Transform.MapID, ray, range, owner).ToList();
|
var rayCastResults = IoCManager.Resolve<IPhysicsManager>().IntersectRay(owner.Transform.MapID, ray, range, owner).ToList();
|
||||||
|
|
||||||
return rayCastResults.Count > 0 && rayCastResults[0].HitEntity == target;
|
return rayCastResults.Count > 0 && rayCastResults[0].HitEntity == target;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ using Robust.Shared.Enums;
|
|||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
|
||||||
using Robust.Shared.Physics;
|
|
||||||
|
|
||||||
namespace Content.Server.Administration.Commands
|
namespace Content.Server.Administration.Commands
|
||||||
{
|
{
|
||||||
@@ -115,9 +113,9 @@ namespace Content.Server.Administration.Commands
|
|||||||
if (found.GetGridId(entityManager) != GridId.Invalid)
|
if (found.GetGridId(entityManager) != GridId.Invalid)
|
||||||
{
|
{
|
||||||
player.AttachedEntity.Transform.Coordinates = found;
|
player.AttachedEntity.Transform.Coordinates = found;
|
||||||
if (player.AttachedEntity.TryGetComponent(out IPhysBody physics))
|
if (player.AttachedEntity.TryGetComponent(out IPhysicsComponent physics))
|
||||||
{
|
{
|
||||||
physics.LinearVelocity = Vector2.Zero;
|
physics.Stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
70
Content.Server/Atmos/HighPressureMovementController.cs
Normal file
70
Content.Server/Atmos/HighPressureMovementController.cs
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#nullable enable
|
||||||
|
using System;
|
||||||
|
using Content.Server.GameObjects.Components.Atmos;
|
||||||
|
using Content.Shared.Atmos;
|
||||||
|
using Content.Shared.Physics;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Map;
|
||||||
|
using Robust.Shared.Maths;
|
||||||
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
|
namespace Content.Server.Atmos
|
||||||
|
{
|
||||||
|
public class HighPressureMovementController : FrictionController
|
||||||
|
{
|
||||||
|
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||||
|
public override IPhysicsComponent? ControlledComponent { protected get; set; }
|
||||||
|
|
||||||
|
private const float MoveForcePushRatio = 1f;
|
||||||
|
private const float MoveForceForcePushRatio = 1f;
|
||||||
|
private const float ProbabilityOffset = 25f;
|
||||||
|
private const float ProbabilityBasePercent = 10f;
|
||||||
|
private const float ThrowForce = 100f;
|
||||||
|
|
||||||
|
public void ExperiencePressureDifference(int cycle, float pressureDifference, AtmosDirection direction,
|
||||||
|
float pressureResistanceProbDelta, EntityCoordinates throwTarget)
|
||||||
|
{
|
||||||
|
if (ControlledComponent == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// TODO ATMOS stuns?
|
||||||
|
|
||||||
|
var transform = ControlledComponent.Owner.Transform;
|
||||||
|
var pressureComponent = ControlledComponent.Owner.GetComponent<MovedByPressureComponent>();
|
||||||
|
var maxForce = MathF.Sqrt(pressureDifference) * 2.25f;
|
||||||
|
var moveProb = 100f;
|
||||||
|
|
||||||
|
if (pressureComponent.PressureResistance > 0)
|
||||||
|
moveProb = MathF.Abs((pressureDifference / pressureComponent.PressureResistance * ProbabilityBasePercent) -
|
||||||
|
ProbabilityOffset);
|
||||||
|
|
||||||
|
if (moveProb > ProbabilityOffset && _robustRandom.Prob(MathF.Min(moveProb / 100f, 1f))
|
||||||
|
&& !float.IsPositiveInfinity(pressureComponent.MoveResist)
|
||||||
|
&& (!ControlledComponent.Anchored
|
||||||
|
&& (maxForce >= (pressureComponent.MoveResist * MoveForcePushRatio)))
|
||||||
|
|| (ControlledComponent.Anchored && (maxForce >= (pressureComponent.MoveResist * MoveForceForcePushRatio))))
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
if (maxForce > ThrowForce)
|
||||||
|
{
|
||||||
|
if (throwTarget != EntityCoordinates.Invalid)
|
||||||
|
{
|
||||||
|
var moveForce = maxForce * MathHelper.Clamp(moveProb, 0, 100) / 150f;
|
||||||
|
var pos = ((throwTarget.Position - transform.Coordinates.Position).Normalized + direction.ToDirection().ToVec()).Normalized;
|
||||||
|
LinearVelocity = pos * moveForce;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var moveForce = MathF.Min(maxForce * MathHelper.Clamp(moveProb, 0, 100) / 2500f, 20f);
|
||||||
|
LinearVelocity = direction.ToDirection().ToVec() * moveForce;
|
||||||
|
}
|
||||||
|
|
||||||
|
pressureComponent.LastHighPressureMovementAirCycle = cycle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,6 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -194,12 +193,14 @@ namespace Content.Server.Atmos
|
|||||||
|
|
||||||
foreach (var entity in _gridTileLookupSystem.GetEntitiesIntersecting(GridIndex, GridIndices))
|
foreach (var entity in _gridTileLookupSystem.GetEntitiesIntersecting(GridIndex, GridIndices))
|
||||||
{
|
{
|
||||||
if (!entity.TryGetComponent(out IPhysBody physics)
|
if (!entity.TryGetComponent(out IPhysicsComponent physics)
|
||||||
|| !entity.IsMovedByPressure(out var pressure)
|
|| !entity.IsMovedByPressure(out var pressure)
|
||||||
|| entity.IsInContainer())
|
|| entity.IsInContainer())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var pressureMovements = physics.Entity.EnsureComponent<MovedByPressureComponent>();
|
physics.WakeBody();
|
||||||
|
|
||||||
|
var pressureMovements = physics.EnsureController<HighPressureMovementController>();
|
||||||
if (pressure.LastHighPressureMovementAirCycle < _gridAtmosphereComponent.UpdateCounter)
|
if (pressure.LastHighPressureMovementAirCycle < _gridAtmosphereComponent.UpdateCounter)
|
||||||
{
|
{
|
||||||
pressureMovements.ExperiencePressureDifference(_gridAtmosphereComponent.UpdateCounter, PressureDifference, _pressureDirection, 0, PressureSpecificTarget?.GridIndices.ToEntityCoordinates(GridIndex, _mapManager) ?? EntityCoordinates.Invalid);
|
pressureMovements.ExperiencePressureDifference(_gridAtmosphereComponent.UpdateCounter, PressureDifference, _pressureDirection, 0, PressureSpecificTarget?.GridIndices.ToEntityCoordinates(GridIndex, _mapManager) ?? EntityCoordinates.Invalid);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using Content.Server.GameObjects.Components.Mobs;
|
|||||||
using Content.Server.GameObjects.Components.Movement;
|
using Content.Server.GameObjects.Components.Movement;
|
||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
using Content.Shared.GameObjects.Components.Mobs.Speech;
|
using Content.Shared.GameObjects.Components.Mobs.Speech;
|
||||||
using Content.Shared.GameObjects.Components.Movement;
|
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
@@ -56,8 +55,7 @@ namespace Content.Server.Commands
|
|||||||
Timer.Spawn(100, () =>
|
Timer.Spawn(100, () =>
|
||||||
{
|
{
|
||||||
entity.EnsureComponent<MindComponent>();
|
entity.EnsureComponent<MindComponent>();
|
||||||
entity.EnsureComponent<SharedPlayerInputMoverComponent>();
|
entity.EnsureComponent<PlayerInputMoverComponent>();
|
||||||
entity.EnsureComponent<SharedPlayerMobMoverComponent>();
|
|
||||||
entity.EnsureComponent<SharedSpeechComponent>();
|
entity.EnsureComponent<SharedSpeechComponent>();
|
||||||
entity.EnsureComponent<SharedEmotingComponent>();
|
entity.EnsureComponent<SharedEmotingComponent>();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,234 +0,0 @@
|
|||||||
// MIT License
|
|
||||||
|
|
||||||
// Copyright (c) 2019 Erin Catto
|
|
||||||
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
|
|
||||||
|
|
||||||
using Content.Server.Administration;
|
|
||||||
using Content.Shared.Administration;
|
|
||||||
using Content.Shared.Physics;
|
|
||||||
using Robust.Server.Player;
|
|
||||||
using Robust.Shared.Console;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Map;
|
|
||||||
using Robust.Shared.Maths;
|
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Physics.Dynamics;
|
|
||||||
using Robust.Shared.Physics.Dynamics.Shapes;
|
|
||||||
using Robust.Shared.Timing;
|
|
||||||
|
|
||||||
#nullable enable
|
|
||||||
|
|
||||||
namespace Content.Server.Commands.Physics
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* I didn't use blueprints because this is way easier to iterate upon as I can shit out testbed upon testbed on new maps
|
|
||||||
* and never have to leave my debugger.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Copies of Box2D's physics testbed for debugging.
|
|
||||||
/// </summary>
|
|
||||||
[AdminCommand(AdminFlags.Mapping)]
|
|
||||||
public class TestbedCommand : IConsoleCommand
|
|
||||||
{
|
|
||||||
public string Command => "testbed";
|
|
||||||
public string Description => "Loads a physics testbed and teleports your player there";
|
|
||||||
public string Help => $"{Command} <mapid> <test>";
|
|
||||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
||||||
{
|
|
||||||
if (args.Length != 2)
|
|
||||||
{
|
|
||||||
shell.WriteLine("Require 2 args for testbed!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
|
||||||
|
|
||||||
if (!int.TryParse(args[0], out var mapInt))
|
|
||||||
{
|
|
||||||
shell.WriteLine($"Unable to parse map {args[0]}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var mapId = new MapId(mapInt);
|
|
||||||
if (!mapManager.MapExists(mapId))
|
|
||||||
{
|
|
||||||
shell.WriteLine("Unable to find map {mapId}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shell.Player == null)
|
|
||||||
{
|
|
||||||
shell.WriteLine("No player found");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var player = (IPlayerSession) shell.Player;
|
|
||||||
|
|
||||||
switch (args[1])
|
|
||||||
{
|
|
||||||
case "boxstack":
|
|
||||||
SetupPlayer(mapId, shell, player, mapManager);
|
|
||||||
CreateBoxStack(mapId);
|
|
||||||
break;
|
|
||||||
case "circlestack":
|
|
||||||
SetupPlayer(mapId, shell, player, mapManager);
|
|
||||||
CreateCircleStack(mapId);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
shell.WriteLine($"testbed {args[0]} not found!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
shell.WriteLine($"Testbed on map {mapId}");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetupPlayer(MapId mapId, IConsoleShell shell, IPlayerSession? player, IMapManager mapManager)
|
|
||||||
{
|
|
||||||
var pauseManager = IoCManager.Resolve<IPauseManager>();
|
|
||||||
pauseManager.SetMapPaused(mapId, false);
|
|
||||||
var map = EntitySystem.Get<SharedPhysicsSystem>().Maps[mapId].Gravity = new Vector2(0, -4.9f);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CreateBoxStack(MapId mapId)
|
|
||||||
{
|
|
||||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
|
||||||
|
|
||||||
var ground = entityManager.SpawnEntity("BlankEntity", new MapCoordinates(0, 0, mapId)).AddComponent<PhysicsComponent>();
|
|
||||||
|
|
||||||
var horizontal = new EdgeShape(new Vector2(-20, 0), new Vector2(20, 0));
|
|
||||||
var horizontalFixture = new Fixture(ground, horizontal)
|
|
||||||
{
|
|
||||||
CollisionLayer = (int) CollisionGroup.Impassable,
|
|
||||||
CollisionMask = (int) CollisionGroup.Impassable,
|
|
||||||
Hard = true
|
|
||||||
};
|
|
||||||
ground.AddFixture(horizontalFixture);
|
|
||||||
|
|
||||||
var vertical = new EdgeShape(new Vector2(10, 0), new Vector2(10, 10));
|
|
||||||
var verticalFixture = new Fixture(ground, vertical)
|
|
||||||
{
|
|
||||||
CollisionLayer = (int) CollisionGroup.Impassable,
|
|
||||||
CollisionMask = (int) CollisionGroup.Impassable,
|
|
||||||
Hard = true
|
|
||||||
};
|
|
||||||
ground.AddFixture(verticalFixture);
|
|
||||||
|
|
||||||
var xs = new[]
|
|
||||||
{
|
|
||||||
0.0f, -10.0f, -5.0f, 5.0f, 10.0f
|
|
||||||
};
|
|
||||||
|
|
||||||
var columnCount = 1;
|
|
||||||
var rowCount = 15;
|
|
||||||
PolygonShape shape;
|
|
||||||
|
|
||||||
for (var j = 0; j < columnCount; j++)
|
|
||||||
{
|
|
||||||
for (var i = 0; i < rowCount; i++)
|
|
||||||
{
|
|
||||||
var x = 0.0f;
|
|
||||||
|
|
||||||
var box = entityManager.SpawnEntity("BlankEntity",
|
|
||||||
new MapCoordinates(new Vector2(xs[j] + x, 0.55f + 2.1f * i), mapId)).AddComponent<PhysicsComponent>();
|
|
||||||
|
|
||||||
box.BodyType = BodyType.Dynamic;
|
|
||||||
box.SleepingAllowed = false;
|
|
||||||
shape = new PolygonShape();
|
|
||||||
shape.SetAsBox(0.5f, 0.5f);
|
|
||||||
box.FixedRotation = false;
|
|
||||||
// TODO: Need to detect shape and work out if we need to use fixedrotation
|
|
||||||
|
|
||||||
var fixture = new Fixture(box, shape)
|
|
||||||
{
|
|
||||||
CollisionMask = (int) CollisionGroup.Impassable,
|
|
||||||
CollisionLayer = (int) CollisionGroup.Impassable,
|
|
||||||
Hard = true,
|
|
||||||
};
|
|
||||||
box.AddFixture(fixture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CreateCircleStack(MapId mapId)
|
|
||||||
{
|
|
||||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
|
||||||
|
|
||||||
// TODO: Need a blank entity we can spawn for testbed.
|
|
||||||
var ground = entityManager.SpawnEntity("BlankEntity", new MapCoordinates(0, 0, mapId)).AddComponent<PhysicsComponent>();
|
|
||||||
|
|
||||||
var horizontal = new EdgeShape(new Vector2(-20, 0), new Vector2(20, 0));
|
|
||||||
var horizontalFixture = new Fixture(ground, horizontal)
|
|
||||||
{
|
|
||||||
CollisionLayer = (int) CollisionGroup.Impassable,
|
|
||||||
CollisionMask = (int) CollisionGroup.Impassable,
|
|
||||||
Hard = true
|
|
||||||
};
|
|
||||||
ground.AddFixture(horizontalFixture);
|
|
||||||
|
|
||||||
var vertical = new EdgeShape(new Vector2(10, 0), new Vector2(10, 10));
|
|
||||||
var verticalFixture = new Fixture(ground, vertical)
|
|
||||||
{
|
|
||||||
CollisionLayer = (int) CollisionGroup.Impassable,
|
|
||||||
CollisionMask = (int) CollisionGroup.Impassable,
|
|
||||||
Hard = true
|
|
||||||
};
|
|
||||||
ground.AddFixture(verticalFixture);
|
|
||||||
|
|
||||||
var xs = new[]
|
|
||||||
{
|
|
||||||
0.0f, -10.0f, -5.0f, 5.0f, 10.0f
|
|
||||||
};
|
|
||||||
|
|
||||||
var columnCount = 1;
|
|
||||||
var rowCount = 15;
|
|
||||||
PhysShapeCircle shape;
|
|
||||||
|
|
||||||
for (var j = 0; j < columnCount; j++)
|
|
||||||
{
|
|
||||||
for (var i = 0; i < rowCount; i++)
|
|
||||||
{
|
|
||||||
var x = 0.0f;
|
|
||||||
|
|
||||||
var box = entityManager.SpawnEntity("BlankEntity",
|
|
||||||
new MapCoordinates(new Vector2(xs[j] + x, 0.55f + 2.1f * i), mapId)).AddComponent<PhysicsComponent>();
|
|
||||||
|
|
||||||
box.BodyType = BodyType.Dynamic;
|
|
||||||
box.SleepingAllowed = false;
|
|
||||||
shape = new PhysShapeCircle {Radius = 0.5f};
|
|
||||||
box.FixedRotation = false;
|
|
||||||
// TODO: Need to detect shape and work out if we need to use fixedrotation
|
|
||||||
|
|
||||||
var fixture = new Fixture(box, shape)
|
|
||||||
{
|
|
||||||
CollisionMask = (int) CollisionGroup.Impassable,
|
|
||||||
CollisionLayer = (int) CollisionGroup.Impassable,
|
|
||||||
Hard = true,
|
|
||||||
};
|
|
||||||
box.AddFixture(fixture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,6 @@ using System.Threading.Tasks;
|
|||||||
using Content.Shared.Construction;
|
using Content.Shared.Construction;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
namespace Content.Server.Construction.Completions
|
namespace Content.Server.Construction.Completions
|
||||||
@@ -20,9 +19,9 @@ namespace Content.Server.Construction.Completions
|
|||||||
|
|
||||||
public async Task PerformAction(IEntity entity, IEntity? user)
|
public async Task PerformAction(IEntity entity, IEntity? user)
|
||||||
{
|
{
|
||||||
if (!entity.TryGetComponent(out IPhysBody? physics)) return;
|
if (!entity.TryGetComponent(out IPhysicsComponent? physics)) return;
|
||||||
|
|
||||||
physics.BodyType = Value ? BodyType.Static : BodyType.Dynamic;
|
physics.Anchored = Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
using Content.Shared.Construction;
|
using Content.Shared.Construction;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
@@ -20,21 +19,21 @@ namespace Content.Server.Construction.Conditions
|
|||||||
|
|
||||||
public async Task<bool> Condition(IEntity entity)
|
public async Task<bool> Condition(IEntity entity)
|
||||||
{
|
{
|
||||||
if (!entity.TryGetComponent(out IPhysBody physics)) return false;
|
if (!entity.TryGetComponent(out IPhysicsComponent physics)) return false;
|
||||||
|
|
||||||
return (physics.BodyType == BodyType.Static && Anchored) || (physics.BodyType != BodyType.Static && !Anchored);
|
return physics.Anchored == Anchored;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DoExamine(IEntity entity, FormattedMessage message, bool inDetailsRange)
|
public bool DoExamine(IEntity entity, FormattedMessage message, bool inDetailsRange)
|
||||||
{
|
{
|
||||||
if (!entity.TryGetComponent(out IPhysBody physics)) return false;
|
if (!entity.TryGetComponent(out IPhysicsComponent physics)) return false;
|
||||||
|
|
||||||
switch (Anchored)
|
switch (Anchored)
|
||||||
{
|
{
|
||||||
case true when physics.BodyType == BodyType.Static:
|
case true when !physics.Anchored:
|
||||||
message.AddMarkup("First, anchor it.\n");
|
message.AddMarkup("First, anchor it.\n");
|
||||||
return true;
|
return true;
|
||||||
case false when physics.BodyType == BodyType.Static:
|
case false when physics.Anchored:
|
||||||
message.AddMarkup("First, unanchor it.\n");
|
message.AddMarkup("First, unanchor it.\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ namespace Content.Server.Explosions
|
|||||||
|
|
||||||
var impassableEntities = new List<Tuple<IEntity, float>>();
|
var impassableEntities = new List<Tuple<IEntity, float>>();
|
||||||
var nonImpassableEntities = new List<Tuple<IEntity, float>>();
|
var nonImpassableEntities = new List<Tuple<IEntity, float>>();
|
||||||
// TODO: Given this seems to rely on physics it should just query directly like everything else.
|
|
||||||
|
|
||||||
// The entities are paired with their distance to the epicenter
|
// The entities are paired with their distance to the epicenter
|
||||||
// and splitted into two lists based on if they are Impassable or not
|
// and splitted into two lists based on if they are Impassable or not
|
||||||
@@ -93,7 +92,7 @@ namespace Content.Server.Explosions
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entity.TryGetComponent(out PhysicsComponent? body) || body.Fixtures.Count < 1)
|
if (!entity.TryGetComponent(out IPhysicsComponent? body) || body.PhysicsShapes.Count < 1)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using Content.Server.Utility;
|
|||||||
using Content.Shared.GameObjects.Components.Interactable;
|
using Content.Shared.GameObjects.Components.Interactable;
|
||||||
using Content.Shared.Interfaces.GameObjects.Components;
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -43,7 +42,7 @@ namespace Content.Server.GameObjects.Components
|
|||||||
/// <returns>true if it is valid, false otherwise</returns>
|
/// <returns>true if it is valid, false otherwise</returns>
|
||||||
private async Task<bool> Valid(IEntity user, IEntity? utilizing, [NotNullWhen(true)] bool force = false)
|
private async Task<bool> Valid(IEntity user, IEntity? utilizing, [NotNullWhen(true)] bool force = false)
|
||||||
{
|
{
|
||||||
if (!Owner.HasComponent<IPhysBody>())
|
if (!Owner.HasComponent<IPhysicsComponent>())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -75,8 +74,8 @@ namespace Content.Server.GameObjects.Components
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var physics = Owner.GetComponent<IPhysBody>();
|
var physics = Owner.GetComponent<IPhysicsComponent>();
|
||||||
physics.BodyType = BodyType.Static;
|
physics.Anchored = true;
|
||||||
|
|
||||||
if (Owner.TryGetComponent(out PullableComponent? pullableComponent))
|
if (Owner.TryGetComponent(out PullableComponent? pullableComponent))
|
||||||
{
|
{
|
||||||
@@ -106,8 +105,8 @@ namespace Content.Server.GameObjects.Components
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var physics = Owner.GetComponent<IPhysBody>();
|
var physics = Owner.GetComponent<IPhysicsComponent>();
|
||||||
physics.BodyType = BodyType.Dynamic;
|
physics.Anchored = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -121,12 +120,12 @@ namespace Content.Server.GameObjects.Components
|
|||||||
/// <returns>true if toggled, false otherwise</returns>
|
/// <returns>true if toggled, false otherwise</returns>
|
||||||
private async Task<bool> TryToggleAnchor(IEntity user, IEntity? utilizing = null, bool force = false)
|
private async Task<bool> TryToggleAnchor(IEntity user, IEntity? utilizing = null, bool force = false)
|
||||||
{
|
{
|
||||||
if (!Owner.TryGetComponent(out IPhysBody? physics))
|
if (!Owner.TryGetComponent(out IPhysicsComponent? physics))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return physics.BodyType == BodyType.Static ?
|
return physics.Anchored ?
|
||||||
await TryUnAnchor(user, utilizing, force) :
|
await TryUnAnchor(user, utilizing, force) :
|
||||||
await TryAnchor(user, utilizing, force);
|
await TryAnchor(user, utilizing, force);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ using Content.Shared.Interfaces.GameObjects.Components;
|
|||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -135,19 +134,19 @@ namespace Content.Server.GameObjects.Components.Atmos
|
|||||||
}
|
}
|
||||||
|
|
||||||
var entity = Owner.EntityManager.GetEntity(uid);
|
var entity = Owner.EntityManager.GetEntity(uid);
|
||||||
var physics = Owner.GetComponent<IPhysBody>();
|
var physics = Owner.GetComponent<IPhysicsComponent>();
|
||||||
var otherPhysics = entity.GetComponent<IPhysBody>();
|
var otherPhysics = entity.GetComponent<IPhysicsComponent>();
|
||||||
|
|
||||||
if (!physics.GetWorldAABB().Intersects(otherPhysics.GetWorldAABB()))
|
if (!physics.WorldAABB.Intersects(otherPhysics.WorldAABB))
|
||||||
{
|
{
|
||||||
_collided.Remove(uid);
|
_collided.Remove(uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CollideWith(IPhysBody ourBody, IPhysBody otherBody)
|
public void CollideWith(IEntity collidedWith)
|
||||||
{
|
{
|
||||||
if (!otherBody.Entity.TryGetComponent(out FlammableComponent otherFlammable))
|
if (!collidedWith.TryGetComponent(out FlammableComponent otherFlammable))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!FireSpread || !otherFlammable.FireSpread)
|
if (!FireSpread || !otherFlammable.FireSpread)
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ using Content.Shared.Interfaces.GameObjects.Components;
|
|||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Atmos
|
namespace Content.Server.GameObjects.Components.Atmos
|
||||||
{
|
{
|
||||||
@@ -41,7 +40,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
|||||||
public GasMixture Air { get; set; } = default!;
|
public GasMixture Air { get; set; } = default!;
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public bool Anchored => !Owner.TryGetComponent<IPhysBody>(out var physics) || physics.BodyType == BodyType.Static;
|
public bool Anchored => !Owner.TryGetComponent<IPhysicsComponent>(out var physics) || physics.Anchored;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The floor connector port that the canister is attached to.
|
/// The floor connector port that the canister is attached to.
|
||||||
@@ -78,7 +77,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
|||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
if (Owner.TryGetComponent<IPhysBody>(out var physics))
|
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
|
||||||
{
|
{
|
||||||
AnchorUpdate();
|
AnchorUpdate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,6 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System;
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using Content.Shared.Atmos;
|
|
||||||
using Content.Shared.GameObjects.Components.Mobs.State;
|
|
||||||
using Content.Shared.Physics;
|
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Map;
|
|
||||||
using Robust.Shared.Maths;
|
|
||||||
using Robust.Shared.Random;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -17,16 +9,8 @@ namespace Content.Server.GameObjects.Components.Atmos
|
|||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class MovedByPressureComponent : Component
|
public class MovedByPressureComponent : Component
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
|
||||||
|
|
||||||
public override string Name => "MovedByPressure";
|
public override string Name => "MovedByPressure";
|
||||||
|
|
||||||
private const float MoveForcePushRatio = 1f;
|
|
||||||
private const float MoveForceForcePushRatio = 1f;
|
|
||||||
private const float ProbabilityOffset = 25f;
|
|
||||||
private const float ProbabilityBasePercent = 10f;
|
|
||||||
private const float ThrowForce = 100f;
|
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public bool Enabled { get; set; } = true;
|
public bool Enabled { get; set; } = true;
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
@@ -43,77 +27,6 @@ namespace Content.Server.GameObjects.Components.Atmos
|
|||||||
serializer.DataField(this, x => PressureResistance, "pressureResistance", 1f);
|
serializer.DataField(this, x => PressureResistance, "pressureResistance", 1f);
|
||||||
serializer.DataField(this, x => MoveResist, "moveResist", 100f);
|
serializer.DataField(this, x => MoveResist, "moveResist", 100f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ExperiencePressureDifference(int cycle, float pressureDifference, AtmosDirection direction,
|
|
||||||
float pressureResistanceProbDelta, EntityCoordinates throwTarget)
|
|
||||||
{
|
|
||||||
if (!Owner.TryGetComponent(out PhysicsComponent? physics))
|
|
||||||
return;
|
|
||||||
|
|
||||||
physics.WakeBody();
|
|
||||||
// TODO ATMOS stuns?
|
|
||||||
|
|
||||||
var transform = physics.Owner.Transform;
|
|
||||||
var maxForce = MathF.Sqrt(pressureDifference) * 2.25f;
|
|
||||||
var moveProb = 100f;
|
|
||||||
|
|
||||||
if (PressureResistance > 0)
|
|
||||||
moveProb = MathF.Abs((pressureDifference / PressureResistance * ProbabilityBasePercent) -
|
|
||||||
ProbabilityOffset);
|
|
||||||
|
|
||||||
if (moveProb > ProbabilityOffset && _robustRandom.Prob(MathF.Min(moveProb / 100f, 1f))
|
|
||||||
&& !float.IsPositiveInfinity(MoveResist)
|
|
||||||
&& (!physics.Anchored
|
|
||||||
&& (maxForce >= (MoveResist * MoveForcePushRatio)))
|
|
||||||
|| (physics.Anchored && (maxForce >= (MoveResist * MoveForceForcePushRatio))))
|
|
||||||
{
|
|
||||||
|
|
||||||
if (physics.Owner.HasComponent<IMobStateComponent>())
|
|
||||||
{
|
|
||||||
physics.BodyStatus = BodyStatus.InAir;
|
|
||||||
|
|
||||||
foreach (var fixture in physics.Fixtures)
|
|
||||||
{
|
|
||||||
fixture.CollisionMask &= ~(int) CollisionGroup.VaultImpassable;
|
|
||||||
}
|
|
||||||
|
|
||||||
Owner.SpawnTimer(2000, () =>
|
|
||||||
{
|
|
||||||
if (Deleted || !Owner.TryGetComponent(out PhysicsComponent? physicsComponent)) return;
|
|
||||||
|
|
||||||
// Uhh if you get race conditions good luck buddy.
|
|
||||||
if (physicsComponent.Owner.HasComponent<IMobStateComponent>())
|
|
||||||
{
|
|
||||||
physicsComponent.BodyStatus = BodyStatus.OnGround;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var fixture in physics.Fixtures)
|
|
||||||
{
|
|
||||||
fixture.CollisionMask |= (int) CollisionGroup.VaultImpassable;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxForce > ThrowForce)
|
|
||||||
{
|
|
||||||
// Vera please fix ;-;
|
|
||||||
if (throwTarget != EntityCoordinates.Invalid)
|
|
||||||
{
|
|
||||||
var moveForce = maxForce * MathHelper.Clamp(moveProb, 0, 100) / 15f;
|
|
||||||
var pos = ((throwTarget.Position - transform.Coordinates.Position).Normalized + direction.ToDirection().ToVec()).Normalized;
|
|
||||||
physics.ApplyLinearImpulse(pos * moveForce);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var moveForce = MathF.Min(maxForce * MathHelper.Clamp(moveProb, 0, 100) / 2500f, 20f);
|
|
||||||
physics.ApplyLinearImpulse(direction.ToDirection().ToVec() * moveForce);
|
|
||||||
}
|
|
||||||
|
|
||||||
LastHighPressureMovementAirCycle = cycle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MovedByPressureExtensions
|
public static class MovedByPressureExtensions
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
@@ -30,6 +29,8 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
|||||||
private float _timer;
|
private float _timer;
|
||||||
private EntityCoordinates _target;
|
private EntityCoordinates _target;
|
||||||
private bool _running;
|
private bool _running;
|
||||||
|
private Vector2 _direction;
|
||||||
|
private float _velocity;
|
||||||
private float _aliveTime;
|
private float _aliveTime;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
@@ -39,16 +40,18 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
|||||||
Owner.EnsureComponentWarn(out SolutionContainerComponent _);
|
Owner.EnsureComponentWarn(out SolutionContainerComponent _);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start(Vector2 dir, float speed, EntityCoordinates target, float aliveTime)
|
public void Start(Vector2 dir, float velocity, EntityCoordinates target, float aliveTime)
|
||||||
{
|
{
|
||||||
_running = true;
|
_running = true;
|
||||||
_target = target;
|
_target = target;
|
||||||
|
_direction = dir;
|
||||||
|
_velocity = velocity;
|
||||||
_aliveTime = aliveTime;
|
_aliveTime = aliveTime;
|
||||||
// Set Move
|
// Set Move
|
||||||
if (Owner.TryGetComponent(out PhysicsComponent physics))
|
if (Owner.TryGetComponent(out IPhysicsComponent physics))
|
||||||
{
|
{
|
||||||
physics.BodyStatus = BodyStatus.InAir;
|
var controller = physics.EnsureController<VaporController>();
|
||||||
physics.ApplyLinearImpulse(dir * speed);
|
controller.Move(_direction, _velocity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +72,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
|||||||
_timer += frameTime;
|
_timer += frameTime;
|
||||||
_reactTimer += frameTime;
|
_reactTimer += frameTime;
|
||||||
|
|
||||||
if (_reactTimer >= ReactTime)
|
if (_reactTimer >= ReactTime && Owner.TryGetComponent(out IPhysicsComponent physics))
|
||||||
{
|
{
|
||||||
_reactTimer = 0;
|
_reactTimer = 0;
|
||||||
var mapGrid = _mapManager.GetGrid(Owner.Transform.GridID);
|
var mapGrid = _mapManager.GetGrid(Owner.Transform.GridID);
|
||||||
@@ -87,6 +90,12 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
|||||||
if(!_reached && _target.TryDistance(Owner.EntityManager, Owner.Transform.Coordinates, out var distance) && distance <= 0.5f)
|
if(!_reached && _target.TryDistance(Owner.EntityManager, Owner.Transform.Coordinates, out var distance) && distance <= 0.5f)
|
||||||
{
|
{
|
||||||
_reached = true;
|
_reached = true;
|
||||||
|
|
||||||
|
if (Owner.TryGetComponent(out IPhysicsComponent coll))
|
||||||
|
{
|
||||||
|
var controller = coll.EnsureController<VaporController>();
|
||||||
|
controller.Stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contents.CurrentVolume == 0 || _timer > _aliveTime)
|
if (contents.CurrentVolume == 0 || _timer > _aliveTime)
|
||||||
@@ -118,17 +127,26 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICollideBehavior.CollideWith(IPhysBody ourBody, IPhysBody otherBody)
|
void ICollideBehavior.CollideWith(IEntity collidedWith)
|
||||||
{
|
{
|
||||||
if (!Owner.TryGetComponent(out SolutionContainerComponent contents))
|
if (!Owner.TryGetComponent(out SolutionContainerComponent contents))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
contents.Solution.DoEntityReaction(otherBody.Entity, ReactionMethod.Touch);
|
contents.Solution.DoEntityReaction(collidedWith, ReactionMethod.Touch);
|
||||||
|
|
||||||
// Check for collision with a impassable object (e.g. wall) and stop
|
// Check for collision with a impassable object (e.g. wall) and stop
|
||||||
if ((otherBody.CollisionLayer & (int) CollisionGroup.Impassable) != 0 && otherBody.Hard)
|
if (collidedWith.TryGetComponent(out IPhysicsComponent physics))
|
||||||
{
|
{
|
||||||
Owner.Delete();
|
if ((physics.CollisionLayer & (int) CollisionGroup.Impassable) != 0 && physics.Hard)
|
||||||
|
{
|
||||||
|
if (Owner.TryGetComponent(out IPhysicsComponent coll))
|
||||||
|
{
|
||||||
|
var controller = coll.EnsureController<VaporController>();
|
||||||
|
controller.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
Owner.Delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
@@ -437,10 +436,10 @@ namespace Content.Server.GameObjects.Components.Construction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Owner.TryGetComponent(out IPhysBody? physics) &&
|
if (Owner.TryGetComponent(out IPhysicsComponent? physics) &&
|
||||||
entity.TryGetComponent(out IPhysBody? otherPhysics))
|
entity.TryGetComponent(out IPhysicsComponent? otherPhysics))
|
||||||
{
|
{
|
||||||
otherPhysics.BodyType = physics.BodyType;
|
otherPhysics.Anchored = physics.Anchored;
|
||||||
}
|
}
|
||||||
|
|
||||||
Owner.Delete();
|
Owner.Delete();
|
||||||
|
|||||||
@@ -4,13 +4,11 @@ using Content.Server.GameObjects.Components.MachineLinking;
|
|||||||
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
||||||
using Content.Shared.GameObjects.Components.Conveyor;
|
using Content.Shared.GameObjects.Components.Conveyor;
|
||||||
using Content.Shared.GameObjects.Components.MachineLinking;
|
using Content.Shared.GameObjects.Components.MachineLinking;
|
||||||
using Content.Shared.GameObjects.Components.Movement;
|
|
||||||
using Content.Shared.Physics;
|
using Content.Shared.Physics;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -29,8 +27,6 @@ namespace Content.Server.GameObjects.Components.Conveyor
|
|||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
private Angle _angle;
|
private Angle _angle;
|
||||||
|
|
||||||
public float Speed => _speed;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The amount of units to move the entity by per second.
|
/// The amount of units to move the entity by per second.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -90,7 +86,7 @@ namespace Content.Server.GameObjects.Components.Conveyor
|
|||||||
/// <returns>
|
/// <returns>
|
||||||
/// The angle when taking into account if the conveyor is reversed
|
/// The angle when taking into account if the conveyor is reversed
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public Angle GetAngle()
|
private Angle GetAngle()
|
||||||
{
|
{
|
||||||
var adjustment = _state == ConveyorState.Reversed ? MathHelper.Pi : 0;
|
var adjustment = _state == ConveyorState.Reversed ? MathHelper.Pi : 0;
|
||||||
var radians = MathHelper.DegreesToRadians(_angle);
|
var radians = MathHelper.DegreesToRadians(_angle);
|
||||||
@@ -98,7 +94,7 @@ namespace Content.Server.GameObjects.Components.Conveyor
|
|||||||
return new Angle(Owner.Transform.LocalRotation.Theta + radians + adjustment);
|
return new Angle(Owner.Transform.LocalRotation.Theta + radians + adjustment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanRun()
|
private bool CanRun()
|
||||||
{
|
{
|
||||||
if (State == ConveyorState.Off)
|
if (State == ConveyorState.Off)
|
||||||
{
|
{
|
||||||
@@ -119,16 +115,15 @@ namespace Content.Server.GameObjects.Components.Conveyor
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanMove(IEntity entity)
|
private bool CanMove(IEntity entity)
|
||||||
{
|
{
|
||||||
// TODO We should only check status InAir or Static or MapGrid or /mayber/ container
|
|
||||||
if (entity == Owner)
|
if (entity == Owner)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entity.TryGetComponent(out IPhysBody? physics) ||
|
if (!entity.TryGetComponent(out IPhysicsComponent? physics) ||
|
||||||
physics.BodyType == BodyType.Static)
|
physics.Anchored)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -151,6 +146,31 @@ namespace Content.Server.GameObjects.Components.Conveyor
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Update(float frameTime)
|
||||||
|
{
|
||||||
|
if (!CanRun())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var intersecting = Owner.EntityManager.GetEntitiesIntersecting(Owner, true);
|
||||||
|
var direction = GetAngle().ToVec();
|
||||||
|
|
||||||
|
foreach (var entity in intersecting)
|
||||||
|
{
|
||||||
|
if (!CanMove(entity))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity.TryGetComponent(out IPhysicsComponent? physics))
|
||||||
|
{
|
||||||
|
var controller = physics.EnsureController<ConveyedController>();
|
||||||
|
controller.Move(direction, _speed, entity.Transform.WorldPosition - Owner.Transform.WorldPosition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void ExposeData(ObjectSerializer serializer)
|
public override void ExposeData(ObjectSerializer serializer)
|
||||||
{
|
{
|
||||||
base.ExposeData(serializer);
|
base.ExposeData(serializer);
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ using Content.Shared.GameObjects.Components.Damage;
|
|||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
@@ -47,16 +46,16 @@ namespace Content.Server.GameObjects.Components.Damage
|
|||||||
serializer.DataField(this, x => x.StunMinimumDamage, "stunMinimumDamage", 10);
|
serializer.DataField(this, x => x.StunMinimumDamage, "stunMinimumDamage", 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CollideWith(IPhysBody ourBody, IPhysBody otherBody)
|
public void CollideWith(IEntity collidedWith)
|
||||||
{
|
{
|
||||||
if (!Owner.TryGetComponent(out IDamageableComponent damageable)) return;
|
if (!Owner.TryGetComponent(out IPhysicsComponent physics) || !Owner.TryGetComponent(out IDamageableComponent damageable)) return;
|
||||||
|
|
||||||
var speed = ourBody.LinearVelocity.Length;
|
var speed = physics.LinearVelocity.Length;
|
||||||
|
|
||||||
if (speed < MinimumSpeed) return;
|
if (speed < MinimumSpeed) return;
|
||||||
|
|
||||||
if(!string.IsNullOrEmpty(SoundHit))
|
if(!string.IsNullOrEmpty(SoundHit))
|
||||||
EntitySystem.Get<AudioSystem>().PlayFromEntity(SoundHit, otherBody.Entity, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f));
|
EntitySystem.Get<AudioSystem>().PlayFromEntity(SoundHit, collidedWith, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f));
|
||||||
|
|
||||||
if ((_gameTiming.CurTime - _lastHit).TotalSeconds < DamageCooldown)
|
if ((_gameTiming.CurTime - _lastHit).TotalSeconds < DamageCooldown)
|
||||||
return;
|
return;
|
||||||
@@ -68,7 +67,7 @@ namespace Content.Server.GameObjects.Components.Damage
|
|||||||
if (Owner.TryGetComponent(out StunnableComponent stun) && _robustRandom.Prob(StunChance))
|
if (Owner.TryGetComponent(out StunnableComponent stun) && _robustRandom.Prob(StunChance))
|
||||||
stun.Stun(StunSeconds);
|
stun.Stun(StunSeconds);
|
||||||
|
|
||||||
damageable.ChangeDamage(Damage, damage, false, otherBody.Entity);
|
damageable.ChangeDamage(Damage, damage, false, collidedWith);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ using Robust.Server.GameObjects;
|
|||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -81,7 +80,7 @@ namespace Content.Server.GameObjects.Components.Disposal
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entity.TryGetComponent(out IPhysBody? physics) ||
|
if (!entity.TryGetComponent(out IPhysicsComponent? physics) ||
|
||||||
!physics.CanCollide)
|
!physics.CanCollide)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -98,7 +97,7 @@ namespace Content.Server.GameObjects.Components.Disposal
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.TryGetComponent(out IPhysBody? physics))
|
if (entity.TryGetComponent(out IPhysicsComponent? physics))
|
||||||
{
|
{
|
||||||
physics.CanCollide = false;
|
physics.CanCollide = false;
|
||||||
}
|
}
|
||||||
@@ -130,7 +129,7 @@ namespace Content.Server.GameObjects.Components.Disposal
|
|||||||
|
|
||||||
foreach (var entity in _contents.ContainedEntities.ToArray())
|
foreach (var entity in _contents.ContainedEntities.ToArray())
|
||||||
{
|
{
|
||||||
if (entity.TryGetComponent(out IPhysBody? physics))
|
if (entity.TryGetComponent(out IPhysicsComponent? physics))
|
||||||
{
|
{
|
||||||
physics.CanCollide = true;
|
physics.CanCollide = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
@@ -143,7 +142,7 @@ namespace Content.Server.GameObjects.Components.Disposal
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entity.TryGetComponent(out IPhysBody? physics) ||
|
if (!entity.TryGetComponent(out IPhysicsComponent? physics) ||
|
||||||
!physics.CanCollide)
|
!physics.CanCollide)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
using static Content.Shared.GameObjects.Components.Disposal.SharedDisposalRouterComponent;
|
using static Content.Shared.GameObjects.Components.Disposal.SharedDisposalRouterComponent;
|
||||||
|
|
||||||
@@ -34,8 +33,8 @@ namespace Content.Server.GameObjects.Components.Disposal
|
|||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public bool Anchored =>
|
public bool Anchored =>
|
||||||
!Owner.TryGetComponent(out IPhysBody? physics) ||
|
!Owner.TryGetComponent(out IPhysicsComponent? physics) ||
|
||||||
physics.BodyType == BodyType.Static;
|
physics.Anchored;
|
||||||
|
|
||||||
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(DisposalRouterUiKey.Key);
|
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(DisposalRouterUiKey.Key);
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
@@ -140,7 +139,7 @@ namespace Content.Server.GameObjects.Components.Disposal
|
|||||||
if (!base.CanInsert(entity))
|
if (!base.CanInsert(entity))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!entity.TryGetComponent(out IPhysBody? physics) ||
|
if (!entity.TryGetComponent(out IPhysicsComponent? physics) ||
|
||||||
!physics.CanCollide)
|
!physics.CanCollide)
|
||||||
{
|
{
|
||||||
if (entity.TryGetComponent(out IMobStateComponent? state) && state.IsDead())
|
if (entity.TryGetComponent(out IMobStateComponent? state) && state.IsDead())
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -25,7 +25,6 @@ using Robust.Shared.Log;
|
|||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Players;
|
using Robust.Shared.Players;
|
||||||
using Robust.Shared.Physics.Broadphase;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
using Timer = Robust.Shared.Timing.Timer;
|
using Timer = Robust.Shared.Timing.Timer;
|
||||||
@@ -39,7 +38,7 @@ namespace Content.Server.GameObjects.Components.Doors
|
|||||||
{
|
{
|
||||||
[ComponentDependency]
|
[ComponentDependency]
|
||||||
private readonly IDoorCheck? _doorCheck = null;
|
private readonly IDoorCheck? _doorCheck = null;
|
||||||
|
|
||||||
public override DoorState State
|
public override DoorState State
|
||||||
{
|
{
|
||||||
get => base.State;
|
get => base.State;
|
||||||
@@ -203,7 +202,7 @@ namespace Content.Server.GameObjects.Components.Doors
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICollideBehavior.CollideWith(IPhysBody ourBody, IPhysBody otherBody)
|
void ICollideBehavior.CollideWith(IEntity entity)
|
||||||
{
|
{
|
||||||
if (State != DoorState.Closed)
|
if (State != DoorState.Closed)
|
||||||
{
|
{
|
||||||
@@ -217,9 +216,9 @@ namespace Content.Server.GameObjects.Components.Doors
|
|||||||
|
|
||||||
// Disabled because it makes it suck hard to walk through double doors.
|
// Disabled because it makes it suck hard to walk through double doors.
|
||||||
|
|
||||||
if (otherBody.Entity.HasComponent<IBody>())
|
if (entity.HasComponent<IBody>())
|
||||||
{
|
{
|
||||||
if (!otherBody.Entity.TryGetComponent<IMoverComponent>(out var mover)) return;
|
if (!entity.TryGetComponent<IMoverComponent>(out var mover)) return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// TODO: temporary hack to fix the physics system raising collision events akwardly.
|
// TODO: temporary hack to fix the physics system raising collision events akwardly.
|
||||||
@@ -232,7 +231,7 @@ namespace Content.Server.GameObjects.Components.Doors
|
|||||||
TryOpen(entity);
|
TryOpen(entity);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TryOpen(otherBody.Entity);
|
TryOpen(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,7 +308,7 @@ namespace Content.Server.GameObjects.Components.Doors
|
|||||||
{
|
{
|
||||||
return _doorCheck.OpenCheck();
|
return _doorCheck.OpenCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,14 +412,18 @@ namespace Content.Server.GameObjects.Components.Doors
|
|||||||
{
|
{
|
||||||
var safety = SafetyCheck();
|
var safety = SafetyCheck();
|
||||||
|
|
||||||
if (safety && Owner.TryGetComponent(out PhysicsComponent? physicsComponent))
|
if (safety && PhysicsComponent != null)
|
||||||
{
|
{
|
||||||
var broadPhaseSystem = EntitySystem.Get<SharedBroadPhaseSystem>();
|
var physics = IoCManager.Resolve<IPhysicsManager>();
|
||||||
|
|
||||||
// Use this version so we can ignore the CanCollide being false
|
foreach(var e in physics.GetCollidingEntities(Owner.Transform.MapID, PhysicsComponent.WorldAABB))
|
||||||
foreach(var e in broadPhaseSystem.GetCollidingEntities(physicsComponent.Entity.Transform.MapID, physicsComponent.GetWorldAABB()))
|
|
||||||
{
|
{
|
||||||
if ((physicsComponent.CollisionMask & e.CollisionLayer) != 0 && broadPhaseSystem.IntersectionPercent(physicsComponent, e) > 0.01f) return true;
|
if (e.CanCollide &&
|
||||||
|
((PhysicsComponent.CollisionMask & e.CollisionLayer) != 0x0 ||
|
||||||
|
(PhysicsComponent.CollisionLayer & e.CollisionMask) != 0x0))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -449,7 +452,7 @@ namespace Content.Server.GameObjects.Components.Doors
|
|||||||
|
|
||||||
OnPartialClose();
|
OnPartialClose();
|
||||||
await Timer.Delay(CloseTimeTwo, _stateChangeCancelTokenSource.Token);
|
await Timer.Delay(CloseTimeTwo, _stateChangeCancelTokenSource.Token);
|
||||||
|
|
||||||
if (Occludes && Owner.TryGetComponent(out OccluderComponent? occluder))
|
if (Occludes && Owner.TryGetComponent(out OccluderComponent? occluder))
|
||||||
{
|
{
|
||||||
occluder.Enabled = true;
|
occluder.Enabled = true;
|
||||||
@@ -492,25 +495,26 @@ namespace Content.Server.GameObjects.Components.Doors
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var doorAABB = PhysicsComponent.GetWorldAABB();
|
var doorAABB = PhysicsComponent.WorldAABB;
|
||||||
var hitsomebody = false;
|
var hitsomebody = false;
|
||||||
|
|
||||||
// Crush
|
// Crush
|
||||||
foreach (var e in collidingentities)
|
foreach (var e in collidingentities)
|
||||||
{
|
{
|
||||||
if (!e.Entity.TryGetComponent(out StunnableComponent? stun)
|
if (!e.TryGetComponent(out StunnableComponent? stun)
|
||||||
|| !e.Entity.TryGetComponent(out IDamageableComponent? damage))
|
|| !e.TryGetComponent(out IDamageableComponent? damage)
|
||||||
|
|| !e.TryGetComponent(out IPhysicsComponent? otherBody))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var percentage = e.GetWorldAABB().IntersectPercentage(doorAABB);
|
var percentage = otherBody.WorldAABB.IntersectPercentage(doorAABB);
|
||||||
|
|
||||||
if (percentage < 0.1f)
|
if (percentage < 0.1f)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
hitsomebody = true;
|
hitsomebody = true;
|
||||||
CurrentlyCrushing.Add(e.Entity.Uid);
|
CurrentlyCrushing.Add(e.Uid);
|
||||||
|
|
||||||
damage.ChangeDamage(DamageType.Blunt, DoorCrushDamage, false, Owner);
|
damage.ChangeDamage(DamageType.Blunt, DoorCrushDamage, false, Owner);
|
||||||
stun.Paralyze(DoorStunTime);
|
stun.Paralyze(DoorStunTime);
|
||||||
|
|||||||
@@ -1,21 +1,22 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
|
using Content.Server.GameObjects.Components.Explosion;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Content.Server.GameObjects.Components.Items;
|
|
||||||
using Content.Server.GameObjects.Components.Trigger.TimerTrigger;
|
using Content.Server.GameObjects.Components.Trigger.TimerTrigger;
|
||||||
using Content.Shared.GameObjects.Components.Explosion;
|
using Content.Server.Throw;
|
||||||
using Content.Shared.Interfaces.GameObjects.Components;
|
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
using Content.Shared.GameObjects.Components.Explosion;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Serialization;
|
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Explosion
|
namespace Content.Server.GameObjects.Components.Explosives
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public sealed class ClusterFlashComponent : Component, IInteractUsing, IUse
|
public sealed class ClusterFlashComponent : Component, IInteractUsing, IUse
|
||||||
@@ -116,13 +117,10 @@ namespace Content.Server.GameObjects.Components.Explosion
|
|||||||
var angleMin = segmentAngle * thrownCount;
|
var angleMin = segmentAngle * thrownCount;
|
||||||
var angleMax = segmentAngle * (thrownCount + 1);
|
var angleMax = segmentAngle * (thrownCount + 1);
|
||||||
var angle = Angle.FromDegrees(random.Next(angleMin, angleMax));
|
var angle = Angle.FromDegrees(random.Next(angleMin, angleMax));
|
||||||
// var distance = random.NextFloat() * _throwDistance;
|
var distance = (float)random.NextFloat() * _throwDistance;
|
||||||
|
var target = new EntityCoordinates(Owner.Uid, angle.ToVec().Normalized * distance);
|
||||||
|
|
||||||
delay += random.Next(550, 900);
|
grenade.Throw(0.5f, target, grenade.Transform.Coordinates);
|
||||||
thrownCount++;
|
|
||||||
|
|
||||||
// TODO: Suss out throw strength
|
|
||||||
grenade.TryThrow(angle.ToVec().Normalized * 50);
|
|
||||||
|
|
||||||
grenade.SpawnTimer(delay, () =>
|
grenade.SpawnTimer(delay, () =>
|
||||||
{
|
{
|
||||||
@@ -134,6 +132,9 @@ namespace Content.Server.GameObjects.Components.Explosion
|
|||||||
useTimer.Trigger(eventArgs.User);
|
useTimer.Trigger(eventArgs.User);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
delay += random.Next(550, 900);
|
||||||
|
thrownCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Owner.Delete();
|
Owner.Delete();
|
||||||
@@ -148,7 +149,7 @@ namespace Content.Server.GameObjects.Components.Explosion
|
|||||||
if (_unspawnedCount > 0)
|
if (_unspawnedCount > 0)
|
||||||
{
|
{
|
||||||
_unspawnedCount--;
|
_unspawnedCount--;
|
||||||
grenade = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.MapPosition);
|
grenade = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.Coordinates);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ using Robust.Shared.IoC;
|
|||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
@@ -373,7 +372,7 @@ namespace Content.Server.GameObjects.Components.Fluids
|
|||||||
|
|
||||||
foreach (var entity in _snapGrid.GetInDir(direction))
|
foreach (var entity in _snapGrid.GetInDir(direction))
|
||||||
{
|
{
|
||||||
if (entity.TryGetComponent(out IPhysBody physics) &&
|
if (entity.TryGetComponent(out IPhysicsComponent physics) &&
|
||||||
(physics.CollisionLayer & (int) CollisionGroup.Impassable) != 0)
|
(physics.CollisionLayer & (int) CollisionGroup.Impassable) != 0)
|
||||||
{
|
{
|
||||||
puddle = default;
|
puddle = default;
|
||||||
|
|||||||
@@ -27,9 +27,6 @@ using Robust.Shared.Maths;
|
|||||||
using Robust.Shared.Network;
|
using Robust.Shared.Network;
|
||||||
using Robust.Shared.Players;
|
using Robust.Shared.Players;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
using Robust.Shared.Map;
|
|
||||||
using Robust.Shared.Network;
|
|
||||||
using Robust.Shared.Physics;
|
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.GUI
|
namespace Content.Server.GameObjects.Components.GUI
|
||||||
{
|
{
|
||||||
@@ -720,13 +717,13 @@ namespace Content.Server.GameObjects.Components.GUI
|
|||||||
|
|
||||||
Dirty();
|
Dirty();
|
||||||
|
|
||||||
if (!message.Entity.TryGetComponent(out IPhysBody? physics))
|
if (!message.Entity.TryGetComponent(out IPhysicsComponent? physics))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set velocity to zero
|
// set velocity to zero
|
||||||
physics.LinearVelocity = Vector2.Zero;
|
physics.Stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
@@ -227,7 +226,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
|
|
||||||
private void ModifyComponents()
|
private void ModifyComponents()
|
||||||
{
|
{
|
||||||
if (!_isCollidableWhenOpen && Owner.TryGetComponent<IPhysBody>(out var physics))
|
if (!_isCollidableWhenOpen && Owner.TryGetComponent<IPhysicsComponent>(out var physics))
|
||||||
{
|
{
|
||||||
if (Open)
|
if (Open)
|
||||||
{
|
{
|
||||||
@@ -253,10 +252,10 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
protected virtual bool AddToContents(IEntity entity)
|
protected virtual bool AddToContents(IEntity entity)
|
||||||
{
|
{
|
||||||
if (entity == Owner) return false;
|
if (entity == Owner) return false;
|
||||||
if (entity.TryGetComponent(out IPhysBody? entityPhysicsComponent))
|
if (entity.TryGetComponent(out IPhysicsComponent? entityPhysicsComponent))
|
||||||
{
|
{
|
||||||
if(MaxSize < entityPhysicsComponent.GetWorldAABB().Size.X
|
if(MaxSize < entityPhysicsComponent.WorldAABB.Size.X
|
||||||
|| MaxSize < entityPhysicsComponent.GetWorldAABB().Size.Y)
|
|| MaxSize < entityPhysicsComponent.WorldAABB.Size.Y)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -286,7 +285,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
if(Contents.Remove(contained))
|
if(Contents.Remove(contained))
|
||||||
{
|
{
|
||||||
contained.Transform.WorldPosition = ContentsDumpPosition();
|
contained.Transform.WorldPosition = ContentsDumpPosition();
|
||||||
if (contained.TryGetComponent<IPhysBody>(out var physics))
|
if (contained.TryGetComponent<IPhysicsComponent>(out var physics))
|
||||||
{
|
{
|
||||||
physics.CanCollide = true;
|
physics.CanCollide = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Content.Server.GameObjects.Components.GUI;
|
using Content.Server.GameObjects.Components.GUI;
|
||||||
using Content.Server.Interfaces.GameObjects.Components.Items;
|
using Content.Server.Interfaces.GameObjects.Components.Items;
|
||||||
|
using Content.Server.Throw;
|
||||||
using Content.Shared.GameObjects;
|
using Content.Shared.GameObjects;
|
||||||
using Content.Shared.GameObjects.Components.Items;
|
using Content.Shared.GameObjects.Components.Items;
|
||||||
using Content.Shared.GameObjects.Components.Storage;
|
using Content.Shared.GameObjects.Components.Storage;
|
||||||
@@ -13,7 +14,6 @@ using Robust.Shared.Containers;
|
|||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Players;
|
using Robust.Shared.Players;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Items.Storage
|
namespace Content.Server.GameObjects.Components.Items.Storage
|
||||||
@@ -87,8 +87,8 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Owner.TryGetComponent(out IPhysBody physics) &&
|
if (Owner.TryGetComponent(out IPhysicsComponent physics) &&
|
||||||
physics.BodyType == BodyType.Static)
|
physics.Anchored)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -141,22 +141,22 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
var targetLocation = eventArgs.Target.Transform.Coordinates;
|
var targetLocation = eventArgs.Target.Transform.Coordinates;
|
||||||
var dirVec = (targetLocation.ToMapPos(Owner.EntityManager) - sourceLocation.ToMapPos(Owner.EntityManager)).Normalized;
|
var dirVec = (targetLocation.ToMapPos(Owner.EntityManager) - sourceLocation.ToMapPos(Owner.EntityManager)).Normalized;
|
||||||
|
|
||||||
float throwForce;
|
var throwForce = 1.0f;
|
||||||
|
|
||||||
switch (eventArgs.Severity)
|
switch (eventArgs.Severity)
|
||||||
{
|
{
|
||||||
case ExplosionSeverity.Destruction:
|
case ExplosionSeverity.Destruction:
|
||||||
throwForce = 30.0f;
|
throwForce = 3.0f;
|
||||||
break;
|
break;
|
||||||
case ExplosionSeverity.Heavy:
|
case ExplosionSeverity.Heavy:
|
||||||
throwForce = 20.0f;
|
throwForce = 2.0f;
|
||||||
break;
|
break;
|
||||||
default:
|
case ExplosionSeverity.Light:
|
||||||
throwForce = 10.0f;
|
throwForce = 1.0f;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Owner.TryThrow(dirVec * throwForce);
|
Owner.Throw(throwForce, targetLocation, sourceLocation, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
#nullable enable
|
|
||||||
using Content.Server.GameObjects.Components.Items.Storage;
|
|
||||||
using Content.Server.GameObjects.EntitySystems.Click;
|
|
||||||
using Content.Shared.GameObjects.Components.Mobs.State;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.Log;
|
|
||||||
using Robust.Shared.Maths;
|
|
||||||
using Robust.Shared.Physics;
|
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Items
|
|
||||||
{
|
|
||||||
internal static class ThrowHelper
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Tries to throw the entity if it has a physics component, otherwise does nothing.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="entity"></param>
|
|
||||||
/// <param name="direction">Will use the vector's magnitude as the strength of the impulse</param>
|
|
||||||
internal static void TryThrow(this IEntity entity, Vector2 direction, IEntity? user = null)
|
|
||||||
{
|
|
||||||
if (direction == Vector2.Zero || !entity.TryGetComponent(out PhysicsComponent? physicsComponent))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (physicsComponent.BodyType == BodyType.Static)
|
|
||||||
{
|
|
||||||
Logger.Warning("Tried to throw entity {entity} but can't throw static bodies!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity.HasComponent<IMobStateComponent>())
|
|
||||||
{
|
|
||||||
Logger.Warning("Throwing not supported for mobs!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity.HasComponent<ItemComponent>())
|
|
||||||
{
|
|
||||||
entity.EnsureComponent<ThrownItemComponent>().Thrower = user;
|
|
||||||
|
|
||||||
if (user != null)
|
|
||||||
EntitySystem.Get<InteractionSystem>().ThrownInteraction(user, entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
physicsComponent.ApplyLinearImpulse(direction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
#nullable enable
|
|
||||||
using Content.Server.GameObjects.EntitySystems.Click;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Physics;
|
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Items
|
|
||||||
{
|
|
||||||
[RegisterComponent]
|
|
||||||
public class ThrownItemComponent : Component, ICollideBehavior
|
|
||||||
{
|
|
||||||
public override string Name => "ThrownItem";
|
|
||||||
|
|
||||||
public IEntity? Thrower { get; set; }
|
|
||||||
|
|
||||||
public override void HandleMessage(ComponentMessage message, IComponent? component)
|
|
||||||
{
|
|
||||||
base.HandleMessage(message, component);
|
|
||||||
switch (message)
|
|
||||||
{
|
|
||||||
case PhysicsSleepCompMessage:
|
|
||||||
EntitySystem.Get<InteractionSystem>().LandInteraction(Thrower, Owner, Owner.Transform.Coordinates);
|
|
||||||
IoCManager.Resolve<IComponentManager>().RemoveComponent(Owner.Uid, this);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CollideWith(IPhysBody ourBody, IPhysBody otherBody)
|
|
||||||
{
|
|
||||||
EntitySystem.Get<InteractionSystem>().ThrowCollideInteraction(Thrower, ourBody, otherBody);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,6 @@ using Content.Shared.GameObjects.Components.Mobs;
|
|||||||
using Content.Shared.GameObjects.Components.Mobs.State;
|
using Content.Shared.GameObjects.Components.Mobs.State;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Mobs.State
|
namespace Content.Server.GameObjects.Components.Mobs.State
|
||||||
{
|
{
|
||||||
@@ -31,7 +30,7 @@ namespace Content.Server.GameObjects.Components.Mobs.State
|
|||||||
|
|
||||||
EntitySystem.Get<StandingStateSystem>().Down(entity);
|
EntitySystem.Get<StandingStateSystem>().Down(entity);
|
||||||
|
|
||||||
if (entity.TryGetComponent(out IPhysBody physics))
|
if (entity.TryGetComponent(out IPhysicsComponent physics))
|
||||||
{
|
{
|
||||||
physics.CanCollide = false;
|
physics.CanCollide = false;
|
||||||
}
|
}
|
||||||
@@ -41,7 +40,7 @@ namespace Content.Server.GameObjects.Components.Mobs.State
|
|||||||
{
|
{
|
||||||
base.ExitState(entity);
|
base.ExitState(entity);
|
||||||
|
|
||||||
if (entity.TryGetComponent(out IPhysBody physics))
|
if (entity.TryGetComponent(out IPhysicsComponent physics))
|
||||||
{
|
{
|
||||||
physics.CanCollide = true;
|
physics.CanCollide = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,8 @@ using Robust.Shared.ViewVariables;
|
|||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Movement
|
namespace Content.Server.GameObjects.Components.Movement
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent, ComponentReference(typeof(IMoverComponent))]
|
||||||
[ComponentReference(typeof(IMobMoverComponent))]
|
public class AiControllerComponent : Component, IMoverComponent
|
||||||
public class AiControllerComponent : Component, IMobMoverComponent, IMoverComponent
|
|
||||||
{
|
{
|
||||||
private float _visionRadius;
|
private float _visionRadius;
|
||||||
|
|
||||||
@@ -108,7 +107,8 @@ namespace Content.Server.GameObjects.Components.Movement
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public float GrabRange { get; set; } = 0.2f;
|
public float GrabRange => 0.2f;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Is the entity Sprinting (running)?
|
/// Is the entity Sprinting (running)?
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -165,11 +164,9 @@ namespace Content.Server.GameObjects.Components.Movement
|
|||||||
|
|
||||||
var result = await EntitySystem.Get<DoAfterSystem>().DoAfter(doAfterEventArgs);
|
var result = await EntitySystem.Get<DoAfterSystem>().DoAfter(doAfterEventArgs);
|
||||||
|
|
||||||
if (result != DoAfterStatus.Cancelled && entityToMove.TryGetComponent(out PhysicsComponent body) && body.Fixtures.Count >= 1)
|
if (result != DoAfterStatus.Cancelled && entityToMove.TryGetComponent(out IPhysicsComponent body) && body.PhysicsShapes.Count >= 1)
|
||||||
{
|
{
|
||||||
var entityPos = entityToMove.Transform.WorldPosition;
|
var direction = (Owner.Transform.WorldPosition - entityToMove.Transform.WorldPosition).Normalized;
|
||||||
|
|
||||||
var direction = (Owner.Transform.WorldPosition - entityPos).Normalized;
|
|
||||||
var endPoint = Owner.Transform.WorldPosition;
|
var endPoint = Owner.Transform.WorldPosition;
|
||||||
|
|
||||||
var climbMode = entityToMove.GetComponent<ClimbingComponent>();
|
var climbMode = entityToMove.GetComponent<ClimbingComponent>();
|
||||||
@@ -177,14 +174,14 @@ namespace Content.Server.GameObjects.Components.Movement
|
|||||||
|
|
||||||
if (MathF.Abs(direction.X) < 0.6f) // user climbed mostly vertically so lets make it a clean straight line
|
if (MathF.Abs(direction.X) < 0.6f) // user climbed mostly vertically so lets make it a clean straight line
|
||||||
{
|
{
|
||||||
endPoint = new Vector2(entityPos.X, endPoint.Y);
|
endPoint = new Vector2(entityToMove.Transform.WorldPosition.X, endPoint.Y);
|
||||||
}
|
}
|
||||||
else if (MathF.Abs(direction.Y) < 0.6f) // user climbed mostly horizontally so lets make it a clean straight line
|
else if (MathF.Abs(direction.Y) < 0.6f) // user climbed mostly horizontally so lets make it a clean straight line
|
||||||
{
|
{
|
||||||
endPoint = new Vector2(endPoint.X, entityPos.Y);
|
endPoint = new Vector2(endPoint.X, entityToMove.Transform.WorldPosition.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
climbMode.TryMoveTo(entityPos, endPoint);
|
climbMode.TryMoveTo(entityToMove.Transform.WorldPosition, endPoint);
|
||||||
// we may potentially need additional logic since we're forcing a player onto a climbable
|
// we may potentially need additional logic since we're forcing a player onto a climbable
|
||||||
// there's also the cases where the user might collide with the person they are forcing onto the climbable that i haven't accounted for
|
// there's also the cases where the user might collide with the person they are forcing onto the climbable that i haven't accounted for
|
||||||
|
|
||||||
@@ -212,12 +209,9 @@ namespace Content.Server.GameObjects.Components.Movement
|
|||||||
|
|
||||||
var result = await EntitySystem.Get<DoAfterSystem>().DoAfter(doAfterEventArgs);
|
var result = await EntitySystem.Get<DoAfterSystem>().DoAfter(doAfterEventArgs);
|
||||||
|
|
||||||
if (result != DoAfterStatus.Cancelled && user.TryGetComponent(out PhysicsComponent body) && body.Fixtures.Count >= 1)
|
if (result != DoAfterStatus.Cancelled && user.TryGetComponent(out IPhysicsComponent body) && body.PhysicsShapes.Count >= 1)
|
||||||
{
|
{
|
||||||
// TODO: Remove the copy-paste code
|
var direction = (Owner.Transform.WorldPosition - user.Transform.WorldPosition).Normalized;
|
||||||
var userPos = user.Transform.WorldPosition;
|
|
||||||
|
|
||||||
var direction = (Owner.Transform.WorldPosition - userPos).Normalized;
|
|
||||||
var endPoint = Owner.Transform.WorldPosition;
|
var endPoint = Owner.Transform.WorldPosition;
|
||||||
|
|
||||||
var climbMode = user.GetComponent<ClimbingComponent>();
|
var climbMode = user.GetComponent<ClimbingComponent>();
|
||||||
@@ -232,7 +226,7 @@ namespace Content.Server.GameObjects.Components.Movement
|
|||||||
endPoint = new Vector2(endPoint.X, user.Transform.WorldPosition.Y);
|
endPoint = new Vector2(endPoint.X, user.Transform.WorldPosition.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
climbMode.TryMoveTo(userPos, endPoint);
|
climbMode.TryMoveTo(user.Transform.WorldPosition, endPoint);
|
||||||
|
|
||||||
var othersMessage = Loc.GetString("{0:theName} jumps onto {1:theName}!", user, Owner);
|
var othersMessage = Loc.GetString("{0:theName} jumps onto {1:theName}!", user, Owner);
|
||||||
user.PopupMessageOtherClients(othersMessage);
|
user.PopupMessageOtherClients(othersMessage);
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System;
|
|
||||||
using Content.Server.GameObjects.EntitySystems;
|
|
||||||
using Content.Shared.GameObjects.Components.Buckle;
|
using Content.Shared.GameObjects.Components.Buckle;
|
||||||
using Content.Shared.GameObjects.Components.Movement;
|
using Content.Shared.GameObjects.Components.Movement;
|
||||||
|
using Content.Shared.Physics;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Players;
|
using Robust.Shared.Players;
|
||||||
using Robust.Shared.Timing;
|
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Movement
|
namespace Content.Server.GameObjects.Components.Movement
|
||||||
{
|
{
|
||||||
@@ -15,41 +12,23 @@ namespace Content.Server.GameObjects.Components.Movement
|
|||||||
[ComponentReference(typeof(SharedClimbingComponent))]
|
[ComponentReference(typeof(SharedClimbingComponent))]
|
||||||
public class ClimbingComponent : SharedClimbingComponent
|
public class ClimbingComponent : SharedClimbingComponent
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
private bool _isClimbing;
|
||||||
|
private ClimbController? _climbController;
|
||||||
|
|
||||||
public override bool IsClimbing
|
public override bool IsClimbing
|
||||||
{
|
{
|
||||||
get => base.IsClimbing;
|
get => _isClimbing;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_isClimbing == value)
|
if (_isClimbing == value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
base.IsClimbing = value;
|
if (!value)
|
||||||
|
|
||||||
if (value)
|
|
||||||
{
|
{
|
||||||
StartClimbTime = IoCManager.Resolve<IGameTiming>().CurTime;
|
Body?.TryRemoveController<ClimbController>();
|
||||||
EntitySystem.Get<ClimbSystem>().AddActiveClimber(this);
|
|
||||||
OwnerIsTransitioning = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EntitySystem.Get<ClimbSystem>().RemoveActiveClimber(this);
|
|
||||||
OwnerIsTransitioning = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Dirty();
|
_isClimbing = value;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OwnerIsTransitioning
|
|
||||||
{
|
|
||||||
get => base.OwnerIsTransitioning;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value == base.OwnerIsTransitioning) return;
|
|
||||||
base.OwnerIsTransitioning = value;
|
|
||||||
Dirty();
|
Dirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,36 +51,38 @@ namespace Content.Server.GameObjects.Components.Movement
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void TryMoveTo(Vector2 from, Vector2 to)
|
public void TryMoveTo(Vector2 from, Vector2 to)
|
||||||
{
|
{
|
||||||
if (Body == null) return;
|
if (Body == null)
|
||||||
|
return;
|
||||||
|
|
||||||
var velocity = (to - from).Length;
|
_climbController = Body.EnsureController<ClimbController>();
|
||||||
|
_climbController.TryMoveTo(from, to);
|
||||||
if (velocity <= 0.0f) return;
|
|
||||||
|
|
||||||
Body.ApplyLinearImpulse((to - from).Normalized * velocity * 400);
|
|
||||||
OwnerIsTransitioning = true;
|
|
||||||
|
|
||||||
Owner.SpawnTimer((int) (BufferTime * 1000), () =>
|
|
||||||
{
|
|
||||||
if (Deleted) return;
|
|
||||||
OwnerIsTransitioning = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
if (!IsClimbing || _gameTiming.CurTime < TimeSpan.FromSeconds(BufferTime) + StartClimbTime)
|
if (!IsClimbing || Body == null)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_climbController != null && (_climbController.IsBlocked || !_climbController.IsActive))
|
||||||
|
{
|
||||||
|
if (Body.TryRemoveController<ClimbController>())
|
||||||
|
{
|
||||||
|
_climbController = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsOnClimbableThisFrame && IsClimbing)
|
if (IsClimbing)
|
||||||
|
Body.WakeBody();
|
||||||
|
|
||||||
|
if (!IsOnClimbableThisFrame && IsClimbing && _climbController == null)
|
||||||
IsClimbing = false;
|
IsClimbing = false;
|
||||||
|
|
||||||
|
IsOnClimbableThisFrame = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ComponentState GetComponentState(ICommonSession player)
|
public override ComponentState GetComponentState(ICommonSession player)
|
||||||
{
|
{
|
||||||
return new ClimbModeComponentState(_isClimbing, OwnerIsTransitioning);
|
return new ClimbModeComponentState(_isClimbing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#nullable enable
|
||||||
|
using Content.Shared.GameObjects.Components.Movement;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Map;
|
||||||
|
|
||||||
|
namespace Content.Server.GameObjects.Components.Movement
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Moves the entity based on input from a KeyBindingInputComponent.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent]
|
||||||
|
[ComponentReference(typeof(IMoverComponent))]
|
||||||
|
public class PlayerInputMoverComponent : SharedPlayerInputMoverComponent
|
||||||
|
{
|
||||||
|
public override EntityCoordinates LastPosition { get; set; }
|
||||||
|
|
||||||
|
public override float StepSoundDistance { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,8 +10,6 @@ using Robust.Shared.IoC;
|
|||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Physics.Dynamics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -21,6 +19,8 @@ namespace Content.Server.GameObjects.Components.Movement
|
|||||||
[ComponentReference(typeof(IMoverComponent))]
|
[ComponentReference(typeof(IMoverComponent))]
|
||||||
internal class ShuttleControllerComponent : Component, IMoverComponent
|
internal class ShuttleControllerComponent : Component, IMoverComponent
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
|
|
||||||
private bool _movingUp;
|
private bool _movingUp;
|
||||||
private bool _movingDown;
|
private bool _movingDown;
|
||||||
private bool _movingLeft;
|
private bool _movingLeft;
|
||||||
@@ -39,19 +39,43 @@ namespace Content.Server.GameObjects.Components.Movement
|
|||||||
|
|
||||||
public override string Name => "ShuttleController";
|
public override string Name => "ShuttleController";
|
||||||
|
|
||||||
public bool IgnorePaused => false;
|
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public float CurrentWalkSpeed { get; } = 8;
|
public float CurrentWalkSpeed { get; } = 8;
|
||||||
public float CurrentSprintSpeed => 0;
|
public float CurrentSprintSpeed => 0;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
[ViewVariables]
|
||||||
|
public float CurrentPushSpeed => 0.0f;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
[ViewVariables]
|
||||||
|
public float GrabRange => 0.0f;
|
||||||
|
|
||||||
public bool Sprinting => false;
|
public bool Sprinting => false;
|
||||||
|
|
||||||
public (Vector2 walking, Vector2 sprinting) VelocityDir { get; set; } = (Vector2.Zero, Vector2.Zero);
|
public (Vector2 walking, Vector2 sprinting) VelocityDir { get; } = (Vector2.Zero, Vector2.Zero);
|
||||||
|
public EntityCoordinates LastPosition { get; set; }
|
||||||
|
public float StepSoundDistance { get; set; }
|
||||||
|
|
||||||
public void SetVelocityDirection(Direction direction, ushort subTick, bool enabled)
|
public void SetVelocityDirection(Direction direction, ushort subTick, bool enabled)
|
||||||
{
|
{
|
||||||
VelocityDir = (CalcNewVelocity(direction, enabled), Vector2.Zero);
|
var gridId = Owner.Transform.GridID;
|
||||||
|
|
||||||
|
if (_mapManager.TryGetGrid(gridId, out var grid) &&
|
||||||
|
Owner.EntityManager.TryGetEntity(grid.GridEntityId, out var gridEntity))
|
||||||
|
{
|
||||||
|
//TODO: Switch to shuttle component
|
||||||
|
if (!gridEntity.TryGetComponent(out IPhysicsComponent? physics))
|
||||||
|
{
|
||||||
|
physics = gridEntity.AddComponent<PhysicsComponent>();
|
||||||
|
physics.Mass = 1;
|
||||||
|
physics.CanCollide = true;
|
||||||
|
physics.PhysicsShapes.Add(new PhysShapeGrid(grid));
|
||||||
|
}
|
||||||
|
|
||||||
|
var controller = physics.EnsureController<ShuttleController>();
|
||||||
|
controller.Push(CalcNewVelocity(direction, enabled), CurrentWalkSpeed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSprinting(ushort subTick, bool walking)
|
public void SetSprinting(ushort subTick, bool walking)
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using System.Linq;
|
|||||||
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
|
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -39,7 +38,7 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Connectable => !_deleting && Anchored;
|
public bool Connectable => !_deleting && Anchored;
|
||||||
|
|
||||||
private bool Anchored => !Owner.TryGetComponent<IPhysBody>(out var physics) || physics.BodyType == BodyType.Static;
|
private bool Anchored => !Owner.TryGetComponent<IPhysicsComponent>(out var physics) || physics.Anchored;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Prevents a node from being used by other nodes while midway through removal.
|
/// Prevents a node from being used by other nodes while midway through removal.
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ using Robust.Server.GameObjects;
|
|||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.PA
|
namespace Content.Server.GameObjects.Components.PA
|
||||||
@@ -16,9 +15,9 @@ namespace Content.Server.GameObjects.Components.PA
|
|||||||
{
|
{
|
||||||
public override string Name => "ParticleProjectile";
|
public override string Name => "ParticleProjectile";
|
||||||
private ParticleAcceleratorPowerState _state;
|
private ParticleAcceleratorPowerState _state;
|
||||||
public void CollideWith(IPhysBody ourBody, IPhysBody otherBody)
|
public void CollideWith(IEntity collidedWith)
|
||||||
{
|
{
|
||||||
if (otherBody.Entity.TryGetComponent<SingularityComponent>(out var singularityComponent))
|
if (collidedWith.TryGetComponent<SingularityComponent>(out var singularityComponent))
|
||||||
{
|
{
|
||||||
var multiplier = _state switch
|
var multiplier = _state switch
|
||||||
{
|
{
|
||||||
@@ -31,8 +30,8 @@ namespace Content.Server.GameObjects.Components.PA
|
|||||||
};
|
};
|
||||||
singularityComponent.Energy += 10 * multiplier;
|
singularityComponent.Energy += 10 * multiplier;
|
||||||
Owner.Delete();
|
Owner.Delete();
|
||||||
}
|
}else if (collidedWith.TryGetComponent<SingularityGeneratorComponent>(out var singularityGeneratorComponent)
|
||||||
else if (otherBody.Entity.TryGetComponent<SingularityGeneratorComponent>(out var singularityGeneratorComponent))
|
)
|
||||||
{
|
{
|
||||||
singularityGeneratorComponent.Power += _state switch
|
singularityGeneratorComponent.Power += _state switch
|
||||||
{
|
{
|
||||||
@@ -56,7 +55,7 @@ namespace Content.Server.GameObjects.Components.PA
|
|||||||
Logger.Error("ParticleProjectile tried firing, but it was spawned without a CollidableComponent");
|
Logger.Error("ParticleProjectile tried firing, but it was spawned without a CollidableComponent");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
physicsComponent.BodyStatus = BodyStatus.InAir;
|
physicsComponent.Status = BodyStatus.InAir;
|
||||||
|
|
||||||
if (!Owner.TryGetComponent<ProjectileComponent>(out var projectileComponent))
|
if (!Owner.TryGetComponent<ProjectileComponent>(out var projectileComponent))
|
||||||
{
|
{
|
||||||
@@ -82,6 +81,7 @@ namespace Content.Server.GameObjects.Components.PA
|
|||||||
spriteComponent.LayerSetState(0, $"particle{suffix}");
|
spriteComponent.LayerSetState(0, $"particle{suffix}");
|
||||||
|
|
||||||
physicsComponent
|
physicsComponent
|
||||||
|
.EnsureController<BulletController>()
|
||||||
.LinearVelocity = angle.ToVec() * 20f;
|
.LinearVelocity = angle.ToVec() * 20f;
|
||||||
|
|
||||||
Owner.Transform.LocalRotation = new Angle(angle + Angle.FromDegrees(180));
|
Owner.Transform.LocalRotation = new Angle(angle + Angle.FromDegrees(180));
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using Content.Shared.GameObjects.Components.Portal;
|
|||||||
using Content.Shared.GameObjects.Components.Tag;
|
using Content.Shared.GameObjects.Components.Tag;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -169,11 +168,11 @@ namespace Content.Server.GameObjects.Components.Portal
|
|||||||
StartCooldown();
|
StartCooldown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CollideWith(IPhysBody ourBody, IPhysBody otherBody)
|
public void CollideWith(IEntity collidedWith)
|
||||||
{
|
{
|
||||||
if (_onCooldown == false)
|
if (_onCooldown == false)
|
||||||
{
|
{
|
||||||
TryPortalEntity(otherBody.Entity);
|
TryPortalEntity(collidedWith);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
@@ -105,7 +104,7 @@ namespace Content.Server.GameObjects.Components.Portal
|
|||||||
{
|
{
|
||||||
// Added this component to avoid stacking portals and causing shenanigans
|
// Added this component to avoid stacking portals and causing shenanigans
|
||||||
// TODO: Doesn't do a great job of stopping stacking portals for directed
|
// TODO: Doesn't do a great job of stopping stacking portals for directed
|
||||||
if (entity.HasComponent<IPhysBody>() || entity.HasComponent<TeleporterComponent>())
|
if (entity.HasComponent<IPhysicsComponent>() || entity.HasComponent<TeleporterComponent>())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -149,7 +148,7 @@ namespace Content.Server.GameObjects.Components.Portal
|
|||||||
// TODO: Check the user's spot? Upside is no stacking TPs but downside is they can't unstuck themselves from walls.
|
// TODO: Check the user's spot? Upside is no stacking TPs but downside is they can't unstuck themselves from walls.
|
||||||
foreach (var entity in _serverEntityManager.GetEntitiesIntersecting(user.Transform.MapID, target))
|
foreach (var entity in _serverEntityManager.GetEntitiesIntersecting(user.Transform.MapID, target))
|
||||||
{
|
{
|
||||||
if (entity.HasComponent<IPhysBody>() || entity.HasComponent<PortalComponent>())
|
if (entity.HasComponent<IPhysicsComponent>() || entity.HasComponent<PortalComponent>())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using Robust.Server.GameObjects;
|
|||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
@@ -22,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly IServerEntityManager _serverEntityManager = default!;
|
[Dependency] private readonly IServerEntityManager _serverEntityManager = default!;
|
||||||
|
|
||||||
[ViewVariables] [ComponentDependency] private readonly IPhysBody? _physicsComponent = null;
|
[ViewVariables] [ComponentDependency] private readonly IPhysicsComponent? _physicsComponent = null;
|
||||||
|
|
||||||
public override string Name => "PowerReceiver";
|
public override string Name => "PowerReceiver";
|
||||||
|
|
||||||
@@ -51,7 +50,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Connectable => Anchored;
|
public bool Connectable => Anchored;
|
||||||
|
|
||||||
private bool Anchored => _physicsComponent == null || _physicsComponent.BodyType == BodyType.Static;
|
private bool Anchored => _physicsComponent == null || _physicsComponent.Anchored;
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public bool NeedsProvider { get; private set; } = true;
|
public bool NeedsProvider { get; private set; } = true;
|
||||||
@@ -99,7 +98,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnRemove()
|
public override void OnRemove()
|
||||||
{
|
{
|
||||||
_provider.RemoveReceiver(this);
|
_provider.RemoveReceiver(this);
|
||||||
base.OnRemove();
|
base.OnRemove();
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
using System;
|
using System;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Projectiles
|
namespace Content.Server.GameObjects.Components.Projectiles
|
||||||
{
|
{
|
||||||
@@ -37,9 +36,9 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
|||||||
_solutionContainer = Owner.EnsureComponent<SolutionContainerComponent>();
|
_solutionContainer = Owner.EnsureComponent<SolutionContainerComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICollideBehavior.CollideWith(IPhysBody ourBody, IPhysBody otherBody)
|
void ICollideBehavior.CollideWith(IEntity entity)
|
||||||
{
|
{
|
||||||
if (!otherBody.Entity.TryGetComponent<BloodstreamComponent>(out var bloodstream))
|
if (!entity.TryGetComponent<BloodstreamComponent>(out var bloodstream))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var solution = _solutionContainer.Solution;
|
var solution = _solutionContainer.Solution;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Content.Server.GameObjects.Components.Explosion;
|
using Content.Server.GameObjects.Components.Explosion;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Projectiles
|
namespace Content.Server.GameObjects.Components.Projectiles
|
||||||
{
|
{
|
||||||
@@ -16,12 +15,18 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
|||||||
Owner.EnsureComponent<ExplosiveComponent>();
|
Owner.EnsureComponent<ExplosiveComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICollideBehavior.CollideWith(IPhysBody ourBody, IPhysBody otherBody)
|
void ICollideBehavior.CollideWith(IEntity entity)
|
||||||
{
|
{
|
||||||
if (Owner.TryGetComponent(out ExplosiveComponent explosive))
|
if (Owner.TryGetComponent(out ExplosiveComponent explosive))
|
||||||
{
|
{
|
||||||
explosive.Explosion();
|
explosive.Explosion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Projectile should handle the deleting
|
||||||
|
void ICollideBehavior.PostCollide(int collisionCount)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Content.Server.GameObjects.Components.Weapon;
|
using Content.Server.GameObjects.Components.Weapon;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Projectiles
|
namespace Content.Server.GameObjects.Components.Projectiles
|
||||||
@@ -32,15 +31,20 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
|||||||
Owner.EnsureComponent<ProjectileComponent>();
|
Owner.EnsureComponent<ProjectileComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICollideBehavior.CollideWith(IPhysBody ourBody, IPhysBody otherBody)
|
void ICollideBehavior.CollideWith(IEntity entity)
|
||||||
{
|
{
|
||||||
if (_flashed)
|
if (_flashed)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FlashableComponent.FlashAreaHelper(Owner, _range, _duration);
|
FlashableComponent.FlashAreaHelper(Owner, _range, _duration);
|
||||||
_flashed = true;
|
_flashed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Projectile should handle the deleting
|
||||||
|
void ICollideBehavior.PostCollide(int collisionCount)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using Robust.Shared.IoC;
|
|||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Physics.Dynamics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using Content.Shared.GameObjects.Components.Damage;
|
|||||||
using Content.Shared.GameObjects.Components.Projectiles;
|
using Content.Shared.GameObjects.Components.Projectiles;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Players;
|
using Robust.Shared.Players;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
@@ -13,7 +12,7 @@ using Robust.Shared.ViewVariables;
|
|||||||
namespace Content.Server.GameObjects.Components.Projectiles
|
namespace Content.Server.GameObjects.Components.Projectiles
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class ProjectileComponent : SharedProjectileComponent, ICollideBehavior, IPostCollide
|
public class ProjectileComponent : SharedProjectileComponent, ICollideBehavior
|
||||||
{
|
{
|
||||||
protected override EntityUid Shooter => _shooter;
|
protected override EntityUid Shooter => _shooter;
|
||||||
|
|
||||||
@@ -28,14 +27,15 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
|||||||
set => _damages = value;
|
set => _damages = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _damagedEntity = false;
|
public bool DeleteOnCollide => _deleteOnCollide;
|
||||||
|
|
||||||
private bool _deleteOnCollide;
|
private bool _deleteOnCollide;
|
||||||
|
|
||||||
// Get that juicy FPS hit sound
|
// Get that juicy FPS hit sound
|
||||||
private string _soundHit;
|
private string _soundHit;
|
||||||
private string _soundHitSpecies;
|
private string _soundHitSpecies;
|
||||||
|
|
||||||
|
private bool _damagedEntity;
|
||||||
|
|
||||||
public override void ExposeData(ObjectSerializer serializer)
|
public override void ExposeData(ObjectSerializer serializer)
|
||||||
{
|
{
|
||||||
base.ExposeData(serializer);
|
base.ExposeData(serializer);
|
||||||
@@ -58,27 +58,39 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
|||||||
Dirty();
|
Dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool _internalDeleteOnCollide;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Applies the damage when our projectile collides with its victim
|
/// Applies the damage when our projectile collides with its victim
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void ICollideBehavior.CollideWith(IPhysBody ourBody, IPhysBody otherBody)
|
/// <param name="entity"></param>
|
||||||
|
void ICollideBehavior.CollideWith(IEntity entity)
|
||||||
{
|
{
|
||||||
// This is so entities that shouldn't get a collision are ignored.
|
if (_damagedEntity)
|
||||||
if (!otherBody.Hard || _damagedEntity)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (otherBody.Entity.TryGetComponent(out IDamageableComponent damage) && _soundHitSpecies != null)
|
// This is so entities that shouldn't get a collision are ignored.
|
||||||
|
if (entity.TryGetComponent(out IPhysicsComponent otherPhysics) && otherPhysics.Hard == false)
|
||||||
{
|
{
|
||||||
EntitySystem.Get<AudioSystem>().PlayAtCoords(_soundHitSpecies, otherBody.Entity.Transform.Coordinates);
|
_internalDeleteOnCollide = false;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (_soundHit != null)
|
else
|
||||||
{
|
{
|
||||||
EntitySystem.Get<AudioSystem>().PlayAtCoords(_soundHit, otherBody.Entity.Transform.Coordinates);
|
_internalDeleteOnCollide = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (damage != null)
|
if (_soundHitSpecies != null && entity.HasComponent<IDamageableComponent>())
|
||||||
|
{
|
||||||
|
EntitySystem.Get<AudioSystem>().PlayAtCoords(_soundHitSpecies, entity.Transform.Coordinates);
|
||||||
|
} else if (_soundHit != null)
|
||||||
|
{
|
||||||
|
EntitySystem.Get<AudioSystem>().PlayAtCoords(_soundHit, entity.Transform.Coordinates);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity.TryGetComponent(out IDamageableComponent damage))
|
||||||
{
|
{
|
||||||
Owner.EntityManager.TryGetEntity(_shooter, out var shooter);
|
Owner.EntityManager.TryGetEntity(_shooter, out var shooter);
|
||||||
|
|
||||||
@@ -90,17 +102,17 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
|||||||
_damagedEntity = true;
|
_damagedEntity = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Damaging it can delete it
|
if (!entity.Deleted && entity.TryGetComponent(out CameraRecoilComponent recoilComponent)
|
||||||
if (!otherBody.Entity.Deleted && otherBody.Entity.TryGetComponent(out CameraRecoilComponent recoilComponent))
|
&& Owner.TryGetComponent(out IPhysicsComponent ownPhysics))
|
||||||
{
|
{
|
||||||
var direction = ourBody.LinearVelocity.Normalized;
|
var direction = ownPhysics.LinearVelocity.Normalized;
|
||||||
recoilComponent.Kick(direction);
|
recoilComponent.Kick(direction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPostCollide.PostCollide(IPhysBody ourBody, IPhysBody otherBody)
|
void ICollideBehavior.PostCollide(int collideCount)
|
||||||
{
|
{
|
||||||
if (_damagedEntity) Owner.Delete();
|
if (collideCount > 0 && DeleteOnCollide && _internalDeleteOnCollide) Owner.Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ComponentState GetComponentState(ICommonSession player)
|
public override ComponentState GetComponentState(ICommonSession player)
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Content.Server.GameObjects.Components.Mobs;
|
using Content.Server.GameObjects.Components.Mobs;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Projectiles
|
namespace Content.Server.GameObjects.Components.Projectiles
|
||||||
@@ -33,14 +32,16 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
|||||||
Owner.EnsureComponentWarn(out ProjectileComponent _);
|
Owner.EnsureComponentWarn(out ProjectileComponent _);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICollideBehavior.CollideWith(IPhysBody ourBody, IPhysBody otherBody)
|
void ICollideBehavior.CollideWith(IEntity entity)
|
||||||
{
|
{
|
||||||
if (otherBody.Entity.TryGetComponent(out StunnableComponent stunnableComponent))
|
if (entity.TryGetComponent(out StunnableComponent stunnableComponent))
|
||||||
{
|
{
|
||||||
stunnableComponent.Stun(_stunAmount);
|
stunnableComponent.Stun(_stunAmount);
|
||||||
stunnableComponent.Knockdown(_knockdownAmount);
|
stunnableComponent.Knockdown(_knockdownAmount);
|
||||||
stunnableComponent.Slowdown(_slowdownAmount);
|
stunnableComponent.Slowdown(_slowdownAmount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ICollideBehavior.PostCollide(int collidedCount) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
using Content.Server.GameObjects.EntitySystems.Click;
|
||||||
|
using Content.Shared.GameObjects;
|
||||||
|
using Content.Shared.Physics;
|
||||||
|
using Robust.Server.GameObjects;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Maths;
|
||||||
|
using Robust.Shared.Physics;
|
||||||
|
|
||||||
|
namespace Content.Server.GameObjects.Components.Projectiles
|
||||||
|
{
|
||||||
|
[RegisterComponent]
|
||||||
|
internal class ThrownItemComponent : ProjectileComponent, ICollideBehavior
|
||||||
|
{
|
||||||
|
public const float DefaultThrowTime = 0.25f;
|
||||||
|
|
||||||
|
private bool _shouldCollide = true;
|
||||||
|
private bool _shouldStop = false;
|
||||||
|
|
||||||
|
public override string Name => "ThrownItem";
|
||||||
|
public override uint? NetID => ContentNetIDs.THROWN_ITEM;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// User who threw the item.
|
||||||
|
/// </summary>
|
||||||
|
public IEntity User { get; set; }
|
||||||
|
|
||||||
|
void ICollideBehavior.CollideWith(IEntity entity)
|
||||||
|
{
|
||||||
|
if (!_shouldCollide || entity.Deleted) return;
|
||||||
|
if (entity.TryGetComponent(out PhysicsComponent collid))
|
||||||
|
{
|
||||||
|
if (!collid.Hard) // ignore non hard
|
||||||
|
return;
|
||||||
|
|
||||||
|
_shouldStop = true; // hit something hard => stop after this collision
|
||||||
|
|
||||||
|
// Raise an event.
|
||||||
|
EntitySystem.Get<InteractionSystem>().ThrowCollideInteraction(User, Owner, entity, Owner.Transform.Coordinates);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop colliding with mobs, this mimics not having enough velocity to do damage
|
||||||
|
// after impacting the first object.
|
||||||
|
// For realism this should actually be changed when the velocity of the object is less than a threshold.
|
||||||
|
// This would allow ricochets off walls, and weird gravity effects from slowing the object.
|
||||||
|
if (!Owner.Deleted && Owner.TryGetComponent(out IPhysicsComponent body) && body.PhysicsShapes.Count >= 1)
|
||||||
|
{
|
||||||
|
_shouldCollide = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StopThrow()
|
||||||
|
{
|
||||||
|
if (Deleted)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Owner.TryGetComponent(out IPhysicsComponent body) && body.PhysicsShapes.Count >= 1)
|
||||||
|
{
|
||||||
|
body.PhysicsShapes[0].CollisionMask &= (int) ~CollisionGroup.ThrownItem;
|
||||||
|
|
||||||
|
if (body.TryGetController(out ThrownController controller))
|
||||||
|
{
|
||||||
|
controller.LinearVelocity = Vector2.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.Status = BodyStatus.OnGround;
|
||||||
|
|
||||||
|
Owner.RemoveComponent<ThrownItemComponent>();
|
||||||
|
EntitySystem.Get<InteractionSystem>().LandInteraction(User, Owner, Owner.Transform.Coordinates);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ICollideBehavior.PostCollide(int collideCount)
|
||||||
|
{
|
||||||
|
if (_shouldStop && collideCount > 0)
|
||||||
|
{
|
||||||
|
StopThrow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StartThrow(Vector2 direction, float speed)
|
||||||
|
{
|
||||||
|
var comp = Owner.GetComponent<IPhysicsComponent>();
|
||||||
|
comp.Status = BodyStatus.InAir;
|
||||||
|
|
||||||
|
var controller = comp.EnsureController<ThrownController>();
|
||||||
|
controller.Push(direction, speed);
|
||||||
|
|
||||||
|
EntitySystem.Get<AudioSystem>()
|
||||||
|
.PlayFromEntity("/Audio/Effects/toss.ogg", Owner);
|
||||||
|
|
||||||
|
StartStopTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StartStopTimer()
|
||||||
|
{
|
||||||
|
Owner.SpawnTimer((int) (DefaultThrowTime * 1000), MaybeStopThrow);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MaybeStopThrow()
|
||||||
|
{
|
||||||
|
if (Deleted)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IoCManager.Resolve<IPhysicsManager>().IsWeightless(Owner.Transform.Coordinates))
|
||||||
|
{
|
||||||
|
StartStopTimer();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
StopThrow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,6 @@ using Content.Shared.GameObjects.EntitySystems;
|
|||||||
using Content.Shared.GameObjects.Verbs;
|
using Content.Shared.GameObjects.Verbs;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Pulling
|
namespace Content.Server.GameObjects.Components.Pulling
|
||||||
{
|
{
|
||||||
@@ -32,15 +31,15 @@ namespace Content.Server.GameObjects.Components.Pulling
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!user.HasComponent<ISharedHandsComponent>() ||
|
if (!user.HasComponent<ISharedHandsComponent>() ||
|
||||||
!user.TryGetComponent(out IPhysBody? userPhysics) ||
|
!user.TryGetComponent(out IPhysicsComponent? userPhysics) ||
|
||||||
!component.Owner.TryGetComponent(out IPhysBody? targetPhysics) ||
|
!component.Owner.TryGetComponent(out IPhysicsComponent? targetPhysics) ||
|
||||||
targetPhysics.BodyType == BodyType.Static)
|
targetPhysics.Anchored)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.Visibility = VerbVisibility.Visible;
|
data.Visibility = VerbVisibility.Visible;
|
||||||
data.Text = component.Puller == userPhysics.Entity
|
data.Text = component.Puller == userPhysics
|
||||||
? Loc.GetString("Stop pulling")
|
? Loc.GetString("Stop pulling")
|
||||||
: Loc.GetString("Pull");
|
: Loc.GetString("Pull");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -31,7 +30,7 @@ namespace Content.Server.GameObjects.Components.Recycling
|
|||||||
{
|
{
|
||||||
public override string Name => "Recycler";
|
public override string Name => "Recycler";
|
||||||
|
|
||||||
public List<IEntity> Intersecting { get; set; } = new();
|
private readonly List<IEntity> _intersecting = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether or not sentient beings will be recycled
|
/// Whether or not sentient beings will be recycled
|
||||||
@@ -73,9 +72,9 @@ namespace Content.Server.GameObjects.Components.Recycling
|
|||||||
|
|
||||||
private void Recycle(IEntity entity)
|
private void Recycle(IEntity entity)
|
||||||
{
|
{
|
||||||
if (!Intersecting.Contains(entity))
|
if (!_intersecting.Contains(entity))
|
||||||
{
|
{
|
||||||
Intersecting.Add(entity);
|
_intersecting.Add(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Prevent collision with recycled items
|
// TODO: Prevent collision with recycled items
|
||||||
@@ -94,7 +93,7 @@ namespace Content.Server.GameObjects.Components.Recycling
|
|||||||
recyclable.Recycle(_efficiency);
|
recyclable.Recycle(_efficiency);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanRun()
|
private bool CanRun()
|
||||||
{
|
{
|
||||||
if (Owner.TryGetComponent(out PowerReceiverComponent? receiver) &&
|
if (Owner.TryGetComponent(out PowerReceiverComponent? receiver) &&
|
||||||
!receiver.Powered)
|
!receiver.Powered)
|
||||||
@@ -110,15 +109,15 @@ namespace Content.Server.GameObjects.Components.Recycling
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanMove(IEntity entity)
|
private bool CanMove(IEntity entity)
|
||||||
{
|
{
|
||||||
if (entity == Owner)
|
if (entity == Owner)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entity.TryGetComponent(out IPhysBody? physics) ||
|
if (!entity.TryGetComponent(out IPhysicsComponent? physics) ||
|
||||||
physics.BodyType == BodyType.Static)
|
physics.Anchored)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -141,6 +140,34 @@ namespace Content.Server.GameObjects.Components.Recycling
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Update(float frameTime)
|
||||||
|
{
|
||||||
|
if (!CanRun())
|
||||||
|
{
|
||||||
|
_intersecting.Clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var direction = Vector2.UnitX;
|
||||||
|
|
||||||
|
for (var i = _intersecting.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
var entity = _intersecting[i];
|
||||||
|
|
||||||
|
if (entity.Deleted || !CanMove(entity) || !Owner.EntityManager.IsIntersecting(Owner, entity))
|
||||||
|
{
|
||||||
|
_intersecting.RemoveAt(i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity.TryGetComponent(out IPhysicsComponent? physics))
|
||||||
|
{
|
||||||
|
var controller = physics.EnsureController<ConveyedController>();
|
||||||
|
controller.Move(direction, frameTime, entity.Transform.WorldPosition - Owner.Transform.WorldPosition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void ExposeData(ObjectSerializer serializer)
|
public override void ExposeData(ObjectSerializer serializer)
|
||||||
{
|
{
|
||||||
base.ExposeData(serializer);
|
base.ExposeData(serializer);
|
||||||
@@ -149,9 +176,9 @@ namespace Content.Server.GameObjects.Components.Recycling
|
|||||||
serializer.DataField(ref _efficiency, "efficiency", 0.25f);
|
serializer.DataField(ref _efficiency, "efficiency", 0.25f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICollideBehavior.CollideWith(IPhysBody ourBody, IPhysBody otherBody)
|
void ICollideBehavior.CollideWith(IEntity collidedWith)
|
||||||
{
|
{
|
||||||
Recycle(otherBody.Entity);
|
Recycle(collidedWith);
|
||||||
}
|
}
|
||||||
|
|
||||||
SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat)
|
SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat)
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using Content.Shared.GameObjects.Verbs;
|
|||||||
using Content.Shared.Interfaces;
|
using Content.Shared.Interfaces;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Rotatable
|
namespace Content.Server.GameObjects.Components.Rotatable
|
||||||
@@ -18,8 +17,8 @@ namespace Content.Server.GameObjects.Components.Rotatable
|
|||||||
|
|
||||||
private void TryFlip(IEntity user)
|
private void TryFlip(IEntity user)
|
||||||
{
|
{
|
||||||
if (Owner.TryGetComponent(out IPhysBody? physics) &&
|
if (Owner.TryGetComponent(out IPhysicsComponent? physics) &&
|
||||||
physics.BodyType == BodyType.Static)
|
physics.Anchored)
|
||||||
{
|
{
|
||||||
Owner.PopupMessage(user, Loc.GetString("It's stuck."));
|
Owner.PopupMessage(user, Loc.GetString("It's stuck."));
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using Content.Shared.Interfaces;
|
|||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -29,9 +28,9 @@ namespace Content.Server.GameObjects.Components.Rotatable
|
|||||||
|
|
||||||
private void TryRotate(IEntity user, Angle angle)
|
private void TryRotate(IEntity user, Angle angle)
|
||||||
{
|
{
|
||||||
if (!RotateWhileAnchored && Owner.TryGetComponent(out IPhysBody physics))
|
if (!RotateWhileAnchored && Owner.TryGetComponent(out IPhysicsComponent physics))
|
||||||
{
|
{
|
||||||
if (physics.BodyType == BodyType.Static)
|
if (physics.Anchored)
|
||||||
{
|
{
|
||||||
Owner.PopupMessage(user, Loc.GetString("It's stuck."));
|
Owner.PopupMessage(user, Loc.GetString("It's stuck."));
|
||||||
return;
|
return;
|
||||||
@@ -46,7 +45,7 @@ namespace Content.Server.GameObjects.Components.Rotatable
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, RotatableComponent component, VerbData data)
|
protected override void GetData(IEntity user, RotatableComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
if (!ActionBlockerSystem.CanInteract(user) || (!component.RotateWhileAnchored && component.Owner.TryGetComponent(out IPhysBody physics) && physics.BodyType == BodyType.Static))
|
if (!ActionBlockerSystem.CanInteract(user) || (!component.RotateWhileAnchored && component.Owner.TryGetComponent(out IPhysicsComponent physics) && physics.Anchored))
|
||||||
{
|
{
|
||||||
data.Visibility = VerbVisibility.Invisible;
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
return;
|
return;
|
||||||
@@ -68,7 +67,7 @@ namespace Content.Server.GameObjects.Components.Rotatable
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, RotatableComponent component, VerbData data)
|
protected override void GetData(IEntity user, RotatableComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
if (!ActionBlockerSystem.CanInteract(user) || (!component.RotateWhileAnchored && component.Owner.TryGetComponent(out IPhysBody physics) && physics.BodyType == BodyType.Static))
|
if (!ActionBlockerSystem.CanInteract(user) || (!component.RotateWhileAnchored && component.Owner.TryGetComponent(out IPhysicsComponent physics) && physics.Anchored))
|
||||||
{
|
{
|
||||||
data.Visibility = VerbVisibility.Invisible;
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Singularity
|
namespace Content.Server.GameObjects.Components.Singularity
|
||||||
{
|
{
|
||||||
@@ -10,7 +9,7 @@ namespace Content.Server.GameObjects.Components.Singularity
|
|||||||
public override string Name => "ContainmentField";
|
public override string Name => "ContainmentField";
|
||||||
public ContainmentFieldConnection? Parent;
|
public ContainmentFieldConnection? Parent;
|
||||||
|
|
||||||
public void CollideWith(IPhysBody ourBody, IPhysBody otherBody)
|
public void CollideWith(IEntity collidedWith)
|
||||||
{
|
{
|
||||||
if (Parent == null)
|
if (Parent == null)
|
||||||
{
|
{
|
||||||
@@ -18,7 +17,7 @@ namespace Content.Server.GameObjects.Components.Singularity
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Parent.TryRepell(Owner, otherBody.Entity);
|
Parent.TryRepell(Owner, collidedWith);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using Content.Shared.Physics;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Timer = Robust.Shared.Timing.Timer;
|
using Timer = Robust.Shared.Timing.Timer;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Singularity
|
namespace Content.Server.GameObjects.Components.Singularity
|
||||||
@@ -90,12 +90,10 @@ namespace Content.Server.GameObjects.Components.Singularity
|
|||||||
/// <param name="toRepell">Entity to repell.</param>
|
/// <param name="toRepell">Entity to repell.</param>
|
||||||
public void TryRepell(IEntity repellFrom, IEntity toRepell)
|
public void TryRepell(IEntity repellFrom, IEntity toRepell)
|
||||||
{
|
{
|
||||||
// TODO: Fix this also it's fucking repel
|
if (!_fields.Contains(repellFrom) || !toRepell.TryGetComponent<IPhysicsComponent>(out var collidableComponent)) return;
|
||||||
if (!_fields.Contains(repellFrom) || !toRepell.TryGetComponent<IPhysBody>(out var collidableComponent)) return;
|
|
||||||
|
|
||||||
return;
|
|
||||||
var speed = 5;
|
var speed = 5;
|
||||||
//var containmentFieldRepellController = collidableComponent.EnsureController<ContainmentFieldRepellController>();
|
var containmentFieldRepellController = collidableComponent.EnsureController<ContainmentFieldRepellController>();
|
||||||
|
|
||||||
if (!CanRepell(toRepell))
|
if (!CanRepell(toRepell))
|
||||||
{
|
{
|
||||||
@@ -108,22 +106,22 @@ namespace Content.Server.GameObjects.Components.Singularity
|
|||||||
{
|
{
|
||||||
if (repellFrom.Transform.WorldPosition.X.CompareTo(toRepell.Transform.WorldPosition.X) > 0)
|
if (repellFrom.Transform.WorldPosition.X.CompareTo(toRepell.Transform.WorldPosition.X) > 0)
|
||||||
{
|
{
|
||||||
//containmentFieldRepellController.Repell(Direction.West, speed);
|
containmentFieldRepellController.Repell(Direction.West, speed);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//containmentFieldRepellController.Repell(Direction.East, speed);
|
containmentFieldRepellController.Repell(Direction.East, speed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (repellFrom.Transform.WorldPosition.Y.CompareTo(toRepell.Transform.WorldPosition.Y) > 0)
|
if (repellFrom.Transform.WorldPosition.Y.CompareTo(toRepell.Transform.WorldPosition.Y) > 0)
|
||||||
{
|
{
|
||||||
//containmentFieldRepellController.Repell(Direction.South, speed);
|
containmentFieldRepellController.Repell(Direction.South, speed);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//containmentFieldRepellController.Repell(Direction.North, speed);
|
containmentFieldRepellController.Repell(Direction.North, speed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ using Robust.Shared.IoC;
|
|||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Physics.Broadphase;
|
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
|
|
||||||
@@ -118,7 +117,7 @@ namespace Content.Server.GameObjects.Components.Singularity
|
|||||||
|
|
||||||
var dirVec = direction.ToVec();
|
var dirVec = direction.ToVec();
|
||||||
var ray = new CollisionRay(Owner.Transform.WorldPosition, dirVec, (int) CollisionGroup.MobMask);
|
var ray = new CollisionRay(Owner.Transform.WorldPosition, dirVec, (int) CollisionGroup.MobMask);
|
||||||
var rawRayCastResults = EntitySystem.Get<SharedBroadPhaseSystem>().IntersectRay(Owner.Transform.MapID, ray, 4.5f, Owner, false);
|
var rawRayCastResults = _physicsManager.IntersectRay(Owner.Transform.MapID, ray, 4.5f, Owner, false);
|
||||||
|
|
||||||
var rayCastResults = rawRayCastResults as RayCastResults[] ?? rawRayCastResults.ToArray();
|
var rayCastResults = rawRayCastResults as RayCastResults[] ?? rawRayCastResults.ToArray();
|
||||||
if(!rayCastResults.Any()) continue;
|
if(!rayCastResults.Any()) continue;
|
||||||
@@ -183,9 +182,9 @@ namespace Content.Server.GameObjects.Components.Singularity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CollideWith(IPhysBody ourBody, IPhysBody otherBody)
|
public void CollideWith(IEntity collidedWith)
|
||||||
{
|
{
|
||||||
if (otherBody.Entity.HasComponent<EmitterBoltComponent>())
|
if(collidedWith.HasComponent<EmitterBoltComponent>())
|
||||||
{
|
{
|
||||||
ReceivePower(4);
|
ReceivePower(4);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ namespace Content.Server.GameObjects.Components.Singularity
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
physicsComponent.BodyStatus = BodyStatus.InAir;
|
physicsComponent.Status = BodyStatus.InAir;
|
||||||
|
|
||||||
if (!projectile.TryGetComponent<ProjectileComponent>(out var projectileComponent))
|
if (!projectile.TryGetComponent<ProjectileComponent>(out var projectileComponent))
|
||||||
{
|
{
|
||||||
@@ -265,6 +265,7 @@ namespace Content.Server.GameObjects.Components.Singularity
|
|||||||
projectileComponent.IgnoreEntity(Owner);
|
projectileComponent.IgnoreEntity(Owner);
|
||||||
|
|
||||||
physicsComponent
|
physicsComponent
|
||||||
|
.EnsureController<BulletController>()
|
||||||
.LinearVelocity = Owner.Transform.WorldRotation.ToVec() * 20f;
|
.LinearVelocity = Owner.Transform.WorldRotation.ToVec() * 20f;
|
||||||
|
|
||||||
projectile.Transform.LocalRotation = Owner.Transform.WorldRotation;
|
projectile.Transform.LocalRotation = Owner.Transform.WorldRotation;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ using Robust.Shared.Log;
|
|||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Physics.Dynamics.Shapes;
|
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
@@ -39,6 +38,7 @@ namespace Content.Server.GameObjects.Components.Singularity
|
|||||||
_energy = value;
|
_energy = value;
|
||||||
if (_energy <= 0)
|
if (_energy <= 0)
|
||||||
{
|
{
|
||||||
|
if(_singularityController != null) _singularityController.LinearVelocity = Vector2.Zero;
|
||||||
_spriteComponent?.LayerSetVisible(0, false);
|
_spriteComponent?.LayerSetVisible(0, false);
|
||||||
|
|
||||||
Owner.Delete();
|
Owner.Delete();
|
||||||
@@ -75,7 +75,7 @@ namespace Content.Server.GameObjects.Components.Singularity
|
|||||||
_spriteComponent?.LayerSetRSI(0, "Effects/Singularity/singularity_" + _level + ".rsi");
|
_spriteComponent?.LayerSetRSI(0, "Effects/Singularity/singularity_" + _level + ".rsi");
|
||||||
_spriteComponent?.LayerSetState(0, "singularity_" + _level);
|
_spriteComponent?.LayerSetState(0, "singularity_" + _level);
|
||||||
|
|
||||||
if(_collidableComponent != null && _collidableComponent.Fixtures.Any() && _collidableComponent.Fixtures[0].Shape is PhysShapeCircle circle)
|
if(_collidableComponent != null && _collidableComponent.PhysicsShapes.Any() && _collidableComponent.PhysicsShapes[0] is PhysShapeCircle circle)
|
||||||
{
|
{
|
||||||
circle.Radius = _level - 0.5f;
|
circle.Radius = _level - 0.5f;
|
||||||
}
|
}
|
||||||
@@ -95,6 +95,7 @@ namespace Content.Server.GameObjects.Components.Singularity
|
|||||||
_ => 0
|
_ => 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private SingularityController? _singularityController;
|
||||||
private PhysicsComponent? _collidableComponent;
|
private PhysicsComponent? _collidableComponent;
|
||||||
private SpriteComponent? _spriteComponent;
|
private SpriteComponent? _spriteComponent;
|
||||||
private RadiationPulseComponent? _radiationPulseComponent;
|
private RadiationPulseComponent? _radiationPulseComponent;
|
||||||
@@ -128,6 +129,9 @@ namespace Content.Server.GameObjects.Components.Singularity
|
|||||||
Logger.Error("SingularityComponent was spawned without SpriteComponent");
|
Logger.Error("SingularityComponent was spawned without SpriteComponent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_singularityController = _collidableComponent?.EnsureController<SingularityController>();
|
||||||
|
if(_singularityController!=null)_singularityController.ControlledComponent = _collidableComponent;
|
||||||
|
|
||||||
if (!Owner.TryGetComponent(out _radiationPulseComponent))
|
if (!Owner.TryGetComponent(out _radiationPulseComponent))
|
||||||
{
|
{
|
||||||
Logger.Error("SingularityComponent was spawned without RadiationPulseComponent");
|
Logger.Error("SingularityComponent was spawned without RadiationPulseComponent");
|
||||||
@@ -136,18 +140,60 @@ namespace Content.Server.GameObjects.Components.Singularity
|
|||||||
Level = 1;
|
Level = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(int seconds)
|
public void Update()
|
||||||
{
|
{
|
||||||
Energy -= EnergyDrain * seconds;
|
Energy -= EnergyDrain;
|
||||||
|
|
||||||
|
if(Level == 1) return;
|
||||||
|
//pushing
|
||||||
|
var pushVector = new Vector2((_random.Next(-10, 10)), _random.Next(-10, 10));
|
||||||
|
while (pushVector.X == 0 && pushVector.Y == 0)
|
||||||
|
{
|
||||||
|
pushVector = new Vector2((_random.Next(-10, 10)), _random.Next(-10, 10));
|
||||||
|
}
|
||||||
|
_singularityController?.Push(pushVector.Normalized, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICollideBehavior.CollideWith(IPhysBody ourBody, IPhysBody otherBody)
|
private readonly List<IEntity> _previousPulledEntities = new();
|
||||||
|
public void CleanupPulledEntities()
|
||||||
{
|
{
|
||||||
var otherEntity = otherBody.Entity;
|
foreach (var previousPulledEntity in _previousPulledEntities)
|
||||||
|
|
||||||
if (otherEntity.TryGetComponent<IMapGridComponent>(out var mapGridComponent))
|
|
||||||
{
|
{
|
||||||
foreach (var tile in mapGridComponent.Grid.GetTilesIntersecting(ourBody.GetWorldAABB()))
|
if(previousPulledEntity.Deleted) continue;
|
||||||
|
if (!previousPulledEntity.TryGetComponent<PhysicsComponent>(out var collidableComponent)) continue;
|
||||||
|
var controller = collidableComponent.EnsureController<SingularityPullController>();
|
||||||
|
controller.StopPull();
|
||||||
|
}
|
||||||
|
_previousPulledEntities.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PullUpdate()
|
||||||
|
{
|
||||||
|
CleanupPulledEntities();
|
||||||
|
var entitiesToPull = Owner.EntityManager.GetEntitiesInRange(Owner.Transform.Coordinates, Level * 10);
|
||||||
|
foreach (var entity in entitiesToPull)
|
||||||
|
{
|
||||||
|
if (!entity.TryGetComponent<PhysicsComponent>(out var collidableComponent)) continue;
|
||||||
|
if (entity.HasComponent<GhostComponent>()) continue;
|
||||||
|
var controller = collidableComponent.EnsureController<SingularityPullController>();
|
||||||
|
if(Owner.Transform.Coordinates.EntityId != entity.Transform.Coordinates.EntityId) continue;
|
||||||
|
var vec = (Owner.Transform.Coordinates - entity.Transform.Coordinates).Position;
|
||||||
|
if (vec == Vector2.Zero) continue;
|
||||||
|
|
||||||
|
var speed = 10 / vec.Length * Level;
|
||||||
|
|
||||||
|
controller.Pull(vec.Normalized, speed);
|
||||||
|
_previousPulledEntities.Add(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ICollideBehavior.CollideWith(IEntity entity)
|
||||||
|
{
|
||||||
|
if (_collidableComponent == null) return; //how did it even collide then? :D
|
||||||
|
|
||||||
|
if (entity.TryGetComponent<IMapGridComponent>(out var mapGridComponent))
|
||||||
|
{
|
||||||
|
foreach (var tile in mapGridComponent.Grid.GetTilesIntersecting(((IPhysBody) _collidableComponent).WorldAABB))
|
||||||
{
|
{
|
||||||
mapGridComponent.Grid.SetTile(tile.GridIndices, Tile.Empty);
|
mapGridComponent.Grid.SetTile(tile.GridIndices, Tile.Empty);
|
||||||
Energy++;
|
Energy++;
|
||||||
@@ -155,14 +201,14 @@ namespace Content.Server.GameObjects.Components.Singularity
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (otherEntity.HasComponent<ContainmentFieldComponent>() || (otherEntity.TryGetComponent<ContainmentFieldGeneratorComponent>(out var component) && component.CanRepell(Owner)))
|
if (entity.HasComponent<ContainmentFieldComponent>() || (entity.TryGetComponent<ContainmentFieldGeneratorComponent>(out var component) && component.CanRepell(Owner)))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (otherEntity.IsInContainer()) return;
|
if (entity.IsInContainer()) return;
|
||||||
|
|
||||||
otherEntity.Delete();
|
entity.Delete();
|
||||||
Energy++;
|
Energy++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,6 +216,7 @@ namespace Content.Server.GameObjects.Components.Singularity
|
|||||||
{
|
{
|
||||||
_playingSound?.Stop();
|
_playingSound?.Stop();
|
||||||
_audioSystem.PlayAtCoords("/Audio/Effects/singularity_collapse.ogg", Owner.Transform.Coordinates);
|
_audioSystem.PlayAtCoords("/Audio/Effects/singularity_collapse.ogg", Owner.Transform.Coordinates);
|
||||||
|
CleanupPulledEntities();
|
||||||
base.OnRemove();
|
base.OnRemove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using Content.Shared.Atmos;
|
|||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.GameObjects.Components.Damage;
|
using Content.Shared.GameObjects.Components.Damage;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -30,7 +29,7 @@ namespace Content.Server.GameObjects.Components.Temperature
|
|||||||
[ViewVariables] public float HeatCapacity {
|
[ViewVariables] public float HeatCapacity {
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (Owner.TryGetComponent<IPhysBody>(out var physics))
|
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
|
||||||
{
|
{
|
||||||
return SpecificHeat * physics.Mass;
|
return SpecificHeat * physics.Mass;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using Content.Shared.GameObjects.Components.Weapons;
|
using Content.Shared.GameObjects.Components.Weapons;
|
||||||
using Content.Shared.Physics;
|
|
||||||
using Content.Shared.Utility;
|
using Content.Shared.Utility;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
@@ -32,17 +31,18 @@ namespace Content.Server.GameObjects.Components.Weapon
|
|||||||
|
|
||||||
public static void FlashAreaHelper(IEntity source, float range, float duration, string sound = null)
|
public static void FlashAreaHelper(IEntity source, float range, float duration, string sound = null)
|
||||||
{
|
{
|
||||||
foreach (var entity in source.EntityManager.GetEntitiesInRange(source.Transform.Coordinates, range))
|
foreach (var entity in IoCManager.Resolve<IEntityManager>().GetEntitiesInRange(source.Transform.Coordinates, range))
|
||||||
{
|
{
|
||||||
if (!entity.TryGetComponent(out FlashableComponent flashable) ||
|
if (!source.InRangeUnobstructed(entity, range, popup: true))
|
||||||
!source.InRangeUnobstructed(entity, range, CollisionGroup.Opaque)) continue;
|
continue;
|
||||||
|
|
||||||
flashable.Flash(duration);
|
if(entity.TryGetComponent(out FlashableComponent flashable))
|
||||||
|
flashable.Flash(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(sound))
|
if (!string.IsNullOrEmpty(sound))
|
||||||
{
|
{
|
||||||
EntitySystem.Get<AudioSystem>().PlayAtCoords(sound, source.Transform.Coordinates);
|
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>().PlayAtCoords(sound, source.Transform.Coordinates);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Physics.Broadphase;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
@@ -197,13 +196,10 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
|||||||
for (var i = 0; i < increments; i++)
|
for (var i = 0; i < increments; i++)
|
||||||
{
|
{
|
||||||
var castAngle = new Angle(baseAngle + increment * i);
|
var castAngle = new Angle(baseAngle + increment * i);
|
||||||
var res = EntitySystem.Get<SharedBroadPhaseSystem>().IntersectRay(mapId,
|
var res = _physicsManager.IntersectRay(mapId, new CollisionRay(position, castAngle.ToWorldVec(), (int) (CollisionGroup.Impassable|CollisionGroup.MobImpassable)), Range, ignore).FirstOrDefault();
|
||||||
new CollisionRay(position, castAngle.ToVec(),
|
if (res.HitEntity != null)
|
||||||
(int) (CollisionGroup.Impassable | CollisionGroup.MobImpassable)), Range, ignore).ToList();
|
|
||||||
|
|
||||||
if (res.Count != 0)
|
|
||||||
{
|
{
|
||||||
resSet.Add(res[0].HitEntity);
|
resSet.Add(res.HitEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ using Robust.Shared.Log;
|
|||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Physics.Broadphase;
|
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
@@ -384,14 +383,15 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
projectileAngle = angle;
|
projectileAngle = angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
var physics = projectile.GetComponent<IPhysBody>();
|
var physics = projectile.GetComponent<IPhysicsComponent>();
|
||||||
physics.BodyStatus = BodyStatus.InAir;
|
physics.Status = BodyStatus.InAir;
|
||||||
|
|
||||||
var projectileComponent = projectile.GetComponent<ProjectileComponent>();
|
var projectileComponent = projectile.GetComponent<ProjectileComponent>();
|
||||||
projectileComponent.IgnoreEntity(shooter);
|
projectileComponent.IgnoreEntity(shooter);
|
||||||
|
|
||||||
projectile
|
projectile
|
||||||
.GetComponent<IPhysBody>()
|
.GetComponent<IPhysicsComponent>()
|
||||||
|
.EnsureController<BulletController>()
|
||||||
.LinearVelocity = projectileAngle.ToVec() * velocity;
|
.LinearVelocity = projectileAngle.ToVec() * velocity;
|
||||||
|
|
||||||
projectile.Transform.LocalRotation = projectileAngle + MathHelper.PiOver2;
|
projectile.Transform.LocalRotation = projectileAngle + MathHelper.PiOver2;
|
||||||
@@ -421,7 +421,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
private void FireHitscan(IEntity shooter, HitscanComponent hitscan, Angle angle)
|
private void FireHitscan(IEntity shooter, HitscanComponent hitscan, Angle angle)
|
||||||
{
|
{
|
||||||
var ray = new CollisionRay(Owner.Transform.Coordinates.ToMapPos(Owner.EntityManager), angle.ToVec(), (int) hitscan.CollisionMask);
|
var ray = new CollisionRay(Owner.Transform.Coordinates.ToMapPos(Owner.EntityManager), angle.ToVec(), (int) hitscan.CollisionMask);
|
||||||
var physicsManager = EntitySystem.Get<SharedBroadPhaseSystem>();
|
var physicsManager = IoCManager.Resolve<IPhysicsManager>();
|
||||||
var rayCastResults = physicsManager.IntersectRay(Owner.Transform.MapID, ray, hitscan.MaxLength, shooter, false).ToList();
|
var rayCastResults = physicsManager.IntersectRay(Owner.Transform.MapID, ray, hitscan.MaxLength, shooter, false).ToList();
|
||||||
|
|
||||||
if (rayCastResults.Count >= 1)
|
if (rayCastResults.Count >= 1)
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
@@ -155,7 +154,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
|||||||
var targetNode = _pathfindingSystem.GetNode(targetTile);
|
var targetNode = _pathfindingSystem.GetNode(targetTile);
|
||||||
|
|
||||||
var collisionMask = 0;
|
var collisionMask = 0;
|
||||||
if (entity.TryGetComponent(out IPhysBody physics))
|
if (entity.TryGetComponent(out IPhysicsComponent physics))
|
||||||
{
|
{
|
||||||
collisionMask = physics.CollisionMask;
|
collisionMask = physics.CollisionMask;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||||||
using Content.Server.GameObjects.Components.Access;
|
using Content.Server.GameObjects.Components.Access;
|
||||||
using Content.Server.GameObjects.Components.Movement;
|
using Content.Server.GameObjects.Components.Movement;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||||
{
|
{
|
||||||
@@ -28,7 +27,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
|||||||
public static ReachableArgs GetArgs(IEntity entity)
|
public static ReachableArgs GetArgs(IEntity entity)
|
||||||
{
|
{
|
||||||
var collisionMask = 0;
|
var collisionMask = 0;
|
||||||
if (entity.TryGetComponent(out IPhysBody? physics))
|
if (entity.TryGetComponent(out IPhysicsComponent? physics))
|
||||||
{
|
{
|
||||||
collisionMask = physics.CollisionMask;
|
collisionMask = physics.CollisionMask;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ using Content.Server.GameObjects.Components.Doors;
|
|||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||||
@@ -41,7 +40,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
|||||||
GenerateMask();
|
GenerateMask();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsRelevant(IEntity entity, IPhysBody physicsComponent)
|
public static bool IsRelevant(IEntity entity, IPhysicsComponent physicsComponent)
|
||||||
{
|
{
|
||||||
if (entity.Transform.GridID == GridId.Invalid ||
|
if (entity.Transform.GridID == GridId.Invalid ||
|
||||||
(PathfindingSystem.TrackedCollisionLayers & physicsComponent.CollisionLayer) == 0)
|
(PathfindingSystem.TrackedCollisionLayers & physicsComponent.CollisionLayer) == 0)
|
||||||
@@ -257,7 +256,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
|||||||
/// <param name="entity"></param>
|
/// <param name="entity"></param>
|
||||||
/// TODO: These 2 methods currently don't account for a bunch of changes (e.g. airlock unpowered, wrenching, etc.)
|
/// TODO: These 2 methods currently don't account for a bunch of changes (e.g. airlock unpowered, wrenching, etc.)
|
||||||
/// TODO: Could probably optimise this slightly more.
|
/// TODO: Could probably optimise this slightly more.
|
||||||
public void AddEntity(IEntity entity, IPhysBody physicsComponent)
|
public void AddEntity(IEntity entity, IPhysicsComponent physicsComponent)
|
||||||
{
|
{
|
||||||
// If we're a door
|
// If we're a door
|
||||||
if (entity.HasComponent<AirlockComponent>() || entity.HasComponent<ServerDoorComponent>())
|
if (entity.HasComponent<AirlockComponent>() || entity.HasComponent<ServerDoorComponent>())
|
||||||
@@ -276,7 +275,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
|||||||
|
|
||||||
DebugTools.Assert((PathfindingSystem.TrackedCollisionLayers & physicsComponent.CollisionLayer) != 0);
|
DebugTools.Assert((PathfindingSystem.TrackedCollisionLayers & physicsComponent.CollisionLayer) != 0);
|
||||||
|
|
||||||
if (physicsComponent.BodyType == BodyType.Static)
|
if (!physicsComponent.Anchored)
|
||||||
{
|
{
|
||||||
_physicsLayers.Add(entity, physicsComponent.CollisionLayer);
|
_physicsLayers.Add(entity, physicsComponent.CollisionLayer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||||
@@ -30,7 +29,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||||
|
|
||||||
public IReadOnlyDictionary<GridId, Dictionary<Vector2i, PathfindingChunk>> Graph => _graph;
|
public IReadOnlyDictionary<GridId, Dictionary<Vector2i, PathfindingChunk>> Graph => _graph;
|
||||||
private readonly Dictionary<GridId, Dictionary<Vector2i, PathfindingChunk>> _graph = new();
|
private readonly Dictionary<GridId, Dictionary<Vector2i, PathfindingChunk>> _graph = new();
|
||||||
|
|
||||||
@@ -82,8 +81,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
|||||||
|
|
||||||
foreach (var update in _collidableUpdateQueue)
|
foreach (var update in _collidableUpdateQueue)
|
||||||
{
|
{
|
||||||
if (!EntityManager.TryGetEntity(update.Owner, out var entity)) continue;
|
var entity = EntityManager.GetEntity(update.Owner);
|
||||||
|
|
||||||
if (update.CanCollide)
|
if (update.CanCollide)
|
||||||
{
|
{
|
||||||
HandleEntityAdd(entity);
|
HandleEntityAdd(entity);
|
||||||
@@ -264,7 +262,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
|||||||
{
|
{
|
||||||
if (entity.Deleted ||
|
if (entity.Deleted ||
|
||||||
_lastKnownPositions.ContainsKey(entity) ||
|
_lastKnownPositions.ContainsKey(entity) ||
|
||||||
!entity.TryGetComponent(out IPhysBody physics) ||
|
!entity.TryGetComponent(out IPhysicsComponent physics) ||
|
||||||
!PathfindingNode.IsRelevant(entity, physics))
|
!PathfindingNode.IsRelevant(entity, physics))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -303,7 +301,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
|||||||
{
|
{
|
||||||
// If we've moved to space or the likes then remove us.
|
// If we've moved to space or the likes then remove us.
|
||||||
if (moveEvent.Sender.Deleted ||
|
if (moveEvent.Sender.Deleted ||
|
||||||
!moveEvent.Sender.TryGetComponent(out IPhysBody physics) ||
|
!moveEvent.Sender.TryGetComponent(out IPhysicsComponent physics) ||
|
||||||
!PathfindingNode.IsRelevant(moveEvent.Sender, physics) ||
|
!PathfindingNode.IsRelevant(moveEvent.Sender, physics) ||
|
||||||
moveEvent.NewPosition.GetGridId(EntityManager) == GridId.Invalid)
|
moveEvent.NewPosition.GetGridId(EntityManager) == GridId.Invalid)
|
||||||
{
|
{
|
||||||
@@ -368,7 +366,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
|||||||
|
|
||||||
public bool CanTraverse(IEntity entity, PathfindingNode node)
|
public bool CanTraverse(IEntity entity, PathfindingNode node)
|
||||||
{
|
{
|
||||||
if (entity.TryGetComponent(out IPhysBody physics) &&
|
if (entity.TryGetComponent(out IPhysicsComponent physics) &&
|
||||||
(physics.CollisionMask & node.BlockedCollisionMask) != 0)
|
(physics.CollisionMask & node.BlockedCollisionMask) != 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
@@ -414,7 +413,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
|||||||
var startTile = gridManager.GetTileRef(entity.Transform.Coordinates);
|
var startTile = gridManager.GetTileRef(entity.Transform.Coordinates);
|
||||||
var endTile = gridManager.GetTileRef(steeringRequest.TargetGrid);
|
var endTile = gridManager.GetTileRef(steeringRequest.TargetGrid);
|
||||||
var collisionMask = 0;
|
var collisionMask = 0;
|
||||||
if (entity.TryGetComponent(out IPhysBody physics))
|
if (entity.TryGetComponent(out IPhysicsComponent physics))
|
||||||
{
|
{
|
||||||
collisionMask = physics.CollisionMask;
|
collisionMask = physics.CollisionMask;
|
||||||
}
|
}
|
||||||
@@ -600,7 +599,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
|||||||
return Vector2.Zero;
|
return Vector2.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target.TryGetComponent(out IPhysBody physics))
|
if (target.TryGetComponent(out IPhysicsComponent physics))
|
||||||
{
|
{
|
||||||
var targetDistance = (targetPos.Position - entityPos.Position);
|
var targetDistance = (targetPos.Position - entityPos.Position);
|
||||||
targetPos = targetPos.Offset(physics.LinearVelocity * targetDistance);
|
targetPos = targetPos.Offset(physics.LinearVelocity * targetDistance);
|
||||||
@@ -618,7 +617,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private Vector2 CollisionAvoidance(IEntity entity, Vector2 direction, ICollection<IEntity> ignoredTargets)
|
private Vector2 CollisionAvoidance(IEntity entity, Vector2 direction, ICollection<IEntity> ignoredTargets)
|
||||||
{
|
{
|
||||||
if (direction == Vector2.Zero || !entity.TryGetComponent(out IPhysBody physics))
|
if (direction == Vector2.Zero || !entity.TryGetComponent(out IPhysicsComponent physics))
|
||||||
{
|
{
|
||||||
return Vector2.Zero;
|
return Vector2.Zero;
|
||||||
}
|
}
|
||||||
@@ -659,7 +658,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
|||||||
// if we're moving in the same direction then ignore
|
// if we're moving in the same direction then ignore
|
||||||
// So if 2 entities are moving towards each other and both detect a collision they'll both move in the same direction
|
// So if 2 entities are moving towards each other and both detect a collision they'll both move in the same direction
|
||||||
// i.e. towards the right
|
// i.e. towards the right
|
||||||
if (physicsEntity.TryGetComponent(out IPhysBody otherPhysics) &&
|
if (physicsEntity.TryGetComponent(out IPhysicsComponent otherPhysics) &&
|
||||||
Vector2.Dot(otherPhysics.LinearVelocity, direction) > 0)
|
Vector2.Dot(otherPhysics.LinearVelocity, direction) > 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Content.Server.GameObjects.Components.Items.Storage;
|
using Content.Server.GameObjects.Components.Items.Storage;
|
||||||
@@ -26,7 +25,6 @@ using Robust.Shared.IoC;
|
|||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Players;
|
using Robust.Shared.Players;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.EntitySystems.Click
|
namespace Content.Server.GameObjects.EntitySystems.Click
|
||||||
@@ -39,8 +37,6 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||||
|
|
||||||
private List<IThrowCollide> _throwCollide = new();
|
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
SubscribeNetworkEvent<DragDropMessage>(HandleDragDropMessage);
|
SubscribeNetworkEvent<DragDropMessage>(HandleDragDropMessage);
|
||||||
@@ -606,43 +602,28 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
|||||||
/// Calls ThrowCollide on all components that implement the IThrowCollide interface
|
/// Calls ThrowCollide on all components that implement the IThrowCollide interface
|
||||||
/// on a thrown entity and the target entity it hit.
|
/// on a thrown entity and the target entity it hit.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ThrowCollideInteraction(IEntity user, IPhysBody thrown, IPhysBody target)
|
public void ThrowCollideInteraction(IEntity user, IEntity thrown, IEntity target, EntityCoordinates location)
|
||||||
{
|
{
|
||||||
// TODO: Just pass in the bodies directly
|
var collideMsg = new ThrowCollideMessage(user, thrown, target, location);
|
||||||
var collideMsg = new ThrowCollideMessage(user, thrown.Entity, target.Entity);
|
|
||||||
RaiseLocalEvent(collideMsg);
|
RaiseLocalEvent(collideMsg);
|
||||||
if (collideMsg.Handled)
|
if (collideMsg.Handled)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var eventArgs = new ThrowCollideEventArgs(user, thrown.Entity, target.Entity);
|
var eventArgs = new ThrowCollideEventArgs(user, thrown, target, location);
|
||||||
|
|
||||||
foreach (var comp in thrown.Entity.GetAllComponents<IThrowCollide>())
|
foreach (var comp in thrown.GetAllComponents<IThrowCollide>().ToArray())
|
||||||
{
|
{
|
||||||
_throwCollide.Add(comp);
|
if (thrown.Deleted) break;
|
||||||
|
comp.DoHit(eventArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var collide in _throwCollide)
|
foreach (var comp in target.GetAllComponents<IThrowCollide>().ToArray())
|
||||||
{
|
{
|
||||||
if (thrown.Entity.Deleted) break;
|
if (target.Deleted) break;
|
||||||
collide.DoHit(eventArgs);
|
comp.HitBy(eventArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
_throwCollide.Clear();
|
|
||||||
|
|
||||||
foreach (var comp in target.Entity.GetAllComponents<IThrowCollide>())
|
|
||||||
{
|
|
||||||
_throwCollide.Add(comp);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var collide in _throwCollide)
|
|
||||||
{
|
|
||||||
if (target.Entity.Deleted) break;
|
|
||||||
collide.HitBy(eventArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
_throwCollide.Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,39 +1,18 @@
|
|||||||
using System.Collections.Generic;
|
using Content.Server.GameObjects.Components.Movement;
|
||||||
using System.Linq;
|
|
||||||
using Content.Server.GameObjects.Components.Movement;
|
|
||||||
using Content.Shared.GameObjects.Components.Movement;
|
|
||||||
using Content.Shared.GameTicking;
|
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.EntitySystems
|
namespace Content.Server.GameObjects.EntitySystems
|
||||||
{
|
{
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
internal sealed class ClimbSystem : EntitySystem, IResettingEntitySystem
|
internal sealed class ClimbSystem : EntitySystem
|
||||||
{
|
{
|
||||||
private readonly HashSet<ClimbingComponent> _activeClimbers = new();
|
|
||||||
|
|
||||||
public void AddActiveClimber(ClimbingComponent climbingComponent)
|
|
||||||
{
|
|
||||||
_activeClimbers.Add(climbingComponent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveActiveClimber(ClimbingComponent climbingComponent)
|
|
||||||
{
|
|
||||||
_activeClimbers.Remove(climbingComponent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
{
|
{
|
||||||
foreach (var climber in _activeClimbers.ToArray())
|
foreach (var comp in ComponentManager.EntityQuery<ClimbingComponent>(true))
|
||||||
{
|
{
|
||||||
climber.Update();
|
comp.Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reset()
|
|
||||||
{
|
|
||||||
_activeClimbers.Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
Content.Server/GameObjects/EntitySystems/ConveyorSystem.cs
Normal file
18
Content.Server/GameObjects/EntitySystems/ConveyorSystem.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using Content.Server.GameObjects.Components.Conveyor;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
|
||||||
|
namespace Content.Server.GameObjects.EntitySystems
|
||||||
|
{
|
||||||
|
[UsedImplicitly]
|
||||||
|
internal sealed class ConveyorSystem : EntitySystem
|
||||||
|
{
|
||||||
|
public override void Update(float frameTime)
|
||||||
|
{
|
||||||
|
foreach (var comp in ComponentManager.EntityQuery<ConveyorComponent>(true))
|
||||||
|
{
|
||||||
|
comp.Update(frameTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.GameObjects.Components.GUI;
|
using Content.Server.GameObjects.Components.GUI;
|
||||||
using Content.Server.GameObjects.Components.Items;
|
|
||||||
using Content.Server.GameObjects.Components.Items.Storage;
|
using Content.Server.GameObjects.Components.Items.Storage;
|
||||||
using Content.Server.GameObjects.Components.Stack;
|
using Content.Server.GameObjects.Components.Stack;
|
||||||
using Content.Server.GameObjects.EntitySystems.Click;
|
using Content.Server.GameObjects.EntitySystems.Click;
|
||||||
using Content.Server.Interfaces.GameObjects.Components.Items;
|
using Content.Server.Interfaces.GameObjects.Components.Items;
|
||||||
|
using Content.Server.Throw;
|
||||||
using Content.Shared.GameObjects.EntitySystems;
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
using Content.Shared.Interfaces;
|
using Content.Shared.Interfaces;
|
||||||
@@ -144,12 +144,12 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
|
|
||||||
private bool HandleThrowItem(ICommonSession session, EntityCoordinates coords, EntityUid uid)
|
private bool HandleThrowItem(ICommonSession session, EntityCoordinates coords, EntityUid uid)
|
||||||
{
|
{
|
||||||
var playerEnt = ((IPlayerSession)session).AttachedEntity;
|
var plyEnt = ((IPlayerSession)session).AttachedEntity;
|
||||||
|
|
||||||
if (playerEnt == null || !playerEnt.IsValid())
|
if (plyEnt == null || !plyEnt.IsValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!playerEnt.TryGetComponent(out HandsComponent handsComp))
|
if (!plyEnt.TryGetComponent(out HandsComponent handsComp))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!handsComp.CanDrop(handsComp.ActiveHand))
|
if (!handsComp.CanDrop(handsComp.ActiveHand))
|
||||||
@@ -168,19 +168,14 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
stackComp.Use(1);
|
stackComp.Use(1);
|
||||||
throwEnt = throwEnt.EntityManager.SpawnEntity(throwEnt.Prototype.ID, playerEnt.Transform.Coordinates);
|
throwEnt = throwEnt.EntityManager.SpawnEntity(throwEnt.Prototype.ID, plyEnt.Transform.Coordinates);
|
||||||
|
|
||||||
// can only throw one item at a time, regardless of what the prototype stack size is.
|
// can only throw one item at a time, regardless of what the prototype stack size is.
|
||||||
if (throwEnt.TryGetComponent<StackComponent>(out var newStackComp))
|
if (throwEnt.TryGetComponent<StackComponent>(out var newStackComp))
|
||||||
newStackComp.Count = 1;
|
newStackComp.Count = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var direction = coords.ToMapPos(EntityManager) - playerEnt.Transform.WorldPosition;
|
throwEnt.ThrowTo(ThrowForce, coords, plyEnt.Transform.Coordinates, false, plyEnt);
|
||||||
if (direction == Vector2.Zero) return true;
|
|
||||||
|
|
||||||
direction = direction.Normalized * MathF.Min(direction.Length, 8.0f);
|
|
||||||
|
|
||||||
throwEnt.TryThrow(direction * ThrowForce * 15);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System.Collections.Generic;
|
|
||||||
using Content.Server.GameObjects.Components.GUI;
|
using Content.Server.GameObjects.Components.GUI;
|
||||||
using Content.Server.GameObjects.Components.Items.Storage;
|
using Content.Server.GameObjects.Components.Items.Storage;
|
||||||
using Content.Server.GameObjects.Components.Mobs;
|
using Content.Server.GameObjects.Components.Mobs;
|
||||||
using Content.Server.GameObjects.Components.Movement;
|
|
||||||
using Content.Server.GameObjects.Components.Sound;
|
using Content.Server.GameObjects.Components.Sound;
|
||||||
using Content.Shared.Audio;
|
using Content.Shared.Audio;
|
||||||
using Content.Shared.GameObjects.Components.Inventory;
|
using Content.Shared.GameObjects.Components.Inventory;
|
||||||
using Content.Shared.GameObjects.Components.Movement;
|
using Content.Shared.GameObjects.Components.Movement;
|
||||||
using Content.Shared.GameObjects.Components.Tag;
|
using Content.Shared.GameObjects.Components.Tag;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Content.Shared.Maps;
|
using Content.Shared.Maps;
|
||||||
using Content.Shared.Physics;
|
using Content.Shared.Physics;
|
||||||
using Content.Shared.Physics.Controllers;
|
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
@@ -19,15 +17,13 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Physics.Dynamics;
|
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
namespace Content.Server.Physics.Controllers
|
namespace Content.Server.GameObjects.EntitySystems
|
||||||
{
|
{
|
||||||
public class MoverController : SharedMoverController
|
[UsedImplicitly]
|
||||||
|
internal class MoverSystem : SharedMoverSystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
|
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
|
||||||
@@ -39,83 +35,54 @@ namespace Content.Server.Physics.Controllers
|
|||||||
private const float StepSoundMoveDistanceRunning = 2;
|
private const float StepSoundMoveDistanceRunning = 2;
|
||||||
private const float StepSoundMoveDistanceWalking = 1.5f;
|
private const float StepSoundMoveDistanceWalking = 1.5f;
|
||||||
|
|
||||||
private HashSet<EntityUid> _excludedMobs = new();
|
/// <inheritdoc />
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
_audioSystem = EntitySystem.Get<AudioSystem>();
|
SubscribeLocalEvent<PlayerDetachedSystemMessage>(PlayerDetached);
|
||||||
|
|
||||||
|
_audioSystem = EntitySystemManager.GetEntitySystem<AudioSystem>();
|
||||||
|
|
||||||
|
UpdatesBefore.Add(typeof(PhysicsSystem));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void UpdateBeforeSolve(bool prediction, float frameTime)
|
public override void Update(float frameTime)
|
||||||
{
|
{
|
||||||
base.UpdateBeforeSolve(prediction, frameTime);
|
foreach (var (moverComponent, collidableComponent) in EntityManager.ComponentManager
|
||||||
_excludedMobs.Clear();
|
.EntityQuery<IMoverComponent, IPhysicsComponent>(false))
|
||||||
|
|
||||||
foreach (var (mobMover, mover, physics) in ComponentManager.EntityQuery<IMobMoverComponent, IMoverComponent, PhysicsComponent>())
|
|
||||||
{
|
{
|
||||||
_excludedMobs.Add(mover.Owner.Uid);
|
var entity = moverComponent.Owner;
|
||||||
HandleMobMovement(mover, physics, mobMover);
|
UpdateKinematics(entity.Transform, moverComponent, collidableComponent);
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var mover in ComponentManager.EntityQuery<ShuttleControllerComponent>())
|
|
||||||
{
|
|
||||||
_excludedMobs.Add(mover.Owner.Uid);
|
|
||||||
HandleShuttleMovement(mover);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var (mover, physics) in ComponentManager.EntityQuery<IMoverComponent, PhysicsComponent>(true))
|
|
||||||
{
|
|
||||||
if (_excludedMobs.Contains(mover.Owner.Uid)) continue;
|
|
||||||
|
|
||||||
HandleKinematicMovement(mover, physics);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
private void PlayerDetached(PlayerDetachedSystemMessage ev)
|
||||||
* Some thoughts:
|
|
||||||
* Unreal actually doesn't predict vehicle movement at all, it's purely server-side which I thought was interesting
|
|
||||||
* The reason for this is that vehicles change direction very slowly compared to players so you don't really have the requirement for quick movement anyway
|
|
||||||
* As such could probably just look at applying a force / impulse to the shuttle server-side only so it controls like the titanic.
|
|
||||||
*/
|
|
||||||
private void HandleShuttleMovement(ShuttleControllerComponent mover)
|
|
||||||
{
|
{
|
||||||
var gridId = mover.Owner.Transform.GridID;
|
if (ev.Entity.TryGetComponent(out IPhysicsComponent? physics) &&
|
||||||
|
physics.TryGetController(out MoverController controller) &&
|
||||||
if (!_mapManager.TryGetGrid(gridId, out var grid) || !EntityManager.TryGetEntity(grid.GridEntityId, out var gridEntity)) return;
|
!ev.Entity.IsWeightless())
|
||||||
|
|
||||||
//TODO: Switch to shuttle component
|
|
||||||
if (!gridEntity.TryGetComponent(out PhysicsComponent? physics))
|
|
||||||
{
|
{
|
||||||
physics = gridEntity.AddComponent<PhysicsComponent>();
|
controller.StopMoving();
|
||||||
physics.BodyStatus = BodyStatus.InAir;
|
|
||||||
physics.Mass = 1;
|
|
||||||
physics.CanCollide = true;
|
|
||||||
physics.AddFixture(new Fixture(physics, new PhysShapeGrid(grid)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Uhh this probably doesn't work but I still need to rip out the entity tree and make RenderingTreeSystem use grids so I'm not overly concerned about breaking shuttles.
|
|
||||||
physics.ApplyForce(mover.VelocityDir.walking + mover.VelocityDir.sprinting);
|
|
||||||
mover.VelocityDir = (Vector2.Zero, Vector2.Zero);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void HandleFootsteps(IMoverComponent mover, IMobMoverComponent mobMover)
|
protected override void HandleFootsteps(IMoverComponent mover)
|
||||||
{
|
{
|
||||||
var transform = mover.Owner.Transform;
|
var transform = mover.Owner.Transform;
|
||||||
// Handle footsteps.
|
// Handle footsteps.
|
||||||
if (_mapManager.GridExists(mobMover.LastPosition.GetGridId(EntityManager)))
|
if (_mapManager.GridExists(mover.LastPosition.GetGridId(EntityManager)))
|
||||||
{
|
{
|
||||||
// Can happen when teleporting between grids.
|
// Can happen when teleporting between grids.
|
||||||
if (!transform.Coordinates.TryDistance(EntityManager, mobMover.LastPosition, out var distance))
|
if (!transform.Coordinates.TryDistance(EntityManager, mover.LastPosition, out var distance))
|
||||||
{
|
{
|
||||||
mobMover.LastPosition = transform.Coordinates;
|
mover.LastPosition = transform.Coordinates;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mobMover.StepSoundDistance += distance;
|
mover.StepSoundDistance += distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
mobMover.LastPosition = transform.Coordinates;
|
mover.LastPosition = transform.Coordinates;
|
||||||
float distanceNeeded;
|
float distanceNeeded;
|
||||||
if (mover.Sprinting)
|
if (mover.Sprinting)
|
||||||
{
|
{
|
||||||
@@ -126,11 +93,11 @@ namespace Content.Server.Physics.Controllers
|
|||||||
distanceNeeded = StepSoundMoveDistanceWalking;
|
distanceNeeded = StepSoundMoveDistanceWalking;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mobMover.StepSoundDistance > distanceNeeded)
|
if (mover.StepSoundDistance > distanceNeeded)
|
||||||
{
|
{
|
||||||
mobMover.StepSoundDistance = 0;
|
mover.StepSoundDistance = 0;
|
||||||
|
|
||||||
if (!mover.Owner.HasTag("FootstepSound") || mover.Owner.Transform.GridID == GridId.Invalid)
|
if (!mover.Owner.HasTag("FootstepSound"))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -192,6 +159,5 @@ namespace Content.Server.Physics.Controllers
|
|||||||
Logger.ErrorS("sound", $"Unable to find sound collection for {soundCollectionName}");
|
Logger.ErrorS("sound", $"Unable to find sound collection for {soundCollectionName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,6 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Physics.Broadphase;
|
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
@@ -138,7 +137,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
// Determine if the solar panel is occluded, and zero out coverage if so.
|
// Determine if the solar panel is occluded, and zero out coverage if so.
|
||||||
// FIXME: The "Opaque" collision group doesn't seem to work right now.
|
// FIXME: The "Opaque" collision group doesn't seem to work right now.
|
||||||
var ray = new CollisionRay(entity.Transform.WorldPosition, TowardsSun.ToVec(), (int) CollisionGroup.Opaque);
|
var ray = new CollisionRay(entity.Transform.WorldPosition, TowardsSun.ToVec(), (int) CollisionGroup.Opaque);
|
||||||
var rayCastResults = EntitySystem.Get<SharedBroadPhaseSystem>().IntersectRay(entity.Transform.MapID, ray, SunOcclusionCheckDistance, entity);
|
var rayCastResults = IoCManager.Resolve<IPhysicsManager>().IntersectRay(entity.Transform.MapID, ray, SunOcclusionCheckDistance, entity);
|
||||||
if (rayCastResults.Any())
|
if (rayCastResults.Any())
|
||||||
coverage = 0;
|
coverage = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
18
Content.Server/GameObjects/EntitySystems/RecyclerSystem.cs
Normal file
18
Content.Server/GameObjects/EntitySystems/RecyclerSystem.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using Content.Server.GameObjects.Components.Recycling;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
|
||||||
|
namespace Content.Server.GameObjects.EntitySystems
|
||||||
|
{
|
||||||
|
[UsedImplicitly]
|
||||||
|
internal sealed class RecyclerSystem : EntitySystem
|
||||||
|
{
|
||||||
|
public override void Update(float frameTime)
|
||||||
|
{
|
||||||
|
foreach (var component in ComponentManager.EntityQuery<RecyclerComponent>(true))
|
||||||
|
{
|
||||||
|
component.Update(frameTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,21 +7,36 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class SingularitySystem : EntitySystem
|
public class SingularitySystem : EntitySystem
|
||||||
{
|
{
|
||||||
private float _accumulator;
|
private float curTimeSingulo;
|
||||||
|
private float curTimePull;
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
{
|
{
|
||||||
base.Update(frameTime);
|
base.Update(frameTime);
|
||||||
|
|
||||||
_accumulator += frameTime;
|
curTimeSingulo += frameTime;
|
||||||
|
curTimePull += frameTime;
|
||||||
|
|
||||||
while (_accumulator > 1.0f)
|
var shouldUpdate = curTimeSingulo >= 1f;
|
||||||
|
var shouldPull = curTimePull >= 0.2f;
|
||||||
|
if (!shouldUpdate && !shouldPull) return;
|
||||||
|
var singulos = ComponentManager.EntityQuery<SingularityComponent>(true);
|
||||||
|
|
||||||
|
if (curTimeSingulo >= 1f)
|
||||||
{
|
{
|
||||||
_accumulator -= 1.0f;
|
curTimeSingulo -= 1f;
|
||||||
|
foreach (var singulo in singulos)
|
||||||
foreach (var singularity in ComponentManager.EntityQuery<SingularityComponent>())
|
|
||||||
{
|
{
|
||||||
singularity.Update(1);
|
singulo.Update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (curTimePull >= 0.5f)
|
||||||
|
{
|
||||||
|
curTimePull -= 0.5f;
|
||||||
|
foreach (var singulo in singulos)
|
||||||
|
{
|
||||||
|
singulo.PullUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,118 +0,0 @@
|
|||||||
#nullable enable
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Content.Server.GameObjects.Components.Conveyor;
|
|
||||||
using Content.Server.GameObjects.Components.Recycling;
|
|
||||||
using Content.Shared.GameObjects.Components.Movement;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.Maths;
|
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Physics.Controllers;
|
|
||||||
|
|
||||||
namespace Content.Server.Physics.Controllers
|
|
||||||
{
|
|
||||||
internal sealed class ConveyorController : VirtualController
|
|
||||||
{
|
|
||||||
public override List<Type> UpdatesAfter => new() {typeof(MoverController)};
|
|
||||||
|
|
||||||
public override void UpdateBeforeSolve(bool prediction, float frameTime)
|
|
||||||
{
|
|
||||||
base.UpdateBeforeSolve(prediction, frameTime);
|
|
||||||
foreach (var comp in ComponentManager.EntityQuery<ConveyorComponent>())
|
|
||||||
{
|
|
||||||
Convey(comp, frameTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Uhh you can probably wrap the recycler's conveying properties into... conveyor
|
|
||||||
foreach (var comp in ComponentManager.EntityQuery<RecyclerComponent>())
|
|
||||||
{
|
|
||||||
ConveyRecycler(comp, frameTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Convey(ConveyorComponent comp, float frameTime)
|
|
||||||
{
|
|
||||||
// TODO: Use ICollideBehavior and cache intersecting
|
|
||||||
// Use an event for conveyors to know what needs to run
|
|
||||||
if (!comp.CanRun())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var intersecting = EntityManager.GetEntitiesIntersecting(comp.Owner, true);
|
|
||||||
var direction = comp.GetAngle().ToVec();
|
|
||||||
Vector2? ownerPos = null;
|
|
||||||
|
|
||||||
foreach (var entity in intersecting)
|
|
||||||
{
|
|
||||||
if (!comp.CanMove(entity)) continue;
|
|
||||||
|
|
||||||
if (!entity.TryGetComponent(out IPhysBody? physics) || physics.BodyStatus == BodyStatus.InAir ||
|
|
||||||
entity.IsWeightless()) continue;
|
|
||||||
|
|
||||||
ownerPos ??= comp.Owner.Transform.WorldPosition;
|
|
||||||
var itemRelativeToConveyor = entity.Transform.WorldPosition - ownerPos.Value;
|
|
||||||
|
|
||||||
physics.LinearVelocity += Convey(direction * comp.Speed, frameTime, itemRelativeToConveyor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO Uhhh I did a shit job plz fix smug
|
|
||||||
private Vector2 Convey(Vector2 velocityDirection, float frameTime, Vector2 itemRelativeToConveyor)
|
|
||||||
{
|
|
||||||
//gravitating item towards center
|
|
||||||
//http://csharphelper.com/blog/2016/09/find-the-shortest-distance-between-a-point-and-a-line-segment-in-c/
|
|
||||||
Vector2 centerPoint;
|
|
||||||
|
|
||||||
var t = 0f;
|
|
||||||
if (velocityDirection.Length > 0) // if velocitydirection is 0, this calculation will divide by 0
|
|
||||||
{
|
|
||||||
t = Vector2.Dot(itemRelativeToConveyor, velocityDirection) /
|
|
||||||
Vector2.Dot(velocityDirection, velocityDirection);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (t < 0)
|
|
||||||
{
|
|
||||||
centerPoint = new Vector2();
|
|
||||||
}
|
|
||||||
else if (t > 1)
|
|
||||||
{
|
|
||||||
centerPoint = velocityDirection;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
centerPoint = velocityDirection * t;
|
|
||||||
}
|
|
||||||
|
|
||||||
var delta = centerPoint - itemRelativeToConveyor;
|
|
||||||
return delta * (400 * delta.Length) * frameTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ConveyRecycler(RecyclerComponent comp, float frameTime)
|
|
||||||
{
|
|
||||||
if (!comp.CanRun())
|
|
||||||
{
|
|
||||||
comp.Intersecting.Clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var direction = Vector2.UnitX;
|
|
||||||
Vector2? ownerPos = null;
|
|
||||||
|
|
||||||
for (var i = comp.Intersecting.Count - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
var entity = comp.Intersecting[i];
|
|
||||||
|
|
||||||
if (entity.Deleted || !comp.CanMove(entity) || !EntityManager.IsIntersecting(comp.Owner, entity))
|
|
||||||
{
|
|
||||||
comp.Intersecting.RemoveAt(i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!entity.TryGetComponent(out IPhysBody? physics)) continue;
|
|
||||||
ownerPos ??= comp.Owner.Transform.WorldPosition;
|
|
||||||
physics.LinearVelocity += Convey(direction, frameTime, entity.Transform.WorldPosition - ownerPos.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
#nullable enable
|
|
||||||
using Content.Server.GameObjects.Components.Observer;
|
|
||||||
using Content.Server.GameObjects.Components.Singularity;
|
|
||||||
using Robust.Server.GameObjects;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Map;
|
|
||||||
using Robust.Shared.Maths;
|
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Physics.Broadphase;
|
|
||||||
using Robust.Shared.Physics.Controllers;
|
|
||||||
using Robust.Shared.Random;
|
|
||||||
|
|
||||||
namespace Content.Server.Physics.Controllers
|
|
||||||
{
|
|
||||||
internal sealed class SingularityController : VirtualController
|
|
||||||
{
|
|
||||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
|
||||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
|
||||||
|
|
||||||
private float _pullAccumulator;
|
|
||||||
private float _moveAccumulator;
|
|
||||||
|
|
||||||
public override void UpdateBeforeSolve(bool prediction, float frameTime)
|
|
||||||
{
|
|
||||||
base.UpdateBeforeSolve(prediction, frameTime);
|
|
||||||
|
|
||||||
_moveAccumulator += frameTime;
|
|
||||||
_pullAccumulator += frameTime;
|
|
||||||
|
|
||||||
while (_pullAccumulator > 0.5f)
|
|
||||||
{
|
|
||||||
_pullAccumulator -= 0.5f;
|
|
||||||
|
|
||||||
foreach (var singularity in ComponentManager.EntityQuery<SingularityComponent>())
|
|
||||||
{
|
|
||||||
// TODO: Use colliders instead probably yada yada
|
|
||||||
PullEntities(singularity);
|
|
||||||
// Yeah look the collision with station wasn't working and I'm 15k lines in and not debugging this shit
|
|
||||||
DestroyTiles(singularity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (_moveAccumulator > 1.0f)
|
|
||||||
{
|
|
||||||
_moveAccumulator -= 1.0f;
|
|
||||||
|
|
||||||
foreach (var (singularity, physics) in ComponentManager.EntityQuery<SingularityComponent, PhysicsComponent>())
|
|
||||||
{
|
|
||||||
if (singularity.Owner.HasComponent<BasicActorComponent>()) continue;
|
|
||||||
|
|
||||||
// TODO: Need to essentially use a push vector in a random direction for us PLUS
|
|
||||||
// Any entity colliding with our larger circlebox needs to have an impulse applied to itself.
|
|
||||||
physics.BodyStatus = BodyStatus.InAir;
|
|
||||||
MoveSingulo(singularity, physics);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MoveSingulo(SingularityComponent singularity, PhysicsComponent physics)
|
|
||||||
{
|
|
||||||
if (singularity.Level <= 1) return;
|
|
||||||
// TODO: Could try gradual changes instead but for now just try to replicate
|
|
||||||
|
|
||||||
var pushVector = new Vector2(_robustRandom.Next(-10, 10), _robustRandom.Next(-10, 10));
|
|
||||||
|
|
||||||
if (pushVector == Vector2.Zero) return;
|
|
||||||
|
|
||||||
physics.LinearVelocity = Vector2.Zero;
|
|
||||||
physics.LinearVelocity = pushVector.Normalized * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PullEntities(SingularityComponent component)
|
|
||||||
{
|
|
||||||
var singularityCoords = component.Owner.Transform.Coordinates;
|
|
||||||
// TODO: Maybe if we have named fixtures needs to pull out the outer circle collider (inner will be for deleting).
|
|
||||||
var entitiesToPull = EntityManager.GetEntitiesInRange(singularityCoords, component.Level * 10);
|
|
||||||
foreach (var entity in entitiesToPull)
|
|
||||||
{
|
|
||||||
if (!entity.TryGetComponent<PhysicsComponent>(out var collidableComponent) || collidableComponent.BodyType == BodyType.Static) continue;
|
|
||||||
if (entity.HasComponent<GhostComponent>()) continue;
|
|
||||||
if (singularityCoords.EntityId != entity.Transform.Coordinates.EntityId) continue;
|
|
||||||
var vec = (singularityCoords - entity.Transform.Coordinates).Position;
|
|
||||||
if (vec == Vector2.Zero) continue;
|
|
||||||
|
|
||||||
var speed = 10 / vec.Length * component.Level;
|
|
||||||
|
|
||||||
collidableComponent.ApplyLinearImpulse(vec.Normalized * speed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DestroyTiles(SingularityComponent component)
|
|
||||||
{
|
|
||||||
if (!component.Owner.TryGetComponent(out PhysicsComponent? physicsComponent)) return;
|
|
||||||
var worldBox = physicsComponent.GetWorldAABB();
|
|
||||||
|
|
||||||
foreach (var grid in _mapManager.FindGridsIntersecting(component.Owner.Transform.MapID, worldBox))
|
|
||||||
{
|
|
||||||
foreach (var tile in grid.GetTilesIntersecting(worldBox))
|
|
||||||
{
|
|
||||||
grid.SetTile(tile.GridIndices, Tile.Empty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
156
Content.Server/Throw/ThrowHelper.cs
Normal file
156
Content.Server/Throw/ThrowHelper.cs
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
using System;
|
||||||
|
using Content.Server.GameObjects.Components.Projectiles;
|
||||||
|
using Content.Shared.GameObjects.Components.Movement;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||||
|
using Content.Shared.Physics;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Map;
|
||||||
|
using Robust.Shared.Maths;
|
||||||
|
using Robust.Shared.Physics;
|
||||||
|
using Robust.Shared.Random;
|
||||||
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
|
namespace Content.Server.Throw
|
||||||
|
{
|
||||||
|
public static class ThrowHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Throw an entity in the direction of <paramref name="targetLoc"/> from <paramref name="sourceLoc"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="thrownEnt">The entity to throw.</param>
|
||||||
|
/// <param name="throwForce">
|
||||||
|
/// The force to throw the entity with.
|
||||||
|
/// Total impulse applied is equal to this force applied for one second.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="targetLoc">
|
||||||
|
/// The target location to throw at.
|
||||||
|
/// This is only used to calculate a direction,
|
||||||
|
/// actual distance is purely determined by <paramref name="throwForce"/>.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="sourceLoc">
|
||||||
|
/// The position to start the throw from.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="spread">
|
||||||
|
/// If true, slightly spread the actual throw angle.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="throwSourceEnt">
|
||||||
|
/// The entity that did the throwing. An opposite impulse will be applied to this entity if passed in.
|
||||||
|
/// </param>
|
||||||
|
public static void Throw(this IEntity thrownEnt, float throwForce, EntityCoordinates targetLoc, EntityCoordinates sourceLoc, bool spread = false, IEntity throwSourceEnt = null)
|
||||||
|
{
|
||||||
|
if (thrownEnt.Deleted)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!thrownEnt.TryGetComponent(out IPhysicsComponent colComp))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
|
var direction_vector = targetLoc.ToMapPos(entityManager) - sourceLoc.ToMapPos(entityManager);
|
||||||
|
|
||||||
|
if (direction_vector.Length == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
colComp.CanCollide = true;
|
||||||
|
// I can now collide with player, so that i can do damage.
|
||||||
|
|
||||||
|
if (!thrownEnt.TryGetComponent(out ThrownItemComponent projComp))
|
||||||
|
{
|
||||||
|
projComp = thrownEnt.AddComponent<ThrownItemComponent>();
|
||||||
|
|
||||||
|
if (colComp.PhysicsShapes.Count == 0)
|
||||||
|
colComp.PhysicsShapes.Add(new PhysShapeAabb());
|
||||||
|
|
||||||
|
colComp.PhysicsShapes[0].CollisionMask |= (int) CollisionGroup.ThrownItem;
|
||||||
|
colComp.Status = BodyStatus.InAir;
|
||||||
|
}
|
||||||
|
|
||||||
|
var angle = new Angle(direction_vector);
|
||||||
|
if (spread)
|
||||||
|
{
|
||||||
|
var spreadRandom = IoCManager.Resolve<IRobustRandom>();
|
||||||
|
angle += Angle.FromDegrees(spreadRandom.NextGaussian(0, 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (throwSourceEnt != null)
|
||||||
|
{
|
||||||
|
projComp.User = throwSourceEnt;
|
||||||
|
projComp.IgnoreEntity(throwSourceEnt);
|
||||||
|
|
||||||
|
if (ActionBlockerSystem.CanChangeDirection(throwSourceEnt))
|
||||||
|
{
|
||||||
|
throwSourceEnt.Transform.LocalRotation = (angle + MathHelper.PiOver2).GetCardinalDir().ToAngle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// scaling is handled elsewhere, this is just multiplying by 60 independent of timing as a fix until elsewhere values are updated
|
||||||
|
var spd = throwForce * 60;
|
||||||
|
|
||||||
|
projComp.StartThrow(angle.ToVec(), spd);
|
||||||
|
|
||||||
|
if (throwSourceEnt != null &&
|
||||||
|
throwSourceEnt.TryGetComponent<IPhysicsComponent>(out var physics))
|
||||||
|
{
|
||||||
|
if (throwSourceEnt.IsWeightless())
|
||||||
|
{
|
||||||
|
// We don't check for surrounding entities,
|
||||||
|
// so you'll still get knocked around if you're hugging the station wall in zero g.
|
||||||
|
// I got kinda lazy is the reason why. Also it makes a bit of sense.
|
||||||
|
// If somebody wants they can come along and make it so magboots completely hold you still.
|
||||||
|
// Would be a cool incentive to use them.
|
||||||
|
const float throwFactor = 0.2f; // Break Newton's Third Law for better gameplay
|
||||||
|
var mover = physics.EnsureController<ThrowKnockbackController>();
|
||||||
|
mover.Push(-angle.ToVec(), spd * throwFactor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Throw an entity at the position of <paramref name="targetLoc"/> from <paramref name="sourceLoc"/>,
|
||||||
|
/// without overshooting.
|
||||||
|
/// </summary>cl
|
||||||
|
/// <param name="thrownEnt">The entity to throw.</param>
|
||||||
|
/// <param name="throwForceMax">
|
||||||
|
/// The MAXIMUM force to throw the entity with.
|
||||||
|
/// Throw force increases with distance to target, this is the maximum force allowed.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="targetLoc">
|
||||||
|
/// The target location to throw at.
|
||||||
|
/// This function will try to land at this exact spot,
|
||||||
|
/// if <paramref name="throwForceMax"/> is large enough to allow for it to be reached.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="sourceLoc">
|
||||||
|
/// The position to start the throw from.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="spread">
|
||||||
|
/// If true, slightly spread the actual throw angle.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="throwSourceEnt">
|
||||||
|
/// The entity that did the throwing. An opposite impulse will be applied to this entity if passed in.
|
||||||
|
/// </param>
|
||||||
|
public static void ThrowTo(this IEntity thrownEnt, float throwForceMax, EntityCoordinates targetLoc,
|
||||||
|
EntityCoordinates sourceLoc, bool spread = false, IEntity throwSourceEnt = null)
|
||||||
|
{
|
||||||
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
|
var timing = IoCManager.Resolve<IGameTiming>();
|
||||||
|
|
||||||
|
// Calculate the force necessary to land a throw based on throw duration, mass and distance.
|
||||||
|
if (!targetLoc.TryDistance(entityManager, sourceLoc, out var distance))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var throwDuration = ThrownItemComponent.DefaultThrowTime;
|
||||||
|
// TODO: Mass isn't even used on the system side yet for controllers so do that someday
|
||||||
|
var velocityNecessary = distance / throwDuration;
|
||||||
|
var forceNecessary = velocityNecessary / timing.TickRate;
|
||||||
|
|
||||||
|
// Then clamp it to the max force allowed and call Throw().
|
||||||
|
thrownEnt.Throw(MathF.Min(forceNecessary, throwForceMax), targetLoc, sourceLoc, spread, throwSourceEnt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -166,15 +166,6 @@ namespace Content.Shared
|
|||||||
public static readonly CVarDef<bool> ParallaxDebug =
|
public static readonly CVarDef<bool> ParallaxDebug =
|
||||||
CVarDef.Create("parallax.debug", false, CVar.CLIENTONLY);
|
CVarDef.Create("parallax.debug", false, CVar.CLIENTONLY);
|
||||||
|
|
||||||
/*
|
|
||||||
* Physics
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static readonly CVarDef<float> TileFrictionModifier =
|
|
||||||
CVarDef.Create("physics.tilefriction", 15.0f);
|
|
||||||
|
|
||||||
public static readonly CVarDef<float> StopSpeed =
|
|
||||||
CVarDef.Create("physics.stopspeed", 0.1f);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ambience
|
* Ambience
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ using Robust.Shared.Serialization;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Physics.Broadphase;
|
|
||||||
|
|
||||||
namespace Content.Shared.Construction.ConstructionConditions
|
namespace Content.Shared.Construction.ConstructionConditions
|
||||||
{
|
{
|
||||||
@@ -35,7 +34,7 @@ namespace Content.Shared.Construction.ConstructionConditions
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// now we need to check that user actually tries to build wallmount on a wall
|
// now we need to check that user actually tries to build wallmount on a wall
|
||||||
var physics = EntitySystem.Get<SharedBroadPhaseSystem>();
|
var physics = IoCManager.Resolve<IPhysicsManager>();
|
||||||
var rUserToObj = new CollisionRay(userWorldPosition, userToObject.Normalized, (int) CollisionGroup.Impassable);
|
var rUserToObj = new CollisionRay(userWorldPosition, userToObject.Normalized, (int) CollisionGroup.Impassable);
|
||||||
var length = userToObject.Length;
|
var length = userToObject.Length;
|
||||||
var userToObjRaycastResults = physics.IntersectRayWithPredicate(user.Transform.MapID, rUserToObj, maxLength: length,
|
var userToObjRaycastResults = physics.IntersectRayWithPredicate(user.Transform.MapID, rUserToObj, maxLength: length,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace Content.Shared.GameObjects.Components.Buckle
|
|||||||
|
|
||||||
public sealed override uint? NetID => ContentNetIDs.BUCKLE;
|
public sealed override uint? NetID => ContentNetIDs.BUCKLE;
|
||||||
|
|
||||||
[ComponentDependency] protected readonly IPhysBody? Physics;
|
[ComponentDependency] protected readonly IPhysicsComponent? Physics;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The range from which this entity can buckle to a <see cref="SharedStrapComponent"/>.
|
/// The range from which this entity can buckle to a <see cref="SharedStrapComponent"/>.
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ namespace Content.Shared.GameObjects.Components.Disposal
|
|||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public bool Anchored =>
|
public bool Anchored =>
|
||||||
!Owner.TryGetComponent(out IPhysBody? physics) ||
|
!Owner.TryGetComponent(out IPhysicsComponent? physics) ||
|
||||||
physics.BodyType == BodyType.Static;
|
physics.Anchored;
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public enum Visuals
|
public enum Visuals
|
||||||
@@ -166,7 +166,7 @@ namespace Content.Shared.GameObjects.Components.Disposal
|
|||||||
if (!Anchored)
|
if (!Anchored)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!entity.TryGetComponent(out IPhysBody? physics) ||
|
if (!entity.TryGetComponent(out IPhysicsComponent? physics) ||
|
||||||
!physics.CanCollide)
|
!physics.CanCollide)
|
||||||
{
|
{
|
||||||
if (!(entity.TryGetComponent(out IMobStateComponent? damageState) && damageState.IsDead())) {
|
if (!(entity.TryGetComponent(out IMobStateComponent? damageState) && damageState.IsDead())) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Content.Shared.GameObjects.Components.Doors
|
|||||||
protected readonly SharedAppearanceComponent? AppearanceComponent = null;
|
protected readonly SharedAppearanceComponent? AppearanceComponent = null;
|
||||||
|
|
||||||
[ComponentDependency]
|
[ComponentDependency]
|
||||||
protected readonly IPhysBody? PhysicsComponent = null;
|
protected readonly IPhysicsComponent? PhysicsComponent = null;
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private DoorState _state = DoorState.Closed;
|
private DoorState _state = DoorState.Closed;
|
||||||
|
|||||||
@@ -21,22 +21,8 @@ namespace Content.Shared.GameObjects.Components.Mobs
|
|||||||
get => _isInCombatMode;
|
get => _isInCombatMode;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_isInCombatMode == value) return;
|
|
||||||
_isInCombatMode = value;
|
_isInCombatMode = value;
|
||||||
Dirty();
|
Dirty();
|
||||||
|
|
||||||
// Regenerate physics contacts -> Can probably just selectively check
|
|
||||||
/* Still a bit jank so left disabled for now.
|
|
||||||
if (Owner.TryGetComponent(out PhysicsComponent? physicsComponent))
|
|
||||||
{
|
|
||||||
if (value)
|
|
||||||
{
|
|
||||||
physicsComponent.WakeBody();
|
|
||||||
}
|
|
||||||
|
|
||||||
physicsComponent.RegenerateContacts();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +32,6 @@ namespace Content.Shared.GameObjects.Components.Mobs
|
|||||||
get => _activeZone;
|
get => _activeZone;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_activeZone == value) return;
|
|
||||||
_activeZone = value;
|
_activeZone = value;
|
||||||
Dirty();
|
Dirty();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.Map;
|
|
||||||
|
|
||||||
|
|
||||||
namespace Content.Shared.GameObjects.Components.Movement
|
|
||||||
{
|
|
||||||
public interface IMobMoverComponent : IComponent
|
|
||||||
{
|
|
||||||
EntityCoordinates LastPosition { get; set; }
|
|
||||||
|
|
||||||
public float StepSoundDistance { get; set; }
|
|
||||||
|
|
||||||
float GrabRange { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -19,6 +19,17 @@ namespace Content.Shared.GameObjects.Components.Movement
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
float CurrentSprintSpeed { get; }
|
float CurrentSprintSpeed { get; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The movement speed (m/s) of the entity when it pushes off of a solid object in zero gravity.
|
||||||
|
/// </summary>
|
||||||
|
float CurrentPushSpeed { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How far an entity can reach (in meters) to grab hold of a solid object in zero gravity.
|
||||||
|
/// </summary>
|
||||||
|
float GrabRange { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Is the entity Sprinting (running)?
|
/// Is the entity Sprinting (running)?
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -29,6 +40,10 @@ namespace Content.Shared.GameObjects.Components.Movement
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
(Vector2 walking, Vector2 sprinting) VelocityDir { get; }
|
(Vector2 walking, Vector2 sprinting) VelocityDir { get; }
|
||||||
|
|
||||||
|
EntityCoordinates LastPosition { get; set; }
|
||||||
|
|
||||||
|
float StepSoundDistance { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Toggles one of the four cardinal directions. Each of the four directions are
|
/// Toggles one of the four cardinal directions. Each of the four directions are
|
||||||
/// composed into a single direction vector, <see cref="SharedPlayerInputMoverComponent.VelocityDir"/>. Enabling
|
/// composed into a single direction vector, <see cref="SharedPlayerInputMoverComponent.VelocityDir"/>. Enabling
|
||||||
@@ -40,5 +55,6 @@ namespace Content.Shared.GameObjects.Components.Movement
|
|||||||
void SetVelocityDirection(Direction direction, ushort subTick, bool enabled);
|
void SetVelocityDirection(Direction direction, ushort subTick, bool enabled);
|
||||||
|
|
||||||
void SetSprinting(ushort subTick, bool walking);
|
void SetSprinting(ushort subTick, bool walking);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,89 +3,64 @@ using System;
|
|||||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||||
using Content.Shared.Physics;
|
using Content.Shared.Physics;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
|
||||||
|
|
||||||
namespace Content.Shared.GameObjects.Components.Movement
|
namespace Content.Shared.GameObjects.Components.Movement
|
||||||
{
|
{
|
||||||
public abstract class SharedClimbingComponent : Component, IActionBlocker
|
public abstract class SharedClimbingComponent : Component, IActionBlocker, ICollideSpecial
|
||||||
{
|
{
|
||||||
public sealed override string Name => "Climbing";
|
public sealed override string Name => "Climbing";
|
||||||
public sealed override uint? NetID => ContentNetIDs.CLIMBING;
|
public sealed override uint? NetID => ContentNetIDs.CLIMBING;
|
||||||
|
|
||||||
protected bool IsOnClimbableThisFrame
|
protected IPhysicsComponent? Body;
|
||||||
|
protected bool IsOnClimbableThisFrame;
|
||||||
|
|
||||||
|
protected bool OwnerIsTransitioning
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (Body == null) return false;
|
if (Body != null && Body.TryGetController<ClimbController>(out var controller))
|
||||||
|
|
||||||
foreach (var entity in Body.GetBodiesIntersecting())
|
|
||||||
{
|
{
|
||||||
if ((entity.CollisionLayer & (int) CollisionGroup.VaultImpassable) != 0) return true;
|
return controller.IsActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract bool IsClimbing { get; set; }
|
||||||
|
|
||||||
bool IActionBlocker.CanMove() => !OwnerIsTransitioning;
|
bool IActionBlocker.CanMove() => !OwnerIsTransitioning;
|
||||||
|
bool IActionBlocker.CanChangeDirection() => !OwnerIsTransitioning;
|
||||||
|
|
||||||
[ViewVariables]
|
bool ICollideSpecial.PreventCollide(IPhysBody collided)
|
||||||
protected virtual bool OwnerIsTransitioning { get; set; }
|
|
||||||
|
|
||||||
[ComponentDependency] protected PhysicsComponent? Body;
|
|
||||||
|
|
||||||
protected TimeSpan StartClimbTime = TimeSpan.Zero;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// We'll launch the mob onto the table and give them at least this amount of time to be on it.
|
|
||||||
/// </summary>
|
|
||||||
protected const float BufferTime = 0.3f;
|
|
||||||
|
|
||||||
public virtual bool IsClimbing
|
|
||||||
{
|
{
|
||||||
get => _isClimbing;
|
if (((CollisionGroup)collided.CollisionLayer).HasFlag(CollisionGroup.VaultImpassable) && collided.Entity.HasComponent<IClimbable>())
|
||||||
set
|
|
||||||
{
|
{
|
||||||
if (_isClimbing == value) return;
|
IsOnClimbableThisFrame = true;
|
||||||
_isClimbing = value;
|
return IsClimbing;
|
||||||
|
|
||||||
ToggleVaultPassable(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool _isClimbing;
|
public override void Initialize()
|
||||||
|
|
||||||
// TODO: Layers need a re-work
|
|
||||||
private void ToggleVaultPassable(bool value)
|
|
||||||
{
|
{
|
||||||
// Hope the mob has one fixture
|
base.Initialize();
|
||||||
if (Body == null || Body.Deleted) return;
|
|
||||||
|
|
||||||
foreach (var fixture in Body.Fixtures)
|
Owner.TryGetComponent(out Body);
|
||||||
{
|
|
||||||
if (value)
|
|
||||||
{
|
|
||||||
fixture.CollisionMask &= ~(int) CollisionGroup.VaultImpassable;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fixture.CollisionMask |= (int) CollisionGroup.VaultImpassable;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
protected sealed class ClimbModeComponentState : ComponentState
|
protected sealed class ClimbModeComponentState : ComponentState
|
||||||
{
|
{
|
||||||
public ClimbModeComponentState(bool climbing, bool isTransitioning) : base(ContentNetIDs.CLIMBING)
|
public ClimbModeComponentState(bool climbing) : base(ContentNetIDs.CLIMBING)
|
||||||
{
|
{
|
||||||
Climbing = climbing;
|
Climbing = climbing;
|
||||||
IsTransitioning = isTransitioning;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Climbing { get; }
|
public bool Climbing { get; }
|
||||||
public bool IsTransitioning { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,14 @@ namespace Content.Shared.GameObjects.Components.Movement
|
|||||||
public class SharedDummyInputMoverComponent : Component, IMoverComponent
|
public class SharedDummyInputMoverComponent : Component, IMoverComponent
|
||||||
{
|
{
|
||||||
public override string Name => "DummyInputMover";
|
public override string Name => "DummyInputMover";
|
||||||
public bool IgnorePaused => false;
|
|
||||||
public float CurrentWalkSpeed => 0f;
|
public float CurrentWalkSpeed => 0f;
|
||||||
public float CurrentSprintSpeed => 0f;
|
public float CurrentSprintSpeed => 0f;
|
||||||
|
public float CurrentPushSpeed => 0f;
|
||||||
|
public float GrabRange => 0f;
|
||||||
public bool Sprinting => false;
|
public bool Sprinting => false;
|
||||||
public (Vector2 walking, Vector2 sprinting) VelocityDir => (Vector2.Zero, Vector2.Zero);
|
public (Vector2 walking, Vector2 sprinting) VelocityDir => (Vector2.Zero, Vector2.Zero);
|
||||||
|
public EntityCoordinates LastPosition { get; set; }
|
||||||
|
public float StepSoundDistance { get; set; }
|
||||||
|
|
||||||
public void SetVelocityDirection(Direction direction, ushort subTick, bool enabled)
|
public void SetVelocityDirection(Direction direction, ushort subTick, bool enabled)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Robust.Shared.Configuration;
|
|||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Players;
|
using Robust.Shared.Players;
|
||||||
@@ -14,9 +15,7 @@ using Robust.Shared.ViewVariables;
|
|||||||
|
|
||||||
namespace Content.Shared.GameObjects.Components.Movement
|
namespace Content.Shared.GameObjects.Components.Movement
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
public abstract class SharedPlayerInputMoverComponent : Component, IMoverComponent, ICollideSpecial
|
||||||
[ComponentReference(typeof(IMoverComponent))]
|
|
||||||
public class SharedPlayerInputMoverComponent : Component, IMoverComponent
|
|
||||||
{
|
{
|
||||||
// This class has to be able to handle server TPS being lower than client FPS.
|
// This class has to be able to handle server TPS being lower than client FPS.
|
||||||
// While still having perfectly responsive movement client side.
|
// While still having perfectly responsive movement client side.
|
||||||
@@ -40,10 +39,8 @@ namespace Content.Shared.GameObjects.Components.Movement
|
|||||||
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
||||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
|
|
||||||
[ComponentDependency] private readonly MovementSpeedModifierComponent? _movementSpeed = default!;
|
public sealed override string Name => "PlayerInputMover";
|
||||||
|
public sealed override uint? NetID => ContentNetIDs.PLAYER_INPUT_MOVER;
|
||||||
public override string Name => "PlayerInputMover";
|
|
||||||
public override uint? NetID => ContentNetIDs.PLAYER_INPUT_MOVER;
|
|
||||||
|
|
||||||
private GameTick _lastInputTick;
|
private GameTick _lastInputTick;
|
||||||
private ushort _lastInputSubTick;
|
private ushort _lastInputSubTick;
|
||||||
@@ -52,19 +49,36 @@ namespace Content.Shared.GameObjects.Components.Movement
|
|||||||
|
|
||||||
private MoveButtons _heldMoveButtons = MoveButtons.None;
|
private MoveButtons _heldMoveButtons = MoveButtons.None;
|
||||||
|
|
||||||
// Don't serialize because it probably shouldn't change and it's a waste.
|
public float CurrentWalkSpeed
|
||||||
public bool IgnorePaused
|
|
||||||
{
|
{
|
||||||
get => _ignorePaused;
|
get
|
||||||
set => _ignorePaused = value;
|
{
|
||||||
|
if (Owner.TryGetComponent(out MovementSpeedModifierComponent? component))
|
||||||
|
{
|
||||||
|
return component.CurrentWalkSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MovementSpeedModifierComponent.DefaultBaseWalkSpeed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _ignorePaused;
|
public float CurrentSprintSpeed
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (Owner.TryGetComponent(out MovementSpeedModifierComponent? component))
|
||||||
|
{
|
||||||
|
return component.CurrentSprintSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
public float CurrentWalkSpeed => _movementSpeed?.CurrentWalkSpeed ?? MovementSpeedModifierComponent.DefaultBaseWalkSpeed;
|
return MovementSpeedModifierComponent.DefaultBaseSprintSpeed;
|
||||||
|
}
|
||||||
public float CurrentSprintSpeed => _movementSpeed?.CurrentSprintSpeed ?? MovementSpeedModifierComponent.DefaultBaseSprintSpeed;
|
}
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public float CurrentPushSpeed => 5;
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public float GrabRange => 0.2f;
|
||||||
public bool Sprinting => !HasFlag(_heldMoveButtons, MoveButtons.Walk);
|
public bool Sprinting => !HasFlag(_heldMoveButtons, MoveButtons.Walk);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -117,24 +131,27 @@ namespace Content.Shared.GameObjects.Components.Movement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract EntityCoordinates LastPosition { get; set; }
|
||||||
|
public abstract float StepSoundDistance { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether or not the player can move diagonally.
|
/// Whether or not the player can move diagonally.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public bool DiagonalMovementEnabled => _configurationManager.GetCVar<bool>(CCVars.GameDiagonalMovement);
|
public bool DiagonalMovementEnabled => _configurationManager.GetCVar<bool>(CCVars.GameDiagonalMovement);
|
||||||
|
|
||||||
public override void ExposeData(ObjectSerializer serializer)
|
/// <inheritdoc />
|
||||||
|
public override void OnAdd()
|
||||||
{
|
{
|
||||||
base.ExposeData(serializer);
|
// This component requires that the entity has a IPhysicsComponent.
|
||||||
serializer.DataField(ref _ignorePaused, "ignorePaused", false);
|
if (!Owner.HasComponent<IPhysicsComponent>())
|
||||||
|
Logger.Error(
|
||||||
|
$"[ECS] {Owner.Prototype?.Name} - {nameof(SharedPlayerInputMoverComponent)} requires" +
|
||||||
|
$" {nameof(IPhysicsComponent)}. ");
|
||||||
|
|
||||||
|
base.OnAdd();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
base.Initialize();
|
|
||||||
Owner.EnsureComponentWarn<PhysicsComponent>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Toggles one of the four cardinal directions. Each of the four directions are
|
/// Toggles one of the four cardinal directions. Each of the four directions are
|
||||||
@@ -249,6 +266,12 @@ namespace Content.Shared.GameObjects.Components.Movement
|
|||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ICollideSpecial.PreventCollide(IPhysBody collidedWith)
|
||||||
|
{
|
||||||
|
// Don't collide with other mobs
|
||||||
|
return collidedWith.Entity.HasComponent<IBody>();
|
||||||
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
private sealed class MoverComponentState : ComponentState
|
private sealed class MoverComponentState : ComponentState
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,100 +0,0 @@
|
|||||||
#nullable enable
|
|
||||||
using System;
|
|
||||||
using Content.Shared.GameObjects.Components.Body;
|
|
||||||
using Content.Shared.GameObjects.Components.Mobs;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.Map;
|
|
||||||
using Robust.Shared.Maths;
|
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Players;
|
|
||||||
using Robust.Shared.Serialization;
|
|
||||||
using Robust.Shared.ViewVariables;
|
|
||||||
|
|
||||||
namespace Content.Shared.GameObjects.Components.Movement
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The basic player mover with footsteps and grabbing
|
|
||||||
/// </summary>
|
|
||||||
[RegisterComponent]
|
|
||||||
[ComponentReference(typeof(IMobMoverComponent))]
|
|
||||||
public class SharedPlayerMobMoverComponent : Component, IMobMoverComponent, ICollideSpecial
|
|
||||||
{
|
|
||||||
public override string Name => "PlayerMobMover";
|
|
||||||
public override uint? NetID => ContentNetIDs.PLAYER_MOB_MOVER;
|
|
||||||
|
|
||||||
private float _stepSoundDistance;
|
|
||||||
private float _grabRange;
|
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
|
||||||
public EntityCoordinates LastPosition { get; set; }
|
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
|
||||||
public float StepSoundDistance
|
|
||||||
{
|
|
||||||
get => _stepSoundDistance;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (MathHelper.CloseTo(_stepSoundDistance, value)) return;
|
|
||||||
_stepSoundDistance = value;
|
|
||||||
Dirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
|
||||||
public float GrabRange
|
|
||||||
{
|
|
||||||
get => _grabRange;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (MathHelper.CloseTo(_grabRange, value)) return;
|
|
||||||
_grabRange = value;
|
|
||||||
Dirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
base.Initialize();
|
|
||||||
if (!Owner.HasComponent<IMoverComponent>())
|
|
||||||
{
|
|
||||||
Owner.EnsureComponentWarn<SharedPlayerInputMoverComponent>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override ComponentState GetComponentState(ICommonSession session)
|
|
||||||
{
|
|
||||||
return new PlayerMobMoverComponentState(StepSoundDistance, GrabRange);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
|
||||||
{
|
|
||||||
base.HandleComponentState(curState, nextState);
|
|
||||||
if (curState is not PlayerMobMoverComponentState playerMoverState) return;
|
|
||||||
StepSoundDistance = playerMoverState.StepSoundDistance;
|
|
||||||
GrabRange = playerMoverState.GrabRange;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ICollideSpecial.PreventCollide(IPhysBody collidedWith)
|
|
||||||
{
|
|
||||||
// Don't collide with other mobs
|
|
||||||
// unless they have combat mode on
|
|
||||||
return collidedWith.Entity.HasComponent<IBody>(); /* &&
|
|
||||||
(!Owner.TryGetComponent(out SharedCombatModeComponent? ownerCombat) || !ownerCombat.IsInCombatMode) &&
|
|
||||||
(!collidedWith.Entity.TryGetComponent(out SharedCombatModeComponent? otherCombat) || !otherCombat.IsInCombatMode);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
|
||||||
private sealed class PlayerMobMoverComponentState : ComponentState
|
|
||||||
{
|
|
||||||
public float StepSoundDistance;
|
|
||||||
public float GrabRange;
|
|
||||||
|
|
||||||
public PlayerMobMoverComponentState(float stepSoundDistance, float grabRange) : base(ContentNetIDs.PLAYER_MOB_MOVER)
|
|
||||||
{
|
|
||||||
StepSoundDistance = stepSoundDistance;
|
|
||||||
GrabRange = grabRange;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,12 +3,10 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Shared.GameObjects.Components.Mobs;
|
using Content.Shared.GameObjects.Components.Mobs;
|
||||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
|
||||||
using Content.Shared.GameObjects.EntitySystems.EffectBlocker;
|
using Content.Shared.GameObjects.EntitySystems.EffectBlocker;
|
||||||
using Content.Shared.Physics;
|
using Content.Shared.Physics;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -55,12 +53,14 @@ namespace Content.Shared.GameObjects.Components.Movement
|
|||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public virtual bool Slippery { get; set; }
|
public virtual bool Slippery { get; set; }
|
||||||
|
|
||||||
private bool TrySlip(IPhysBody ourBody, IPhysBody otherBody)
|
private bool TrySlip(IEntity entity)
|
||||||
{
|
{
|
||||||
if (!Slippery
|
if (!Slippery
|
||||||
|| Owner.IsInContainer()
|
|| Owner.IsInContainer()
|
||||||
|| _slipped.Contains(otherBody.Entity.Uid)
|
|| _slipped.Contains(entity.Uid)
|
||||||
|| !otherBody.Entity.TryGetComponent(out SharedStunnableComponent? stun))
|
|| !entity.TryGetComponent(out SharedStunnableComponent? stun)
|
||||||
|
|| !entity.TryGetComponent(out IPhysicsComponent? otherBody)
|
||||||
|
|| !Owner.TryGetComponent(out IPhysicsComponent? body))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -70,22 +70,26 @@ namespace Content.Shared.GameObjects.Components.Movement
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var percentage = otherBody.GetWorldAABB().IntersectPercentage(ourBody.GetWorldAABB());
|
var percentage = otherBody.WorldAABB.IntersectPercentage(body.WorldAABB);
|
||||||
|
|
||||||
if (percentage < IntersectPercentage)
|
if (percentage < IntersectPercentage)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EffectBlockerSystem.CanSlip(otherBody.Entity))
|
if (!EffectBlockerSystem.CanSlip(entity))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
otherBody.LinearVelocity *= LaunchForwardsMultiplier;
|
if (entity.TryGetComponent(out IPhysicsComponent? physics))
|
||||||
|
{
|
||||||
|
var controller = physics.EnsureController<SlipController>();
|
||||||
|
controller.LinearVelocity = physics.LinearVelocity * LaunchForwardsMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
stun.Paralyze(5);
|
stun.Paralyze(5);
|
||||||
_slipped.Add(otherBody.Entity.Uid);
|
_slipped.Add(entity.Uid);
|
||||||
|
|
||||||
OnSlip();
|
OnSlip();
|
||||||
|
|
||||||
@@ -94,9 +98,9 @@ namespace Content.Shared.GameObjects.Components.Movement
|
|||||||
|
|
||||||
protected virtual void OnSlip() { }
|
protected virtual void OnSlip() { }
|
||||||
|
|
||||||
public void CollideWith(IPhysBody ourBody, IPhysBody otherBody)
|
public void CollideWith(IEntity collidedWith)
|
||||||
{
|
{
|
||||||
TrySlip(ourBody, otherBody);
|
TrySlip(collidedWith);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
@@ -110,10 +114,10 @@ namespace Content.Shared.GameObjects.Components.Movement
|
|||||||
}
|
}
|
||||||
|
|
||||||
var entity = Owner.EntityManager.GetEntity(uid);
|
var entity = Owner.EntityManager.GetEntity(uid);
|
||||||
var physics = Owner.GetComponent<IPhysBody>();
|
var physics = Owner.GetComponent<IPhysicsComponent>();
|
||||||
var otherPhysics = entity.GetComponent<IPhysBody>();
|
var otherPhysics = entity.GetComponent<IPhysicsComponent>();
|
||||||
|
|
||||||
if (!physics.GetWorldAABB().Intersects(otherPhysics.GetWorldAABB()))
|
if (!physics.WorldAABB.Intersects(otherPhysics.WorldAABB))
|
||||||
{
|
{
|
||||||
_slipped.Remove(uid);
|
_slipped.Remove(uid);
|
||||||
}
|
}
|
||||||
@@ -128,12 +132,12 @@ namespace Content.Shared.GameObjects.Components.Movement
|
|||||||
|
|
||||||
physics.Hard = false;
|
physics.Hard = false;
|
||||||
|
|
||||||
var fixtures = physics.Fixtures.FirstOrDefault();
|
var shape = physics.PhysicsShapes.FirstOrDefault();
|
||||||
|
|
||||||
if (fixtures != null)
|
if (shape != null)
|
||||||
{
|
{
|
||||||
fixtures.CollisionLayer |= (int) CollisionGroup.SmallImpassable;
|
shape.CollisionLayer |= (int) CollisionGroup.SmallImpassable;
|
||||||
fixtures.CollisionMask = (int) CollisionGroup.None;
|
shape.CollisionMask = (int) CollisionGroup.None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user