Named fixtures for banana peels (#3822)

* Named fixtures for banana peels

* Soaps and PDAs

* Update submodule
This commit is contained in:
metalgearsloth
2021-04-13 20:57:29 +10:00
committed by GitHub
parent 499cfe7c3d
commit dc48b25a3b
31 changed files with 124 additions and 97 deletions

View File

@@ -19,6 +19,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -144,9 +145,9 @@ namespace Content.Server.GameObjects.Components.Atmos
}
}
void IStartCollide.CollideWith(IPhysBody ourBody, IPhysBody otherBody, in Manifold manifold)
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
if (!otherBody.Entity.TryGetComponent(out FlammableComponent? otherFlammable))
if (!otherFixture.Body.Owner.TryGetComponent(out FlammableComponent? otherFlammable))
return;
if (!FireSpread || !otherFlammable.FireSpread)

View File

@@ -9,6 +9,7 @@ using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -114,15 +115,15 @@ namespace Content.Server.GameObjects.Components.Chemistry
return true;
}
void IStartCollide.CollideWith(IPhysBody ourBody, IPhysBody otherBody, in Manifold manifold)
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
if (!Owner.TryGetComponent(out SolutionContainerComponent? contents))
return;
contents.Solution.DoEntityReaction(otherBody.Entity, ReactionMethod.Touch);
contents.Solution.DoEntityReaction(otherFixture.Body.Owner, ReactionMethod.Touch);
// Check for collision with a impassable object (e.g. wall) and stop
if ((otherBody.CollisionLayer & (int) CollisionGroup.Impassable) != 0 && otherBody.Hard)
if ((otherFixture.CollisionLayer & (int) CollisionGroup.Impassable) != 0 && otherFixture.Hard)
{
Owner.Delete();
}

View File

@@ -9,6 +9,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -44,16 +45,16 @@ namespace Content.Server.GameObjects.Components.Damage
public float DamageCooldown { get; set; } = 2f;
private TimeSpan _lastHit = TimeSpan.Zero;
void IStartCollide.CollideWith(IPhysBody ourBody, IPhysBody otherBody, in Manifold manifold)
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
if (!Owner.TryGetComponent(out IDamageableComponent? damageable)) return;
var speed = ourBody.LinearVelocity.Length;
var speed = ourFixture.Body.LinearVelocity.Length;
if (speed < MinimumSpeed) return;
if (!string.IsNullOrEmpty(SoundHit))
SoundSystem.Play(Filter.Pvs(otherBody.Entity), SoundHit, otherBody.Entity, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f));
SoundSystem.Play(Filter.Pvs(otherFixture.Body.Owner), SoundHit, otherFixture.Body.Owner, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f));
if ((_gameTiming.CurTime - _lastHit).TotalSeconds < DamageCooldown)
return;
@@ -65,7 +66,7 @@ namespace Content.Server.GameObjects.Components.Damage
if (Owner.TryGetComponent(out StunnableComponent? stun) && _robustRandom.Prob(StunChance))
stun.Stun(StunSeconds);
damageable.ChangeDamage(Damage, damage, false, otherBody.Entity);
damageable.ChangeDamage(Damage, damage, false, otherFixture.Body.Owner);
}
}
}

View File

