-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
port DeltaV-Station/Delta-v#2707 (with permission) :cl: ElusiveCoin - add: Added a new species, the Chitinid. --------- Signed-off-by: sleepyyapril <[email protected]> Co-authored-by: ElusiveCoin <[email protected]> Co-authored-by: rosieposie <[email protected]> Co-authored-by: Delta-V bot <[email protected]> Co-authored-by: Nemanja <[email protected]> Co-authored-by: VMSolidus <[email protected]>
- Loading branch information
1 parent
3417f35
commit ce310bb
Showing
142 changed files
with
2,193 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
Content.Server/_DV/Abilities/Chitinid/BlockInjectionComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Content.Server.Abilities.Chitinid; | ||
|
||
|
||
[RegisterComponent] | ||
public sealed partial class BlockInjectionComponent : Component | ||
{ | ||
[DataField] | ||
public string BlockReason { get; set; } = string.Empty; | ||
} |
41 changes: 41 additions & 0 deletions
41
Content.Server/_DV/Abilities/Chitinid/ChitinidComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Content.Shared.Damage; | ||
using Content.Shared.Damage.Prototypes; | ||
using Content.Shared.FixedPoint; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; | ||
|
||
namespace Content.Server.Abilities.Chitinid; | ||
|
||
[RegisterComponent] | ||
public sealed partial class ChitinidComponent : Component | ||
{ | ||
[DataField] | ||
public EntProtoId ChitzitePrototype = "Chitzite"; | ||
|
||
[DataField] | ||
public EntProtoId ChitziteActionId = "ActionChitzite"; | ||
|
||
[DataField] | ||
public EntityUid? ChitziteAction; | ||
|
||
[DataField] | ||
public FixedPoint2 AmountAbsorbed = 0f; | ||
|
||
[DataField] | ||
public DamageSpecifier Healing = new() | ||
{ | ||
DamageDict = new() | ||
{ | ||
{ "Radiation", -0.5 }, | ||
} | ||
}; | ||
|
||
[DataField] | ||
public FixedPoint2 MaximumAbsorbed = 30f; | ||
|
||
[DataField] | ||
public TimeSpan UpdateInterval = TimeSpan.FromSeconds(1); | ||
|
||
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))] | ||
public TimeSpan NextUpdate; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
using Content.Server.Nutrition.Components; | ||
using Content.Shared.Actions; | ||
using Content.Shared.Actions.Events; | ||
using Content.Shared.Audio; | ||
using Content.Shared.Damage; | ||
using Content.Shared.IdentityManagement; | ||
using Content.Shared.Inventory; | ||
using Content.Shared.Mobs.Systems; | ||
using Content.Shared.Popups; | ||
using Robust.Shared.Audio.Systems; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Server.Abilities.Chitinid; | ||
|
||
public sealed partial class ChitinidSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedActionsSystem _actions = default!; | ||
[Dependency] private readonly SharedAudioSystem _audio = default!; | ||
[Dependency] private readonly IPrototypeManager _proto = default!; | ||
[Dependency] private readonly SharedPopupSystem _popup = default!; | ||
[Dependency] private readonly InventorySystem _inventory = default!; | ||
[Dependency] private readonly IGameTiming _timing = default!; | ||
[Dependency] private readonly DamageableSystem _damageable = default!; | ||
[Dependency] private readonly MobStateSystem _mobState = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<ChitinidComponent, ChitziteActionEvent>(OnChitzite); | ||
SubscribeLocalEvent<ChitinidComponent, MapInitEvent>(OnMapInit); | ||
} | ||
|
||
public override void Update(float frameTime) | ||
{ | ||
base.Update(frameTime); | ||
var query = EntityQueryEnumerator<ChitinidComponent, DamageableComponent>(); | ||
while (query.MoveNext(out var uid, out var chitinid, out var damageable)) | ||
{ | ||
if (_timing.CurTime < chitinid.NextUpdate) | ||
continue; | ||
|
||
chitinid.NextUpdate += chitinid.UpdateInterval; | ||
|
||
if (chitinid.AmountAbsorbed >= chitinid.MaximumAbsorbed || _mobState.IsDead(uid)) | ||
continue; | ||
|
||
if (_damageable.TryChangeDamage(uid, chitinid.Healing, damageable: damageable) is {} delta) | ||
{ | ||
chitinid.AmountAbsorbed += -delta.GetTotal().Float(); | ||
if (chitinid.ChitziteAction != null && chitinid.AmountAbsorbed >= chitinid.MaximumAbsorbed) | ||
{ | ||
_actions.SetCharges(chitinid.ChitziteAction, 1); // You get the charge back and that's it. Tough. | ||
_actions.SetEnabled(chitinid.ChitziteAction, true); | ||
} | ||
} | ||
} | ||
|
||
var entQuery = EntityQueryEnumerator<CoughingUpChitziteComponent, ChitinidComponent>(); | ||
while (entQuery.MoveNext(out var ent, out var chitzite, out var chitinid)) | ||
{ | ||
if (_timing.CurTime < chitzite.NextCough) | ||
continue; | ||
|
||
Spawn(chitinid.ChitzitePrototype, Transform(ent).Coordinates); | ||
chitinid.AmountAbsorbed = 0f; | ||
RemCompDeferred(ent, chitzite); | ||
} | ||
} | ||
|
||
private void OnMapInit(Entity<ChitinidComponent> ent, ref MapInitEvent args) | ||
{ | ||
if (ent.Comp.ChitziteAction != null) | ||
return; | ||
|
||
ent.Comp.NextUpdate = _timing.CurTime + ent.Comp.UpdateInterval; | ||
|
||
_actions.AddAction(ent, ref ent.Comp.ChitziteAction, ent.Comp.ChitziteActionId); | ||
} | ||
|
||
private void OnChitzite(Entity<ChitinidComponent> ent, ref ChitziteActionEvent args) | ||
{ | ||
if (_inventory.TryGetSlotEntity(ent, "mask", out var maskUid) && | ||
TryComp<IngestionBlockerComponent>(maskUid, out var blocker) && | ||
blocker.Enabled) | ||
{ | ||
_popup.PopupEntity(Loc.GetString("chitzite-mask", ("mask", maskUid)), ent, ent); | ||
return; | ||
} | ||
|
||
_popup.PopupEntity(Loc.GetString("chitzite-cough", ("name", Identity.Entity(ent, EntityManager))), ent); | ||
_audio.PlayPvs("/Audio/Animals/cat_hiss.ogg", ent, AudioHelpers.WithVariation(0.15f)); | ||
|
||
var chitzite = EnsureComp<CoughingUpChitziteComponent>(ent); | ||
chitzite.NextCough = _timing.CurTime + chitzite.CoughUpTime; | ||
args.Handled = true; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Content.Server/_DV/Abilities/Chitinid/CoughingUpChitziteComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; | ||
|
||
namespace Content.Server.Abilities.Chitinid; | ||
|
||
[RegisterComponent, AutoGenerateComponentPause] | ||
public sealed partial class CoughingUpChitziteComponent : Component | ||
{ | ||
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))] | ||
[AutoPausedField] | ||
public TimeSpan NextCough; | ||
|
||
[DataField] | ||
public TimeSpan CoughUpTime = TimeSpan.FromSeconds(2.15); | ||
} |
30 changes: 30 additions & 0 deletions
30
Content.Shared/Temperature/Components/TemperatureSpeedComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Content.Shared.Temperature.Systems; | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Temperature.Components; | ||
|
||
/// <summary> | ||
/// This is used for an entity that varies in speed based on current temperature. | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent, Access(typeof(SharedTemperatureSystem)), AutoGenerateComponentState, AutoGenerateComponentPause] | ||
public sealed partial class TemperatureSpeedComponent : Component | ||
{ | ||
/// <summary> | ||
/// Pairs of temperature thresholds to applied slowdown values. | ||
/// </summary> | ||
[DataField] | ||
public Dictionary<float, float> Thresholds = new(); | ||
|
||
/// <summary> | ||
/// The current speed modifier from <see cref="Thresholds"/> we reached. | ||
/// Stored and networked so that the client doesn't mispredict temperature | ||
/// </summary> | ||
[DataField, AutoNetworkedField] | ||
public float? CurrentSpeedModifier; | ||
|
||
/// <summary> | ||
/// The time at which the temperature slowdown is updated. | ||
/// </summary> | ||
[DataField, AutoNetworkedField, AutoPausedField] | ||
public TimeSpan? NextSlowdownUpdate; | ||
} |
Oops, something went wrong.