forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
235 changed files
with
13,387 additions
and
5,423 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Content.Shared.Body.Components; | ||
using Content.Shared.Body.Systems; | ||
using Content.Shared.Body.Events; | ||
using Content.Shared.Body.Organ; | ||
using Content.Server.DelayedDeath; | ||
using Content.Server.Body.Components; | ||
namespace Content.Server.Body.Systems; | ||
|
||
public sealed class HeartSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedBodySystem _bodySystem = default!; | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<HeartComponent, OrganAddedToBodyEvent>(HandleAddition); | ||
SubscribeLocalEvent<HeartComponent, OrganRemovedFromBodyEvent>(HandleRemoval); | ||
} | ||
|
||
private void HandleRemoval(EntityUid uid, HeartComponent _, ref OrganRemovedFromBodyEvent args) | ||
{ | ||
if (TerminatingOrDeleted(uid) || TerminatingOrDeleted(args.OldBody)) | ||
return; | ||
|
||
// TODO: Add some form of very violent bleeding effect. | ||
EnsureComp<DelayedDeathComponent>(args.OldBody); | ||
} | ||
|
||
private void HandleAddition(EntityUid uid, HeartComponent _, ref OrganAddedToBodyEvent args) | ||
{ | ||
if (TerminatingOrDeleted(uid) || TerminatingOrDeleted(args.Body)) | ||
return; | ||
|
||
if (_bodySystem.TryGetBodyOrganComponents<BrainComponent>(args.Body, out var _)) | ||
RemComp<DelayedDeathComponent>(args.Body); | ||
} | ||
// Shitmed-End | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace Content.Server.DelayedDeath; | ||
|
||
[RegisterComponent] | ||
public sealed partial class DelayedDeathComponent : Component | ||
{ | ||
/// <summary> | ||
/// How long it takes to kill the entity. | ||
/// </summary> | ||
[DataField] | ||
public float DeathTime = 60; | ||
|
||
/// <summary> | ||
/// How long it has been since the delayed death timer started. | ||
/// </summary> | ||
public float DeathTimer; | ||
} |
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,31 @@ | ||
using Content.Shared.Body.Organ; | ||
using Content.Shared.Body.Events; | ||
using Content.Shared.Damage; | ||
using Content.Shared.Damage.Prototypes; | ||
using Content.Shared.Mobs.Systems; | ||
using Robust.Shared.Timing; | ||
using Robust.Shared.Prototypes; | ||
namespace Content.Server.DelayedDeath; | ||
|
||
public partial class DelayedDeathSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly DamageableSystem _damageable = default!; | ||
[Dependency] private readonly MobStateSystem _mobState = default!; | ||
[Dependency] private readonly IPrototypeManager _prototypes = default!; | ||
public override void Update(float frameTime) | ||
{ | ||
base.Update(frameTime); | ||
|
||
using var query = EntityQueryEnumerator<DelayedDeathComponent>(); | ||
while (query.MoveNext(out var ent, out var component)) | ||
{ | ||
component.DeathTimer += frameTime; | ||
|
||
if (component.DeathTimer >= component.DeathTime && !_mobState.IsDead(ent)) | ||
{ | ||
var damage = new DamageSpecifier(_prototypes.Index<DamageTypePrototype>("Bloodloss"), 150); | ||
_damageable.TryChangeDamage(ent, damage, partMultiplier: 0f); | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using Robust.Shared.Timing; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Map.Components; | ||
using Content.Shared.TimeCycle; | ||
|
||
namespace Content.Server.TimeCycle; | ||
|
||
public sealed partial class TimeCycleSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IGameTiming _gameTiming = default!; | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
} | ||
|
||
public override void Update(float frameTime) | ||
{ | ||
var curTime = _gameTiming.CurTime; | ||
var query = EntityQueryEnumerator<TimeCycleComponent, MapLightComponent>(); | ||
|
||
while (query.MoveNext(out var mapid, out var timeComp, out var mapLightComp)) | ||
{ | ||
if (timeComp.Paused | ||
|| curTime < timeComp.DelayTime) | ||
continue; | ||
|
||
// Should be used for developing time palletes or for debuging | ||
// O-o-or... You can cosplay pucchi from JoJo 6 with his 'Made In Heaven' | ||
timeComp.DelayTime = curTime + (timeComp.SpeedUp ? timeComp.SpeedUpMinuteDuration : timeComp.MinuteDuration); | ||
|
||
// Pass minute of map time | ||
timeComp.CurrentTime += TimeSpan.FromMinutes(1); | ||
|
||
// Change ambient color | ||
UpdateAmbientColor(mapid, timeComp, mapLightComp); | ||
} | ||
|
||
base.Update(frameTime); | ||
} | ||
|
||
private void UpdateAmbientColor(EntityUid mapid, TimeCycleComponent timeComp, MapLightComponent mapLightComp) | ||
{ | ||
if (!_prototypeManager.TryIndex(timeComp.PalettePrototype, out TimeCyclePalettePrototype? timeEntries) | ||
|| timeEntries is null) | ||
return; | ||
|
||
var timeInCycle = GetTimeInCycle(timeComp.CurrentTime); | ||
mapLightComp.AmbientLightColor = GetInterpolatedColor(timeEntries, timeInCycle); | ||
Dirty(mapid, mapLightComp); | ||
} | ||
|
||
// We should convert current 'TimeSpan' (with days) time into one day cycle time (in 24 hours) | ||
private TimeSpan GetTimeInCycle(TimeSpan timeSpan) => | ||
TimeSpan.FromMilliseconds(timeSpan.TotalMilliseconds % TimeSpan.FromHours(24).TotalMilliseconds); | ||
|
||
private Color GetInterpolatedColor(TimeCyclePalettePrototype proto, TimeSpan timeInCycle) | ||
{ | ||
// If there is no one any time entries of palette - return black | ||
if (proto.TimeEntries is null) | ||
return Color.Black; | ||
|
||
var currentTime = timeInCycle.TotalHours; | ||
var startTime = -1; | ||
var endTime = -1; | ||
|
||
foreach (KeyValuePair<int, Color> kvp in proto.TimeEntries) | ||
{ | ||
var hour = kvp.Key; | ||
var color = kvp.Value; | ||
|
||
if (hour <= currentTime) | ||
startTime = hour; | ||
else if (hour >= currentTime && endTime == -1) | ||
endTime = hour; | ||
} | ||
|
||
if (startTime == -1) | ||
startTime = 0; | ||
else if (endTime == -1) | ||
endTime = 23; | ||
|
||
var entryStart = proto.TimeEntries[startTime]; | ||
var entryEnd = proto.TimeEntries[endTime]; | ||
var entryProgress = GetEntryProgress(TimeSpan.FromHours(startTime), TimeSpan.FromHours(endTime), timeInCycle); | ||
|
||
return Color.InterpolateBetween(entryStart, entryEnd, entryProgress); | ||
} | ||
|
||
private float GetEntryProgress(TimeSpan startTime, TimeSpan endTime, TimeSpan currentTime) => | ||
((float)(currentTime.TotalMinutes - startTime.TotalMinutes) / (float)(endTime.TotalMinutes - startTime.TotalMinutes)); | ||
|
||
} |
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
Oops, something went wrong.