Files
crystall-punk-14/Content.Server/Salvage/SalvageMobRestrictionsSystem.cs
Rane f36d278499 Biomass (#10313)
* Material

* good prototype

* Fix material storage

* You can insert biomass into the cloner

* ok, basic biomass subtraction works

* amogus

* ok chance works

* Alright, the biomass and genetic stuff works

* feedback for cloning

* more reclaimer polish

* ship it

* starting biomass + fix lathes

* I changed my mind on rat mass and these guys are definitely getting ground up

* Doafter

* clean up, sync the two

* fix naming, fix mass

* technology + construction

* additional logging, stop unanchoring when active

* fix event / logs

* dont gib dead salvage

* auto eject

* fix deconstruction behavior

* make warning message better, temporarily disable cancer scanner

* fix biomass stacks

* add easy mode CVAR

* stack cleanup, make biomass 2x as fast

* bugfix

* new sprite from hyenh

* fix tests

* hello? :smilethink:

* :smilethink:

* medical scanner gets antirotting

* fix cloner and medical scanner

Co-authored-by: Moony <moonheart08@users.noreply.github.com>
2022-08-29 21:31:27 -05:00

68 lines
2.5 KiB
C#

using Content.Shared.Damage;
using Content.Server.Body.Components;
using Content.Server.MobState;
namespace Content.Server.Salvage;
public sealed class SalvageMobRestrictionsSystem : EntitySystem
{
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SalvageMobRestrictionsComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<SalvageMobRestrictionsComponent, ComponentRemove>(OnRemove);
SubscribeLocalEvent<SalvageMobRestrictionsGridComponent, ComponentRemove>(OnRemoveGrid);
}
private void OnInit(EntityUid uid, SalvageMobRestrictionsComponent component, ComponentInit args)
{
var gridUid = Transform(uid).ParentUid;
if (!EntityManager.EntityExists(gridUid))
{
// Give up, we were spawned improperly
return;
}
// When this code runs, the salvage magnet hasn't actually gotten ahold of the entity yet.
// So it therefore isn't in a position to do this.
if (!TryComp(gridUid, out SalvageMobRestrictionsGridComponent? rg))
{
rg = AddComp<SalvageMobRestrictionsGridComponent>(gridUid);
}
rg.MobsToKill.Add(uid);
component.LinkedGridEntity = gridUid;
}
private void OnRemove(EntityUid uid, SalvageMobRestrictionsComponent component, ComponentRemove args)
{
if (TryComp(component.LinkedGridEntity, out SalvageMobRestrictionsGridComponent? rg))
{
rg.MobsToKill.Remove(uid);
}
}
private void OnRemoveGrid(EntityUid uid, SalvageMobRestrictionsGridComponent component, ComponentRemove args)
{
var metaQuery = GetEntityQuery<MetaDataComponent>();
var bodyQuery = GetEntityQuery<BodyComponent>();
var damageQuery = GetEntityQuery<DamageableComponent>();
foreach (var target in component.MobsToKill)
{
if (Deleted(target, metaQuery)) continue;
if (_mobStateSystem.IsDead(target)) continue; // DONT WASTE BIOMASS
if (bodyQuery.TryGetComponent(target, out var body))
{
// Just because.
body.Gib();
}
else if (damageQuery.TryGetComponent(target, out var damageableComponent))
{
_damageableSystem.SetAllDamage(damageableComponent, 200);
}
}
}
}