-
-
Notifications
You must be signed in to change notification settings - Fork 270
учим боргов сидеть #556
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
Fooksy2304
wants to merge
5
commits into
makura-games:master
Choose a base branch
from
Fooksy2304:borgee
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
учим боргов сидеть #556
Changes from all commits
Commits
Show all changes
5 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
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,94 @@ | ||
| using Content.Shared._Lust.Borgs.Components; | ||
| using Content.Shared.Mobs; | ||
| using Content.Shared.Silicons.Borgs.Components; | ||
| using Robust.Client.GameObjects; | ||
| using Robust.Client.Graphics; | ||
|
|
||
| // Lust edit start - визуал сидения боргов в отдельном файле | ||
| #pragma warning disable IDE0130 | ||
| namespace Content.Client.Silicons.Borgs; | ||
|
|
||
| public sealed partial class BorgSystem | ||
| { | ||
| partial void UpdateLustBorgStandingVisuals( | ||
| Entity<BorgChassisComponent?, AppearanceComponent?, SpriteComponent?> ent, | ||
| ref bool handled) | ||
| { | ||
| if (!TryGetLayerState(ent, BorgVisualLayers.Body, out var bodyState)) | ||
| return; | ||
|
|
||
| var alive = !_appearance.TryGetData<MobState>(ent.Owner, MobStateVisuals.State, out var mobState, ent.Comp2) | ||
| || mobState == MobState.Alive; | ||
| var resting = alive | ||
| && _appearance.TryGetData<bool>(ent.Owner, BorgRestVisuals.Resting, out var restingVisual, ent.Comp2) | ||
| && restingVisual; | ||
|
|
||
| if (TrySetDerivedLayerState(ent, BorgVisualLayers.Resting, bodyState, "rest")) | ||
| _sprite.LayerSetVisible((ent.Owner, ent.Comp3), BorgVisualLayers.Resting, resting); | ||
| else | ||
| HideLayer(ent, BorgVisualLayers.Resting); | ||
|
|
||
| if (TrySetDerivedLayerState(ent, BorgVisualLayers.Wrecked, bodyState, "wreck")) | ||
| _sprite.LayerSetVisible((ent.Owner, ent.Comp3), BorgVisualLayers.Wrecked, !alive); | ||
| else | ||
| HideLayer(ent, BorgVisualLayers.Wrecked); | ||
|
|
||
| _sprite.LayerSetVisible((ent.Owner, ent.Comp3), BorgVisualLayers.Body, alive && !resting); | ||
|
|
||
| if (alive && !resting) | ||
| return; | ||
|
|
||
| _sprite.LayerSetVisible((ent.Owner, ent.Comp3), BorgVisualLayers.Light, false); | ||
|
|
||
| if (_sprite.LayerExists((ent.Owner, ent.Comp3), BorgVisualLayers.LightStatus)) | ||
| _sprite.LayerSetVisible((ent.Owner, ent.Comp3), BorgVisualLayers.LightStatus, false); | ||
|
|
||
| handled = true; | ||
| } | ||
|
|
||
| private bool TryGetLayerState( | ||
| Entity<BorgChassisComponent?, AppearanceComponent?, SpriteComponent?> ent, | ||
| BorgVisualLayers layer, | ||
| out string state) | ||
| { | ||
| state = string.Empty; | ||
|
|
||
| if (!_sprite.LayerExists((ent.Owner, ent.Comp3), layer)) | ||
| return false; | ||
|
|
||
| var stateId = _sprite.LayerGetRsiState((ent.Owner, ent.Comp3), layer, RSI.StateId.Invalid); | ||
| if (!stateId.IsValid || stateId.Name == null) | ||
| return false; | ||
|
|
||
| state = stateId.Name; | ||
| return true; | ||
| } | ||
|
|
||
| private void HideLayer( | ||
| Entity<BorgChassisComponent?, AppearanceComponent?, SpriteComponent?> ent, | ||
| BorgVisualLayers layer) | ||
| { | ||
| if (_sprite.LayerExists((ent.Owner, ent.Comp3), layer)) | ||
| _sprite.LayerSetVisible((ent.Owner, ent.Comp3), layer, false); | ||
| } | ||
|
|
||
| private bool TrySetDerivedLayerState( | ||
| Entity<BorgChassisComponent?, AppearanceComponent?, SpriteComponent?> ent, | ||
| BorgVisualLayers layer, | ||
| string bodyState, | ||
| string suffix) | ||
| { | ||
| if (!_sprite.LayerExists((ent.Owner, ent.Comp3), layer)) | ||
| return false; | ||
|
|
||
| var state = $"{bodyState}_{suffix}"; | ||
| var rsi = _sprite.LayerGetEffectiveRsi((ent.Owner, ent.Comp3), layer, RSI.StateId.Invalid); | ||
| if (rsi == null || !rsi.TryGetState(state, out _)) | ||
| return false; | ||
|
|
||
| _sprite.LayerSetRsiState((ent.Owner, ent.Comp3), layer, state); | ||
| return true; | ||
| } | ||
| } | ||
| #pragma warning restore IDE0130 | ||
| // Lust edit end | ||
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
39 changes: 39 additions & 0 deletions
39
Content.Shared/_Lust/Borgs/Components/BorgRestActionComponent.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,39 @@ | ||
| using Content.Shared._Lust.Borgs; | ||
| using Content.Shared.Actions; | ||
| using Robust.Shared.GameStates; | ||
| using Robust.Shared.Prototypes; | ||
| using Robust.Shared.Serialization; | ||
|
|
||
| namespace Content.Shared._Lust.Borgs.Components; | ||
|
|
||
| /// <summary> | ||
| /// Adds a borg action that toggles voluntary resting. | ||
| /// </summary> | ||
| [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
| [Access(typeof(SharedBorgRestActionSystem))] | ||
| public sealed partial class BorgRestActionComponent : Component | ||
| { | ||
| /// <summary> | ||
| /// Action prototype used to sit down or stand up. | ||
| /// </summary> | ||
| [DataField] | ||
| public EntProtoId ToggleAction = "ActionBorgToggleRest"; | ||
|
|
||
| /// <summary> | ||
| /// Action entity currently granted to the borg. | ||
| /// </summary> | ||
| [AutoNetworkedField] | ||
| public EntityUid? ToggleActionEntity; | ||
| } | ||
|
|
||
| [RegisterComponent, NetworkedComponent] | ||
| [Access(typeof(SharedBorgRestActionSystem))] | ||
| public sealed partial class BorgRestingComponent : Component; | ||
|
|
||
| public sealed partial class BorgToggleRestActionEvent : InstantActionEvent; | ||
|
|
||
| [Serializable, NetSerializable] | ||
| public enum BorgRestVisuals : byte | ||
| { | ||
| Resting, | ||
| } |
155 changes: 155 additions & 0 deletions
155
Content.Shared/_Lust/Borgs/SharedBorgRestActionSystem.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,155 @@ | ||
| using Content.Shared._Lust.Borgs.Components; | ||
| using Content.Shared.Actions; | ||
| using Content.Shared.Mobs.Systems; | ||
| using Content.Shared.Rotation; | ||
| using Content.Shared.Silicons.Borgs.Components; | ||
| using Content.Shared.Stunnable; | ||
| using Robust.Shared.Player; | ||
|
|
||
| namespace Content.Shared._Lust.Borgs; | ||
|
|
||
| public sealed class SharedBorgRestActionSystem : EntitySystem | ||
| { | ||
| [Dependency] private readonly SharedAppearanceSystem _appearance = default!; | ||
| [Dependency] private readonly SharedActionsSystem _actions = default!; | ||
| [Dependency] private readonly MobStateSystem _mobState = default!; | ||
| [Dependency] private readonly SharedStunSystem _stun = default!; | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
|
|
||
| SubscribeLocalEvent<BorgRestActionComponent, ComponentStartup>(OnStartup); | ||
| SubscribeLocalEvent<BorgRestActionComponent, ComponentShutdown>(OnShutdown); | ||
| SubscribeLocalEvent<BorgRestActionComponent, BorgToggleRestActionEvent>(OnToggleRest); | ||
| SubscribeLocalEvent<BorgRestingComponent, ComponentStartup>(OnRestingStartup); | ||
| SubscribeLocalEvent<BorgRestingComponent, ComponentRemove>(OnRestingRemove); | ||
| SubscribeLocalEvent<KnockedDownComponent, ComponentRemove>(OnKnockedDownRemove); | ||
| } | ||
|
|
||
| private void OnStartup(Entity<BorgRestActionComponent> ent, ref ComponentStartup args) | ||
| { | ||
| _actions.AddAction(ent, ref ent.Comp.ToggleActionEntity, ent.Comp.ToggleAction); | ||
| UpdateActionState(ent); | ||
| } | ||
|
|
||
| private void OnShutdown(Entity<BorgRestActionComponent> ent, ref ComponentShutdown args) | ||
| { | ||
| _actions.RemoveAction(ent.Owner, ent.Comp.ToggleActionEntity); | ||
| } | ||
|
|
||
| private void OnToggleRest(Entity<BorgRestActionComponent> ent, ref BorgToggleRestActionEvent args) | ||
| { | ||
| if (args.Handled) | ||
| return; | ||
|
|
||
| if (TryToggleRest(ent.AsNullable())) | ||
| args.Handled = true; | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| private void OnRestingStartup(Entity<BorgRestingComponent> ent, ref ComponentStartup args) | ||
| { | ||
| if (TryComp<BorgRestActionComponent>(ent, out var borgRest)) | ||
| UpdateActionState((ent.Owner, borgRest)); | ||
| } | ||
|
|
||
| private void OnRestingRemove(Entity<BorgRestingComponent> ent, ref ComponentRemove args) | ||
| { | ||
| ClearRestingVisual(ent.Owner); | ||
|
|
||
| if (TryComp<BorgRestActionComponent>(ent, out var borgRest)) | ||
| UpdateActionState((ent.Owner, borgRest), resting: false); | ||
| } | ||
|
|
||
| private void OnKnockedDownRemove(Entity<KnockedDownComponent> ent, ref ComponentRemove args) | ||
| { | ||
| RemCompDeferred<BorgRestingComponent>(ent); | ||
| } | ||
|
|
||
| private void UpdateActionState(Entity<BorgRestActionComponent> ent) | ||
| { | ||
| UpdateActionState(ent, HasComp<BorgRestingComponent>(ent)); | ||
| } | ||
|
|
||
| private void UpdateActionState(Entity<BorgRestActionComponent> ent, bool resting) | ||
| { | ||
| _actions.SetToggled(ent.Comp.ToggleActionEntity, resting); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Пытается переключить состояние отдыха борга. | ||
| /// </summary> | ||
| public bool TryToggleRest(Entity<BorgRestActionComponent?> ent) | ||
| { | ||
| if (!Resolve(ent, ref ent.Comp)) | ||
| return false; | ||
|
|
||
| if (!CanToggleRest(ent)) | ||
| return false; | ||
|
|
||
| Entity<BorgRestActionComponent> borgRest = (ent.Owner, ent.Comp); | ||
|
|
||
| if (HasComp<BorgRestingComponent>(ent)) | ||
| { | ||
| DoStandUp(borgRest); | ||
| return true; | ||
| } | ||
|
|
||
| return DoRest(borgRest); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Проверяет, может ли борг переключить состояние отдыха. | ||
| /// </summary> | ||
| public bool CanToggleRest(Entity<BorgRestActionComponent?> ent, bool quiet = false) | ||
| { | ||
| if (!Resolve(ent, ref ent.Comp)) | ||
| return false; | ||
|
|
||
| if (HasComp<BorgRestingComponent>(ent)) | ||
| return true; | ||
|
|
||
| if (!TryComp<BorgChassisComponent>(ent, out var borg) || borg.BrainEntity == null) | ||
| return false; | ||
|
|
||
| if (!HasComp<ActorComponent>(ent)) | ||
| return false; | ||
|
|
||
| return _mobState.IsAlive(ent); | ||
| } | ||
|
|
||
| private bool DoRest(Entity<BorgRestActionComponent> ent) | ||
| { | ||
| if (!_stun.TryKnockdown(ent.Owner, null, refresh: true, autoStand: false, drop: false, force: true)) | ||
| { | ||
| ClearRestingVisual(ent); | ||
| return false; | ||
| } | ||
|
|
||
| EnsureComp<BorgRestingComponent>(ent); | ||
| SetRestingVisual(ent, true); | ||
| return true; | ||
| } | ||
|
|
||
| private void DoStandUp(Entity<BorgRestActionComponent> ent) | ||
| { | ||
| RemComp<BorgRestingComponent>(ent); | ||
| RemComp<KnockedDownComponent>(ent); | ||
| } | ||
|
|
||
| private void SetRestingVisualRotation(EntityUid uid) | ||
| { | ||
| _appearance.SetData(uid, RotationVisuals.RotationState, RotationState.Vertical); | ||
| } | ||
|
|
||
| private void SetRestingVisual(EntityUid uid, bool resting) | ||
| { | ||
| _appearance.SetData(uid, BorgRestVisuals.Resting, resting); | ||
| SetRestingVisualRotation(uid); | ||
| } | ||
|
|
||
| private void ClearRestingVisual(EntityUid uid) | ||
| { | ||
| SetRestingVisual(uid, false); | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.