Skip to content

Commit

Permalink
move contractor target comp from shared to server, some fixes, and re…
Browse files Browse the repository at this point in the history
…ally work photo view on client
  • Loading branch information
ReeZer2 committed Feb 11, 2025
1 parent e0b08dc commit 60a05f9
Show file tree
Hide file tree
Showing 20 changed files with 402 additions and 300 deletions.
13 changes: 0 additions & 13 deletions Content.Client/SS220/Contractor/Systems/ContractorClientSystem.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
using Content.Shared.Preferences;
using Content.Shared.SS220.Contractor;

namespace Content.Client.SS220.Contractor.Systems;

public sealed class ContractorClientSystem : SharedContractorSystem
{
public Dictionary<EntityUid, HumanoidCharacterProfile> ProfileForTarget = [];
public override void Initialize()
{
base.Initialize();
SubscribeNetworkEvent<ContractorReceiveHumanoidMessage>(OnReceiveHumanoid);
}

private void OnReceiveHumanoid(ContractorReceiveHumanoidMessage msg)
{
ProfileForTarget.Add(GetEntity(msg.Target), msg.Profile);
}

}
75 changes: 51 additions & 24 deletions Content.Client/SS220/Contractor/UI/ContractorBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Linq;
using System.Numerics;
using Content.Client.SS220.Contractor.Systems;
using Content.Client.SS220.CriminalRecords.UI;
using Content.Shared.FixedPoint;
using Content.Shared.SS220.Contractor;
Expand All @@ -23,7 +23,6 @@ public sealed class ContractorBoundUserInterface : BoundUserInterface
private DefaultWindow? _withdrawWindow;
private DefaultWindow? _photoWindow;

private readonly ContractorClientSystem _contractorSystem;
private readonly ContractorPdaComponent _contractorPdaComponent;
private readonly ContractorComponent? _contractorComponent;

Expand All @@ -32,7 +31,6 @@ public sealed class ContractorBoundUserInterface : BoundUserInterface
public ContractorBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
IoCManager.InjectDependencies(this);
_contractorSystem = EntMan.System<ContractorClientSystem>();
_contractorPdaComponent = EntMan.GetComponent<ContractorPdaComponent>(owner);
EntMan.TryGetComponent<ContractorComponent>(
EntMan.GetEntity(_contractorPdaComponent.PdaOwner),
Expand All @@ -45,7 +43,7 @@ protected override void ReceiveMessage(BoundUserInterfaceMessage message)
{
base.ReceiveMessage(message);

if(_menu == null)
if (_menu == null)
return;

switch (message)
Expand Down Expand Up @@ -152,7 +150,7 @@ private void AddContract(NetEntity key, ContractorContract contract)
if (_menu == null)
return;

var contractContainer = new PanelContainer()
var contractContainer = new PanelContainer
{
Margin = new Thickness(0),
HorizontalExpand = true,
Expand All @@ -173,7 +171,7 @@ private void AddContract(NetEntity key, ContractorContract contract)
Text = "Замечен в контакте с вульпой, что вызывает подозрения в утечке информации.",
StyleClasses = { "ContractorRichLabelStyle" },
HorizontalAlignment = Control.HAlignment.Left,
Margin = new Thickness(2, 20, 170, 0),
Margin = new Thickness(2, 45, 170, 0),
SetSize = new Vector2(137, 93),
Modulate = Color.FromHex("#647b88"),
RectClipContent = true,
Expand Down Expand Up @@ -219,18 +217,20 @@ private void AddContract(NetEntity key, ContractorContract contract)
Title = "Фото цели",
};

_contractorSystem.ProfileForTarget.TryGetValue(EntMan.GetEntity(key), out var profile);

if (profile == null)
if (_contractorComponent == null)
return;

var profile = _contractorComponent.Profiles[key];

var iconTargetSprite = new CharacterVisualisation
{
SetSize = new Vector2(400, 300),
Margin = new Thickness(100, 0, 0, 0),
SetSize = new Vector2(200, 200),
VerticalAlignment = Control.VAlignment.Center,
HorizontalAlignment = Control.HAlignment.Center,
Margin = new Thickness(10, 0, 0, 0),
};

iconTargetSprite.SetupCharacterSpriteView(profile, _prototypeManager.Index(contract.Job).ID);
iconTargetSprite.SetupCharacterSpriteView(profile, _prototypeManager.Index(contract.Job).ID, true);

_photoWindow.OnClose += () => _photoWindow = null;

Expand All @@ -245,7 +245,7 @@ private void AddContract(NetEntity key, ContractorContract contract)
{
Orientation = BoxContainer.LayoutOrientation.Vertical,
HorizontalExpand = true,
VerticalAlignment = Control.VAlignment.Center,
VerticalAlignment = Control.VAlignment.Top,
Margin = new Thickness(5, 30, 0, 0),
};

Expand All @@ -254,26 +254,42 @@ private void AddContract(NetEntity key, ContractorContract contract)

var abortButton = new Button
{
Text = "Отмена",
VerticalExpand = false,
HorizontalExpand = false,
Visible = false,
MaxSize = new Vector2(100, 30),
HorizontalAlignment = Control.HAlignment.Center,
VerticalAlignment = Control.VAlignment.Top,
SetSize = new Vector2(80, 30),
Margin = new Thickness(0, 18, 2, 0),
StyleClasses= { "ContractorExecutionButton" },
Modulate = Color.DarkRed,
};

var abortLabel = new Label
{
Text = "Отменить",
HorizontalAlignment = Control.HAlignment.Center,
VerticalAlignment = Control.VAlignment.Center,
StyleClasses = { "ContractorLabelStyle" },
};

abortButton.AddChild(abortLabel);

abortButton.OnPressed += _ =>
{
SendMessage(new ContractorAbortContractMessage(key));
topContainer.RemoveChild(abortButton);
positionsContainer.RemoveChild(abortButton);
};

topContainer.AddChild(abortButton);
positionsContainer.AddChild(abortButton);

foreach (var amountPosition in contract.AmountPositions)
{
if (_contractorPdaComponent.CurrentContractEntity == key)
{
abortButton.Visible = true;
contractContainer.AddStyleClass("ContractAcceptedBorder");
ClearPositionButtons(positionsContainer);
}

var positionButton = new Button
Expand Down Expand Up @@ -306,13 +322,19 @@ private void AddContract(NetEntity key, ContractorContract contract)

abortButton.Visible = true;

contractContainer.AddStyleClass("ContractAcceptedBorder");

ClearPositionButtons(positionsContainer);

positionsContainer.AddChild(positionButton);
_allPositionButtons.Add(positionButton);

foreach (var buttons in _allPositionButtons)
{
buttons.Disabled = true;
}
};


_allPositionButtons.Add(positionButton);
positionsContainer.AddChild(positionButton);
}
Expand All @@ -323,6 +345,17 @@ private void AddContract(NetEntity key, ContractorContract contract)
_menu.ContractsListPanel.AddChild(contractContainer);
}

