-
Notifications
You must be signed in to change notification settings - Fork 55
Фиксы и дырочка в моем очке #277
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 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,92 @@ | ||
| using Content.Server.Fluids.EntitySystems; | ||
| using Content.Shared.Chemistry.Components; | ||
| using Content.Shared.Chemistry.EntitySystems; | ||
| using Content.Shared.Popups; | ||
|
|
||
| namespace Content.Server.Chemistry.EntitySystems; | ||
|
|
||
| public sealed class TankLeakSystem : EntitySystem | ||
| { | ||
| [Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!; | ||
| [Dependency] private readonly PuddleSystem _puddle = default!; | ||
| [Dependency] private readonly SharedPopupSystem _popup = default!; | ||
|
|
||
| private const float LeakInterval = 1f; | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
| SubscribeLocalEvent<TankLeakComponent, ComponentStartup>(OnStartup); | ||
| } | ||
|
|
||
| private void OnStartup(EntityUid uid, TankLeakComponent comp, ComponentStartup args) | ||
| { | ||
| comp.LeakAccumulator = 0f; | ||
| } | ||
|
|
||
| public void AddLeak(EntityUid uid, TankLeakComponent? comp = null) | ||
| { | ||
| if (!Resolve(uid, ref comp, false)) | ||
| comp = EnsureComp<TankLeakComponent>(uid); | ||
|
|
||
| comp.LeakCount++; | ||
| Dirty(uid, comp); | ||
|
|
||
| _popup.PopupEntity( | ||
| Loc.GetString("tank-leak-popup", ("entity", uid)), | ||
| uid, | ||
| PopupType.SmallCaution); | ||
|
|
||
| if (comp.LeakCount >= comp.MaxLeaks) | ||
| { | ||
| _popup.PopupEntity( | ||
| Loc.GetString("tank-leak-destroy-popup", ("entity", uid)), | ||
| uid, | ||
| PopupType.MediumCaution); | ||
|
|
||
| if (_solutionContainer.TryGetSolution(uid, comp.Solution, out _, out var solution)) | ||
| { | ||
| var coords = Transform(uid).Coordinates; | ||
| _puddle.TrySpillAt(coords, solution, out _); | ||
| } | ||
|
|
||
| QueueDel(uid); | ||
| } | ||
| } | ||
|
|
||
| public override void Update(float frameTime) | ||
| { | ||
| base.Update(frameTime); | ||
|
|
||
| var query = EntityQueryEnumerator<TankLeakComponent>(); | ||
| while (query.MoveNext(out var uid, out var comp)) | ||
| { | ||
| if (comp.LeakCount <= 0) | ||
| continue; | ||
|
|
||
| comp.LeakAccumulator += frameTime; | ||
| if (comp.LeakAccumulator < LeakInterval) | ||
| continue; | ||
|
|
||
| comp.LeakAccumulator -= LeakInterval; | ||
|
|
||
| var leakAmount = comp.LeakRatePerHole * comp.LeakCount; | ||
|
|
||
| if (!_solutionContainer.TryGetSolution(uid, comp.Solution, out var soln, out var solution)) | ||
| continue; | ||
|
|
||
| if (solution.Volume <= 0) | ||
| continue; | ||
|
|
||
| if (leakAmount > solution.Volume) | ||
| leakAmount = solution.Volume; | ||
|
|
||
| var leaked = _solutionContainer.SplitSolution(soln.Value, leakAmount); | ||
| if (leaked.Volume <= 0) | ||
| continue; | ||
|
|
||
| var coords = Transform(uid).Coordinates; | ||
| _puddle.TrySpillAt(coords, leaked, out _, sound: false); | ||
| } | ||
| } | ||
| } | ||
29 changes: 29 additions & 0 deletions
29
Content.Server/Destructible/Thresholds/Behaviors/TankLeakBehavior.cs
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,29 @@ | ||
| using Content.Server.Chemistry.EntitySystems; | ||
| using Content.Shared.Chemistry.Components; | ||
| using JetBrains.Annotations; | ||
|
|
||
| namespace Content.Server.Destructible.Thresholds.Behaviors; | ||
|
|
||
| [UsedImplicitly] | ||
| [DataDefinition] | ||
| public sealed partial class TankLeakBehavior : IThresholdBehavior | ||
| { | ||
| [DataField] | ||
| public int LeaksToAdd = 1; | ||
|
|
||
| [DataField] | ||
| public string Solution = "tank"; | ||
|
|
||
| public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null) | ||
| { | ||
| var tankLeakSystem = system.EntityManager.System<TankLeakSystem>(); | ||
|
|
||
| var comp = system.EntityManager.EnsureComponent<TankLeakComponent>(owner); | ||
| comp.Solution = Solution; | ||
|
|
||
| for (var i = 0; i < LeaksToAdd; i++) | ||
| { | ||
| tankLeakSystem.AddLeak(owner, comp); | ||
| } | ||
| } | ||
| } |
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
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,23 @@ | ||
| using Content.Shared.FixedPoint; | ||
| using Robust.Shared.GameStates; | ||
|
|
||
| namespace Content.Shared.Chemistry.Components; | ||
|
|
||
| [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
| public sealed partial class TankLeakComponent : Component | ||
| { | ||
| [DataField, AutoNetworkedField] | ||
| public int LeakCount; | ||
|
|
||
| [DataField] | ||
| public FixedPoint2 LeakRatePerHole = FixedPoint2.New(5); | ||
|
|
||
| [DataField] | ||
| public int MaxLeaks = 5; | ||
|
|
||
| [DataField] | ||
| public float LeakAccumulator; | ||
|
|
||
| [DataField] | ||
| public string Solution = "tank"; | ||
| } |
2 changes: 2 additions & 0 deletions
2
Resources/Locale/en-US/chemistry/components/tank-leak-component.ftl
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,2 @@ | ||
| tank-leak-popup = { CAPITALIZE($entity) } springs a leak! | ||
| tank-leak-destroy-popup = { CAPITALIZE($entity) } breaks apart, spilling its contents! |
2 changes: 2 additions & 0 deletions
2
Resources/Locale/ru-RU/chemistry/components/tank-leak-component.ftl
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,2 @@ | ||
| tank-leak-popup = В { $entity } образовалась дырка! | ||
| tank-leak-destroy-popup = { CAPITALIZE($entity) } разваливается, разливая содержимое! |
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
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
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
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
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
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
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.
Пропускаются интервалы утечки при просадке
frameTime.Сейчас за апдейт обрабатывается только один тик утечки, поэтому при
frameTime > 1fфактическая скорость течи становится ниже ожидаемой. Нужно учитывать все накопленные интервалы за кадр.💡 Предлагаемое исправление
🤖 Prompt for AI Agents