Skip to content

Commit

Permalink
Fixes compiling errors - Hopefully this works!
Browse files Browse the repository at this point in the history
  • Loading branch information
deathride58 committed Nov 21, 2023
1 parent 6edadb4 commit 9a0d9ea
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server._Citadel.Contracts.Systems;
using Content.Shared._Citadel.Contracts;
using Content.Shared.Mind;

namespace Content.Server._Citadel.Contracts.Components;

Expand All @@ -19,12 +20,12 @@ public sealed partial class ContractComponent : Component
/// The contractor that owns this contract.
/// </summary>
[ViewVariables]
public Mind.Mind? OwningContractor = default;
public MindComponent? OwningContractor = default;
/// <summary>
/// All subcontractors for the contract, who signed on or were invited by the owning contractor.
/// </summary>
[ViewVariables]
public List<Mind.Mind> SubContractors = new();
public List<MindComponent> SubContractors = new();

[DataField("autostart")]
public bool AutoStart = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server._Citadel.Contracts.Components;
using Content.Shared._Citadel.Contracts;
using Content.Shared.Mind;
using Robust.Shared.Map;
using Robust.Shared.Utility;

Expand Down Expand Up @@ -53,7 +54,7 @@ public EntityUid CreateUnboundContract(string contractProto)
return contractEnt;
}

public void BindContract(EntityUid contractEnt, Mind.Mind contractor)
public void BindContract(EntityUid contractEnt, MindComponent contractor)
{
var contract = Comp<ContractComponent>(contractEnt);
if (contract.OwningContractor is null)
Expand All @@ -73,7 +74,14 @@ public void BindContract(EntityUid contractEnt, Mind.Mind contractor)
contractor.Contracts.Add(contractEnt);
}

public EntityUid CreateBoundContract(string contractProto, Mind.Mind owner)
public void BindContract(EntityUid contractEnt, EntityUid? mindID)
{
if (!TryComp<MindComponent>(mindID, out var mind))
throw new Exception("BindContract couldn't get a MindComponent!");
BindContract(contractEnt, mind);
}

public EntityUid CreateBoundContract(string contractProto, MindComponent owner)
{
var contractEnt = CreateUnboundContract(contractProto);
BindContract(contractEnt, owner);
Expand All @@ -82,6 +90,13 @@ public EntityUid CreateBoundContract(string contractProto, Mind.Mind owner)
return contractEnt;
}

public EntityUid CreateBoundContract(string contractProto, EntityUid? mindID)
{
if (!TryComp<MindComponent>(mindID, out var mind))
throw new Exception("CreateBoundContract couldn't get a MindComponent!");
return CreateBoundContract(contractProto, mind);
}

