Merge branch 'master' into replace-sounds-with-sound-specifier

# Conflicts:
#	Content.Server/Actions/Actions/DisarmAction.cs
#	Content.Server/Actions/Actions/ScreamAction.cs
#	Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs
#	Content.Server/Damage/Components/DamageOnHighSpeedImpactComponent.cs
#	Content.Server/Explosion/Components/FlashExplosiveComponent.cs
#	Content.Server/Physics/Controllers/MoverController.cs
#	Content.Server/Portal/Components/PortalComponent.cs
#	Content.Server/Portal/Components/TeleporterComponent.cs
#	Content.Server/Projectiles/Components/ProjectileComponent.cs
#	Content.Server/Singularity/Components/EmitterComponent.cs
#	Content.Server/Sound/EmitSoundSystem.cs
#	Content.Server/Stunnable/Components/StunbatonComponent.cs
#	Content.Server/Tools/Components/MultitoolComponent.cs
#	Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs
#	Content.Shared/Gravity/GravityComponent.cs
#	Content.Shared/Light/Component/SharedExpendableLightComponent.cs
#	Content.Shared/Maps/ContentTileDefinition.cs
#	Content.Shared/Slippery/SlipperyComponent.cs
#	Content.Shared/Standing/StandingStateComponent.cs
#	Resources/Prototypes/Entities/Objects/Fun/bike_horn.yml
This commit is contained in:
Galactic Chimp
2021-07-25 14:12:00 +02:00
4171 changed files with 15603 additions and 14404 deletions

View File

@@ -1,14 +1,8 @@
using System.Collections.Generic;
using Content.Server.Camera;
using Content.Shared.Damage;
using Content.Shared.Damage.Components;
using Content.Shared.Projectiles;
using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -17,9 +11,8 @@ namespace Content.Server.Projectiles.Components
{
[RegisterComponent]
[ComponentReference(typeof(SharedProjectileComponent))]
public class ProjectileComponent : SharedProjectileComponent, IStartCollide
public class ProjectileComponent : SharedProjectileComponent
{
[DataField("damages")] private Dictionary<DamageType, int> _damages = new();
[ViewVariables]
@@ -33,10 +26,11 @@ namespace Content.Server.Projectiles.Components
public bool DeleteOnCollide { get; } = true;
// Get that juicy FPS hit sound
[DataField("soundHit")]
[DataField("soundHit")] public string? SoundHit = default;
private SoundSpecifier _soundHit = default!;
[DataField("soundHitSpecies")] public string? SoundHitSpecies = default;
private bool _damagedEntity;
public bool DamagedEntity;
public float TimeLeft { get; set; } = 10;
@@ -50,47 +44,6 @@ namespace Content.Server.Projectiles.Components
Dirty();
}
/// <summary>
/// Applies the damage when our projectile collides with its victim
/// </summary>
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
// This is so entities that shouldn't get a collision are ignored.
if (!otherFixture.Hard || _damagedEntity)
{
return;
}
var coordinates = otherFixture.Body.Owner.Transform.Coordinates;
var playerFilter = Filter.Pvs(coordinates);
if (otherFixture.Body.Owner.TryGetComponent(out IDamageableComponent? damage) && _soundHit.TryGetSound(out var soundHit))
{
SoundSystem.Play(playerFilter, soundHit, coordinates);
}
if (damage != null)
{
Owner.EntityManager.TryGetEntity(Shooter, out var shooter);
foreach (var (damageType, amount) in _damages)
{
damage.ChangeDamage(damageType, amount, false, shooter);
}
_damagedEntity = true;
}
// Damaging it can delete it
if (!otherFixture.Body.Deleted && otherFixture.Body.Owner.TryGetComponent(out CameraRecoilComponent? recoilComponent))
{
var direction = ourFixture.Body.LinearVelocity.Normalized;
recoilComponent.Kick(direction);
}
if(DeleteOnCollide)
Owner.QueueDelete();
}
public override ComponentState GetComponentState(ICommonSession player)
{
return new ProjectileComponentState(Shooter, IgnoreShooter);