Technology Disks (#13077)
* clean up a bunch of R&D code * don't store components * brug * speedrun some sloth review * technology disks * expand functionality, begin work on printer * disk printer ui * file * fix the rebase * disk console is finito * Update DiskConsoleSystem.cs
This commit is contained in:
8
Content.Client/Research/ResearchSystem.cs
Normal file
8
Content.Client/Research/ResearchSystem.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using Content.Shared.Research.Systems;
|
||||||
|
|
||||||
|
namespace Content.Client.Research;
|
||||||
|
|
||||||
|
public sealed class ResearchSystem : SharedResearchSystem
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
using Content.Shared.Research.Components;
|
|
||||||
using Content.Shared.Research.Prototypes;
|
|
||||||
using Robust.Shared.Prototypes;
|
|
||||||
|
|
||||||
namespace Content.Client.Research
|
|
||||||
{
|
|
||||||
[RegisterComponent]
|
|
||||||
public sealed class TechnologyDatabaseComponent : SharedTechnologyDatabaseComponent
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Event called when the database is updated.
|
|
||||||
/// </summary>
|
|
||||||
public event Action? OnDatabaseUpdated;
|
|
||||||
|
|
||||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
|
||||||
{
|
|
||||||
base.HandleComponentState(curState, nextState);
|
|
||||||
|
|
||||||
if (curState is not TechnologyDatabaseState state) return;
|
|
||||||
|
|
||||||
TechnologyIds.Clear();
|
|
||||||
|
|
||||||
var protoManager = IoCManager.Resolve<IPrototypeManager>();
|
|
||||||
|
|
||||||
foreach (var techID in state.Technologies)
|
|
||||||
{
|
|
||||||
if (!protoManager.HasIndex<TechnologyPrototype>(techID)) continue;
|
|
||||||
TechnologyIds.Add(techID);
|
|
||||||
}
|
|
||||||
|
|
||||||
OnDatabaseUpdated?.Invoke();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
53
Content.Client/Research/UI/DiskConsoleBoundUserInterface.cs
Normal file
53
Content.Client/Research/UI/DiskConsoleBoundUserInterface.cs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
using Content.Shared.Lathe;
|
||||||
|
using Content.Shared.Research;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
|
|
||||||
|
namespace Content.Client.Research.UI
|
||||||
|
{
|
||||||
|
public sealed class DiskConsoleBoundUserInterface : BoundUserInterface
|
||||||
|
{
|
||||||
|
private DiskConsoleMenu? _menu;
|
||||||
|
|
||||||
|
public DiskConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Open()
|
||||||
|
{
|
||||||
|
base.Open();
|
||||||
|
|
||||||
|
_menu = new();
|
||||||
|
|
||||||
|
_menu.OnClose += Close;
|
||||||
|
_menu.OpenCentered();
|
||||||
|
|
||||||
|
_menu.OnServerButtonPressed += () =>
|
||||||
|
{
|
||||||
|
SendMessage(new LatheServerSelectionMessage());
|
||||||
|
};
|
||||||
|
_menu.OnPrintButtonPressed += () =>
|
||||||
|
{
|
||||||
|
SendMessage(new DiskConsolePrintDiskMessage());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
base.Dispose(disposing);
|
||||||
|
if (!disposing)
|
||||||
|
return;
|
||||||
|
_menu?.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void UpdateState(BoundUserInterfaceState state)
|
||||||
|
{
|
||||||
|
base.UpdateState(state);
|
||||||
|
|
||||||
|
if (state is not DiskConsoleBoundUserInterfaceState msg)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_menu?.Update(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Content.Client/Research/UI/DiskConsoleMenu.xaml
Normal file
36
Content.Client/Research/UI/DiskConsoleMenu.xaml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<controls:FancyWindow xmlns="https://spacestation14.io"
|
||||||
|
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
||||||
|
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||||
|
Title="{Loc 'tech-disk-ui-name'}"
|
||||||
|
MinSize="400 260"
|
||||||
|
SetSize="400 260">
|
||||||
|
<BoxContainer Orientation="Vertical"
|
||||||
|
HorizontalExpand="True"
|
||||||
|
VerticalExpand="True"
|
||||||
|
Margin="10 10 10 10">
|
||||||
|
<Button Name="ServerButton"
|
||||||
|
Text="{Loc 'lathe-menu-server-list'}"
|
||||||
|
HorizontalAlignment="Left"></Button>
|
||||||
|
<PanelContainer Margin="0 10 0 0" VerticalExpand="True">
|
||||||
|
<PanelContainer.PanelOverride>
|
||||||
|
<graphics:StyleBoxFlat BackgroundColor="#000000FF"/>
|
||||||
|
</PanelContainer.PanelOverride>
|
||||||
|
<BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True" VerticalAlignment="Center">
|
||||||
|
<Label Name="TotalLabel"
|
||||||
|
HorizontalAlignment="Center">
|
||||||
|
</Label>
|
||||||
|
<Label Name="CostLabel"
|
||||||
|
HorizontalAlignment="Center">
|
||||||
|
</Label>
|
||||||
|
<BoxContainer MinHeight="20"></BoxContainer>
|
||||||
|
<Button
|
||||||
|
Name="PrintButton"
|
||||||
|
Text="{Loc 'tech-disk-ui-print-button'}"
|
||||||
|
MaxWidth="120"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalExpand="False">
|
||||||
|
</Button>
|
||||||
|
</BoxContainer>
|
||||||
|
</PanelContainer>
|
||||||
|
</BoxContainer>
|
||||||
|
</controls:FancyWindow>
|
||||||
29
Content.Client/Research/UI/DiskConsoleMenu.xaml.cs
Normal file
29
Content.Client/Research/UI/DiskConsoleMenu.xaml.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using Content.Client.UserInterface.Controls;
|
||||||
|
using Content.Shared.Research;
|
||||||
|
using Robust.Client.AutoGenerated;
|
||||||
|
using Robust.Client.UserInterface.XAML;
|
||||||
|
|
||||||
|
namespace Content.Client.Research.UI;
|
||||||
|
|
||||||
|
[GenerateTypedNameReferences]
|
||||||
|
public sealed partial class DiskConsoleMenu : FancyWindow
|
||||||
|
{
|
||||||
|
public event Action? OnServerButtonPressed;
|
||||||
|
public event Action? OnPrintButtonPressed;
|
||||||
|
|
||||||
|
public DiskConsoleMenu()
|
||||||
|
{
|
||||||
|
RobustXamlLoader.Load(this);
|
||||||
|
|
||||||
|
ServerButton.OnPressed += _ => OnServerButtonPressed?.Invoke();
|
||||||
|
PrintButton.OnPressed += _ => OnPrintButtonPressed?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(DiskConsoleBoundUserInterfaceState state)
|
||||||
|
{
|
||||||
|
PrintButton.Disabled = !state.CanPrint;
|
||||||
|
TotalLabel.Text = Loc.GetString("tech-disk-ui-total-label", ("amount", state.ServerPoints));
|
||||||
|
CostLabel.Text = Loc.GetString("tech-disk-ui-cost-label", ("amount", state.PointCost));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using Content.Shared.Research.Components;
|
using Content.Shared.Research.Components;
|
||||||
using Content.Shared.Research.Prototypes;
|
using Content.Shared.Research.Prototypes;
|
||||||
|
using Content.Shared.Research.Systems;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
|
|
||||||
@@ -12,17 +13,22 @@ namespace Content.Client.Research.UI
|
|||||||
public int PointsPerSecond { get; private set; }
|
public int PointsPerSecond { get; private set; }
|
||||||
private ResearchConsoleMenu? _consoleMenu;
|
private ResearchConsoleMenu? _consoleMenu;
|
||||||
private TechnologyDatabaseComponent? _technologyDatabase;
|
private TechnologyDatabaseComponent? _technologyDatabase;
|
||||||
|
private readonly IEntityManager _entityManager;
|
||||||
|
private readonly SharedResearchSystem _research;
|
||||||
|
|
||||||
public ResearchConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
|
public ResearchConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
|
||||||
{
|
{
|
||||||
SendMessage(new ConsoleServerSyncMessage());
|
SendMessage(new ConsoleServerSyncMessage());
|
||||||
|
_entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
|
_research = _entityManager.System<SharedResearchSystem>();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Open()
|
protected override void Open()
|
||||||
{
|
{
|
||||||
base.Open();
|
base.Open();
|
||||||
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner, out _technologyDatabase)) return;
|
if (!_entityManager.TryGetComponent(Owner.Owner, out _technologyDatabase))
|
||||||
|
return;
|
||||||
|
|
||||||
_consoleMenu = new ResearchConsoleMenu(this);
|
_consoleMenu = new ResearchConsoleMenu(this);
|
||||||
|
|
||||||
@@ -47,18 +53,22 @@ namespace Content.Client.Research.UI
|
|||||||
};
|
};
|
||||||
|
|
||||||
_consoleMenu.OpenCentered();
|
_consoleMenu.OpenCentered();
|
||||||
|
|
||||||
_technologyDatabase.OnDatabaseUpdated += _consoleMenu.Populate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsTechnologyUnlocked(TechnologyPrototype technology)
|
public bool IsTechnologyUnlocked(TechnologyPrototype technology)
|
||||||
{
|
{
|
||||||
return _technologyDatabase?.IsTechnologyUnlocked(technology.ID) ?? false;
|
if (_technologyDatabase == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return _research.IsTechnologyUnlocked(_technologyDatabase.Owner, technology, _technologyDatabase);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanUnlockTechnology(TechnologyPrototype technology)
|
public bool CanUnlockTechnology(TechnologyPrototype technology)
|
||||||
{
|
{
|
||||||
return _technologyDatabase?.CanUnlockTechnology(technology) ?? false;
|
if (_technologyDatabase == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return _research.CanUnlockTechnology(_technologyDatabase.Owner, technology, _technologyDatabase);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateState(BoundUserInterfaceState state)
|
protected override void UpdateState(BoundUserInterfaceState state)
|
||||||
@@ -70,12 +80,14 @@ namespace Content.Client.Research.UI
|
|||||||
PointsPerSecond = castState.PointsPerSecond;
|
PointsPerSecond = castState.PointsPerSecond;
|
||||||
// We update the user interface here.
|
// We update the user interface here.
|
||||||
_consoleMenu?.PopulatePoints();
|
_consoleMenu?.PopulatePoints();
|
||||||
|
_consoleMenu?.Populate();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
if (!disposing) return;
|
if (!disposing)
|
||||||
|
return;
|
||||||
_consoleMenu?.Dispose();
|
_consoleMenu?.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,12 +43,12 @@ namespace Content.Server.Lathe
|
|||||||
|
|
||||||
SubscribeLocalEvent<LatheComponent, LatheQueueRecipeMessage>(OnLatheQueueRecipeMessage);
|
SubscribeLocalEvent<LatheComponent, LatheQueueRecipeMessage>(OnLatheQueueRecipeMessage);
|
||||||
SubscribeLocalEvent<LatheComponent, LatheSyncRequestMessage>(OnLatheSyncRequestMessage);
|
SubscribeLocalEvent<LatheComponent, LatheSyncRequestMessage>(OnLatheSyncRequestMessage);
|
||||||
SubscribeLocalEvent<LatheComponent, LatheServerSelectionMessage>(OnLatheServerSelectionMessage);
|
|
||||||
|
|
||||||
SubscribeLocalEvent<LatheComponent, BeforeActivatableUIOpenEvent>((u,c,_) => UpdateUserInterfaceState(u,c));
|
SubscribeLocalEvent<LatheComponent, BeforeActivatableUIOpenEvent>((u,c,_) => UpdateUserInterfaceState(u,c));
|
||||||
SubscribeLocalEvent<LatheComponent, MaterialAmountChangedEvent>((u,c,_) => UpdateUserInterfaceState(u,c));
|
SubscribeLocalEvent<LatheComponent, MaterialAmountChangedEvent>((u,c,_) => UpdateUserInterfaceState(u,c));
|
||||||
|
|
||||||
SubscribeLocalEvent<TechnologyDatabaseComponent, LatheGetRecipesEvent>(OnGetRecipes);
|
SubscribeLocalEvent<TechnologyDatabaseComponent, LatheGetRecipesEvent>(OnGetRecipes);
|
||||||
|
SubscribeLocalEvent<ResearchClientComponent, LatheServerSelectionMessage>(OnLatheServerSelectionMessage);
|
||||||
SubscribeLocalEvent<TechnologyDatabaseComponent, LatheServerSyncMessage>(OnLatheServerSyncMessage);
|
SubscribeLocalEvent<TechnologyDatabaseComponent, LatheServerSyncMessage>(OnLatheServerSyncMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,14 +202,7 @@ namespace Content.Server.Lathe
|
|||||||
if (uid != args.Lathe || !TryComp<LatheComponent>(uid, out var latheComponent) || latheComponent.DynamicRecipes == null)
|
if (uid != args.Lathe || !TryComp<LatheComponent>(uid, out var latheComponent) || latheComponent.DynamicRecipes == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//gets all of the techs that are unlocked and also in the DynamicRecipes list
|
args.Recipes = args.Recipes.Union(component.RecipeIds.Where(r => latheComponent.DynamicRecipes.Contains(r))).ToList();
|
||||||
var allTechs = (from technology in from tech in component.TechnologyIds
|
|
||||||
select _proto.Index<TechnologyPrototype>(tech)
|
|
||||||
from recipe in technology.UnlockedRecipes
|
|
||||||
where latheComponent.DynamicRecipes.Contains(recipe)
|
|
||||||
select recipe).ToList();
|
|
||||||
|
|
||||||
args.Recipes = args.Recipes.Union(allTechs).ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -308,16 +301,13 @@ namespace Content.Server.Lathe
|
|||||||
UpdateUserInterfaceState(uid, component);
|
UpdateUserInterfaceState(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLatheServerSelectionMessage(EntityUid uid, LatheComponent component, LatheServerSelectionMessage args)
|
private void OnLatheServerSelectionMessage(EntityUid uid, ResearchClientComponent component, LatheServerSelectionMessage args)
|
||||||
{
|
{
|
||||||
// TODO: one day, when you can open BUIs clientside, do that. Until then, picture Electro seething.
|
_uiSys.TryOpen(uid, ResearchClientUiKey.Key, (IPlayerSession) args.Session);
|
||||||
if (component.DynamicRecipes != null)
|
|
||||||
_uiSys.TryOpen(uid, ResearchClientUiKey.Key, (IPlayerSession) args.Session);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLatheServerSyncMessage(EntityUid uid, TechnologyDatabaseComponent component, LatheServerSyncMessage args)
|
private void OnLatheServerSyncMessage(EntityUid uid, TechnologyDatabaseComponent component, LatheServerSyncMessage args)
|
||||||
{
|
{
|
||||||
Logger.Debug("OnLatheServerSyncMessage");
|
|
||||||
_researchSys.SyncWithServer(component);
|
_researchSys.SyncWithServer(component);
|
||||||
UpdateUserInterfaceState(uid);
|
UpdateUserInterfaceState(uid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
using Content.Shared.Research.Components;
|
|
||||||
|
|
||||||
namespace Content.Server.Research.Components
|
|
||||||
{
|
|
||||||
[RegisterComponent]
|
|
||||||
public sealed class TechnologyDatabaseComponent : SharedTechnologyDatabaseComponent {}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using Content.Server.Power.EntitySystems;
|
using Content.Server.Power.EntitySystems;
|
||||||
using Content.Server.Research.Components;
|
using Content.Server.Research.Components;
|
||||||
|
using Content.Shared.Research.Components;
|
||||||
using Content.Shared.Research.Prototypes;
|
using Content.Shared.Research.Prototypes;
|
||||||
|
|
||||||
namespace Content.Server.Research.Systems;
|
namespace Content.Server.Research.Systems;
|
||||||
@@ -44,7 +45,7 @@ public sealed partial class ResearchSystem
|
|||||||
{
|
{
|
||||||
if (!Resolve(component.Owner, ref databaseComponent, false))
|
if (!Resolve(component.Owner, ref databaseComponent, false))
|
||||||
return false;
|
return false;
|
||||||
return databaseComponent.IsTechnologyUnlocked(prototype.ID);
|
return IsTechnologyUnlocked(databaseComponent.Owner, prototype.ID, databaseComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanUnlockTechnology(ResearchServerComponent component, TechnologyPrototype technology, TechnologyDatabaseComponent? databaseComponent = null)
|
public bool CanUnlockTechnology(ResearchServerComponent component, TechnologyPrototype technology, TechnologyDatabaseComponent? databaseComponent = null)
|
||||||
@@ -52,7 +53,7 @@ public sealed partial class ResearchSystem
|
|||||||
if (!Resolve(component.Owner, ref databaseComponent, false))
|
if (!Resolve(component.Owner, ref databaseComponent, false))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!databaseComponent.CanUnlockTechnology(technology) ||
|
if (!CanUnlockTechnology(databaseComponent.Owner, technology, databaseComponent) ||
|
||||||
component.Points < technology.RequiredPoints ||
|
component.Points < technology.RequiredPoints ||
|
||||||
IsTechnologyUnlocked(component, technology, databaseComponent))
|
IsTechnologyUnlocked(component, technology, databaseComponent))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Linq;
|
||||||
using Content.Server.Research.Components;
|
using Content.Server.Research.Components;
|
||||||
using Content.Shared.Research.Components;
|
using Content.Shared.Research.Components;
|
||||||
using Content.Shared.Research.Prototypes;
|
using Content.Shared.Research.Prototypes;
|
||||||
@@ -7,16 +8,6 @@ namespace Content.Server.Research.Systems;
|
|||||||
|
|
||||||
public sealed partial class ResearchSystem
|
public sealed partial class ResearchSystem
|
||||||
{
|
{
|
||||||
private void InitializeTechnology()
|
|
||||||
{
|
|
||||||
SubscribeLocalEvent<TechnologyDatabaseComponent, ComponentGetState>(OnTechnologyGetState);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnTechnologyGetState(EntityUid uid, TechnologyDatabaseComponent component, ref ComponentGetState args)
|
|
||||||
{
|
|
||||||
args.State = new TechnologyDatabaseState(component.TechnologyIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Synchronizes this database against other,
|
/// Synchronizes this database against other,
|
||||||
/// adding all technologies from the other that
|
/// adding all technologies from the other that
|
||||||
@@ -27,11 +18,8 @@ public sealed partial class ResearchSystem
|
|||||||
/// <param name="twoway">Whether the other database should be synced against this one too or not.</param>
|
/// <param name="twoway">Whether the other database should be synced against this one too or not.</param>
|
||||||
public void Sync(TechnologyDatabaseComponent component, TechnologyDatabaseComponent otherDatabase, bool twoway = true)
|
public void Sync(TechnologyDatabaseComponent component, TechnologyDatabaseComponent otherDatabase, bool twoway = true)
|
||||||
{
|
{
|
||||||
foreach (var tech in otherDatabase.TechnologyIds)
|
otherDatabase.TechnologyIds = otherDatabase.TechnologyIds.Union(component.TechnologyIds).ToList();
|
||||||
{
|
otherDatabase.RecipeIds = otherDatabase.RecipeIds.Union(component.RecipeIds).ToList();
|
||||||
if (!component.IsTechnologyUnlocked(tech))
|
|
||||||
AddTechnology(component, tech);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (twoway)
|
if (twoway)
|
||||||
Sync(otherDatabase, component, false);
|
Sync(otherDatabase, component, false);
|
||||||
@@ -65,11 +53,9 @@ public sealed partial class ResearchSystem
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool UnlockTechnology(TechnologyDatabaseComponent component, TechnologyPrototype technology)
|
public bool UnlockTechnology(TechnologyDatabaseComponent component, TechnologyPrototype technology)
|
||||||
{
|
{
|
||||||
if (!component.CanUnlockTechnology(technology))
|
if (!CanUnlockTechnology(component.Owner, technology, component)) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
AddTechnology(component, technology.ID);
|
AddTechnology(component, technology.ID);
|
||||||
Dirty(component);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +66,39 @@ public sealed partial class ResearchSystem
|
|||||||
/// <param name="technology"></param>
|
/// <param name="technology"></param>
|
||||||
public void AddTechnology(TechnologyDatabaseComponent component, string technology)
|
public void AddTechnology(TechnologyDatabaseComponent component, string technology)
|
||||||
{
|
{
|
||||||
component.TechnologyIds.Add(technology);
|
if (!_prototypeManager.TryIndex<TechnologyPrototype>(technology, out var prototype))
|
||||||
|
return;
|
||||||
|
AddTechnology(component, prototype);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddTechnology(TechnologyDatabaseComponent component, TechnologyPrototype technology)
|
||||||
|
{
|
||||||
|
component.TechnologyIds.Add(technology.ID);
|
||||||
|
foreach (var unlock in technology.UnlockedRecipes)
|
||||||
|
{
|
||||||
|
if (component.RecipeIds.Contains(unlock))
|
||||||
|
continue;
|
||||||
|
component.RecipeIds.Add(unlock);
|
||||||
|
}
|
||||||
|
Dirty(component);
|
||||||
|
|
||||||
|
if (!TryComp<ResearchServerComponent>(component.Owner, out var server))
|
||||||
|
return;
|
||||||
|
foreach (var client in server.Clients)
|
||||||
|
{
|
||||||
|
if (!TryComp<ResearchConsoleComponent>(client, out var console))
|
||||||
|
continue;
|
||||||
|
UpdateConsoleInterface(console);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddLatheRecipe(TechnologyDatabaseComponent component, string recipe, bool dirty = true)
|
||||||
|
{
|
||||||
|
if (component.RecipeIds.Contains(recipe))
|
||||||
|
return;
|
||||||
|
|
||||||
|
component.RecipeIds.Add(recipe);
|
||||||
|
if (dirty)
|
||||||
|
Dirty(component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.Research.Components;
|
using Content.Server.Research.Components;
|
||||||
|
using Content.Shared.Research.Systems;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
@@ -8,7 +9,7 @@ using Robust.Shared.Timing;
|
|||||||
namespace Content.Server.Research.Systems
|
namespace Content.Server.Research.Systems
|
||||||
{
|
{
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed partial class ResearchSystem : EntitySystem
|
public sealed partial class ResearchSystem : SharedResearchSystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IGameTiming _timing = default!;
|
[Dependency] private readonly IGameTiming _timing = default!;
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
@@ -22,7 +23,6 @@ namespace Content.Server.Research.Systems
|
|||||||
InitializeClient();
|
InitializeClient();
|
||||||
InitializeConsole();
|
InitializeConsole();
|
||||||
InitializeSource();
|
InitializeSource();
|
||||||
InitializeTechnology();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnStartup(EntityUid uid, ResearchServerComponent component, ComponentStartup args)
|
private void OnStartup(EntityUid uid, ResearchServerComponent component, ComponentStartup args)
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using Robust.Shared.Audio;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||||
|
|
||||||
|
namespace Content.Server.Research.TechnologyDisk.Components;
|
||||||
|
|
||||||
|
[RegisterComponent]
|
||||||
|
public sealed class DiskConsoleComponent : Component
|
||||||
|
{
|
||||||
|
[DataField("pricePerDisk"), ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public int PricePerDisk = 2500;
|
||||||
|
|
||||||
|
[DataField("diskPrototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||||
|
public string DiskPrototype = "TechnologyDisk";
|
||||||
|
|
||||||
|
[DataField("printDuration")]
|
||||||
|
public TimeSpan PrintDuration = TimeSpan.FromSeconds(1);
|
||||||
|
|
||||||
|
[DataField("printSound")]
|
||||||
|
public SoundSpecifier PrintSound = new SoundPathSpecifier("/Audio/Machines/printer.ogg");
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Content.Server.Research.TechnologyDisk.Components;
|
||||||
|
|
||||||
|
[RegisterComponent]
|
||||||
|
public sealed class DiskConsolePrintingComponent : Component
|
||||||
|
{
|
||||||
|
public TimeSpan FinishTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace Content.Server.Research.TechnologyDisk.Components;
|
||||||
|
|
||||||
|
[RegisterComponent]
|
||||||
|
public sealed class TechnologyDiskComponent : Component
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The recipe that will be added. If null, one will be randomly generated
|
||||||
|
/// </summary>
|
||||||
|
[DataField("recipes")]
|
||||||
|
public List<string>? Recipes;
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
using Content.Server.Research.Components;
|
||||||
|
using Content.Server.Research.Systems;
|
||||||
|
using Content.Server.Research.TechnologyDisk.Components;
|
||||||
|
using Content.Server.UserInterface;
|
||||||
|
using Content.Shared.Research;
|
||||||
|
using Robust.Server.GameObjects;
|
||||||
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
|
namespace Content.Server.Research.TechnologyDisk.Systems;
|
||||||
|
|
||||||
|
public sealed class DiskConsoleSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly IGameTiming _timing = default!;
|
||||||
|
[Dependency] private readonly AudioSystem _audio = default!;
|
||||||
|
[Dependency] private readonly ResearchSystem _research = default!;
|
||||||
|
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
SubscribeLocalEvent<DiskConsoleComponent, DiskConsolePrintDiskMessage>(OnPrintDisk);
|
||||||
|
SubscribeLocalEvent<DiskConsoleComponent, ResearchServerPointsChangedEvent>(OnPointsChanged);
|
||||||
|
SubscribeLocalEvent<DiskConsoleComponent, BeforeActivatableUIOpenEvent>(OnBeforeUiOpen);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<DiskConsolePrintingComponent, ComponentShutdown>(OnShutdown);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update(float frameTime)
|
||||||
|
{
|
||||||
|
base.Update(frameTime);
|
||||||
|
|
||||||
|
foreach (var (printing, console, xform) in EntityQuery<DiskConsolePrintingComponent, DiskConsoleComponent, TransformComponent>())
|
||||||
|
{
|
||||||
|
if (printing.FinishTime > _timing.CurTime)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
RemComp(printing.Owner, printing);
|
||||||
|
EntityManager.SpawnEntity(console.DiskPrototype, xform.Coordinates);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPrintDisk(EntityUid uid, DiskConsoleComponent component, DiskConsolePrintDiskMessage args)
|
||||||
|
{
|
||||||
|
if (!TryComp<ResearchClientComponent>(uid, out var client) || client.Server == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (client.Server.Points < component.PricePerDisk)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_research.ChangePointsOnServer(client.Server.Owner, -component.PricePerDisk, client.Server);
|
||||||
|
_audio.PlayPvs(component.PrintSound, uid);
|
||||||
|
|
||||||
|
var printing = EnsureComp<DiskConsolePrintingComponent>(uid);
|
||||||
|
printing.FinishTime = _timing.CurTime + component.PrintDuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPointsChanged(EntityUid uid, DiskConsoleComponent component, ref ResearchServerPointsChangedEvent args)
|
||||||
|
{
|
||||||
|
UpdateUserInterface(uid, component);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnBeforeUiOpen(EntityUid uid, DiskConsoleComponent component, BeforeActivatableUIOpenEvent args)
|
||||||
|
{
|
||||||
|
UpdateUserInterface(uid, component);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateUserInterface(EntityUid uid, DiskConsoleComponent? component = null)
|
||||||
|
{
|
||||||
|
if (!Resolve(uid, ref component, false))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var totalPoints = 0;
|
||||||
|
if (TryComp<ResearchClientComponent>(uid, out var client) && client.Server != null)
|
||||||
|
{
|
||||||
|
totalPoints = client.Server.Points;
|
||||||
|
}
|
||||||
|
var canPrint = !HasComp<DiskConsolePrintingComponent>(uid) && totalPoints >= component.PricePerDisk;
|
||||||
|
|
||||||
|
var state = new DiskConsoleBoundUserInterfaceState(totalPoints, component.PricePerDisk, canPrint);
|
||||||
|
_ui.TrySetUiState(uid, DiskConsoleUiKey.Key, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnShutdown(EntityUid uid, DiskConsolePrintingComponent component, ComponentShutdown args)
|
||||||
|
{
|
||||||
|
UpdateUserInterface(uid);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using Content.Server.Popups;
|
||||||
|
using Content.Server.Research.Components;
|
||||||
|
using Content.Server.Research.Systems;
|
||||||
|
using Content.Server.Research.TechnologyDisk.Components;
|
||||||
|
using Content.Shared.Examine;
|
||||||
|
using Content.Shared.Interaction;
|
||||||
|
using Content.Shared.Research.Components;
|
||||||
|
using Content.Shared.Research.Prototypes;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
|
namespace Content.Server.Research.TechnologyDisk.Systems;
|
||||||
|
|
||||||
|
public sealed class TechnologyDiskSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly PopupSystem _popup = default!;
|
||||||
|
[Dependency] private readonly ResearchSystem _research = default!;
|
||||||
|
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
||||||
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
SubscribeLocalEvent<TechnologyDiskComponent, AfterInteractEvent>(OnAfterInteract);
|
||||||
|
SubscribeLocalEvent<TechnologyDiskComponent, ExaminedEvent>(OnExamine);
|
||||||
|
SubscribeLocalEvent<TechnologyDiskComponent, MapInitEvent>(OnMapInit);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnAfterInteract(EntityUid uid, TechnologyDiskComponent component, AfterInteractEvent args)
|
||||||
|
{
|
||||||
|
if (args.Handled || !args.CanReach || args.Target is not { } target)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!HasComp<ResearchServerComponent>(target) || !TryComp<TechnologyDatabaseComponent>(target, out var database))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (component.Recipes != null)
|
||||||
|
{
|
||||||
|
foreach (var recipe in component.Recipes)
|
||||||
|
{
|
||||||
|
_research.AddLatheRecipe(database, recipe, false);
|
||||||
|
}
|
||||||
|
Dirty(database);
|
||||||
|
}
|
||||||
|
_popup.PopupEntity(Loc.GetString("tech-disk-inserted"), target, args.User);
|
||||||
|
EntityManager.DeleteEntity(uid);
|
||||||
|
args.Handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnExamine(EntityUid uid, TechnologyDiskComponent component, ExaminedEvent args)
|
||||||
|
{
|
||||||
|
var message = Loc.GetString("tech-disk-examine-none");
|
||||||
|
if (component.Recipes != null && component.Recipes.Any())
|
||||||
|
{
|
||||||
|
var prototype = _prototype.Index<LatheRecipePrototype>(component.Recipes[0]);
|
||||||
|
var resultPrototype = _prototype.Index<EntityPrototype>(prototype.Result);
|
||||||
|
message = Loc.GetString("tech-disk-examine", ("result", resultPrototype.Name));
|
||||||
|
|
||||||
|
if (component.Recipes.Count > 1) //idk how to do this well. sue me.
|
||||||
|
message += " " + Loc.GetString("tech-disk-examine-more");
|
||||||
|
}
|
||||||
|
args.PushMarkup(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMapInit(EntityUid uid, TechnologyDiskComponent component, MapInitEvent args)
|
||||||
|
{
|
||||||
|
if (component.Recipes != null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//get a list of every distinct recipe in all the technologies.
|
||||||
|
var allTechs = new List<string>();
|
||||||
|
foreach (var tech in _prototype.EnumeratePrototypes<TechnologyPrototype>())
|
||||||
|
{
|
||||||
|
allTechs.AddRange(tech.UnlockedRecipes);
|
||||||
|
}
|
||||||
|
allTechs = allTechs.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.RecipeIds);
|
||||||
|
}
|
||||||
|
allUnlocked = allUnlocked.Distinct().ToList();
|
||||||
|
|
||||||
|
//make a list of every single non-unlocked tech
|
||||||
|
var validTechs = allTechs.Where(tech => !allUnlocked.Contains(tech)).ToList();
|
||||||
|
|
||||||
|
//pick one
|
||||||
|
component.Recipes = new();
|
||||||
|
component.Recipes.Add(_random.Pick(validTechs));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
using Content.Shared.Research.Prototypes;
|
|
||||||
using Robust.Shared.GameStates;
|
|
||||||
using Robust.Shared.Prototypes;
|
|
||||||
using Robust.Shared.Serialization;
|
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
|
||||||
|
|
||||||
namespace Content.Shared.Research.Components
|
|
||||||
{
|
|
||||||
[NetworkedComponent()]
|
|
||||||
public abstract class SharedTechnologyDatabaseComponent : Component
|
|
||||||
{
|
|
||||||
[DataField("technologies", customTypeSerializer: typeof(PrototypeIdListSerializer<TechnologyPrototype>))]
|
|
||||||
public readonly List<string> TechnologyIds = new();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns whether a technology is unlocked on this database or not.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="technology">The technology to be checked</param>
|
|
||||||
/// <returns>Whether it is unlocked or not</returns>
|
|
||||||
public bool IsTechnologyUnlocked(string technologyId)
|
|
||||||
{
|
|
||||||
return TechnologyIds.Contains(technologyId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns whether a technology can be unlocked on this database,
|
|
||||||
/// taking parent technologies into account.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="technology">The technology to be checked</param>
|
|
||||||
/// <returns>Whether it could be unlocked or not</returns>
|
|
||||||
public bool CanUnlockTechnology(TechnologyPrototype technology)
|
|
||||||
{
|
|
||||||
if (IsTechnologyUnlocked(technology.ID)) return false;
|
|
||||||
var protoMan = IoCManager.Resolve<IPrototypeManager>();
|
|
||||||
foreach (var technologyId in technology.RequiredTechnologies)
|
|
||||||
{
|
|
||||||
protoMan.TryIndex(technologyId, out TechnologyPrototype? requiredTechnology);
|
|
||||||
if (requiredTechnology == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!IsTechnologyUnlocked(requiredTechnology.ID))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
|
||||||
public sealed class TechnologyDatabaseState : ComponentState
|
|
||||||
{
|
|
||||||
public List<string> Technologies;
|
|
||||||
public TechnologyDatabaseState(List<string> technologies)
|
|
||||||
{
|
|
||||||
Technologies = technologies;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TechnologyDatabaseState(List<TechnologyPrototype> technologies)
|
|
||||||
{
|
|
||||||
Technologies = new List<string>();
|
|
||||||
foreach (var technology in technologies)
|
|
||||||
{
|
|
||||||
Technologies.Add(technology.ID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using Content.Shared.Research.Prototypes;
|
||||||
|
using Robust.Shared.GameStates;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||||
|
|
||||||
|
namespace Content.Shared.Research.Components
|
||||||
|
{
|
||||||
|
[RegisterComponent, NetworkedComponent]
|
||||||
|
public sealed class TechnologyDatabaseComponent : Component
|
||||||
|
{
|
||||||
|
[DataField("technologyIds", customTypeSerializer: typeof(PrototypeIdListSerializer<TechnologyPrototype>))]
|
||||||
|
public List<string> TechnologyIds = new();
|
||||||
|
|
||||||
|
[DataField("recipeIds", customTypeSerializer: typeof(PrototypeIdListSerializer<LatheRecipePrototype>))]
|
||||||
|
public List<string> RecipeIds = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public sealed class TechnologyDatabaseState : ComponentState
|
||||||
|
{
|
||||||
|
public List<string> Technologies;
|
||||||
|
public List<string> Recipes;
|
||||||
|
|
||||||
|
public TechnologyDatabaseState(List<string> technologies, List<string> recipes)
|
||||||
|
{
|
||||||
|
Technologies = technologies;
|
||||||
|
Recipes = recipes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
30
Content.Shared/Research/SharedDiskConsole.cs
Normal file
30
Content.Shared/Research/SharedDiskConsole.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
|
namespace Content.Shared.Research;
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public enum DiskConsoleUiKey : byte
|
||||||
|
{
|
||||||
|
Key
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public sealed class DiskConsoleBoundUserInterfaceState : BoundUserInterfaceState
|
||||||
|
{
|
||||||
|
public bool CanPrint;
|
||||||
|
public int PointCost;
|
||||||
|
public int ServerPoints;
|
||||||
|
|
||||||
|
public DiskConsoleBoundUserInterfaceState(int serverPoints, int pointCost, bool canPrint)
|
||||||
|
{
|
||||||
|
CanPrint = canPrint;
|
||||||
|
PointCost = pointCost;
|
||||||
|
ServerPoints = serverPoints;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public sealed class DiskConsolePrintDiskMessage : BoundUserInterfaceMessage
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
75
Content.Shared/Research/Systems/SharedResearchSystem.cs
Normal file
75
Content.Shared/Research/Systems/SharedResearchSystem.cs
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
using Content.Shared.Research.Components;
|
||||||
|
using Content.Shared.Research.Prototypes;
|
||||||
|
using Robust.Shared.GameStates;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
|
namespace Content.Shared.Research.Systems;
|
||||||
|
|
||||||
|
public abstract class SharedResearchSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
SubscribeLocalEvent<TechnologyDatabaseComponent, ComponentGetState>(OnTechnologyGetState);
|
||||||
|
SubscribeLocalEvent<TechnologyDatabaseComponent, ComponentHandleState>(OnTechnologyHandleState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTechnologyHandleState(EntityUid uid, TechnologyDatabaseComponent component, ref ComponentHandleState args)
|
||||||
|
{
|
||||||
|
if (args.Current is not TechnologyDatabaseState state)
|
||||||
|
return;
|
||||||
|
component.TechnologyIds = new (state.Technologies);
|
||||||
|
component.RecipeIds = new(state.Recipes);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTechnologyGetState(EntityUid uid, TechnologyDatabaseComponent component, ref ComponentGetState args)
|
||||||
|
{
|
||||||
|
args.State = new TechnologyDatabaseState(component.TechnologyIds, component.RecipeIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns whether a technology is unlocked on this database or not.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Whether it is unlocked or not</returns>
|
||||||
|
public bool IsTechnologyUnlocked(EntityUid uid, string technologyId, TechnologyDatabaseComponent? component = null)
|
||||||
|
{
|
||||||
|
return Resolve(uid, ref component) && component.TechnologyIds.Contains(technologyId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns whether a technology is unlocked on this database or not.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Whether it is unlocked or not</returns>
|
||||||
|
public bool IsTechnologyUnlocked(EntityUid uid, TechnologyPrototype technologyId, TechnologyDatabaseComponent? component = null)
|
||||||
|
{
|
||||||
|
return Resolve(uid, ref component) && IsTechnologyUnlocked(uid, technologyId.ID, component);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns whether a technology can be unlocked on this database,
|
||||||
|
/// taking parent technologies into account.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Whether it could be unlocked or not</returns>
|
||||||
|
public bool CanUnlockTechnology(EntityUid uid, TechnologyPrototype technology, TechnologyDatabaseComponent? component = null)
|
||||||
|
{
|
||||||
|
if (!Resolve(uid, ref component))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (IsTechnologyUnlocked(uid, technology.ID, component))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
foreach (var technologyId in technology.RequiredTechnologies)
|
||||||
|
{
|
||||||
|
_prototypeManager.TryIndex(technologyId, out TechnologyPrototype? requiredTechnology);
|
||||||
|
if (requiredTechnology == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!IsTechnologyUnlocked(uid, requiredTechnology.ID, component))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
tech-disk-inserted = You insert the disk, adding a new recipe to the server.
|
||||||
|
tech-disk-examine-none = The label is blank.
|
||||||
|
tech-disk-examine = The label has a small dot matrix printed image depicting a {$result}.
|
||||||
|
tech-disk-examine-more = There are more images printed, but they're too small to discern.
|
||||||
|
|
||||||
|
tech-disk-ui-name = technology disk terminal
|
||||||
|
tech-disk-ui-total-label = There are {$amount} points on the selected server
|
||||||
|
tech-disk-ui-cost-label = Each disk costs {$amount} points to print
|
||||||
|
tech-disk-ui-print-button = Print Disk
|
||||||
@@ -479,6 +479,7 @@
|
|||||||
requiredTechnologies:
|
requiredTechnologies:
|
||||||
- BasicResearch
|
- BasicResearch
|
||||||
unlockedRecipes:
|
unlockedRecipes:
|
||||||
|
- TechDiskComputerCircuitboard
|
||||||
- CapacitorStockPart
|
- CapacitorStockPart
|
||||||
- MatterBinStockPart
|
- MatterBinStockPart
|
||||||
- MicroLaserStockPart
|
- MicroLaserStockPart
|
||||||
|
|||||||
@@ -146,6 +146,17 @@
|
|||||||
- type: ComputerBoard
|
- type: ComputerBoard
|
||||||
prototype: ComputerAnalysisConsole
|
prototype: ComputerAnalysisConsole
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
parent: BaseComputerCircuitboard
|
||||||
|
id: TechDiskComputerCircuitboard
|
||||||
|
name: technology disk terminal board
|
||||||
|
description: A computer printed circuit board for a technology disk terminal.
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
state: cpu_science
|
||||||
|
- type: ComputerBoard
|
||||||
|
prototype: ComputerTechnologyDiskTerminal
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: BaseComputerCircuitboard
|
parent: BaseComputerCircuitboard
|
||||||
id: CrewMonitoringComputerCircuitboard
|
id: CrewMonitoringComputerCircuitboard
|
||||||
|
|||||||
@@ -36,3 +36,21 @@
|
|||||||
components:
|
components:
|
||||||
- type: ResearchDisk
|
- type: ResearchDisk
|
||||||
unlockAllTech: true
|
unlockAllTech: true
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
parent: BaseItem
|
||||||
|
id: TechnologyDisk
|
||||||
|
name: technology disk
|
||||||
|
description: A disk for the R&D server containing research technology.
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
sprite: Objects/Misc/module.rsi
|
||||||
|
layers:
|
||||||
|
- state: datadisk_base
|
||||||
|
map: ["enum.DamageStateVisualLayers.Base"]
|
||||||
|
- state: datadisk_label
|
||||||
|
- type: RandomSprite
|
||||||
|
available:
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
datadisk_base: Sixteen
|
||||||
|
- type: TechnologyDisk
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
- type: entity
|
||||||
|
parent: BaseComputer
|
||||||
|
id: ComputerTechnologyDiskTerminal
|
||||||
|
name: technology disk terminal
|
||||||
|
description: A terminal used to print out technology disks.
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
netsync: false
|
||||||
|
noRot: true
|
||||||
|
sprite: Structures/Machines/tech_disk_printer.rsi
|
||||||
|
layers:
|
||||||
|
- state: icon
|
||||||
|
map: ["enum.ComputerVisualizer+Layers.Body"]
|
||||||
|
- state: unshaded
|
||||||
|
shader: unshaded
|
||||||
|
map: ["enum.ComputerVisualizer+Layers.Screen"]
|
||||||
|
- type: Appearance
|
||||||
|
visuals:
|
||||||
|
- type: ComputerVisualizer
|
||||||
|
screen: unshaded
|
||||||
|
key: ""
|
||||||
|
body: icon
|
||||||
|
bodyBroken: icon
|
||||||
|
- type: DiskConsole
|
||||||
|
- type: ResearchClient
|
||||||
|
- type: ActivatableUI
|
||||||
|
key: enum.DiskConsoleUiKey.Key
|
||||||
|
- type: ActivatableUIRequiresPower
|
||||||
|
- type: UserInterface
|
||||||
|
interfaces:
|
||||||
|
- key: enum.DiskConsoleUiKey.Key
|
||||||
|
type: DiskConsoleBoundUserInterface
|
||||||
|
- key: enum.ResearchClientUiKey.Key
|
||||||
|
type: ResearchClientBoundUserInterface
|
||||||
|
- type: ExtensionCableReceiver
|
||||||
|
- type: Computer
|
||||||
|
board: TechDiskComputerCircuitboard
|
||||||
|
- type: PointLight
|
||||||
|
radius: 0.8
|
||||||
|
energy: 0.5
|
||||||
|
color: "#b53ca1"
|
||||||
@@ -292,6 +292,7 @@
|
|||||||
- ShuttleConsoleCircuitboard
|
- ShuttleConsoleCircuitboard
|
||||||
- RadarConsoleCircuitboard
|
- RadarConsoleCircuitboard
|
||||||
- CircuitImprinterMachineCircuitboard
|
- CircuitImprinterMachineCircuitboard
|
||||||
|
- TechDiskComputerCircuitboard
|
||||||
- DawInstrumentMachineCircuitboard
|
- DawInstrumentMachineCircuitboard
|
||||||
- CloningConsoleComputerCircuitboard
|
- CloningConsoleComputerCircuitboard
|
||||||
- StasisBedMachineCircuitboard
|
- StasisBedMachineCircuitboard
|
||||||
|
|||||||
@@ -233,6 +233,16 @@
|
|||||||
Glass: 900
|
Glass: 900
|
||||||
Gold: 100
|
Gold: 100
|
||||||
|
|
||||||
|
- type: latheRecipe
|
||||||
|
id: TechDiskComputerCircuitboard
|
||||||
|
icon: { sprite: Objects/Misc/module.rsi, state: cpu_science }
|
||||||
|
result: TechDiskComputerCircuitboard
|
||||||
|
completetime: 4
|
||||||
|
materials:
|
||||||
|
Steel: 100
|
||||||
|
Glass: 900
|
||||||
|
Gold: 100
|
||||||
|
|
||||||
- type: latheRecipe
|
- type: latheRecipe
|
||||||
id: CrewMonitoringComputerCircuitboard
|
id: CrewMonitoringComputerCircuitboard
|
||||||
icon: { sprite: Objects/Misc/module.rsi, state: id_mod }
|
icon: { sprite: Objects/Misc/module.rsi, state: id_mod }
|
||||||
|
|||||||
BIN
Resources/Textures/Objects/Misc/module.rsi/datadisk_base.png
Normal file
BIN
Resources/Textures/Objects/Misc/module.rsi/datadisk_base.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 188 B |
BIN
Resources/Textures/Objects/Misc/module.rsi/datadisk_label.png
Normal file
BIN
Resources/Textures/Objects/Misc/module.rsi/datadisk_label.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 224 B |
@@ -1 +1 @@
|
|||||||
{"version": 1, "size": {"x": 32, "y": 32}, "license": "CC-BY-SA-3.0", "copyright": "Taken from https://github.com/tgstation/tgstation at 0d9c9a8233dfc3fc55edc538955a761a6328bee0, generic, service, command, science, security, medical, supply, and engineering taken from shiptest at https://github.com/shiptest-ss13/Shiptest/pull/1473, additional sprites created by EmoGarbage404", "states": [{"name": "abductor_mod"}, {"name": "airalarm_electronics"}, {"name": "ash_plating"}, {"name": "beaker_holder"}, {"name": "blank_mod"}, {"name": "bluespacearray"}, {"name": "boris"}, {"name": "boris_recharging", "delays": [[1.0, 1.0]]}, {"name": "card_mini"}, {"name": "card_mod"}, {"name": "cargodisk"}, {"name": "cart_connector"}, {"name": "cddrive"}, {"name": "cell"}, {"name": "cell_con"}, {"name": "cell_con_micro"}, {"name": "cell_micro"}, {"name": "cell_mini"}, {"name": "charger_APC"}, {"name": "charger_lambda"}, {"name": "charger_pda"}, {"name": "charger_wire"}, {"name": "clock_mod", "delays": [[0.6, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]]}, {"name": "command"}, {"name": "cpu"}, {"name": "cpu_adv"}, {"name": "cpu_command"}, {"name": "cpu_engineering"}, {"name": "cpu_medical"}, {"name": "cpu_science"}, {"name": "cpu_security"}, {"name": "cpu_service"}, {"name": "cpu_super", "delays": [[0.1, 0.1]]}, {"name": "cpu_supply"}, {"name": "cpuboard"}, {"name": "cpuboard_adv"}, {"name": "cpuboard_super", "delays": [[0.1, 0.1]]}, {"name": "cyborg_upgrade"}, {"name": "cyborg_upgrade1"}, {"name": "cyborg_upgrade2"}, {"name": "cyborg_upgrade3"}, {"name": "cyborg_upgrade4"}, {"name": "cyborg_upgrade5"}, {"name": "datadisk0"}, {"name": "datadisk1"}, {"name": "datadisk2"}, {"name": "datadisk3"}, {"name": "datadisk4"}, {"name": "datadisk5"}, {"name": "datadisk6"}, {"name": "datadisk_gene", "delays": [[0.1, 0.1, 0.1]]}, {"name": "datadisk_hydro", "delays": [[0.1, 0.1, 0.1]]}, {"name": "depositbox"}, {"name": "door_electronics"}, {"name": "engineering"}, {"name": "flopdrive"}, {"name": "generic"}, {"name": "harddisk"}, {"name": "harddisk_micro"}, {"name": "harddisk_mini"}, {"name": "holodisk", "delays": [[0.1, 0.1]]}, {"name": "id_mod"}, {"name": "mainboard"}, {"name": "mcontroller"}, {"name": "medical"}, {"name": "net_wired"}, {"name": "nucleardisk", "delays": [[0.1, 0.1]]}, {"name": "power_mod"}, {"name": "printer"}, {"name": "printer_mini"}, {"name": "prizevendor"}, {"name": "radio"}, {"name": "radio_micro"}, {"name": "radio_mini"}, {"name": "ram"}, {"name": "rndmajordisk"}, {"name": "science"}, {"name": "secmodschematic"}, {"name": "security"}, {"name": "selfrepair_off"}, {"name": "selfrepair_on", "delays": [[0.1, 0.1, 0.1, 0.1]]}, {"name": "service"}, {"name": "servo"}, {"name": "ssd"}, {"name": "ssd_large"}, {"name": "ssd_micro"}, {"name": "ssd_mini"}, {"name": "std_mod"}, {"name": "supply"}]}
|
{"version": 1, "size": {"x": 32, "y": 32}, "license": "CC-BY-SA-3.0", "copyright": "Taken from https://github.com/tgstation/tgstation at 0d9c9a8233dfc3fc55edc538955a761a6328bee0, generic, service, command, science, security, medical, supply, and engineering taken from shiptest at https://github.com/shiptest-ss13/Shiptest/pull/1473, additional sprites created by EmoGarbage404", "states": [{"name": "abductor_mod"}, {"name": "airalarm_electronics"}, {"name": "ash_plating"}, {"name": "beaker_holder"}, {"name": "blank_mod"}, {"name": "bluespacearray"}, {"name": "boris"}, {"name": "boris_recharging", "delays": [[1.0, 1.0]]}, {"name": "card_mini"}, {"name": "card_mod"}, {"name": "cargodisk"}, {"name": "cart_connector"}, {"name": "cddrive"}, {"name": "cell"}, {"name": "cell_con"}, {"name": "cell_con_micro"}, {"name": "cell_micro"}, {"name": "cell_mini"}, {"name": "charger_APC"}, {"name": "charger_lambda"}, {"name": "charger_pda"}, {"name": "charger_wire"}, {"name": "clock_mod", "delays": [[0.6, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]]}, {"name": "command"}, {"name": "cpu"}, {"name": "cpu_adv"}, {"name": "cpu_command"}, {"name": "cpu_engineering"}, {"name": "cpu_medical"}, {"name": "cpu_science"}, {"name": "cpu_security"}, {"name": "cpu_service"}, {"name": "cpu_super", "delays": [[0.1, 0.1]]}, {"name": "cpu_supply"}, {"name": "cpuboard"}, {"name": "cpuboard_adv"}, {"name": "cpuboard_super", "delays": [[0.1, 0.1]]}, {"name": "cyborg_upgrade"}, {"name": "cyborg_upgrade1"}, {"name": "cyborg_upgrade2"}, {"name": "cyborg_upgrade3"}, {"name": "cyborg_upgrade4"}, {"name": "cyborg_upgrade5"}, {"name": "datadisk_base"}, {"name": "datadisk0"}, {"name": "datadisk1"}, {"name": "datadisk2"}, {"name": "datadisk3"}, {"name": "datadisk4"}, {"name": "datadisk5"}, {"name": "datadisk6"}, {"name": "datadisk_gene", "delays": [[0.1, 0.1, 0.1]]}, {"name": "datadisk_hydro", "delays": [[0.1, 0.1, 0.1]]}, {"name": "datadisk_label"}, {"name": "depositbox"}, {"name": "door_electronics"}, {"name": "engineering"}, {"name": "flopdrive"}, {"name": "generic"}, {"name": "harddisk"}, {"name": "harddisk_micro"}, {"name": "harddisk_mini"}, {"name": "holodisk", "delays": [[0.1, 0.1]]}, {"name": "id_mod"}, {"name": "mainboard"}, {"name": "mcontroller"}, {"name": "medical"}, {"name": "net_wired"}, {"name": "nucleardisk", "delays": [[0.1, 0.1]]}, {"name": "power_mod"}, {"name": "printer"}, {"name": "printer_mini"}, {"name": "prizevendor"}, {"name": "radio"}, {"name": "radio_micro"}, {"name": "radio_mini"}, {"name": "ram"}, {"name": "rndmajordisk"}, {"name": "science"}, {"name": "secmodschematic"}, {"name": "security"}, {"name": "selfrepair_off"}, {"name": "selfrepair_on", "delays": [[0.1, 0.1, 0.1, 0.1]]}, {"name": "service"}, {"name": "servo"}, {"name": "ssd"}, {"name": "ssd_large"}, {"name": "ssd_micro"}, {"name": "ssd_mini"}, {"name": "std_mod"}, {"name": "supply"}]}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 699 B |
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"license": "CC0-1.0",
|
||||||
|
"copyright": "Created by EmoGarbage",
|
||||||
|
"size": {
|
||||||
|
"x": 32,
|
||||||
|
"y": 32
|
||||||
|
},
|
||||||
|
"states": [
|
||||||
|
{
|
||||||
|
"name": "icon"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "printing",
|
||||||
|
"delays": [[0.25, 0.25, 0.25, 0.25]]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "unshaded"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 178 B |
Binary file not shown.
|
After Width: | Height: | Size: 280 B |
Reference in New Issue
Block a user