Add a LOT more dakka (#1033)
* Start adding flashy flash * Change slop Might give a smoother decline * flashy flash * Add flashbang and flash projectiles Bang bang bang pull my flash trigger * Add collision check to area flash * Flash cleanupo * flash.ogg mixed to mono * Adjusted flash curve again * Enhancing flashes with unshaded and lights and shit Still a WIP * Add the other ballistic gun types Re-organised some of the gun stuff so the powercell guns share the shooting code with the ballistic guns. * Re-merging branch with master Also fixed some visualizer bugs * Last cleanup Fixed some crashes Fixed Deckard sprite Fixed Hitscan effects Re-applied master changes Re-factor to using soundsystem Add some more audio effects * Cleanup flashes for merge Can put flashbangs in lockers so you don't get blinded Fix some bugs * Fix shotties Also removed some redundant code * Bulldoze some legacycode brrrrrrrrt * Fix clientignore warnings * Add the other Stunnable types to StunnableProjectile * Some gun refactoring * Removed extra visualizers * All casing ejections use the same code * Speed loaders can have their ammo pulled out * Bolt sound less loud * Stop ThrowController from throwing * Fix speed loader visuals * Update hitscan collision mask and fix typo * Cleanup * Fit hitscan and flashbang collisions * Use the new flags support * Update taser placeholder description * Update protonames per style guide * Add yaml flag support for gun firerates * Cleanup crew * Fix Audio up (components, audio file, + remove global sounds) * Add server-side recoil back-in (forgot that I was testing this client-side) * Add Flag support for fire-rate selectors * Wrong int you dolt * Fix AI conflicts Haha ranged bulldozer go BRR (I'll rewrite it after the other AI systems are done). * Mix bang.ogg from stereo to mono * Make sure serializer's reading for guns Fixes integration test * Change EntitySystem calls to use the static function Also removed the Pumpbarrel commented-out code * Change StunnableProjectile defaults to 0 * Fix taser paralyse Apparently removing defaults means you have to specify the values, whodathunkit * Add slowdown to stunnableprojectiles and fix tasers * Remove FlagsFor from gun components Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com> Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using Content.Server.GameObjects.Components.Explosion;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Log;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Projectiles
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class ExplosiveProjectileComponent : Component, ICollideBehavior
|
||||
{
|
||||
public override string Name => "ExplosiveProjectile";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
if (!Owner.HasComponent<ExplosiveComponent>())
|
||||
{
|
||||
Logger.Error("ExplosiveProjectiles need an ExplosiveComponent");
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
void ICollideBehavior.CollideWith(IEntity entity)
|
||||
{
|
||||
var explosiveComponent = Owner.GetComponent<ExplosiveComponent>();
|
||||
explosiveComponent.Explosion();
|
||||
}
|
||||
|
||||
// Projectile should handle the deleting
|
||||
void ICollideBehavior.PostCollide(int collisionCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.Components.Weapon;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Projectiles
|
||||
{
|
||||
/// <summary>
|
||||
/// Upon colliding with an object this will flash in an area around it
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public class FlashProjectileComponent : Component, ICollideBehavior
|
||||
{
|
||||
public override string Name => "FlashProjectile";
|
||||
|
||||
private double _range;
|
||||
private double _duration;
|
||||
|
||||
private bool _flashed;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(ref _range, "range", 1.0);
|
||||
serializer.DataField(ref _duration, "duration", 8.0);
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
// Shouldn't be using this without a ProjectileComponent because it will just immediately collide with thrower
|
||||
if (!Owner.HasComponent<ProjectileComponent>())
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
void ICollideBehavior.CollideWith(IEntity entity)
|
||||
{
|
||||
if (_flashed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ServerFlashableComponent.FlashAreaHelper(Owner, _range, _duration);
|
||||
_flashed = true;
|
||||
}
|
||||
|
||||
// Projectile should handle the deleting
|
||||
void ICollideBehavior.PostCollide(int collisionCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
using System;
|
||||
using Content.Shared.GameObjects;
|
||||
using Content.Shared.Physics;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.EntitySystemMessages;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Serialization;
|
||||
using Robust.Shared.Interfaces.Timing;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Serialization;
|
||||
using Timer = Robust.Shared.Timers.Timer;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Projectiles
|
||||
{
|
||||
/// <summary>
|
||||
/// Lasers etc.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public class HitscanComponent : Component
|
||||
{
|
||||
public override string Name => "Hitscan";
|
||||
public CollisionGroup CollisionMask => (CollisionGroup) _collisionMask;
|
||||
private int _collisionMask;
|
||||
|
||||
public float Damage
|
||||
{
|
||||
get => _damage;
|
||||
set => _damage = value;
|
||||
}
|
||||
private float _damage;
|
||||
public DamageType DamageType => _damageType;
|
||||
private DamageType _damageType;
|
||||
public float MaxLength => 20.0f;
|
||||
|
||||
private TimeSpan _startTime;
|
||||
private TimeSpan _deathTime;
|
||||
|
||||
public float ColorModifier { get; set; } = 1.0f;
|
||||
private string _spriteName;
|
||||
private string _muzzleFlash;
|
||||
private string _impactFlash;
|
||||
private string _soundHitWall;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(ref _collisionMask, "layers", (int) CollisionGroup.Opaque, WithFormat.Flags<CollisionLayer>());
|
||||
serializer.DataField(ref _damage, "damage", 10.0f);
|
||||
serializer.DataField(ref _damageType, "damageType", DamageType.Heat);
|
||||
serializer.DataField(ref _spriteName, "spriteName", "Objects/Guns/Projectiles/laser.png");
|
||||
serializer.DataField(ref _muzzleFlash, "muzzleFlash", null);
|
||||
serializer.DataField(ref _impactFlash, "impactFlash", null);
|
||||
serializer.DataField(ref _soundHitWall, "soundHitWall", "/Audio/Guns/Hits/laser_sear_wall.ogg");
|
||||
}
|
||||
|
||||
public void FireEffects(IEntity user, float distance, Angle angle, IEntity hitEntity = null)
|
||||
{
|
||||
var effectSystem = EntitySystem.Get<EffectSystem>();
|
||||
_startTime = IoCManager.Resolve<IGameTiming>().CurTime;
|
||||
_deathTime = _startTime + TimeSpan.FromSeconds(1);
|
||||
|
||||
var afterEffect = AfterEffects(user.Transform.GridPosition, angle, distance, 1.0f);
|
||||
if (afterEffect != null)
|
||||
{
|
||||
effectSystem.CreateParticle(afterEffect);
|
||||
}
|
||||
|
||||
// if we're too close we'll stop the impact and muzzle / impact sprites from clipping
|
||||
if (distance > 1.0f)
|
||||
{
|
||||
var impactEffect = ImpactFlash(distance, angle);
|
||||
if (impactEffect != null)
|
||||
{
|
||||
effectSystem.CreateParticle(impactEffect);
|
||||
}
|
||||
|
||||
var muzzleEffect = MuzzleFlash(user.Transform.GridPosition, angle);
|
||||
if (muzzleEffect != null)
|
||||
{
|
||||
effectSystem.CreateParticle(muzzleEffect);
|
||||
}
|
||||
}
|
||||
|
||||
if (hitEntity != null && _soundHitWall != null)
|
||||
{
|
||||
// TODO: No wall component so ?
|
||||
var offset = angle.ToVec().Normalized / 2;
|
||||
EntitySystem.Get<AudioSystem>().PlayAtCoords(_soundHitWall, user.Transform.GridPosition.Translated(offset));
|
||||
}
|
||||
|
||||
Timer.Spawn((int) _deathTime.TotalMilliseconds, () =>
|
||||
{
|
||||
if (!Owner.Deleted)
|
||||
{
|
||||
Owner.Delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private EffectSystemMessage MuzzleFlash(GridCoordinates grid, Angle angle)
|
||||
{
|
||||
if (_muzzleFlash == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var offset = angle.ToVec().Normalized / 2;
|
||||
|
||||
var message = new EffectSystemMessage
|
||||
{
|
||||
EffectSprite = _muzzleFlash,
|
||||
Born = _startTime,
|
||||
DeathTime = _deathTime,
|
||||
Coordinates = grid.Translated(offset),
|
||||
//Rotated from east facing
|
||||
Rotation = (float) angle.Theta,
|
||||
Color = Vector4.Multiply(new Vector4(255, 255, 255, 750), ColorModifier),
|
||||
ColorDelta = new Vector4(0, 0, 0, -1500f),
|
||||
Shaded = false
|
||||
};
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
private EffectSystemMessage AfterEffects(GridCoordinates origin, Angle angle, float distance, float offset = 0.0f)
|
||||
{
|
||||
var midPointOffset = angle.ToVec() * distance / 2;
|
||||
var message = new EffectSystemMessage
|
||||
{
|
||||
EffectSprite = _spriteName,
|
||||
Born = _startTime,
|
||||
DeathTime = _deathTime,
|
||||
Size = new Vector2(distance - offset, 1f),
|
||||
Coordinates = origin.Translated(midPointOffset),
|
||||
//Rotated from east facing
|
||||
Rotation = (float) angle.Theta,
|
||||
Color = Vector4.Multiply(new Vector4(255, 255, 255, 750), ColorModifier),
|
||||
ColorDelta = new Vector4(0, 0, 0, -1500f),
|
||||
|
||||
Shaded = false
|
||||
};
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
private EffectSystemMessage ImpactFlash(float distance, Angle angle)
|
||||
{
|
||||
if (_impactFlash == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var message = new EffectSystemMessage
|
||||
{
|
||||
EffectSprite = _impactFlash,
|
||||
Born = _startTime,
|
||||
DeathTime = _deathTime,
|
||||
Coordinates = Owner.Transform.GridPosition.Translated(angle.ToVec() * distance),
|
||||
//Rotated from east facing
|
||||
Rotation = (float) angle.FlipPositive(),
|
||||
Color = Vector4.Multiply(new Vector4(255, 255, 255, 750), ColorModifier),
|
||||
ColorDelta = new Vector4(0, 0, 0, -1500f),
|
||||
Shaded = false
|
||||
};
|
||||
|
||||
return message;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,13 @@
|
||||
using Content.Server.GameObjects.Components.Mobs;
|
||||
using Content.Shared.GameObjects;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
@@ -18,24 +22,32 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
||||
|
||||
public bool IgnoreShooter = true;
|
||||
|
||||
private EntityUid Shooter = EntityUid.Invalid;
|
||||
private EntityUid _shooter = EntityUid.Invalid;
|
||||
|
||||
private Dictionary<DamageType, int> _damages;
|
||||
|
||||
[ViewVariables]
|
||||
public Dictionary<DamageType, int> Damages => _damages;
|
||||
private float _velocity;
|
||||
public float Velocity
|
||||
public Dictionary<DamageType, int> Damages
|
||||
{
|
||||
get => _velocity;
|
||||
set => _velocity = value;
|
||||
get => _damages;
|
||||
set => _damages = value;
|
||||
}
|
||||
|
||||
public bool DeleteOnCollide => _deleteOnCollide;
|
||||
private bool _deleteOnCollide;
|
||||
|
||||
// Get that juicy FPS hit sound
|
||||
private string _soundHit;
|
||||
private string _soundHitSpecies;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(ref _deleteOnCollide, "delete_on_collide", true);
|
||||
// If not specified 0 damage
|
||||
serializer.DataField(ref _damages, "damages", new Dictionary<DamageType, int>());
|
||||
serializer.DataField(ref _velocity, "velocity", 20f);
|
||||
serializer.DataField(ref _soundHit, "soundHit", null);
|
||||
serializer.DataField(ref _soundHitSpecies, "soundHitSpecies", null);
|
||||
}
|
||||
|
||||
public float TimeLeft { get; set; } = 10;
|
||||
@@ -46,7 +58,7 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
||||
/// <param name="shooter"></param>
|
||||
public void IgnoreEntity(IEntity shooter)
|
||||
{
|
||||
Shooter = shooter.Uid;
|
||||
_shooter = shooter.Uid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -56,7 +68,7 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
||||
/// <returns></returns>
|
||||
bool ICollideSpecial.PreventCollide(IPhysBody collidedwith)
|
||||
{
|
||||
if (IgnoreShooter && collidedwith.Owner.Uid == Shooter)
|
||||
if (IgnoreShooter && collidedwith.Owner.Uid == _shooter)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -67,9 +79,17 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
||||
/// <param name="entity"></param>
|
||||
void ICollideBehavior.CollideWith(IEntity entity)
|
||||
{
|
||||
if (_soundHitSpecies != null && entity.HasComponent<SpeciesComponent>())
|
||||
{
|
||||
EntitySystem.Get<AudioSystem>().PlayAtCoords(_soundHitSpecies, entity.Transform.GridPosition);
|
||||
} else if (_soundHit != null)
|
||||
{
|
||||
EntitySystem.Get<AudioSystem>().PlayAtCoords(_soundHit, entity.Transform.GridPosition);
|
||||
}
|
||||
|
||||
if (entity.TryGetComponent(out DamageableComponent damage))
|
||||
{
|
||||
Owner.EntityManager.TryGetEntity(Shooter, out var shooter);
|
||||
Owner.EntityManager.TryGetEntity(_shooter, out var shooter);
|
||||
|
||||
foreach (var (damageType, amount) in _damages)
|
||||
{
|
||||
@@ -87,7 +107,7 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
||||
|
||||
void ICollideBehavior.PostCollide(int collideCount)
|
||||
{
|
||||
if (collideCount > 0) Owner.Delete();
|
||||
if (collideCount > 0 && DeleteOnCollide) Owner.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using Content.Server.GameObjects.Components.Mobs;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Projectiles
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds stun when it collides with an entity
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class StunnableProjectileComponent : Component, ICollideBehavior
|
||||
{
|
||||
public override string Name => "StunnableProjectile";
|
||||
|
||||
// See stunnable for what these do
|
||||
private int _stunAmount;
|
||||
private int _knockdownAmount;
|
||||
private int _slowdownAmount;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(ref _stunAmount, "stunAmount", 0);
|
||||
serializer.DataField(ref _knockdownAmount, "knockdownAmount", 0);
|
||||
serializer.DataField(ref _slowdownAmount, "slowdownAmount", 0);
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
if (!Owner.HasComponent<ProjectileComponent>())
|
||||
{
|
||||
Logger.Error("StunProjectile entity must have a ProjectileComponent");
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
void ICollideBehavior.CollideWith(IEntity entity)
|
||||
{
|
||||
if (entity.TryGetComponent(out StunnableComponent stunnableComponent))
|
||||
{
|
||||
stunnableComponent.Stun(_stunAmount);
|
||||
stunnableComponent.Knockdown(_knockdownAmount);
|
||||
stunnableComponent.Slowdown(_slowdownAmount);
|
||||
}
|
||||
}
|
||||
|
||||
void ICollideBehavior.PostCollide(int collidedCount) {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user