@@ -34,6 +34,7 @@ using Robust.Shared.ViewVariables;
using Timer = Robust.Shared.Timing.Timer;
using Content.Server.GameObjects.Components.Construction;
using Robust.Shared.Containers;
using Robust.Shared.Physics.Dynamics;
namespace Content.Server.GameObjects.Components.Doors
{
@@ -215,7 +216,7 @@ namespace Content.Server.GameObjects.Components.Doors
}
}
void IStartCollide.CollideWith(IPhysBody ourBody, IPhysBody otherBody, in Manifold manifold)
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
if (State != DoorState.Closed)
{
@@ -229,9 +230,9 @@ namespace Content.Server.GameObjects.Components.Doors
// Disabled because it makes it suck hard to walk through double doors.
if (otherBody.Entity.HasComponent<IBody>())
if (otherFixture.Body.Owner.HasComponent<IBody>())
{
if (!otherBody.Entity.TryGetComponent<IMoverComponent>(out var mover)) return;
if (!otherFixture.Body.Owner.TryGetComponent<IMoverComponent>(out var mover)) return;
/*
// TODO: temporary hack to fix the physics system raising collision events akwardly.
@@ -244,7 +245,7 @@ namespace Content.Server.GameObjects.Components.Doors
TryOpen(entity);
*/
TryOpen(otherBody.Entity);
TryOpen(otherFixture.Body.Owner);
}
}
@@ -430,7 +431,7 @@ namespace Content.Server.GameObjects.Components.Doors
var broadPhaseSystem = EntitySystem.Get<SharedBroadPhaseSystem>();
// Use this version so we can ignore the CanCollide being false
foreach(var e in broadPhaseSystem.GetCollidingEntities(physicsComponent.Entity.Transform.MapID, physicsComponent.GetWorldAABB()))
foreach(var e in broadPhaseSystem.GetCollidingEntities(physicsComponent.Owner.Transform.MapID, physicsComponent.GetWorldAABB()))
{
if ((physicsComponent.CollisionMask & e.CollisionLayer) != 0 && broadPhaseSystem.IntersectionPercent(physicsComponent, e) > 0.01f) return true;
}
@@ -510,8 +511,8 @@ namespace Content.Server.GameObjects.Components.Doors
// Crush
foreach (var e in collidingentities)
{
if (!e.Entity.TryGetComponent(out StunnableComponent? stun)
|| !e.Entity.TryGetComponent(out IDamageableComponent? damage))
if (!e.Owner.TryGetComponent(out StunnableComponent? stun)
|| !e.Owner.TryGetComponent(out IDamageableComponent? damage))
{
continue;
}
@@ -522,7 +523,7 @@ namespace Content.Server.GameObjects.Components.Doors
continue;
hitsomebody = true;
CurrentlyCrushing.Add(e.Entity.Uid);
CurrentlyCrushing.Add(e.Owner.Uid);
damage.ChangeDamage(DamageType.Blunt, DoorCrushDamage, false, Owner);
stun.Paralyze(DoorStunTime);

View File

@@ -8,6 +8,7 @@ using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Timing;
namespace Content.Server.GameObjects.Components.PA
@@ -17,9 +18,9 @@ namespace Content.Server.GameObjects.Components.PA
{
public override string Name => "ParticleProjectile";
private ParticleAcceleratorPowerState _state;
void IStartCollide.CollideWith(IPhysBody ourBody, IPhysBody otherBody, in Manifold manifold)
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
if (otherBody.Entity.TryGetComponent<ServerSingularityComponent>(out var singularityComponent))
if (otherFixture.Body.Owner.TryGetComponent<ServerSingularityComponent>(out var singularityComponent))
{
var multiplier = _state switch
{
@@ -33,7 +34,7 @@ namespace Content.Server.GameObjects.Components.PA
singularityComponent.Energy += 10 * multiplier;
Owner.Delete();
}
else if (otherBody.Entity.TryGetComponent<SingularityGeneratorComponent>(out var singularityGeneratorComponent))
else if (otherFixture.Body.Owner.TryGetComponent<SingularityGeneratorComponent>(out var singularityGeneratorComponent))
{
singularityGeneratorComponent.Power += _state switch
{

View File

@@ -9,6 +9,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Player;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -156,11 +157,11 @@ namespace Content.Server.GameObjects.Components.Portal
StartCooldown();
}
void IStartCollide.CollideWith(IPhysBody ourBody, IPhysBody otherBody, in Manifold manifold)
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
if (_onCooldown == false)
{
TryPortalEntity(otherBody.Entity);
TryPortalEntity(otherFixture.Body.Owner);
}
}
}

View File

@@ -5,6 +5,7 @@ using Content.Shared.Chemistry;
using Robust.Shared.GameObjects;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -33,9 +34,9 @@ namespace Content.Server.GameObjects.Components.Projectiles
_solutionContainer = Owner.EnsureComponent<SolutionContainerComponent>();
}
void IStartCollide.CollideWith(IPhysBody ourBody, IPhysBody otherBody, in Manifold manifold)
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
if (!otherBody.Entity.TryGetComponent<BloodstreamComponent>(out var bloodstream))
if (!otherFixture.Body.Owner.TryGetComponent<BloodstreamComponent>(out var bloodstream))
return;
var solution = _solutionContainer.Solution;

View File

@@ -2,6 +2,7 @@ using Content.Server.GameObjects.Components.Explosion;
using Robust.Shared.GameObjects;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
namespace Content.Server.GameObjects.Components.Projectiles
{
@@ -17,7 +18,7 @@ namespace Content.Server.GameObjects.Components.Projectiles
Owner.EnsureComponent<ExplosiveComponent>();
}
void IStartCollide.CollideWith(IPhysBody ourBody, IPhysBody otherBody, in Manifold manifold)
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
if (Owner.TryGetComponent(out ExplosiveComponent? explosive))
{

View File

@@ -3,6 +3,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Projectiles
@@ -29,12 +30,9 @@ namespace Content.Server.GameObjects.Components.Projectiles
Owner.EnsureComponent<ProjectileComponent>();
}
void IStartCollide.CollideWith(IPhysBody ourBody, IPhysBody otherBody, in Manifold manifold)
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
if (_flashed)
{
return;
}
if (_flashed) return;
FlashableComponent.FlashAreaHelper(Owner, _range, _duration);
_flashed = true;

View File

@@ -8,6 +8,7 @@ using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -57,17 +58,17 @@ namespace Content.Server.GameObjects.Components.Projectiles
/// <summary>
/// Applies the damage when our projectile collides with its victim
/// </summary>
void IStartCollide.CollideWith(IPhysBody ourBody, IPhysBody otherBody, in Manifold manifold)
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
// This is so entities that shouldn't get a collision are ignored.
if (!otherBody.Hard || _damagedEntity)
if (!otherFixture.Hard || _damagedEntity)
{
return;
}
var coordinates = otherBody.Entity.Transform.Coordinates;
var coordinates = otherFixture.Body.Owner.Transform.Coordinates;
var playerFilter = Filter.Pvs(coordinates);
if (otherBody.Entity.TryGetComponent(out IDamageableComponent? damage) && _soundHitSpecies != null)
if (otherFixture.Body.Owner.TryGetComponent(out IDamageableComponent? damage) && _soundHitSpecies != null)
{
SoundSystem.Play(playerFilter, _soundHitSpecies, coordinates);
}
@@ -89,9 +90,9 @@ namespace Content.Server.GameObjects.Components.Projectiles
}
// Damaging it can delete it
if (!otherBody.Entity.Deleted && otherBody.Entity.TryGetComponent(out CameraRecoilComponent? recoilComponent))
if (!otherFixture.Body.Deleted && otherFixture.Body.Owner.TryGetComponent(out CameraRecoilComponent? recoilComponent))
{
var direction = ourBody.LinearVelocity.Normalized;
var direction = ourFixture.Body.LinearVelocity.Normalized;
recoilComponent.Kick(direction);
}

