Skip to content

Commit

Permalink
pizdec prosto
Browse files Browse the repository at this point in the history
  • Loading branch information
Roudenn authored and AwareFoxy committed Dec 17, 2024
1 parent e9c7200 commit 018e88a
Show file tree
Hide file tree
Showing 51 changed files with 590 additions and 360 deletions.
12 changes: 0 additions & 12 deletions Content.Client/Inventory/ClientInventorySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public override void Initialize()

SubscribeLocalEvent<InventorySlotsComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<InventorySlotsComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<InventorySlotsComponent, RefreshInventorySlotsEvent>(OnRefreshInventorySlots); // CorvaxNext: surgery
SubscribeLocalEvent<InventoryComponent, ComponentShutdown>(OnShutdown);

SubscribeLocalEvent<InventorySlotsComponent, DidEquipEvent>((_, comp, args) =>
Expand Down Expand Up @@ -182,17 +181,6 @@ public void UpdateSlot(EntityUid owner, InventorySlotsComponent component, strin
EntitySlotUpdate?.Invoke(newData);
}

// start-_CorvaxNext: surgery
public void OnRefreshInventorySlots(EntityUid owner, InventorySlotsComponent component, RefreshInventorySlotsEvent args)
{
if (!component.SlotData.TryGetValue(args.SlotName, out var slotData)
|| _playerManager.LocalEntity != owner)
return;

OnSlotRemoved?.Invoke(slotData);
}
// end-_CorvaxNext: surgery

public bool TryAddSlotDef(EntityUid owner, InventorySlotsComponent component, SlotDefinition newSlotDef)
{
SlotData newSlotData = newSlotDef; //convert to slotData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public DefaultGameScreen()

Chat.OnResized += ChatOnResized;
Chat.OnChatResizeFinish += ChatOnResizeFinish;

MainViewport.OnResized += ResizeActionContainer;
MainViewport.OnResized += ResizeAlertsContainer;
Inventory.OnResized += ResizeActionContainer;
}

Expand All @@ -37,6 +37,12 @@ private void ResizeActionContainer()
Actions.ActionsContainer.MaxGridHeight = MainViewport.Size.Y - indent;
}

private void ResizeAlertsContainer()
{
float indent = Chat.Size.Y + Targeting.Size.Y + 120;
Alerts.AlertContainer.MaxGridHeight = Math.Max(MainViewport.Size.Y - indent, 1);
}

