Skip to content
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

Recyclable clothing arbitrage test #10

Closed
wants to merge 103 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
2f8f4d3
base items
ErhardSteinhauer Oct 9, 2024
89c03e7
recyclable outer clothes
ErhardSteinhauer Oct 9, 2024
dde8c52
recycle books
ErhardSteinhauer Oct 9, 2024
7add0e6
more random items
ErhardSteinhauer Oct 10, 2024
cc765da
instruments and flags
ErhardSteinhauer Oct 10, 2024
7da96b6
encryption keys, cartons
ErhardSteinhauer Oct 10, 2024
7c3505b
Merge branch 'master' into 2024-10-Recyclable-Clothing
ErhardSteinhauer Oct 10, 2024
84f63e7
fix
ErhardSteinhauer Oct 10, 2024
d9791c0
ammo boxes
ErhardSteinhauer Oct 10, 2024
d89347e
gun magazines
ErhardSteinhauer Oct 10, 2024
f3a8e1c
nades
ErhardSteinhauer Oct 10, 2024
e324de2
tabletop games, dropper, pickaxe
ErhardSteinhauer Oct 10, 2024
bb43e15
monkey cubes, pills, lighters
ErhardSteinhauer Oct 10, 2024
aa69491
traffic key (take that STC)
ErhardSteinhauer Oct 10, 2024
de87e0f
biomass from plants
ErhardSteinhauer Oct 12, 2024
67f42dd
Update build-test-debug.yml
dvir001 Oct 13, 2024
66e6f13
Merge branch 'master' into 2024-10-13-Workflows2
dvir001 Oct 13, 2024
f5d2c47
Merge branch 'master' into 2024-10-13-Workflows2
dvir001 Oct 13, 2024
70f326e
Update PostMapInitTest.cs
dvir001 Oct 13, 2024
4778d70
flatpacks
ErhardSteinhauer Oct 13, 2024
43ad3db
Merge branch 'new-frontiers-14:master' into 2024-10-Recyclable-Clothing
ErhardSteinhauer Oct 13, 2024
2c9c11f
Merge branch 'master' into 2024-10-13-Workflows2
dvir001 Oct 14, 2024
5cf1e74
Update PostMapInitTest.cs
dvir001 Oct 14, 2024
9c2e19b
Merge branch 'master' into 2024-10-13-Workflows2
dvir001 Oct 14, 2024
2962401
Merge branch 'master' into 2024-10-13-Workflows2
dvir001 Oct 14, 2024
5ed7922
cards, bullets, ame jar
ErhardSteinhauer Oct 14, 2024
548cd8b
reclaimer magnet radius, revert bullets
ErhardSteinhauer Oct 14, 2024
177d09b
more tags for recycler
ErhardSteinhauer Oct 14, 2024
1c1e819
Merge branch 'master' into 2024-10-13-Workflows2
dvir001 Oct 14, 2024
ffdcac4
Merge branch 'master' into 2024-10-13-Workflows2
dvir001 Oct 14, 2024
08ed4c1
Update AutoInternalsTests.cs
dvir001 Oct 14, 2024
0bd3349
My pain is real
dvir001 Oct 14, 2024
94cff2c
Workflow fixes, WIP
whatston3 Oct 14, 2024
9d51d43
Merge branch 'master' of https://github.com/new-frontiers-14/frontier…
whatston3 Oct 14, 2024
ae81bc1
SectorServices: spawn in nullspace
whatston3 Oct 14, 2024
cfbb5a2
Check invalid entity
whatston3 Oct 14, 2024
15a5576
SectorService: init/remove
whatston3 Oct 14, 2024
0e2968a
wendigo entity fixes
whatston3 Oct 14, 2024
5de8231
camper price fix, DeadDrop compromise
whatston3 Oct 15, 2024
fa2c4f1
Merge branch 'master' into 2024-10-13-Workflows2
dvir001 Oct 15, 2024
2969d44
Merge branch 'master' into 2024-10-13-Workflows2
dvir001 Oct 15, 2024
8114b0d
Merge branch 'master' into 2024-10-13-Workflows2
dvir001 Oct 15, 2024
0346b33
Merge branch 'master' into 2024-10-13-Workflows2
dvir001 Oct 15, 2024
5bfcfcf
Merge branch 'master' into 2024-10-13-Workflows2
whatston3 Oct 15, 2024
c7b7bc6
Exclude shipyard tests from build-test-debug job
whatston3 Oct 15, 2024
c22bce3
Merge branch 'master' into 2024-10-13-Workflows2
dvir001 Oct 15, 2024
4ba4696
Only use Frontier game maps
whatston3 Oct 15, 2024
f72bbb5
Merge branch 'master' into 2024-10-13-Workflows2
dvir001 Oct 16, 2024
c19b6bd
Merge branch '2024-10-13-Workflows2' of https://github.com/dvir001/fr…
whatston3 Oct 16, 2024
e085769
Merge branch 'master' into 2024-10-13-Workflows2
dvir001 Oct 16, 2024
d9330d7
Merge branch 'master' into 2024-10-13-Workflows2
dvir001 Oct 16, 2024
1c1f2be
Merge branch 'master' into 2024-10-13-Workflows2
dvir001 Oct 16, 2024
ce2f5c5
Merge branch 'master' into 2024-10-13-Workflows2
dvir001 Oct 16, 2024
4329200
Merge branch '2024-10-13-Workflows2' of https://github.com/dvir001/fr…
whatston3 Oct 16, 2024
2cfca6b
Update CargoTest.cs
dvir001 Oct 16, 2024
547e196
Log for tests
whatston3 Oct 16, 2024
9b1e017
EntityTest fixes, SectorService cleanup, welders
whatston3 Oct 16, 2024
8ec6c69
component init, salvage mob restrictions checks
whatston3 Oct 16, 2024
1bd1fd8
Merge branch '2024-10-13-Workflows2' of https://github.com/dvir001/fr…
whatston3 Oct 16, 2024
a150566
Merge branch 'master' of https://github.com/new-frontiers-14/frontier…
whatston3 Oct 16, 2024
bd844c0
Ammolathe Blueprints (for real), Hide Secfab (#2268)
whatston3 Oct 17, 2024
3bbb3c7
Goblinbane Nerf (#2265)
ErhardSteinhauer Oct 17, 2024
4eda96d
Automatic Changelog (#2265)
FrontierATC Oct 17, 2024
79626e3
Halloween: Cauldron to replace deep fryers (#2240)
arimah Oct 17, 2024
2d2da1e
Components & lathe speed balance pass (#2269)
whatston3 Oct 17, 2024
ba7e2d1
Automatic Changelog (#2269)
FrontierATC Oct 17, 2024
5e1fe8a
Folding Plastic Table (#2191)
ErhardSteinhauer Oct 17, 2024
1c83b5e
Automatic Changelog (#2191)
FrontierATC Oct 17, 2024
191c146
Adds Medical Assembler to FSB Stasis (#2207)
dustylens Oct 17, 2024
6060339
Automatic Changelog (#2207)
FrontierATC Oct 17, 2024
d6ae4e5
Remove salvage magnet board recipes (#2272)
whatston3 Oct 17, 2024
f029ce4
Automatic Changelog (#2272)
FrontierATC Oct 17, 2024
d209f7e
Replace NSF Inquisitor tiny fans with directionals, fix up some other…
chrome-cirrus Oct 17, 2024
8056cdf
Automatic Changelog (#2169)
FrontierATC Oct 17, 2024
ce248f0
updates the NSF Prowler (#2094)
Tych0theSynth Oct 17, 2024
78cb36e
Automatic Changelog (#2094)
FrontierATC Oct 17, 2024
caf6fcd
Replaces Spectre tiny fans with directional fans. (#2105)
dustylens Oct 17, 2024
284e846
Automatic Changelog (#2105)
FrontierATC Oct 17, 2024
aecb2f7
Lodge QoL Update (#2233)
ErhardSteinhauer Oct 17, 2024
6582c25
SSS Camper (UPDATE) (#2115)
AF-Buyrcsp2 Oct 17, 2024
8f94b64
Automatic Changelog (#2233)
FrontierATC Oct 17, 2024
6692ef5
Fix up the NSF Templar (#2186)
chrome-cirrus Oct 18, 2024
9f2ba05
Fix up the NSF mini-shuttles (#2243)
chrome-cirrus Oct 18, 2024
f66b210
Automatic Changelog (#2243)
FrontierATC Oct 18, 2024
f0739a9
Interceptor (Update Shuttle) (#2199)
chrome-cirrus Oct 18, 2024
4ff44da
Automatic Changelog (#2199)
FrontierATC Oct 18, 2024
1eaae60
Hospitaller (Update Shuttle) (#2194)
chrome-cirrus Oct 18, 2024
8315689
Automatic Changelog (#2194)
FrontierATC Oct 18, 2024
c692530
Add EMP Blast effect shader (#2262)
dvir001 Oct 18, 2024
4ee1a0c
Automatic Changelog (#2262)
FrontierATC Oct 18, 2024
25c6538
End of Round Cash Summary Revision (#2276)
whatston3 Oct 18, 2024
f71965e
Automatic Changelog (#2276)
FrontierATC Oct 18, 2024
d71b576
Wall freezers (#2190)
ErhardSteinhauer Oct 18, 2024
ee85177
Automatic Changelog (#2190)
FrontierATC Oct 18, 2024
6f9845a
Lathe Cleanup and allow printing boxes in service (#2278)
dvir001 Oct 18, 2024
1388224
Automatic Changelog (#2278)
FrontierATC Oct 18, 2024
89a1aa5
Adds some spookuary cheer from Bing and Ghost Prince. (#2256)
dustylens Oct 19, 2024
8295e91
Automatic Changelog (#2256)
FrontierATC Oct 19, 2024
4c861d7
Gatfruit again (#2286)
dvir001 Oct 19, 2024
eb7c588
Merge branch 'master' into 2024-10-Recyclable-Clothing
ErhardSteinhauer Oct 19, 2024
8a70eea
fix cards.yml
ErhardSteinhauer Oct 19, 2024
c5a088d
more fixes
ErhardSteinhauer Oct 19, 2024
179d351
Merge remote-tracking branch 'erhard/2024-10-Recyclable-Clothing' int…
whatston3 Oct 19, 2024
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: 5 additions & 5 deletions .github/workflows/build-test-debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ jobs:
- name: Run Content.Tests
run: dotnet test --no-build --configuration DebugOpt Content.Tests/Content.Tests.csproj -- NUnit.ConsoleOut=0

# - name: Run Content.IntegrationTests
# shell: pwsh
# run: |
# $env:DOTNET_gcServer=1
# dotnet test --no-build --configuration DebugOpt Content.IntegrationTests/Content.IntegrationTests.csproj --filter FullyQualifiedName!~ShipyardTest -- NUnit.ConsoleOut=0 NUnit.MapWarningTo=Failed
- name: Run Content.IntegrationTests
shell: pwsh
run: |
$env:DOTNET_gcServer=1
dotnet test --no-build --configuration DebugOpt Content.IntegrationTests/Content.IntegrationTests.csproj --filter FullyQualifiedName!~ShipyardTest -- NUnit.ConsoleOut=0 NUnit.MapWarningTo=Failed
ci-success:
name: Build & Test Debug
needs:
Expand Down
2 changes: 2 additions & 0 deletions Content.Client/Entry/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Replays;
using Robust.Shared.Timing;
using Content.Client._NF.Emp.Overlays; // Frontier

namespace Content.Client.Entry
{
Expand Down Expand Up @@ -154,6 +155,7 @@ public override void PostInit()

_overlayManager.AddOverlay(new SingularityOverlay());
_overlayManager.AddOverlay(new RadiationPulseOverlay());
_overlayManager.AddOverlay(new EmpBlastOverlay()); // Frontier
_chatManager.Initialize();
_clientPreferencesManager.Initialize();
_euiManager.Initialize();
Expand Down
145 changes: 145 additions & 0 deletions Content.Client/_NF/Emp/Overlays/EmpBlastOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
using System.Numerics;
using Content.Shared._NF.Emp.Components;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.Enums;
using Robust.Shared.Graphics;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;

namespace Content.Client._NF.Emp.Overlays
{
public sealed class EmpBlastOverlay : Overlay
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
private TransformSystem? _transform;

private const float PvsDist = 25.0f;

public override OverlaySpace Space => OverlaySpace.WorldSpace;
public override bool RequestScreenTexture => true;

private readonly ShaderInstance _baseShader;
private readonly Dictionary<EntityUid, (ShaderInstance shd, EmpShaderInstance instance)> _blasts = new();

public EmpBlastOverlay()
{
IoCManager.InjectDependencies(this);
_baseShader = _prototypeManager.Index<ShaderPrototype>("Emp").Instance().Duplicate();
}

protected override bool BeforeDraw(in OverlayDrawArgs args)
{
EmpQuery(args.Viewport.Eye);
return _blasts.Count > 0;
}

protected override void Draw(in OverlayDrawArgs args)
{
if (ScreenTexture == null)
return;

var worldHandle = args.WorldHandle;
var viewport = args.Viewport;

foreach ((var shd, var instance) in _blasts.Values)
{
if (instance.CurrentMapCoords.MapId != args.MapId)
continue;

// To be clear, this needs to use "inside-viewport" pixels.
// In other words, specifically NOT IViewportControl.WorldToScreen (which uses outer coordinates).
var tempCoords = viewport.WorldToLocal(instance.CurrentMapCoords.Position);
tempCoords.Y = viewport.Size.Y - tempCoords.Y;
shd?.SetParameter("renderScale", viewport.RenderScale);
shd?.SetParameter("positionInput", tempCoords);
shd?.SetParameter("range", instance.Range);
var life = (_gameTiming.RealTime - instance.Start).TotalSeconds / instance.Duration;
shd?.SetParameter("life", (float)life);

// There's probably a very good reason not to do this.
// Oh well!
shd?.SetParameter("SCREEN_TEXTURE", viewport.RenderTarget.Texture);

worldHandle.UseShader(shd);
worldHandle.DrawRect(Box2.CenteredAround(instance.CurrentMapCoords.Position, new Vector2(instance.Range, instance.Range) * 2f), Color.White);
}

worldHandle.UseShader(null);
}

//Queries all blasts on the map and either adds or removes them from the list of rendered blasts based on whether they should be drawn (in range? on the same z-level/map? blast entity still exists?)
private void EmpQuery(IEye? currentEye)
{
_transform ??= _entityManager.System<TransformSystem>();

if (currentEye == null)
{
_blasts.Clear();
return;
}

var currentEyeLoc = currentEye.Position;

var blasts = _entityManager.EntityQueryEnumerator<EmpBlastComponent>();
//Add all blasts that are not added yet but qualify
while (blasts.MoveNext(out var blastEntity, out var blast))
{
if (!_blasts.ContainsKey(blastEntity) && BlastQualifies(blastEntity, currentEyeLoc, blast))
{
_blasts.Add(
blastEntity,
(
_baseShader.Duplicate(),
new EmpShaderInstance(
_transform.GetMapCoordinates(blastEntity),
blast.VisualRange,
blast.StartTime,
blast.VisualDuration
)
)
);
}
}

var activeShaderIds = _blasts.Keys;
foreach (var blastEntity in activeShaderIds) //Remove all blasts that are added and no longer qualify
{
if (_entityManager.EntityExists(blastEntity) &&
_entityManager.TryGetComponent(blastEntity, out EmpBlastComponent? blast) &&
BlastQualifies(blastEntity, currentEyeLoc, blast))
{
var shaderInstance = _blasts[blastEntity];
shaderInstance.instance.CurrentMapCoords = _transform.GetMapCoordinates(blastEntity);
shaderInstance.instance.Range = blast.VisualRange;
}
else
{
_blasts[blastEntity].shd.Dispose();
_blasts.Remove(blastEntity);
}
}

}

private bool BlastQualifies(EntityUid blastEntity, MapCoordinates currentEyeLoc, EmpBlastComponent blast)
{
var transformComponent = _entityManager.GetComponent<TransformComponent>(blastEntity);
var transformSystem = _entityManager.System<SharedTransformSystem>();
return transformComponent.MapID == currentEyeLoc.MapId
&& transformSystem.InRange(transformComponent.Coordinates, transformSystem.ToCoordinates(transformComponent.ParentUid, currentEyeLoc), PvsDist + blast.VisualRange);
}

private sealed record EmpShaderInstance(MapCoordinates CurrentMapCoords, float Range, TimeSpan Start, float Duration)
{
public MapCoordinates CurrentMapCoords = CurrentMapCoords;
public float Range = Range;
public TimeSpan Start = Start;
public float Duration = Duration;
};
}
}

30 changes: 27 additions & 3 deletions Content.IntegrationTests/Tests/EntityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,21 @@ await server.WaitPost(() =>
.Where(p => !p.Components.ContainsKey("MapGrid")) // This will smash stuff otherwise.
.Select(p => p.ID)
.ToList();
bool anyException = false;
foreach (var protoId in protoIds)
{
entityMan.SpawnEntity(protoId, map.GridCoords);
Logger.Info($"Spawning proto {protoId}");
try
{
entityMan.SpawnEntity(protoId, map.GridCoords);
}
catch (Exception e)
{
Logger.Info($"Exception while spawning proto {protoId}: \"{e.Message}\" {e.StackTrace}");
anyException = true;
}
}
Assert.That(anyException, Is.EqualTo(false), "One or more exceptions occurred during entity spawn.");
});
await server.WaitRunTicks(15);
await server.WaitPost(() =>
Expand All @@ -120,13 +131,26 @@ await server.WaitPost(() =>
}
}

bool anyException = false;
var entityMetas = Query<MetaDataComponent>(entityMan).ToList();
foreach (var (uid, meta) in entityMetas)
{
if (!meta.EntityDeleted)
entityMan.DeleteEntity(uid);
Logger.Info($"Deleting entity {meta.EntityPrototype?.ID ?? "null"} ({uid})");
try
{
if (!meta.EntityDeleted)
entityMan.DeleteEntity(uid);
}
catch (Exception e)
{
Logger.Info($"Exception while deleting entity {meta.EntityPrototype?.ID ?? "null"} ({uid}): \"{e.Message}\" {e.StackTrace}");
anyException = true;
}
}

Assert.That(anyException, Is.EqualTo(false), "One or more exceptions occurred during entity deletion.");


Assert.That(entityMan.EntityCount, Is.Zero);
});

Expand Down
18 changes: 16 additions & 2 deletions Content.Server/Emp/EmpSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@
using Content.Shared.Tiles; // Frontier
using Robust.Server.GameObjects;
using Robust.Shared.Map;
using Content.Shared._NF.Emp.Components; // Frontier
using Robust.Server.GameStates; // Frontier: EMP Blast PVS
using Robust.Shared.Configuration; // Frontier: EMP Blast PVS
using Robust.Shared; // Frontier: EMP Blast PVS

namespace Content.Server.Emp;

public sealed class EmpSystem : SharedEmpSystem
{
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly PvsOverrideSystem _pvs = default!; // Frontier: EMP Blast PVS
[Dependency] private readonly IConfigurationManager _cfg = default!; // Frontier: EMP Blast PVS

public const string EmpPulseEffectPrototype = "EffectEmpPulse";
public const string EmpPulseEffectPrototype = "EffectEmpBlast"; // Frontier: EffectEmpPulse

public override void Initialize()
{
Expand Down Expand Up @@ -54,7 +60,15 @@ public void EmpPulse(MapCoordinates coordinates, float range, float energyConsum

TryEmpEffects(uid, energyConsumption, duration);
}
Spawn(EmpPulseEffectPrototype, coordinates);

var empBlast = Spawn(EmpPulseEffectPrototype, coordinates); // Frontier: Added visual effect
EnsureComp<EmpBlastComponent>(empBlast, out var empBlastComp); // Frontier
empBlastComp.VisualRange = range; // Frontier

if (range > _cfg.GetCVar(CVars.NetMaxUpdateRange)) // Frontier
_pvs.AddGlobalOverride(empBlast); // Frontier

Dirty(empBlast, empBlastComp); // Frontier
}

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Holiday/HolidayPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public sealed partial class HolidayPrototype : IPrototype
[DataField("celebrate")]
private IHolidayCelebrate? _celebrate = null;

[DataField("entityReplacements")] // Frontier
public Dictionary<EntProtoId, EntProtoId>? EntityReplacements = null; // Frontier

public bool ShouldCelebrate(DateTime date)
{
return _shouldCelebrate.ShouldCelebrate(date, this);
Expand Down
18 changes: 18 additions & 0 deletions Content.Server/Holiday/HolidaySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Shared.CCVar;
using Content.Shared.Holiday;
using Robust.Shared.Configuration;
using Robust.Shared.Map.Events;
using Robust.Shared.Prototypes;

namespace Content.Server.Holiday
Expand All @@ -26,6 +27,7 @@ public override void Initialize()
Subs.CVar(_configManager, CCVars.HolidaysEnabled, OnHolidaysEnableChange);
SubscribeLocalEvent<GameRunLevelChangedEvent>(OnRunLevelChanged);
SubscribeLocalEvent<HolidayVisualsComponent, ComponentInit>(OnVisualsInit);
SubscribeLocalEvent<BeforeEntityReadEvent>(OnBeforeRead);
}

public void RefreshCurrentHolidays()
Expand Down Expand Up @@ -115,6 +117,22 @@ private void OnVisualsInit(Entity<HolidayVisualsComponent> ent, ref ComponentIni
break;
}
}

// Frontier: holiday-themed entity replacement
private void OnBeforeRead(BeforeEntityReadEvent ev)
{
foreach (var holiday in _currentHolidays)
{
if (holiday.EntityReplacements is { } replacements)
{
foreach (var (original, replacement) in replacements)
{
ev.RenamedPrototypes.TryAdd(original, replacement);
}
}
}
}
// End Frontier
}

/// <summary>
Expand Down
32 changes: 29 additions & 3 deletions Content.Server/_NF/Bank/BankSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ public bool TryBankDeposit(ICommonSession session, PlayerPreferences prefs, Huma
}

/// <summary>
/// Attempts to add money to a character's bank account. This should always be used instead of attempting to modify the bankaccountcomponent directly
/// Retrieves a character's balance via its in-game entity, if it has one.
/// </summary>
/// <param name="ent">The UID that the bank account is connected to, typically the player controlled mob</param>
/// <param name="balance">The amount of spesos to add into the bank account</param>
/// <returns>true if the transaction was successful, false if it was not</returns>
/// <param name="balance">When successful, contains the account balance in spesos. Otherwise, set to 0.</param>
/// <returns>true if the account was successfully queried.</returns>
public bool TryGetBalance(EntityUid ent, out int balance)
{
if (!_playerManager.TryGetSessionByEntity(ent, out var session) ||
Expand All @@ -234,6 +234,32 @@ public bool TryGetBalance(EntityUid ent, out int balance)
return true;
}

/// <summary>
/// Retrieves a character's balance via a player's session.
/// </summary>
/// <param name="session">The session of the player character to query.</param>
/// <param name="balance">When successful, contains the account balance in spesos. Otherwise, set to 0.</param>
/// <returns>true if the account was successfully queried.</returns>
public bool TryGetBalance(ICommonSession session, out int balance)
{
if (!_prefsManager.TryGetCachedPreferences(session.UserId, out var prefs))
{
_log.Info($"{session.UserId} has no cached prefs");
balance = 0;
return false;
}

if (prefs.SelectedCharacter is not HumanoidCharacterProfile profile)
{
_log.Info($"{session.UserId} has the wrong prefs type");
balance = 0;
return false;
}

balance = profile.BankBalance;
return true;
}

/// <summary>
/// Update the bank balance to the character's current account balance.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public Dictionary<string, float> GetPartsRatings(List<MachinePartState> partStat
amount += state.Quantity();
sumRating += state.Part.Rating * state.Quantity();
}
var rating = amount != 0 ? sumRating / amount : 0;
var rating = amount != 0 ? sumRating / amount : 1.0f;
output.Add(type.ID, rating);
}

Expand Down
Loading
Loading