@@ -1,4 +1,7 @@
|
||||
namespace Content.Server.Research.TechnologyDisk.Components;
|
||||
using Content.Shared.Random;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Research.TechnologyDisk.Components;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed class TechnologyDiskComponent : Component
|
||||
@@ -8,4 +11,10 @@ public sealed class TechnologyDiskComponent : Component
|
||||
/// </summary>
|
||||
[DataField("recipes")]
|
||||
public List<string>? Recipes;
|
||||
|
||||
/// <summary>
|
||||
/// A weighted random prototype for how rare each tier should be.
|
||||
/// </summary>
|
||||
[DataField("tierWeightPrototype", customTypeSerializer: typeof(PrototypeIdSerializer<WeightedRandomPrototype>))]
|
||||
public string TierWeightPrototype = "TechDiskTierWeights";
|
||||
}
|
||||
|
||||
@@ -85,7 +85,9 @@ public sealed class DiskConsoleSystem : EntitySystem
|
||||
{
|
||||
totalPoints = server.Points;
|
||||
}
|
||||
var canPrint = !HasComp<DiskConsolePrintingComponent>(uid) && totalPoints >= component.PricePerDisk;
|
||||
|
||||
var canPrint = !(TryComp<DiskConsolePrintingComponent>(uid, out var printing) && printing.FinishTime >= _timing.CurTime) &&
|
||||
totalPoints >= component.PricePerDisk;
|
||||
|
||||
var state = new DiskConsoleBoundUserInterfaceState(totalPoints, component.PricePerDisk, canPrint);
|
||||
_ui.TrySetUiState(uid, DiskConsoleUiKey.Key, state);
|
||||
|
||||
@@ -4,6 +4,8 @@ using Content.Server.Research.Systems;
|
||||
using Content.Server.Research.TechnologyDisk.Components;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Random;
|
||||
using Content.Shared.Random.Helpers;
|
||||
using Content.Shared.Research.Components;
|
||||
using Content.Shared.Research.Prototypes;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -66,46 +68,25 @@ public sealed class TechnologyDiskSystem : EntitySystem
|
||||
if (component.Recipes != null)
|
||||
return;
|
||||
|
||||
var lockoutTiers = new Dictionary<string, int>();
|
||||
foreach (var discipline in _prototype.EnumeratePrototypes<TechDisciplinePrototype>())
|
||||
{
|
||||
lockoutTiers.Add(discipline.ID, discipline.LockoutTier);
|
||||
}
|
||||
var weightedRandom = _prototype.Index<WeightedRandomPrototype>(component.TierWeightPrototype);
|
||||
var tier = int.Parse(weightedRandom.Pick(_random));
|
||||
|
||||
//get a list of every distinct recipe in all the technologies.
|
||||
var allTechs = new List<string>();
|
||||
var techs = new List<string>();
|
||||
foreach (var tech in _prototype.EnumeratePrototypes<TechnologyPrototype>())
|
||||
{
|
||||
if (tech.Tier >= lockoutTiers[tech.Discipline])
|
||||
if (tech.Tier != tier)
|
||||
continue;
|
||||
|
||||
allTechs.AddRange(tech.RecipeUnlocks);
|
||||
techs.AddRange(tech.RecipeUnlocks);
|
||||
}
|
||||
allTechs = allTechs.Distinct().ToList();
|
||||
techs = techs.Distinct().ToList();
|
||||
|
||||
//get a list of every distinct unlocked tech across all databases
|
||||
var allUnlocked = new List<string>();
|
||||
foreach (var database in EntityQuery<TechnologyDatabaseComponent>())
|
||||
{
|
||||
allUnlocked.AddRange(database.UnlockedRecipes);
|
||||
}
|
||||
allUnlocked = allUnlocked.Distinct().ToList();
|
||||
|
||||
//make a list of every single non-unlocked tech
|
||||
var validTechs = new List<string>();
|
||||
foreach (var tech in allTechs)
|
||||
{
|
||||
if (allUnlocked.Contains(tech))
|
||||
continue;
|
||||
|
||||
validTechs.Add(tech);
|
||||
}
|
||||
|
||||
if (!validTechs.Any())
|
||||
if (!techs.Any())
|
||||
return;
|
||||
|
||||
//pick one
|
||||
component.Recipes = new();
|
||||
component.Recipes.Add(_random.Pick(validTechs));
|
||||
component.Recipes.Add(_random.Pick(techs));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@
|
||||
- type: entity
|
||||
parent: BaseComputerCircuitboard
|
||||
id: TechDiskComputerCircuitboard
|
||||
name: technology disk terminal board
|
||||
name: tech disk terminal board
|
||||
description: A computer printed circuit board for a technology disk terminal.
|
||||
components:
|
||||
- type: Sprite
|
||||
|
||||
@@ -54,3 +54,5 @@
|
||||
- enum.DamageStateVisualLayers.Base:
|
||||
datadisk_base: Sixteen
|
||||
- type: TechnologyDisk
|
||||
- type: StaticPrice
|
||||
price: 50
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
- type: entity
|
||||
parent: BaseComputer
|
||||
id: ComputerTechnologyDiskTerminal
|
||||
name: technology disk terminal
|
||||
name: tech disk terminal
|
||||
description: A terminal used to print out technology disks.
|
||||
components:
|
||||
- type: Sprite
|
||||
@@ -31,3 +31,10 @@
|
||||
radius: 0.8
|
||||
energy: 0.5
|
||||
color: "#b53ca1"
|
||||
|
||||
- type: weightedRandom
|
||||
id: TechDiskTierWeights
|
||||
weights:
|
||||
1: 25
|
||||
2: 10
|
||||
3: 1
|
||||
|
||||
Reference in New Issue
Block a user