private void ChatOnResizeFinish(Vector2 _)
{
var marginBottom = Chat.GetValue<float>(MarginBottomProperty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
MinSize="64 64">
<GridContainer Columns="1" HorizontalAlignment="Right" VerticalAlignment="Top">
<PanelContainer >
<BoxContainer Name="AlertContainer" Access="Public" Orientation="Vertical" />
<GridContainer Name="AlertContainer" Columns="1" HorizontalAlignment="Right" VerticalAlignment="Center" Access="Public" />
</PanelContainer>
<partStatus:PartStatusControl Name="PartStatus" Access="Protected"/>
</GridContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public sealed partial class AlertsUI : UIWidget
public AlertsUI()
{
RobustXamlLoader.Load(this);
LayoutContainer.SetGrowHorizontal(this, LayoutContainer.GrowDirection.Begin);
}

public void SyncControls(AlertsSystem alertsSystem,
Expand Down
14 changes: 7 additions & 7 deletions Content.Server/Backmen/Mood/MoodSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using Timer = Robust.Shared.Timing.Timer;
using Robust.Shared.Player;
using Robust.Shared.Configuration;
using Content.Shared._CorvaxNext.CCVar;
using Content.Shared._CorvaxNext.NextVars;
using Content.Shared.Examine;
using Content.Shared.Humanoid;

Expand Down Expand Up @@ -141,10 +141,10 @@ private void OnRefreshMoveSpeed(EntityUid uid, MoodComponent component, RefreshM
var modifier =
Math.Clamp(
(component.CurrentMoodLevel >= component.MoodThresholds[MoodThreshold.Neutral])
? _config.GetCVar(CCVars.MoodIncreasesSpeed)
? _config.GetCVar(NextVars.MoodIncreasesSpeed)
? MathF.Pow(1.003f, component.CurrentMoodLevel - component.MoodThresholds[MoodThreshold.Neutral])
: 1
: _config.GetCVar(CCVars.MoodDecreasesSpeed)
: _config.GetCVar(NextVars.MoodDecreasesSpeed)
? 2 - component.MoodThresholds[MoodThreshold.Neutral] / component.CurrentMoodLevel
: 1,
component.MinimumSpeedModifier,
Expand All @@ -165,7 +165,7 @@ private void OnTraitStartup(EntityUid uid, MoodModifyTraitComponent component, C

private void OnMoodEffect(EntityUid uid, MoodComponent component, MoodEffectEvent args)
{
if (!_config.GetCVar(CCVars.MoodEnabled)
if (!_config.GetCVar(NextVars.MoodEnabled)
|| !_prototypeManager.TryIndex<MoodEffectPrototype>(args.EffectId, out var prototype))
return;

Expand Down Expand Up @@ -312,7 +312,7 @@ private void RefreshMood(EntityUid uid, MoodComponent component)

private void OnInit(EntityUid uid, MoodComponent component, ComponentStartup args)
{
if (_config.GetCVar(CCVars.MoodModifiesThresholds)
if (_config.GetCVar(NextVars.MoodModifiesThresholds)
&& TryComp<MobThresholdsComponent>(uid, out var mobThresholdsComponent)
&& _mobThreshold.TryGetThresholdForState(uid, MobState.Critical, out var critThreshold, mobThresholdsComponent))
component.CritThresholdBeforeModify = critThreshold.Value;
Expand All @@ -322,7 +322,7 @@ private void OnInit(EntityUid uid, MoodComponent component, ComponentStartup arg

private void SetMood(EntityUid uid, float amount, MoodComponent? component = null, bool force = false, bool refresh = false)
{
if (!_config.GetCVar(CCVars.MoodEnabled)
if (!_config.GetCVar(NextVars.MoodEnabled)
|| !Resolve(uid, ref component)
|| component.CurrentMoodThreshold == MoodThreshold.Dead && !refresh)
return;
Expand Down Expand Up @@ -403,7 +403,7 @@ private void RefreshShaders(EntityUid uid, int modifier)

private void SetCritThreshold(EntityUid uid, MoodComponent component, int modifier)
{
if (!_config.GetCVar(CCVars.MoodModifiesThresholds)
if (!_config.GetCVar(NextVars.MoodModifiesThresholds)
|| !TryComp<MobThresholdsComponent>(uid, out var mobThresholds)
|| !_mobThreshold.TryGetThresholdForState(uid, MobState.Critical, out var key))
return;
Expand Down
5 changes: 4 additions & 1 deletion Content.Server/Body/Commands/AddHandCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
if (attachAt == default)
attachAt = bodySystem.GetBodyChildren(entity, body).First();

var slotId = part.GetHashCode().ToString();
// Shitmed Change Start
var slotId = $"{part.Symmetry.ToString().ToLower()} {part.GetHashCode().ToString()}";
part.SlotId = part.GetHashCode().ToString();
// Shitmed Change End

if (!bodySystem.TryCreatePartSlotAndAttach(attachAt.Id, slotId, hand, BodyPartType.Hand, attachAt.Component, part))
{
Expand Down
9 changes: 8 additions & 1 deletion Content.Server/Body/Commands/AttachBodyPartCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,15 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
return;
}

var slotId = $"AttachBodyPartVerb-{partUid}";
// Shitmed Change Start
var slotId = "";
if (part.Symmetry != BodyPartSymmetry.None)
slotId = $"{part.Symmetry.ToString().ToLower()} {part.GetHashCode().ToString()}";
else
slotId = $"{part.GetHashCode().ToString()}";

part.SlotId = part.GetHashCode().ToString();
// Shitmed Change End
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
if (body.RootContainer.ContainedEntity != null)
{
Expand Down
47 changes: 30 additions & 17 deletions Content.Server/_CorvaxNext/Surgery/SurgerySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using Content.Shared._CorvaxNext.Surgery.Tools;
using Content.Shared.Bed.Sleep;
using Content.Shared.Medical.Surgery;
using Content.Shared.Verbs;

namespace Content.Server._CorvaxNext.Surgery;

Expand All @@ -42,7 +43,7 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<SurgeryToolComponent, AfterInteractEvent>(OnToolAfterInteract);
SubscribeLocalEvent<SurgeryToolComponent, GetVerbsEvent<UtilityVerb>>(OnUtilityVerb);
SubscribeLocalEvent<SurgeryTargetComponent, SurgeryStepDamageEvent>(OnSurgeryStepDamage);
// You might be wondering "why aren't we using StepEvent for these two?" reason being that StepEvent fires off regardless of success on the previous functions
// so this would heal entities even if you had a used or incorrect organ.
Expand Down Expand Up @@ -101,30 +102,42 @@ private void SetDamage(EntityUid body,
targetPart: _body.GetTargetBodyPart(partComp));
}

private void OnToolAfterInteract(Entity<SurgeryToolComponent> ent, ref AfterInteractEvent args)
private void AttemptStartSurgery(Entity<SurgeryToolComponent> ent, EntityUid user, EntityUid target)
{
var user = args.User;
if (args.Handled
|| !args.CanReach
|| args.Target == null
|| !HasComp<SurgeryTargetComponent>(args.Target)
|| !TryComp<SurgeryTargetComponent>(args.User, out var surgery)
|| !surgery.CanOperate
|| !IsLyingDown(args.Target.Value, args.User))
{
if (!IsLyingDown(target, user))
return;
}

if (user == args.Target && !_config.GetCVar(Shared._CorvaxNext.NextVars.NextVars.CanOperateOnSelf))
if (user == target && !_config.GetCVar(Shared._CorvaxNext.NextVars.NextVars.CanOperateOnSelf))

{
_popup.PopupEntity(Loc.GetString("surgery-error-self-surgery"), user, user);
return;
}

args.Handled = true;
_ui.OpenUi(args.Target.Value, SurgeryUIKey.Key, user);
//Logger.Debug("UI opened");
RefreshUI(args.Target.Value);
_ui.OpenUi(target, SurgeryUIKey.Key, user);
RefreshUI(target);
}

private void OnUtilityVerb(Entity<SurgeryToolComponent> ent, ref GetVerbsEvent<UtilityVerb> args)
{
if (!args.CanInteract
|| !args.CanAccess
|| !HasComp<SurgeryTargetComponent>(args.Target))
return;

var user = args.User;
var target = args.Target;

var verb = new UtilityVerb()
{
Act = () => AttemptStartSurgery(ent, user, target),
Icon = new SpriteSpecifier.Rsi(new("/Textures/Objects/Specific/Medical/Surgery/scalpel.rsi/"), "scalpel"),
Text = Loc.GetString("surgery-verb-text"),
Message = Loc.GetString("surgery-verb-message"),
DoContactInteraction = true
};

args.Verbs.Add(verb);
}

private void OnSurgeryStepDamage(Entity<SurgeryTargetComponent> ent, ref SurgeryStepDamageEvent args) =>
Expand Down
10 changes: 5 additions & 5 deletions Content.Shared/Body/Part/BodyPartComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Content.Shared.Body.Part;

[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(SharedBodySystem))]
//[Access(typeof(SharedBodySystem))]
public sealed partial class BodyPartComponent : Component, ISurgeryToolComponent
{
// Need to set this on container changes as it may be several transform parents up the hierarchy.
Expand All @@ -23,9 +23,6 @@ public sealed partial class BodyPartComponent : Component, ISurgeryToolComponent
public EntityUid? Body;

// start-_CorvaxNext: surgery
[DataField, AutoNetworkedField]
public EntityUid? OriginalBody;

[DataField, AutoNetworkedField]
public BodyPartSlot? ParentSlot;
// end-_CorvaxNext: surgery
Expand All @@ -43,6 +40,9 @@ public sealed partial class BodyPartComponent : Component, ISurgeryToolComponent
[DataField, AlwaysPushInheritance]
public string ToolName { get; set; } = "A body part";

[DataField, AlwaysPushInheritance]
public string SlotId { get; set; } = "";

[DataField, AutoNetworkedField]
public bool? Used { get; set; } = null;

Expand Down Expand Up @@ -158,7 +158,7 @@ public sealed partial class BodyPartComponent : Component, ISurgeryToolComponent
public bool IsVital;

[DataField, AutoNetworkedField]
public BodyPartSymmetry Symmetry = BodyPartSymmetry.None;
public BodyPartSymmetry Symmetry { get; set; } = BodyPartSymmetry.None;

/// <summary>
/// When attached, the part will ensure these components on the entity, and delete them on removal.
Expand Down
34 changes: 26 additions & 8 deletions Content.Shared/Body/Systems/SharedBodySystem.Body.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Events;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
using Content.Shared.Rejuvenate;
using Content.Shared.Silicons.Borgs.Components;
using Content.Shared.Standing;
Expand All @@ -24,6 +25,7 @@
using Robust.Shared.Map;
using Robust.Shared.Utility;
using Robust.Shared.Timing;

namespace Content.Shared.Body.Systems;

public partial class SharedBodySystem
Expand Down Expand Up @@ -52,8 +54,10 @@ private void InitializeBody()
SubscribeLocalEvent<BodyComponent, ComponentInit>(OnBodyInit);
SubscribeLocalEvent<BodyComponent, MapInitEvent>(OnBodyMapInit);
SubscribeLocalEvent<BodyComponent, CanDragEvent>(OnBodyCanDrag);
SubscribeLocalEvent<BodyComponent, StandAttemptEvent>(OnStandAttempt); // CorvaxNext: surgery
SubscribeLocalEvent<BodyComponent, ProfileLoadFinishedEvent>(OnProfileLoadFinished); // CorvaxNext: surgery

SubscribeLocalEvent<BodyComponent, StandAttemptEvent>(OnStandAttempt);
SubscribeLocalEvent<BodyComponent, ProfileLoadFinishedEvent>(OnProfileLoadFinished);
SubscribeLocalEvent<BodyComponent, IsEquippingAttemptEvent>(OnBeingEquippedAttempt);
}

private void OnBodyInserted(Entity<BodyComponent> ent, ref EntInsertedIntoContainerMessage args)
Expand Down Expand Up @@ -127,7 +131,6 @@ private void MapInitBody(EntityUid bodyEntity, BodyPrototype prototype)
var rootPartUid = SpawnInContainerOrDrop(protoRoot.Part, bodyEntity, BodyRootContainerId);
var rootPart = Comp<BodyPartComponent>(rootPartUid);
rootPart.Body = bodyEntity;
rootPart.OriginalBody = bodyEntity;
Dirty(rootPartUid, rootPart);
// Setup the rest of the body entities.
SetupOrgans((rootPartUid, rootPart), protoRoot.Organs);
Expand Down Expand Up @@ -189,7 +192,6 @@ private void MapInitParts(EntityUid rootPartId, BodyPartComponent rootPart, Body
var childPartComponent = Comp<BodyPartComponent>(childPart);
var partSlot = CreatePartSlot(parentEntity, connection, childPartComponent.PartType, parentPartComponent);
childPartComponent.ParentSlot = partSlot;
childPartComponent.OriginalBody = rootPart.Body;
Dirty(childPart, childPartComponent);
var cont = Containers.GetContainer(parentEntity, GetPartSlotContainerId(connection));

Expand Down Expand Up @@ -397,8 +399,7 @@ public virtual HashSet<EntityUid> GibPart(
if (IsPartRoot(bodyEnt, partId, part: part) || !part.CanSever)
return gibs;

ChangeSlotState((partId, part), true);

DropSlotContents((partId, part));
RemovePartChildren((partId, part), bodyEnt);
foreach (var organ in GetPartOrgans(partId, part))
{
Expand Down Expand Up @@ -437,7 +438,7 @@ public virtual bool BurnPart(EntityUid partId,
if (IsPartRoot(bodyEnt, partId, part: part))
return false;

ChangeSlotState((partId, part), true);
DropSlotContents((partId, part));
RemovePartChildren((partId, part), bodyEnt);
QueueDel(partId);
return true;
Expand All @@ -455,5 +456,22 @@ private void OnProfileLoadFinished(EntityUid uid, BodyComponent component, Profi
foreach (var part in GetBodyChildren(uid, component))
EnsureComp<BodyPartAppearanceComponent>(part.Id);
}
// end-_CorvaxNext: surgery


private void OnBeingEquippedAttempt(Entity<BodyComponent> ent, ref IsEquippingAttemptEvent args)
{
TryGetPartFromSlotContainer(args.Slot, out var bodyPart);
if (bodyPart is not null)
{
if (!GetBodyChildrenOfType(args.EquipTarget, bodyPart.Value).Any())
{
if (_timing.IsFirstTimePredicted)
_popup.PopupEntity(Loc.GetString("equip-part-missing-error",
("target", args.EquipTarget), ("part", bodyPart.Value.ToString())), args.Equipee, args.Equipee);
args.Cancel();
}
}
}

// Shitmed Change End
}
4 changes: 3 additions & 1 deletion Content.Shared/Body/Systems/SharedBodySystem.Organs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ private void RemoveOrgan(Entity<OrganComponent> organEnt, EntityUid parentPartUi
RaiseLocalEvent(organEnt, ref removedInBodyEv);
}

if (TryComp(parentPartUid, out DamageableComponent? damageable) // CorvaxNext: surgery

if (parentPartUid is { Valid: true }
&& TryComp(parentPartUid, out DamageableComponent? damageable)
&& damageable.TotalDamage > 200)
TrySetOrganUsed(organEnt, true, organEnt.Comp);

Expand Down
Loading

0 comments on commit 018e88a

Please sign in to comment.