Telecrystals (and a bit more ECS) (#4775)
This commit is contained in:
@@ -1,32 +1,16 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using System;
|
||||
|
||||
namespace Content.Shared.Traitor.Uplink
|
||||
{
|
||||
public class UplinkAccount
|
||||
{
|
||||
public event Action<UplinkAccount>? BalanceChanged;
|
||||
public EntityUid AccountHolder;
|
||||
private int _balance;
|
||||
[ViewVariables]
|
||||
public int Balance => _balance;
|
||||
public readonly EntityUid? AccountHolder;
|
||||
public int Balance;
|
||||
|
||||
public UplinkAccount(EntityUid uid, int startingBalance)
|
||||
public UplinkAccount(int startingBalance, EntityUid? accountHolder = null)
|
||||
{
|
||||
AccountHolder = uid;
|
||||
_balance = startingBalance;
|
||||
}
|
||||
|
||||
public bool ModifyAccountBalance(int newBalance)
|
||||
{
|
||||
if (newBalance < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_balance = newBalance;
|
||||
BalanceChanged?.Invoke(this);
|
||||
return true;
|
||||
AccountHolder = accountHolder;
|
||||
Balance = startingBalance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user