-
-
Notifications
You must be signed in to change notification settings - Fork 270
IVdrip #582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
xaocsource
wants to merge
2
commits into
makura-games:master
Choose a base branch
from
xaocsource:IVdrip
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
IVdrip #582
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,72 @@ | ||
| using Content.Shared._RMC14.Medical.IV; | ||
| using Robust.Client.GameObjects; | ||
| using Robust.Client.Graphics; | ||
| using Robust.Shared.Enums; | ||
| using Robust.Shared.Map; | ||
|
|
||
| namespace Content.Client._RMC14.Medical.IV; | ||
|
|
||
| public sealed class IVDripOverlay : Overlay | ||
| { | ||
| [Dependency] private readonly IEntityManager _entity = default!; | ||
|
|
||
| public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowEntities; | ||
|
|
||
| public IVDripOverlay() | ||
| { | ||
| IoCManager.InjectDependencies(this); | ||
| } | ||
|
|
||
| protected override void Draw(in OverlayDrawArgs args) | ||
| { | ||
| var transformSystem = _entity.System<TransformSystem>(); | ||
| var handle = args.WorldHandle; | ||
|
|
||
| var ivDrips = _entity.EntityQueryEnumerator<IVDripComponent>(); | ||
| while (ivDrips.MoveNext(out var ivDripId, out var ivDripComponent)) | ||
| { | ||
| if (ivDripComponent.AttachedTo is not { Valid: true } attachedTo) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| var ivDripPosition = transformSystem.GetMapCoordinates(ivDripId); | ||
| var attachedPosition = transformSystem.GetMapCoordinates(attachedTo); | ||
|
|
||
| if (ivDripPosition.MapId == MapId.Nullspace || attachedPosition.MapId == MapId.Nullspace) | ||
| continue; | ||
|
|
||
| handle.DrawLine(ivDripPosition.Position, attachedPosition.Position, Color.White); | ||
| } | ||
|
|
||
| var bloodPacks = _entity.EntityQueryEnumerator<BloodPackComponent>(); | ||
| while (bloodPacks.MoveNext(out var packId, out var packComponent)) | ||
| { | ||
| if (packComponent.AttachedTo is not { Valid: true } attachedTo) | ||
| continue; | ||
|
|
||
| var packPosition = transformSystem.GetMapCoordinates(packId); | ||
| var attachedPosition = transformSystem.GetMapCoordinates(attachedTo); | ||
|
|
||
| if (packPosition.MapId == MapId.Nullspace || attachedPosition.MapId == MapId.Nullspace) | ||
| continue; | ||
|
|
||
| handle.DrawLine(packPosition.Position, attachedPosition.Position, Color.White); | ||
| } | ||
|
|
||
| var dialysisMachines = _entity.EntityQueryEnumerator<PortableDialysisComponent>(); | ||
| while (dialysisMachines.MoveNext(out var dialysisId, out var dialysisComponent)) | ||
| { | ||
| if (dialysisComponent.AttachedTo is not { Valid: true } attachedTo) | ||
| continue; | ||
|
|
||
| var dialysisPosition = transformSystem.GetMapCoordinates(dialysisId); | ||
| var attachedPosition = transformSystem.GetMapCoordinates(attachedTo); | ||
|
|
||
| if (dialysisPosition.MapId == MapId.Nullspace || attachedPosition.MapId == MapId.Nullspace) | ||
| continue; | ||
|
|
||
| handle.DrawLine(dialysisPosition.Position, attachedPosition.Position, Color.White); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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,113 @@ | ||
| using Content.Shared._RMC14.Medical.IV; | ||
| using Content.Shared.Rounding; | ||
| using Robust.Client.GameObjects; | ||
| using Robust.Client.Graphics; | ||
| using Robust.Shared.Timing; | ||
|
|
||
| namespace Content.Client._RMC14.Medical.IV; | ||
|
|
||
| public sealed class IVDripSystem : SharedIVDripSystem | ||
| { | ||
| [Dependency] private readonly IOverlayManager _overlay = default!; | ||
| [Dependency] private readonly SpriteSystem _spriteSystem = default!; | ||
| [Dependency] private readonly IGameTiming _timing = default!; | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
| if (!_overlay.HasOverlay<IVDripOverlay>()) | ||
| _overlay.AddOverlay(new IVDripOverlay()); | ||
| } | ||
|
|
||
| public override void Shutdown() | ||
| { | ||
| base.Shutdown(); | ||
| _overlay.RemoveOverlay<IVDripOverlay>(); | ||
| } | ||
|
|
||
| protected override void UpdateIVAppearance(Entity<IVDripComponent> iv) | ||
| { | ||
| base.UpdateIVAppearance(iv); | ||
| if (!TryComp(iv, out SpriteComponent? sprite)) | ||
| return; | ||
|
|
||
| var hookedState = iv.Comp.AttachedTo == default | ||
| ? iv.Comp.UnattachedState | ||
| : iv.Comp.AttachedState; | ||
| _spriteSystem.LayerSetRsiState((iv.Owner, sprite), IVDripVisualLayers.Base, hookedState); | ||
|
|
||
| string? reagentState = null; | ||
| for (var i = iv.Comp.ReagentStates.Count - 1; i >= 0; i--) | ||
| { | ||
| var (amount, state) = iv.Comp.ReagentStates[i]; | ||
| if (amount <= iv.Comp.FillPercentage) | ||
| { | ||
| reagentState = state; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if (reagentState == null) | ||
| { | ||
| _spriteSystem.LayerSetVisible((iv.Owner, sprite), IVDripVisualLayers.Reagent, false); | ||
| return; | ||
| } | ||
|
|
||
| _spriteSystem.LayerSetVisible((iv.Owner, sprite), IVDripVisualLayers.Reagent, true); | ||
| _spriteSystem.LayerSetRsiState((iv.Owner, sprite), IVDripVisualLayers.Reagent, reagentState); | ||
| _spriteSystem.LayerSetColor((iv.Owner, sprite), IVDripVisualLayers.Reagent, iv.Comp.FillColor); | ||
| } | ||
|
|
||
| protected override void UpdatePackAppearance(Entity<BloodPackComponent> pack) | ||
| { | ||
| base.UpdatePackAppearance(pack); | ||
| if (!TryComp(pack, out SpriteComponent? sprite)) | ||
| return; | ||
|
|
||
| // TODO RMC14 blood types | ||
| _spriteSystem.LayerSetVisible((pack.Owner, sprite), BloodPackVisuals.Label, false); | ||
|
|
||
| if (_spriteSystem.LayerMapTryGet((pack.Owner, sprite), BloodPackVisuals.Fill, out var fillLayer, false)) | ||
| { | ||
| var fill = pack.Comp.FillPercentage.Float(); | ||
| var level = ContentHelpers.RoundToLevels(fill, 1, pack.Comp.MaxFillLevels + 1); | ||
| var state = level > 0 ? $"{pack.Comp.FillBaseName}{level}" : pack.Comp.FillBaseName; | ||
| _spriteSystem.LayerSetRsiState((pack.Owner, sprite), fillLayer, state); | ||
| _spriteSystem.LayerSetColor((pack.Owner, sprite), fillLayer, pack.Comp.FillColor); | ||
| _spriteSystem.LayerSetVisible((pack.Owner, sprite), fillLayer, true); | ||
| } | ||
| } | ||
|
|
||
| protected override void UpdateDialysisAppearance(Entity<PortableDialysisComponent> dialysis) | ||
| { | ||
| base.UpdateDialysisAppearance(dialysis); | ||
| if (!TryComp(dialysis, out SpriteComponent? sprite)) | ||
| return; | ||
|
|
||
| var attachmentState = dialysis.Comp.AttachedTo != null ? "hooked" : "unhooked"; | ||
| if (_spriteSystem.LayerMapTryGet((dialysis.Owner, sprite), DialysisVisualLayers.Attachment, out var attachmentLayer, false)) | ||
| _spriteSystem.LayerSetRsiState((dialysis.Owner, sprite), attachmentLayer, attachmentState); | ||
|
|
||
| var isDetaching = dialysis.Comp.DetachingEnd > _timing.CurTime; | ||
| if (_spriteSystem.LayerMapTryGet((dialysis.Owner, sprite), DialysisVisualLayers.Effect, out var effectLayer, false)) | ||
| { | ||
| string? effectState = null; | ||
| if (isDetaching) | ||
| effectState = "draining"; | ||
| else if (dialysis.Comp.IsAttaching) | ||
| effectState = "filling"; | ||
| else if (dialysis.Comp.AttachedTo != null) | ||
| effectState = "running"; | ||
|
|
||
| _spriteSystem.LayerSetVisible((dialysis.Owner, sprite), effectLayer, effectState != null); | ||
| if (effectState != null) | ||
| _spriteSystem.LayerSetRsiState((dialysis.Owner, sprite), effectLayer, effectState); | ||
| } | ||
|
|
||
| if (_spriteSystem.LayerMapTryGet((dialysis.Owner, sprite), DialysisVisualLayers.Filtering, out var filteringLayer, false)) | ||
| { | ||
| var showFiltering = dialysis.Comp is { AttachedTo: not null, IsAttaching: false } && !isDetaching; | ||
| _spriteSystem.LayerSetVisible((dialysis.Owner, sprite), filteringLayer, showFiltering); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: makura-games/lust-station
Length of output: 18123
🏁 Script executed:
Repository: makura-games/lust-station
Length of output: 21542
Добавьте ранний выход для чужого viewport.
Если
args.Viewport.Eye != _eyeManager.CurrentEye, завершитеDrawдо полученияTransformSystemи ECS-переборов. Иначе overlay выполняет три ECS-перебора для неподходящего viewport.🤖 Prompt for AI Agents
Source: Coding guidelines