Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
9 changes: 7 additions & 2 deletions Content.Server/Construction/ConstructionSystem.Computer.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using Content.Server._NF.BindToStation; // Frontier
using Content.Server.Construction.Components;
using Content.Server.Power.Components;
using Content.Server.Station.Systems; // Frontier
using Content.Shared._NF.BindToStation; // Frontier
using Content.Server.Station.Systems;
using Content.Shared._Coyote.RedeemableStuff; // Frontier
using Content.Shared._NF.BindToStation; // Frontier
using Content.Shared.Computer;
using Content.Shared.Power;
using Robust.Shared.Containers;
Expand Down Expand Up @@ -85,6 +86,10 @@ private void CreateComputerBoard(Entity<ComputerComponent> ent)
}
}
// End Frontier
if (HasComp<UnRedeemableComponent>(ent.Owner))
{
AddComp<UnRedeemableComponent>(board);
}

if (!_container.Insert(board, container))
Log.Warning($"Couldn't insert board {board} to computer {ent}!");
Expand Down
14 changes: 11 additions & 3 deletions Content.Server/Construction/ConstructionSystem.Machine.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.Linq; // Frontier
using Content.Server._NF.BindToStation; // Frontier
using Content.Server.Construction.Components;
using Content.Server.Station.Systems; // Frontier
using Content.Shared._NF.BindToStation; // Frontier
using Content.Server.Station.Systems;
using Content.Shared._Coyote.RedeemableStuff; // Frontier
using Content.Shared._NF.BindToStation; // Frontier
using Content.Shared.Construction.Components;
using Content.Shared.Construction.Prototypes;
using Robust.Shared.Containers;
Expand Down Expand Up @@ -32,6 +33,8 @@ private void OnMachineInit(EntityUid uid, MachineComponent component, ComponentI
{
if (TryComp<StationBoundObjectComponent>(board, out var binding))
_bindToStation.BindToStation(uid, binding.BoundStation, binding.Enabled);
if (HasComp<UnRedeemableComponent>(board) && !HasComp<UnRedeemableComponent>(uid))
AddComp<UnRedeemableComponent>(uid);
}
// End Frontier
}
Expand Down Expand Up @@ -66,7 +69,7 @@ private void CreateBoardAndStockParts(EntityUid uid, MachineComponent component)
throw new Exception($"Entity with prototype {component.Board} doesn't have a {nameof(MachineBoardComponent)}!");
}

// Frontier: Only bind the board if the machine itself has the BindToStationComponent and the board doesn't already have BindToStationComponent
// Frontier: Only bind the board if the machine itself has the BindToStationComponent and the board doesn't already have BindToStationComponent
if (HasComp<BindToStationComponent>(uid) && board != null)
{
var machineStation = _station.GetOwningStation(uid);
Expand All @@ -77,6 +80,11 @@ private void CreateBoardAndStockParts(EntityUid uid, MachineComponent component)
}
// End Frontier

if (board is not null && HasComp<UnRedeemableComponent>(uid))
{
AddComp<UnRedeemableComponent>(board.Value);
}

