@@ -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]
|
[RegisterComponent]
|
||||||
public sealed class TechnologyDiskComponent : Component
|
public sealed class TechnologyDiskComponent : Component
|
||||||
@@ -8,4 +11,10 @@ public sealed class TechnologyDiskComponent : Component
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("recipes")]
|
[DataField("recipes")]
|
||||||
public List<string>? 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;
|
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);
|
var state = new DiskConsoleBoundUserInterfaceState(totalPoints, component.PricePerDisk, canPrint);
|
||||||
_ui.TrySetUiState(uid, DiskConsoleUiKey.Key, state);
|
_ui.TrySetUiState(uid, DiskConsoleUiKey.Key, state);
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ using Content.Server.Research.Systems;
|
|||||||
using Content.Server.Research.TechnologyDisk.Components;
|
using Content.Server.Research.TechnologyDisk.Components;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
|
using Content.Shared.Random;
|
||||||
|
using Content.Shared.Random.Helpers;
|
||||||
using Content.Shared.Research.Components;
|
using Content.Shared.Research.Components;
|
||||||
using Content.Shared.Research.Prototypes;
|
using Content.Shared.Research.Prototypes;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
@@ -66,46 +68,25 @@ public sealed class TechnologyDiskSystem : EntitySystem
|
|||||||
if (component.Recipes != null)
|
if (component.Recipes != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var lockoutTiers = new Dictionary<string, int>();
|
var weightedRandom = _prototype.Index<WeightedRandomPrototype>(component.TierWeightPrototype);
|
||||||
foreach (var discipline in _prototype.EnumeratePrototypes<TechDisciplinePrototype>())
|
var tier = int.Parse(weightedRandom.Pick(_random));
|
||||||
{
|
|
||||||
lockoutTiers.Add(discipline.ID, discipline.LockoutTier);
|
|
||||||
}
|
|
||||||
|
|
||||||
//get a list of every distinct recipe in all the technologies.
|
//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>())
|
foreach (var tech in _prototype.EnumeratePrototypes<TechnologyPrototype>())
|
||||||
{
|
{
|
||||||
if (tech.Tier >= lockoutTiers[tech.Discipline])
|
if (tech.Tier != tier)
|
||||||
continue;
|
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
|
if (!techs.Any())
|
||||||
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())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//pick one
|
//pick one
|
||||||
component.Recipes = new();
|
component.Recipes = new();
|
||||||
component.Recipes.Add(_random.Pick(validTechs));
|
component.Recipes.Add(_random.Pick(techs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,7 +169,7 @@
|
|||||||
- type: entity
|
- type: entity
|
||||||
parent: BaseComputerCircuitboard
|
parent: BaseComputerCircuitboard
|
||||||
id: TechDiskComputerCircuitboard
|
id: TechDiskComputerCircuitboard
|
||||||
name: technology disk terminal board
|
name: tech disk terminal board
|
||||||
description: A computer printed circuit board for a technology disk terminal.
|
description: A computer printed circuit board for a technology disk terminal.
|
||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
|
|||||||
@@ -54,3 +54,5 @@
|
|||||||
- enum.DamageStateVisualLayers.Base:
|
- enum.DamageStateVisualLayers.Base:
|
||||||
datadisk_base: Sixteen
|
datadisk_base: Sixteen
|
||||||
- type: TechnologyDisk
|
- type: TechnologyDisk
|
||||||
|
- type: StaticPrice
|
||||||
|
price: 50
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
- type: entity
|
- type: entity
|
||||||
parent: BaseComputer
|
parent: BaseComputer
|
||||||
id: ComputerTechnologyDiskTerminal
|
id: ComputerTechnologyDiskTerminal
|
||||||
name: technology disk terminal
|
name: tech disk terminal
|
||||||
description: A terminal used to print out technology disks.
|
description: A terminal used to print out technology disks.
|
||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
@@ -31,3 +31,10 @@
|
|||||||
radius: 0.8
|
radius: 0.8
|
||||||
energy: 0.5
|
energy: 0.5
|
||||||
color: "#b53ca1"
|
color: "#b53ca1"
|
||||||
|
|
||||||
|
- type: weightedRandom
|
||||||
|
id: TechDiskTierWeights
|
||||||
|
weights:
|
||||||
|
1: 25
|
||||||
|
2: 10
|
||||||
|
3: 1
|
||||||
|
|||||||
Reference in New Issue
Block a user