mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 22:18:52 +03:00
Lots of stuff. Also moved everything I could to the _Shitmed namespace
as I do in Goob. Will make future ports way faster
# Changelog
🆑 Mocho
- add: Added some fun organs and other thingies, check out the Goob PRs
if you want more details.
- fix: Fixed tons of issues with shitmed. Too many for the changelog in
fact.
(cherry picked from commit 3c9db94102cb25b28a83d51ac8d659fa31fe7d12)
90 lines
2.9 KiB
C#
90 lines
2.9 KiB
C#
/*using Content.Shared.Damage;
|
|
using Content.Shared.Body.Organ;
|
|
using Content.Shared._Shitmed.Body.Organ;
|
|
using Content.Shared.FixedPoint;
|
|
|
|
// Namespace has set accessors, leaving it on the default.
|
|
namespace Content.Shared.Body.Systems;
|
|
|
|
public partial class SharedBodySystem
|
|
{
|
|
/// <summary>
|
|
/// Essentially we want to check on every tick if the organ is within the acceptable thresholds. And if it isnt
|
|
/// then we will degrade the organ by dealing damage to it. The further away from the threshold, the more damage.
|
|
/// </summary>
|
|
|
|
public void UpdateOrgan(float frameTime)
|
|
{
|
|
var query = EntityQueryEnumerator<OrganComponent, DamageableComponent>();
|
|
var now = _gameTiming.CurTime;
|
|
while (query.MoveNext(out var uid, out var organ, out var damageable))
|
|
{
|
|
if (organ.Body is not { } body || now < organ.NextUpdate || _mobState.IsDead(body))
|
|
continue;
|
|
|
|
organ.NextUpdate = now + organ.UpdateDelay;
|
|
|
|
if (organ.Status < organ.DamagedStatus)
|
|
_damageable.TryChangeDamage(uid, GetHealingSpecifier(organ), canSever: false);
|
|
|
|
if (organ.Status != OrganStatus.Ruined && !organ.Enabled)
|
|
{
|
|
var ev = new OrganEnabledEvent((uid, organ));
|
|
RaiseLocalEvent(uid, ref ev);
|
|
}
|
|
|
|
if (organ.Status == OrganStatus.Ruined && organ.Enabled)
|
|
{
|
|
var ev = new OrganDisabledEvent((uid, organ));
|
|
RaiseLocalEvent(uid, ref ev);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnDamageChanged(EntityUid entity, OrganComponent component, ref DamageChangedEvent args)
|
|
{
|
|
if (!TryComp<DamageableComponent>(entity, out var damageable))
|
|
return;
|
|
|
|
OrganStatus newStatus = GetOrganStatus(component, damageable.TotalDamage);
|
|
if (newStatus != component.Status)
|
|
component.Status = newStatus;
|
|
|
|
var ev = new OrganDamageChangedEvent(args.DamageIncreased);
|
|
RaiseLocalEvent(entity, ev);
|
|
}
|
|
|
|
public DamageSpecifier GetHealingSpecifier(OrganComponent organ)
|
|
{
|
|
var damage = new DamageSpecifier()
|
|
{
|
|
DamageDict = new Dictionary<string, FixedPoint2>()
|
|
{
|
|
{ "Decay", -organ.SelfHealingAmount },
|
|
{ "Trauma", -organ.SelfHealingAmount },
|
|
}
|
|
};
|
|
|
|
return damage;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Fetches the OrganStatus equivalent of the current integrity value for the organ.
|
|
/// </summary>
|
|
public static OrganStatus GetOrganStatus(OrganComponent component, FixedPoint2 integrity)
|
|
{
|
|
var targetIntegrity = OrganStatus.Healthy;
|
|
foreach (var threshold in component.IntegrityThresholds)
|
|
{
|
|
if (integrity <= threshold.Value)
|
|
targetIntegrity = threshold.Key;
|
|
}
|
|
|
|
return targetIntegrity;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
*/ |