private void ClearPositionButtons(Control positionsContainer)
{
foreach (var button in _allPositionButtons.ToList())
{
if (button.Parent == positionsContainer)
{
positionsContainer.RemoveChild(button);
}
}
}

private void UpdateHub(Dictionary<string, FixedPoint2> shopItems)
{
if (_menu == null)
Expand Down Expand Up @@ -382,11 +415,6 @@ private void UpdateHub(Dictionary<string, FixedPoint2> shopItems)
buyButton.OnPressed += _ =>
{
SendMessage(new ContractorHubBuyItemMessage(item.Key, item.Value));

//if (_contractorComponent is not null)
//UpdateStats(_contractorComponent);


};

topRow.AddChild(itemIcon);
Expand Down Expand Up @@ -481,7 +509,6 @@ public void OnWithdrawButtonPressed()

_withdrawWindow.OnClose += () => _withdrawWindow = null;


var mainContainer = new BoxContainer
{
Orientation = BoxContainer.LayoutOrientation.Vertical,
Expand Down
41 changes: 7 additions & 34 deletions Content.Client/SS220/Contractor/UI/ContractorStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,43 +181,16 @@ protected override void CreateRules()
.Class("ContractorPhotoImage")
.Prop(PanelContainer.StylePropertyPanel, StrechedStyleBoxTexture(Tex("/Textures/SS220/Interface/Contractor/contractor-pda-photo-image.png")));

/*
Builder
.Element<PanelContainer>()
.Class("ContractorFontPanel")
.Class("ContractAcceptedBorder")
.Prop(PanelContainer.StylePropertyPanel,
StrechedStyleBoxTexture(Tex("/Textures/SS220/Interface/Contractor/font-uplink-contractor.png")));
Builder
.Element<SpriteButton>()
.Class("ContractorContractsButton")
.Prop(SpriteButton.StylePropertySprite,
Sprite("/Textures/SS220/Interface/Contractor/buttons.rsi", "contracts"));
Builder
.Element<SpriteButton>()
.Class("ContractorHubButton")
.Prop(SpriteButton.StylePropertySprite,
Sprite("/Textures/SS220/Interface/Contractor/button-hub.rsi", "hub"));
Builder
.Element<SpriteButton>()
.Class("ContractorWithdrawButton")
.Prop(SpriteButton.StylePropertySprite,
Sprite("/Textures/SS220/Interface/Contractor/button-withdraw.rsi", "withdraw"));
Builder
.Element<SpriteButton>()
.Class("ContractorExecutionButton")
.Prop(SpriteButton.StylePropertySprite,
Sprite("/Textures/SS220/Interface/Contractor/button-execution.rsi", "execution"));
Builder
.Element<SpriteButton>()
.Class("ContractorPhotoButton")
.Prop(SpriteButton.StylePropertySprite,
Sprite("/Textures/SS220/Interface/Contractor/button-photo.rsi", "photo"));
*/
new StyleBoxFlat
{
BorderColor = Color.FromHex("#43ff4a"),
BorderThickness = new Thickness(2),
BackgroundColor = Color.FromHex("#93abb2"),
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void ResetCharacterSpriteView()
_entMan.DeleteEntity(_previewDummy);
}

public void SetupCharacterSpriteView(HumanoidCharacterProfile profile, string jobPrototype)
public void SetupCharacterSpriteView(HumanoidCharacterProfile profile, string jobPrototype, bool onlyFaceSide = false)
{
HumanoidAppearanceSystem appearanceSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<HumanoidAppearanceSystem>();

Expand All @@ -63,6 +63,13 @@ public void SetupCharacterSpriteView(HumanoidCharacterProfile profile, string jo
GiveDummyJobClothes(_previewDummy, profile, realjobprototype);

_face.SetEntity(_previewDummy);

if (onlyFaceSide)
{
RemoveChild(_side);
return;
}

_side.SetEntity(_previewDummy);
}

Expand Down
55 changes: 55 additions & 0 deletions Content.Server/Administration/Systems/AdminVerbSystem.Antags.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System.Linq;
using Content.Server.Administration.Commands;
using Content.Server.Antag;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.Implants;
using Content.Server.Roles;
using Content.Server.Zombies;
using Content.Shared.Administration;
using Content.Shared.Database;
Expand All @@ -11,13 +14,23 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using Content.Server.SS220.GameTicking.Rules.Components;
using Content.Server.Traitor.Uplink;
using Content.Shared.FixedPoint;
using Content.Shared.Implants;
using Content.Shared.Implants.Components;
using Content.Shared.SS220.Contractor;
using Content.Shared.Store.Components;
using Robust.Shared.Map;

namespace Content.Server.Administration.Systems;

public sealed partial class AdminVerbSystem
{
[Dependency] private readonly AntagSelectionSystem _antag = default!;
[Dependency] private readonly ZombieSystem _zombie = default!;
[Dependency] private readonly SharedRoleSystem _role = default!;
[Dependency] private readonly UplinkSystem _uplink = default!;
[Dependency] private readonly ImplanterSystem _implant = default!;

[ValidatePrototypeId<EntityPrototype>]
private const string DefaultTraitorRule = "Traitor";
Expand Down Expand Up @@ -72,6 +85,48 @@ private void AddAntagVerbs(GetVerbsEvent<Verb> args)
};
args.Verbs.Add(traitor);

//ss220 add verb for shitspawn contractor start
Verb contractor = new()
{
Text = Loc.GetString("admin-verb-make-contractor"),
Category = VerbCategory.Antag,
Icon = new SpriteSpecifier.Rsi(new ResPath("/Textures/Structures/Wallmounts/posters.rsi"), "poster2_legit"),
Act = () =>
{
if (!_mindSystem.TryGetMind(targetPlayer, out var mindId, out var mind))
return;

if (!_role.MindHasRole<TraitorRoleComponent>(mindId))
{
_antag.ForceMakeAntag<TraitorRuleComponent>(targetPlayer, DefaultTraitorRule);
}

var uplink = _uplink.FindUplinkTarget(targetPlayer.AttachedEntity!.Value);

if (uplink is null)
{
if (!TryComp<ImplantedComponent>(targetPlayer.AttachedEntity.Value, out var implanted))
return;

uplink = implanted.ImplantContainer.ContainedEntities
.FirstOrDefault(entity => Prototype(entity)?.ID == "UplinkImplant");
}

var uplinkComp = EnsureComp<StoreComponent>(uplink.Value);
uplinkComp.Balance["Telecrystal"] -= FixedPoint2.New(20);

EnsureComp<ContractorComponent>(targetPlayer.AttachedEntity!.Value);

var box = Spawn("BoxContractor", MapCoordinates.Nullspace);
uplinkComp.FullListingsCatalog.FirstOrDefault(boxContractor => boxContractor.ID == "UplinkContractor")!.PurchaseAmount++;
_handsSystem.PickupOrDrop(targetPlayer.AttachedEntity.Value, box);
},
Impact = LogImpact.High,
Message = Loc.GetString("admin-verb-make-contractor"),
};
args.Verbs.Add(contractor);
//ss220 add verb for shitspawn contractor end

Verb initialInfected = new()
{
Text = Loc.GetString("admin-verb-text-make-initial-infected"),
Expand Down
Loading

0 comments on commit 60a05f9

Please sign in to comment.