* basic radiation generator * might need this * thonk * big thonk * oop * e * werks * sprite * oopsy woopsy * radiation * clean up file * makes it work, probably * minor fixes * resources * progress on component * this will no longer be necessary * radiation go brrrr * finally fix container issues * out var Co-authored-by: Remie Richards <remierichards@gmail.com> * second out fix * another out fix Co-authored-by: Remie Richards <remierichards@gmail.com> * switch case * fix switch * sound and improvements * nullable * basic containment field system * ensure alignment * fix beam placement logic * field generation fully working * fix potential crash * working containment functionality * extremely basic emitter functionality * fix radiation panel naming * emitter stuff * oopsies * fixes * some fixes * cleanup * small fix and move emitter file * add sprite resources for PA * slight rework of the singulo adds rads * pushing for smugleaf :) * added radiationpanels * some fixes for the singulo * containmentfield * pa wip * progress * pa working * emitter fix * works :) * ui works * some work on ui & pa * progress * ui work & misc fixes * GREYSCALE * pa ui polish containmentfieldgen rework * singulo rework added snapgrid * getcomponent get out * singulo rework added collisiongroups underplating & passable * yaml work: - collision boxes - singulo now unshaded * no unlit * misc changes * pa wires * add usability check * nullable enable * minor fix * power need added * reenables containment field energy drain menu close button singularity collider fix * sprite replacement * finished singulo pulling * pjb fixes * fixing sprites & minor adjustments * decrease containmentfield power * some yml adjustments * unlit layers singulogenerator * singulogen * everything works just not the powergetting on the pa i wanna die * Adds PA construction graphs, PA construction works * Snap to grid parts when completing construction * updated to newest master * inb4 i work on power * fixes upstream merge adds power need to particleaccelerator * properly implements power & apc power * Emitters are now fancy. * I have actually no idea how this happened. * Give PA a wiring LayoutId * PA is an acronym * indicators fixes hacking * Singulo is a word you blasphemous IDE. * Rewrite the PA. * Fancy names for PA parts. * Wiring fixes, strength wire cutting. * fixes projectile & ignores components * nullability errors * fixes integration tests Co-authored-by: unusualcrow <unusualcrow@protonmail.com> Co-authored-by: L.E.D <10257081+unusualcrow@users.noreply.github.com> Co-authored-by: Remie Richards <remierichards@gmail.com> Co-authored-by: Víctor Aguilera Puerto <zddm@outlook.es> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
126 lines
4.3 KiB
C#
126 lines
4.3 KiB
C#
using System.Collections.Generic;
|
|
using Content.Server.GameObjects.Components.Mobs;
|
|
using Content.Shared.Damage;
|
|
using Content.Shared.GameObjects.Components.Damage;
|
|
using Content.Shared.GameObjects.Components.Projectiles;
|
|
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.Serialization;
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
namespace Content.Server.GameObjects.Components.Projectiles
|
|
{
|
|
[RegisterComponent]
|
|
public class ProjectileComponent : SharedProjectileComponent, ICollideBehavior
|
|
{
|
|
protected override EntityUid Shooter => _shooter;
|
|
|
|
private EntityUid _shooter = EntityUid.Invalid;
|
|
|
|
private Dictionary<DamageType, int> _damages;
|
|
|
|
[ViewVariables]
|
|
public Dictionary<DamageType, int> Damages
|
|
{
|
|
get => _damages;
|
|
set => _damages = value;
|
|
}
|
|
|
|
public bool DeleteOnCollide => _deleteOnCollide;
|
|
private bool _deleteOnCollide;
|
|
|
|
// Get that juicy FPS hit sound
|
|
private string _soundHit;
|
|
private string _soundHitSpecies;
|
|
|
|
private bool _damagedEntity;
|
|
|
|
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 _soundHit, "soundHit", null);
|
|
serializer.DataField(ref _soundHitSpecies, "soundHitSpecies", null);
|
|
}
|
|
|
|
public float TimeLeft { get; set; } = 10;
|
|
|
|
/// <summary>
|
|
/// Function that makes the collision of this object ignore a specific entity so we don't collide with ourselves
|
|
/// </summary>
|
|
/// <param name="shooter"></param>
|
|
public void IgnoreEntity(IEntity shooter)
|
|
{
|
|
_shooter = shooter.Uid;
|
|
Dirty();
|
|
}
|
|
|
|
private bool _internalDeleteOnCollide;
|
|
|
|
/// <summary>
|
|
/// Applies the damage when our projectile collides with its victim
|
|
/// </summary>
|
|
/// <param name="entity"></param>
|
|
void ICollideBehavior.CollideWith(IEntity entity)
|
|
{
|
|
if (_damagedEntity)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// This is so entities that shouldn't get a collision are ignored.
|
|
if (entity.TryGetComponent(out IPhysicsComponent otherPhysics) && otherPhysics.Hard == false)
|
|
{
|
|
_internalDeleteOnCollide = false;
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
_internalDeleteOnCollide = true;
|
|
}
|
|
|
|
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);
|
|
|
|
foreach (var (damageType, amount) in _damages)
|
|
{
|
|
damage.ChangeDamage(damageType, amount, false, shooter);
|
|
}
|
|
|
|
_damagedEntity = true;
|
|
}
|
|
|
|
if (!entity.Deleted && entity.TryGetComponent(out CameraRecoilComponent recoilComponent)
|
|
&& Owner.TryGetComponent(out IPhysicsComponent ownPhysics))
|
|
{
|
|
var direction = ownPhysics.LinearVelocity.Normalized;
|
|
recoilComponent.Kick(direction);
|
|
}
|
|
}
|
|
|
|
void ICollideBehavior.PostCollide(int collideCount)
|
|
{
|
|
if (collideCount > 0 && DeleteOnCollide && _internalDeleteOnCollide) Owner.Delete();
|
|
}
|
|
|
|
public override ComponentState GetComponentState()
|
|
{
|
|
return new ProjectileComponentState(NetID!.Value, _shooter, IgnoreShooter);
|
|
}
|
|
}
|
|
}
|