View File

@@ -2,6 +2,7 @@ using Content.Server.GameObjects.Components.Mobs;
using Robust.Shared.GameObjects;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.GameObjects.Components.Projectiles
@@ -29,9 +30,9 @@ namespace Content.Server.GameObjects.Components.Projectiles
Owner.EnsureComponentWarn(out ProjectileComponent _);
}
void IStartCollide.CollideWith(IPhysBody ourBody, IPhysBody otherBody, in Manifold manifold)
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
if (otherBody.Entity.TryGetComponent(out StunnableComponent? stunnableComponent))
if (otherFixture.Body.Owner.TryGetComponent(out StunnableComponent? stunnableComponent))
{
stunnableComponent.Stun(_stunAmount);
stunnableComponent.Knockdown(_knockdownAmount);

View File

@@ -40,7 +40,7 @@ namespace Content.Server.GameObjects.Components.Pulling
}
data.Visibility = VerbVisibility.Visible;
data.Text = component.Puller == userPhysics.Entity
data.Text = component.Puller == userPhysics.Owner
? Loc.GetString("Stop pulling")
: Loc.GetString("Pull");
}

View File

@@ -19,6 +19,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -140,9 +141,9 @@ namespace Content.Server.GameObjects.Components.Recycling
return true;
}
void IStartCollide.CollideWith(IPhysBody ourBody, IPhysBody otherBody, in Manifold manifold)
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
Recycle(otherBody.Entity);
Recycle(otherFixture.Body.Owner);
}
SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat)

View File

@@ -2,6 +2,7 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
namespace Content.Server.GameObjects.Components.Singularity
{
@@ -11,7 +12,7 @@ namespace Content.Server.GameObjects.Components.Singularity
public override string Name => "ContainmentField";
public ContainmentFieldConnection? Parent;
void IStartCollide.CollideWith(IPhysBody ourBody, IPhysBody otherBody, in Manifold manifold)
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
if (Parent == null)
{
@@ -19,7 +20,7 @@ namespace Content.Server.GameObjects.Components.Singularity
return;
}
Parent.TryRepell(Owner, otherBody.Entity);
Parent.TryRepell(Owner, otherFixture.Body.Owner);
}
}
}

View File

@@ -13,6 +13,7 @@ using Robust.Shared.Physics.Broadphase;
using Robust.Shared.ViewVariables;
using Robust.Server.GameObjects;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
namespace Content.Server.GameObjects.Components.Singularity
{
@@ -177,9 +178,9 @@ namespace Content.Server.GameObjects.Components.Singularity
}
}
void IStartCollide.CollideWith(IPhysBody ourBody, IPhysBody otherBody, in Manifold manifold)
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
if(otherBody.Entity.HasTag("EmitterBolt")) {
if(otherFixture.Body.Owner.HasTag("EmitterBolt")) {
ReceivePower(4);
}
}

View File

@@ -10,6 +10,7 @@ using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Collision.Shapes;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Timing;
@@ -121,13 +122,13 @@ namespace Content.Server.GameObjects.Components.Singularity
Energy -= EnergyDrain * seconds;
}
void IStartCollide.CollideWith(IPhysBody ourBody, IPhysBody otherBody, in Manifold manifold)
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
var otherEntity = otherBody.Entity;
var otherEntity = otherFixture.Body.Owner;
if (otherEntity.TryGetComponent<IMapGridComponent>(out var mapGridComponent))
{
foreach (var tile in mapGridComponent.Grid.GetTilesIntersecting(ourBody.GetWorldAABB()))
foreach (var tile in mapGridComponent.Grid.GetTilesIntersecting(ourFixture.Body.GetWorldAABB()))
{
mapGridComponent.Grid.SetTile(tile.GridIndices, Tile.Empty);
Energy++;