Files
OldThink/Content.Shared/Changeling/ChemicalsSystem.cs
rhailrake aa8e31fa7e - add: Changeling antagonist (#2)
* Changeling WIP

* UI

* Pointers fix

* Moved out abilities

* Regenerate ability

* Fixed Regenerate ability
Prevent ghosting while regenerating

* Cleanup

* Base lesser form

* Finished Lesser Form && Transform

* Transform Sting

* Blind Sting

* Mute Sting
Added OnExamine on absorbed human

* Hallucination Sting
Changeling Absorb and transfer absorbed entities to absorber

* Cryogenic Sting

* Adrenaline Sacs

* Transform now uses Polymorph

* Armblade, Shield, Armor

* Tentacle Arm ability
Tentacle Gun system

* WIP with bugs

* WiP bugs

* fix implant transfer

* Fixed bugs with shop transfer and actions transfer

* Just in case

* Vi sitter i ventrilo och spelar DotA

* Fixes and proper LesserForm tracking

* !!!!!

* Fixed empty buttons

* WIP Gamerule
Ready - shop

* nerf stun time cause its sucks

* cleaning

* just in case

* Absorb DNA Objective.

* Partial objectives with bugs

* fix

* fix pointer

* Changeling objectives

* Changeling objectives №2

* Admin verb, game rule

* Fixed empty list check
Icons for objectives

* Changeling chat, changeling names etc.

* fix some merge errors

* - fix: Fixed all bugs with changeling

---------

Co-authored-by: Y-Parvus <yevhen.parvus@gmail.com>
Co-authored-by: Y-Parvus <61109031+Y-Parvus@users.noreply.github.com>
Co-authored-by: HitPanda <104197232+EnefFlow@users.noreply.github.com>
Co-authored-by: EnefFlow <regeto90@mail.ru>
2024-01-31 14:01:35 +00:00

89 lines
2.4 KiB
C#

using Content.Shared.Alert;
using Content.Shared.Mobs.Systems;
using Robust.Shared.Network;
namespace Content.Shared.Changeling;
public sealed class ChemicalsSystem : EntitySystem
{
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
[Dependency] private readonly INetManager _net = default!;
public bool AddChemicals(EntityUid uid, ChangelingComponent component, int quantity)
{
if (_mobStateSystem.IsDead(uid))
return false;
var toAdd = quantity;
if (component.ChemicalsBalance == component.ChemicalCapacity)
return false;
if (component.ChemicalsBalance + toAdd > component.ChemicalCapacity)
{
var overflow = component.ChemicalsBalance + toAdd - component.ChemicalCapacity;
toAdd -= overflow;
component.ChemicalsBalance += toAdd;
}
component.ChemicalsBalance += toAdd;
Dirty(uid, component);
UpdateAlert(uid, component);
return true;
}
public bool RemoveChemicals(EntityUid uid, ChangelingComponent component, int quantity)
{
if (_mobStateSystem.IsDead(uid) && !component.IsRegenerating)
return false;
var toRemove = quantity;
if (component.ChemicalsBalance == 0)
return false;
if (component.ChemicalsBalance - toRemove < 0)
return false;
component.ChemicalsBalance -= toRemove;
Dirty(uid, component);
UpdateAlert(uid, component);
return true;
}
public override void Update(float frameTime)
{
base.Update(frameTime);
var query = EntityQueryEnumerator<ChangelingComponent>();
while (query.MoveNext(out var uid, out var component))
{
component.Accumulator += frameTime;
if(component.Accumulator < component.UpdateDelay)
continue;
if (component.IsRegenerating)
continue;
component.Accumulator = 0;
AddChemicals(uid, component, component.ChemicalRegenRate);
}
}
public void UpdateAlert(EntityUid uid, ChangelingComponent component)
{
if(_net.IsServer)
{
_alertsSystem.ShowAlert(uid, AlertType.Chemicals,
(short) Math.Clamp(Math.Round(component.ChemicalsBalance / 10f), 0, 7));
}
}
}