public bool CouldChangeStatusTo(EntityUid contractUid, ContractStatus newStatus, out FormattedMessage? failMsg, ContractComponent? contractComponent = null)
{
failMsg = null;
Expand Down
10 changes: 5 additions & 5 deletions Content.Server/_Citadel/Contracts/Toolshed/ContractCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
using Content.Server.Players;
using Content.Shared._Citadel.Contracts;
using Content.Shared.Administration;
using Content.Shared.Mind;
using Content.Shared.Players;
using Robust.Server.Player;
using Robust.Shared.Players;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.TypeParsers;
Expand All @@ -32,8 +34,7 @@ public EntityUid New([CommandArgument] Prototype<EntityPrototype> contract)
public EntityUid New([PipedArgument] EntityUid contract, [CommandArgument] ICommonSession session)
{
_contractManagement ??= GetSys<ContractManagementSystem>();
var player = (IPlayerSession) session;
_contractManagement.BindContract(contract, player.GetMind()!);
_contractManagement.BindContract(contract, session.GetMind());
return contract;
}

Expand All @@ -43,8 +44,7 @@ public EntityUid New([PipedArgument] ICommonSession session, [CommandArgument] P
{
_contractManagement ??= GetSys<ContractManagementSystem>();

var player = (IPlayerSession) session;
return _contractManagement.CreateBoundContract(contract.AsType(), player.GetMind()!);
return _contractManagement.CreateBoundContract(contract.AsType(), session.GetMind());
}

[CommandImplementation("list")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
using Content.Server._Citadel.PDAContracts.Components;
using Content.Server._Citadel.VesselContracts.Components;
using Content.Server.CartridgeLoader;
using Content.Server.Players;
using Content.Shared._Citadel.Contracts;
using Content.Shared._Citadel.Contracts.BUI;
using Content.Shared.CartridgeLoader;
using Content.Shared.FixedPoint;
using Content.Shared.Mind;
using Content.Shared.Players;
using Robust.Server.Player;
using Robust.Shared.Player;
using Robust.Shared.Utility;

namespace Content.Server._Citadel.PDAContracts.Systems;
Expand All @@ -35,27 +37,30 @@ private void OnMessage(EntityUid uid, ContractsCartridgeComponent component, Car
if (args is not ContractsUiMessageEvent { } ev)
return;

var player = (IPlayerSession) args.Session!;
var player = (ICommonSession) args.Session!;
var mindID = player.GetMind();
if (!TryComp(mindID, out MindComponent? mind))
return;
var contract = EntityQuery<ContractComponent>().First(x => x.Uuid == ev.Contract);
switch (ev.Action)
{
case ContractsUiMessageEvent.ContractAction.Sign:
if (contract.OwningContractor is not null)
return;
_contracts.BindContract(contract.Owner, player.GetMind()!);
_contracts.BindContract(contract.Owner, mindID);
break;
case ContractsUiMessageEvent.ContractAction.Join:
_contracts.BindContract(contract.Owner, player.GetMind()!);
_contracts.BindContract(contract.Owner, mindID);
break;
case ContractsUiMessageEvent.ContractAction.Cancel:
if (contract.OwningContractor != player.GetMind()!)
if (contract.OwningContractor != mind)
return;
_contracts.TryCancelContract(contract.Owner);
break;
case ContractsUiMessageEvent.ContractAction.Leave:
break;
case ContractsUiMessageEvent.ContractAction.Start:
if (contract.OwningContractor != player.GetMind()!)
if (contract.OwningContractor != mind)
return;
_contracts.TryActivateContract(contract.Owner);
break;
Expand All @@ -65,17 +70,20 @@ private void OnMessage(EntityUid uid, ContractsCartridgeComponent component, Car
throw new ArgumentOutOfRangeException();
}

UpdateUiState(uid, args.LoaderUid, player, component);
UpdateUiState(uid, GetEntity(args.LoaderUid), player, component);
}

private void OnUiReady(EntityUid uid, ContractsCartridgeComponent component, CartridgeUiReadyEvent args)
{
UpdateUiState(uid, args.Loader, (IPlayerSession)args.Session, component);
UpdateUiState(uid, args.Loader, (ICommonSession)args.Session, component);
}

public ContractListUiState GenerateState(EntityUid cart, IPlayerSession user)
public ContractListUiState GenerateState(EntityUid cart, ICommonSession user)
{
var mind = user.GetMind()!;
var mindID = user.GetMind()!;
if (!TryComp(mindID, out MindComponent? mind))
throw new Exception("GenerateState could not get MindComponent from session");

var conQuery = EntityQueryEnumerator<ContractComponent, ContractCriteriaControlComponent, ContractGroupsComponent>();

var contractStates = new Dictionary<Guid, ContractUiState>();
Expand Down Expand Up @@ -166,7 +174,7 @@ status is not ContractUiState.ContractUserStatus.Owner
return new ContractListUiState(contractStates, mind.BankAccount?.Thalers ?? FixedPoint2.Zero);
}

private void UpdateUiState(EntityUid uid, EntityUid loaderUid, IPlayerSession session, ContractsCartridgeComponent? component)
private void UpdateUiState(EntityUid uid, EntityUid loaderUid, ICommonSession session, ContractsCartridgeComponent? component)
{
if (!Resolve(uid, ref component))
return;
Expand Down
11 changes: 6 additions & 5 deletions Content.Server/_Citadel/Thalers/PersonalBankSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
using Content.Server._Citadel.PDAContracts.Systems;
using Content.Server.Chat.Managers;
using Content.Server.Chat.Systems;
using Content.Server.Mind.Components;
using Content.Server.Station.Systems;
using Content.Shared._Citadel.Contracts;
using Content.Shared._Citadel.Thalers;
using Content.Shared.Chat;
using Content.Shared.Mind;
using Content.Shared.Mind.Components;
using Content.Shared.FixedPoint;
using JetBrains.Annotations;
using Robust.Shared.Toolshed;

namespace Content.Server._Citadel.Thalers;

Expand Down Expand Up @@ -78,7 +79,7 @@ public bool TryGetBalance(EntityUid user, [NotNullWhen(true)] out FixedPoint2? b
{
balance = null;

if (!TryComp<MindContainerComponent>(user, out var mindComp) || mindComp.Mind is not {BankAccount: { } account})
if (!TryComp<MindComponent>(user, out var mindComp) || mindComp is not {BankAccount: { } account})
return false;

balance = account.Thalers;
Expand All @@ -88,7 +89,7 @@ public bool TryGetBalance(EntityUid user, [NotNullWhen(true)] out FixedPoint2? b
[PublicAPI]
public bool CanAdjustBalance(EntityUid user, FixedPoint2 amount)
{
if (!TryComp<MindContainerComponent>(user, out var mindComp) || mindComp.Mind is not {BankAccount: { } account} mind)
if (!TryComp<MindComponent>(user, out var mindComp) || mindComp is not {BankAccount: { } account} mind)
return false;

var newSum = account.Thalers + amount;
Expand All @@ -106,7 +107,7 @@ public bool CanAdjustBalance(EntityUid user, FixedPoint2 amount)
[PublicAPI]
public bool TryAdjustBalance(EntityUid user, FixedPoint2 amount)
{
if (!TryComp<MindContainerComponent>(user, out var mindComp) || mindComp.Mind is not {BankAccount: { } account})
if (!TryComp<MindComponent>(user, out var mindComp) || mindComp is not {BankAccount: { } account})
return false;

if (!CanAdjustBalance(user, amount))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
using Content.Server._Citadel.Contracts.Components;
using Content.Server._Citadel.VesselContracts.Components;
using Content.Server.Chat.Systems;
using Content.Server.Mind.Components;
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Systems;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Shared._Citadel.Contracts;
using Content.Shared.Mind;
using Content.Shared.Mind.Components;
using Content.Shared.Localizations;
using Robust.Server.GameObjects;
using Robust.Server.Maps;
Expand Down Expand Up @@ -69,7 +70,7 @@ public void ContractVesselAnnouncement(EntityUid contract, string message)
return LocateUserVesselContract(mind);
}

public EntityUid? LocateUserVesselContract(Mind.Mind mind)
public EntityUid? LocateUserVesselContract(MindComponent mind)
{
var contract = mind.Contracts.Where(HasComp<VesselContractComponent>).FirstOrDefault();
if (contract == EntityUid.Invalid)
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/CartridgeLoader/CartridgeUiMessage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Robust.Shared.Players;
using Robust.Shared.Player;
using Robust.Shared.Serialization;

namespace Content.Shared.CartridgeLoader;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Content.Shared.Containers.ItemSlots;
using Robust.Shared.Containers;
using Robust.Shared.Players;
using Robust.Shared.Player;
using Robust.Shared.Network;

namespace Content.Shared.CartridgeLoader;
Expand Down
6 changes: 5 additions & 1 deletion Content.Shared/_Citadel/Thalers/SharedPersonalBankSystem.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using Content.Shared.FixedPoint;
using Robust.Shared.Toolshed;
using Content.Shared.Mind;
using Content.Shared.Mind.Components;
using System.Collections;


namespace Content.Shared._Citadel.Thalers;

[Access(typeof(PersonalBankSystem), typeof(Mind.Mind))]
public sealed class BankAccount : IToolshedPrettyPrint
{
// TODO(Lunar): FixedPoint2 can't represent more than ~20mil or so. Maybe need a new thing if we expect people to get stupid rich.
Expand Down

0 comments on commit 9a0d9ea

Please sign in to comment.