foreach (var (stackType, amount) in machineBoard.StackRequirements)
{
var stack = _stackSystem.Spawn(amount, stackType, xform.Coordinates);
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Construction/FlatpackSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Content.Shared._NF.BindToStation; // Frontier: station binding
using Content.Server._NF.BindToStation; // Frontier: station binding
using Content.Server._NF.BindToStation;
using Content.Shared._Coyote.RedeemableStuff; // Frontier: station binding

namespace Content.Server.Construction;

Expand Down
5 changes: 4 additions & 1 deletion Content.Server/Lathe/LatheSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Content.Shared.Cargo.Components; // Frontier
using Content.Server._NF.Contraband.Systems; // Frontier
using Content.Server._NF.Contraband.Systems;
using Content.Shared._Coyote.RedeemableStuff; // Frontier
using Robust.Shared.Containers;
using Content.Shared._NF.Lathe; // Frontier

Expand Down Expand Up @@ -532,6 +533,8 @@ private void ModifyPrintedEntityPrice(EntityUid uid, LatheComponent component, E
|| component.ProductValueModifier < 0f)
return;

EnsureComp<UnRedeemableComponent>(target); // Make unredeemable

if (TryComp<StackPriceComponent>(target, out var stackPrice))
{
if (stackPrice.Price > 0)
Expand Down
9 changes: 6 additions & 3 deletions Content.Server/VendingMachines/VendingMachineSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
using Content.Shared._NF.Bank.BUI; // Frontier
using Content.Server._NF.Contraband.Systems; // Frontier
using Content.Shared.Stacks; // Frontier
using Content.Server.Stack; // Frontier
using Robust.Shared.Containers; // Frontier
using Content.Shared._NF.Bank.Components; // Frontier
using Content.Server.Stack;
using Content.Shared._Coyote.RedeemableStuff; // Frontier
using Robust.Shared.Containers; // Frontier
using Content.Shared._NF.Bank.Components; // Frontier

namespace Content.Server.VendingMachines
{
Expand Down Expand Up @@ -285,6 +286,8 @@ protected override void EjectItem(EntityUid uid, VendingMachineComponent? vendCo

var ent = Spawn(vendComponent.NextItemToEject, spawnCoordinates);

AddComp<UnRedeemableComponent>(ent); // Frontier

_contraband.ClearContrabandValue(ent); // Frontier

if (vendComponent.ThrowNextItem)
Expand Down
22 changes: 16 additions & 6 deletions Content.Server/_NF/Contraband/Systems/ContrabandTurnInSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Robust.Shared.Prototypes;
using Content.Server._NF.Cargo.Systems;
using Content.Server.Hands.Systems;
using Content.Shared._Coyote.RedeemableStuff;

namespace Content.Server._NF.Contraband.Systems;

Expand Down Expand Up @@ -149,15 +150,24 @@ private void GetPalletGoods(EntityUid gridUid, ContrabandPalletConsoleComponent
if (_blacklistQuery.HasComponent(ent))
continue;

if (TryComp<ContrabandComponent>(ent, out var comp))
// if (TryComp<ContrabandComponent>(ent, out var comp))
// {
// if (!comp.TurnInValues.ContainsKey(console.RewardType))
// continue;
//
// toSell.Add(ent);
// var value = comp.TurnInValues[console.RewardType];
// if (value <= 0)
// continue;
// amount += value;
// }
GetRedeemValueEvent ev = new ();
RaiseLocalEvent(ent, ref ev);
if (ev.Values.TryGetValue(console.RewardType, out int value))
{
if (!comp.TurnInValues.ContainsKey(console.RewardType))
continue;

toSell.Add(ent);
var value = comp.TurnInValues[console.RewardType];
if (value <= 0)
continue;
toSell.Add(ent);
amount += value;
}
}
Expand Down
29 changes: 24 additions & 5 deletions Content.Server/_NF/Security/ContrabandPriceGunSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Server.Popups;
using Content.Shared.Contraband;
using Content.Server._NF.Security.Components;
using Content.Shared._Coyote.RedeemableStuff;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Timing;
Expand Down Expand Up @@ -33,10 +34,14 @@ private void OnUtilityVerb(Entity<ContrabandPriceGunComponent> entity, ref GetVe
if (!TryComp(entity, out UseDelayComponent? useDelay) || _useDelay.IsDelayed((entity, useDelay)))
return;

if (!TryComp<ContrabandComponent>(args.Target, out var contraband) || !contraband.TurnInValues.ContainsKey(entity.Comp.Currency))
// if (!TryComp<ContrabandComponent>(args.Target, out var contraband) || !contraband.TurnInValues.ContainsKey(entity.Comp.Currency))
// return;
GetRedeemValueEvent ev = new ();
RaiseLocalEvent(args.Target, ref ev);
if (!ev.Values.ContainsKey(entity.Comp.Currency))
return;

var price = contraband.TurnInValues[entity.Comp.Currency];
var price = ev.Values[entity.Comp.Currency];
var user = args.User;
var target = args.Target;

Expand All @@ -62,10 +67,24 @@ private void OnAfterInteract(Entity<ContrabandPriceGunComponent> entity, ref Aft
if (!TryComp(entity, out UseDelayComponent? useDelay) || _useDelay.IsDelayed((entity, useDelay)))
return;

if (TryComp<ContrabandComponent>(args.Target, out var contraband) && contraband.TurnInValues.ContainsKey(entity.Comp.Currency))
_popupSystem.PopupEntity(Loc.GetString($"{entity.Comp.LocStringPrefix}contraband-price-gun-pricing-result", ("object", Identity.Entity(args.Target.Value, EntityManager)), ("price", contraband.TurnInValues[entity.Comp.Currency])), args.User, args.User);
GetRedeemValueEvent ev = new ();
RaiseLocalEvent(args.Target.Value, ref ev);

if (ev.Values.TryGetValue(entity.Comp.Currency, out int price))
_popupSystem.PopupEntity(
Loc.GetString(
$"{entity.Comp.LocStringPrefix}contraband-price-gun-pricing-result",
("object", Identity.Entity(args.Target.Value, EntityManager)),
("price", price)),
args.User,
args.User);
else
_popupSystem.PopupEntity(Loc.GetString($"{entity.Comp.LocStringPrefix}contraband-price-gun-pricing-result-none", ("object", Identity.Entity(args.Target.Value, EntityManager))), args.User, args.User);
_popupSystem.PopupEntity(
Loc.GetString(
$"{entity.Comp.LocStringPrefix}contraband-price-gun-pricing-result-none",
("object", Identity.Entity(args.Target.Value, EntityManager))),
args.User,
args.User);

_audio.PlayPvs(entity.Comp.AppraisalSound, entity.Owner);
_useDelay.TryResetDelay((entity, useDelay));
Expand Down
10 changes: 10 additions & 0 deletions Content.Shared/Construction/SharedFlatpackSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Shared._Coyote.RedeemableStuff;
using Content.Shared.Construction.Components;
using Content.Shared.Administration.Logs;
using Content.Shared.Containers.ItemSlots;
Expand Down Expand Up @@ -98,6 +99,10 @@ private void OnFlatpackInteractUsing(Entity<FlatpackComponent> ent, ref Interact
spawnXform.LocalRotation = xform.LocalRotation.GetCardinalDir().ToAngle(); // Frontier: rotatable flatpacks
if (TryComp<StationBoundObjectComponent>(uid, out var bound)) // Frontier: station binding
BindToStation(spawn, bound); // Frontier: station binding
if (HasComp<UnRedeemableComponent>(uid))
{
AddComp<UnRedeemableComponent>(spawn);
}

_adminLogger.Add(LogType.Construction,
LogImpact.Low,
Expand Down Expand Up @@ -127,6 +132,11 @@ protected void SetupFlatpack(Entity<FlatpackComponent?> ent, EntProtoId proto, E
_metaData.SetEntityName(ent, Loc.GetString("flatpack-entity-name", ("name", machinePrototype.Name)), meta);
_metaData.SetEntityDescription(ent, Loc.GetString("flatpack-entity-description", ("name", machinePrototype.Name)), meta);

if (HasComp<UnRedeemableComponent>(board))
{
AddComp<UnRedeemableComponent>(ent.Owner);
}

if (TryComp<StationBoundObjectComponent>(board, out var bound)) // Frontier: station binding
BindToStation(ent, bound); // Frontier: station binding

Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/Stacks/SharedStackSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Numerics;
using Content.Shared._Coyote.RedeemableStuff;
using Content.Shared.Examine;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
Expand Down Expand Up @@ -122,6 +123,11 @@ private bool TryMergeStacks(
if (string.IsNullOrEmpty(recipientStack.StackTypeId) || !recipientStack.StackTypeId.Equals(donorStack.StackTypeId))
return false;

bool mecomp = HasComp<UnRedeemableComponent>(donor);
bool youcomp = HasComp<UnRedeemableComponent>(recipient);
if (mecomp != youcomp)
return false;

transferred = Math.Min(donorStack.Count, GetAvailableSpace(recipientStack));
SetCount(donor, donorStack.Count - transferred, donorStack);
SetCount(recipient, recipientStack.Count + transferred, recipientStack);
Expand Down
28 changes: 28 additions & 0 deletions Content.Shared/_Coyote/RedeemableStuff/RedeemableComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Content.Shared.Store;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;

namespace Content.Shared._Coyote.RedeemableStuff;

/// <summary>
/// This is for making it so an entity can be redeemed for something.
/// Like nfsd stuff being redeemed on the Den for like, den bullion
/// Or guns! Trade them in for whatever!
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class RedeemableComponent : Component
{
/// <summary>
/// How much of which kinds of currency this item can be redeemed for.
/// </summary>
[DataField]
[AutoNetworkedField]
public Dictionary<ProtoId<CurrencyPrototype>, int> TurnInValues = new();

/// <summary>
/// Easy presets for common turn-in values.
/// </summary>
[DataField]
[AutoNetworkedField]
public ProtoId<RedeemablePresetPrototype>? Preset;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Robust.Shared.Prototypes;

namespace Content.Shared._Coyote.RedeemableStuff;

/// <summary>
/// This is a prototype for easy presets for redeemable values.
/// </summary>
[Prototype("redeemablePreset")]
public sealed partial class RedeemablePresetPrototype : IPrototype
{
/// <inheritdoc/>
[IdDataField]
public string ID { get; } = default!;

/// <summary>
/// Fucs you get for turning this in.
/// </summary>
[DataField]
public int FucValue = 0;

/// <summary>
/// Den Bullion you get for turning this in.
/// </summary>
[DataField]
public int DenBullionValue = 0;
}
54 changes: 54 additions & 0 deletions Content.Shared/_Coyote/RedeemableStuff/RedeemableSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System.Linq;
using Content.Shared.Store;
using Robust.Shared.Prototypes;

namespace Content.Shared._Coyote.RedeemableStuff;

/// <summary>
/// This handles...
/// </summary>
public sealed class RedeemableSystem : EntitySystem
{
[Dependency]
private readonly IPrototypeManager _prototypeManager = default!;

/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<RedeemableComponent, ComponentInit>(OnRedeemableInit);
SubscribeLocalEvent<RedeemableComponent, GetRedeemValueEvent>(OnGetRedeemValue);
}

private void OnRedeemableInit(EntityUid uid, RedeemableComponent c, ComponentInit args)
{
if (c.Preset == null)
return;
if (!_prototypeManager.TryIndex(c.Preset, out RedeemablePresetPrototype? preset))
return;
c.TurnInValues = new Dictionary<ProtoId<CurrencyPrototype>, int>
{
{ "FrontierUplinkCoin", preset.FucValue },
{ "Doubloon", preset.DenBullionValue }
};
}

private void OnGetRedeemValue(EntityUid uid, RedeemableComponent c, GetRedeemValueEvent args)
{
if (c.TurnInValues.Count == 0)
return;
if (TryComp(uid, out UnRedeemableComponent? unRedeemable))
return;
foreach (var (currency, amount) in c.TurnInValues)
{
if (!args.Values.TryAdd(currency, amount))
args.Values[currency] += amount;
}
}

}

[ByRefEvent]
public sealed class GetRedeemValueEvent : EntityEventArgs
{
public Dictionary<ProtoId<CurrencyPrototype>, int> Values = new();
}
26 changes: 26 additions & 0 deletions Content.Shared/_Coyote/RedeemableStuff/UnRedeemableComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Content.Shared.Store;
using Robust.Shared.Prototypes;

namespace Content.Shared._Coyote.RedeemableStuff;

/// <summary>
/// This is used to explicitly mark an entity as unredeemable.
/// Can
/// </summary>
[RegisterComponent]
public sealed partial class UnRedeemableComponent : Component
{
/// <summary>
/// Does this unredeemable component block all redeeming, or only certain types of currency?
/// If null or empty, blocks all redeeming.
/// </summary>
[DataField]
public HashSet<ProtoId<CurrencyPrototype>> BlockedCurrencies = new();

/// <summary>
/// If true, it will attempt to spread from itself to anything derived from it
/// Like if you craft something from an unredeemable item, the result will also be unredeemable.
/// </summary>
[DataField("sticky")]
public bool Sticky = false;
}
Loading
Loading