Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Content.Client/Silicons/Borgs/BorgSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ private void UpdateBorgAppearance(Entity<BorgChassisComponent?, AppearanceCompon
if (!Resolve(ent, ref ent.Comp1, ref ent.Comp2, ref ent.Comp3))
return;

// Lust edit start - отдельная обработка визуала сидящих боргов
var lustHandled = false;
UpdateLustBorgStandingVisuals(ent, ref lustHandled);
if (lustHandled)
return;
// Lust edit end

if (_appearance.TryGetData<MobState>(ent.Owner, MobStateVisuals.State, out var state, ent.Comp2))
{
if (state != MobState.Alive)
Expand All @@ -90,6 +97,9 @@ private void UpdateBorgAppearance(Entity<BorgChassisComponent?, AppearanceCompon
_sprite.LayerSetRsiState((ent.Owner, ent.Comp3), BorgVisualLayers.Light, hasPlayer ? ent.Comp1.HasMindState : ent.Comp1.NoMindState);
}

// Lust edit - отдельная обработка визуала сидящих боргов
partial void UpdateLustBorgStandingVisuals(Entity<BorgChassisComponent?, AppearanceComponent?, SpriteComponent?> ent, ref bool handled);

private void OnMMIAppearanceChanged(EntityUid uid, MMIComponent component, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
Expand Down
94 changes: 94 additions & 0 deletions Content.Client/_Lust/Borgs/BorgSystem.StandingVisuals.cs
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);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
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
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,16 @@ public enum BorgVisualLayers : byte
/// Layer for the borg flashlight status.
/// </summary>
LightStatus,

// Lust edit start - визуальные слои сидящего и сломанного борга
/// <summary>
/// Layer for the borg's voluntary resting state.
/// </summary>
Resting,

/// <summary>
/// Layer for the borg's wrecked state.
/// </summary>
Wrecked,
// Lust edit end
}
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 Content.Shared/_Lust/Borgs/SharedBorgRestActionSystem.cs
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;
}
Comment thread
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);
}
}
2 changes: 2 additions & 0 deletions Resources/Locale/en-US/_prototypes/actions/borgs.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ ent-ActionViewLaws = View Laws
.desc = View the laws that you must follow.
ent-ActionSelectBorgType = Select Cyborg Type
.desc = { "" }
ent-ActionBorgToggleRest = Sit down
.desc = Sit down or stand up.
2 changes: 2 additions & 0 deletions Resources/Locale/ru-RU/_prototypes/actions/borgs.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ ent-ActionViewLaws = Просмотреть законы
.desc = Просмотреть законы, которым вы должны следовать.
ent-ActionSelectBorgType = Select Cyborg Type
.desc = { "" }
ent-ActionBorgToggleRest = Сесть
.desc = Сесть или встать.
17 changes: 17 additions & 0 deletions Resources/Prototypes/Actions/borgs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,20 @@
useDelay: 0.5
- type: InstantAction
event: !type:BorgToggleSelectTypeEvent

- type: entity
parent: BaseToggleAction
id: ActionBorgToggleRest
name: Sit down
description: Sit down or stand up.
components:
# Lust edit start - действие сидения для боргов
- type: Action
itemIconStyle: NoItem
icon:
sprite: _Lust/Mobs/Silicon/chassis.rsi
state: robot
useDelay: 0.5
- type: InstantAction
event: !type:BorgToggleRestActionEvent
Comment thread
coderabbitai[bot] marked this conversation as resolved.
# Lust edit end
15 changes: 15 additions & 0 deletions Resources/Prototypes/Entities/Mobs/Cyborgs/borg_chassis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,26 @@
shader: unshaded
map: ["light","enum.BorgVisualLayers.LightStatus"]
visible: false
# Lust edit start - слои общего визуала сидения и поломки боргов
- state: robot_rest
map: ["enum.BorgVisualLayers.Resting"]
visible: false
- state: robot_wreck
map: ["enum.BorgVisualLayers.Wrecked"]
visible: false
# Lust edit end
- type: BorgChassis
# Default borg can take no modules until selected type.
maxModules: 0
hasMindState: robot_e
noMindState: robot_e_r
# Lust edit - кнопка сидения для боргов с resting-спрайтами
- type: BorgRestAction
# Lust edit start - борги с кнопкой сидения используют общий механизм вставания
- type: Crawler
standTime: 1
speedModifier: 0
# Lust edit end
- type: BorgTransponder
sprite:
sprite: Mobs/Silicon/chassis.rsi
Expand Down
Loading