* Laws

* positronic brain and PAI rewrite

* MMI

* MMI pt. 2

* borg brain transfer

* Roleban support, Borg job (WIP), the end of mind shenaniganry

* battery drain, item slot cleanup, alerts

* visuals

* fix this pt1

* fix this pt2

* Modules, Lingering Stacks, Better borg flashlight

* Start on UI, fix battery alerts, expand activation/deactivation, low movement speed on no power.

* sprotes

* no zombie borgs

* oh fuck yeah i love a good relay

* charger

* fix the tiniest of sprite issues

* adjustable names

* a functional UI????

* foobar

* more modules

* this shit for some reason

* upstream

* genericize selectable borg modules

* upstream again

* holy fucking shit

* i love christ

* proper construction

* da job

* AA borgs

* and boom more shit

* admin logs

* laws redux

* ok just do this rq

* oh boy that looks like modules

* oh shit research

* testos passo

* so much shit holy fuck

* fuckit we SHIP

* last minute snags

* should've gotten me on a better day
This commit is contained in:
Nemanja
2023-08-12 17:39:58 -04:00
committed by GitHub
parent ac4f496535
commit 98fa00a21f
314 changed files with 7094 additions and 484 deletions

View File

@@ -0,0 +1,45 @@
using Robust.Shared.Containers;
namespace Content.Shared.Construction.Components;
/// <summary>
/// This is used for construction which requires a set of
/// entities with specific tags to be inserted into another entity.
/// todo: in a pr that isn't 6k loc, combine this with MechAssemblyComponent
/// </summary>
[RegisterComponent]
public sealed class PartAssemblyComponent : Component
{
/// <summary>
/// A dictionary of a set of parts to a list of tags for each assembly.
/// </summary>
[DataField("parts", required: true)]
public Dictionary<string, List<string>> Parts = new();
/// <summary>
/// The entry in <see cref="Parts"/> that is currently being worked on.
/// </summary>
[DataField("currentAssembly")]
public string? CurrentAssembly;
/// <summary>
/// The container where the parts are stored
/// </summary>
[DataField("containerId")]
public string ContainerId = "part-container";
/// <summary>
/// The container that stores all of the parts when
/// they're being assembled.
/// </summary>
[ViewVariables]
public Container PartsContainer = default!;
}
/// <summary>
/// Event raised when a valid part is inserted into the part assembly.
/// </summary>
public sealed class PartAssemblyPartInsertedEvent
{
}

View File

@@ -0,0 +1,147 @@
using Content.Shared.Construction.Components;
using Content.Shared.Interaction;
using Content.Shared.Tag;
using Robust.Shared.Containers;
namespace Content.Shared.Construction;
/// <summary>
/// This handles <see cref="PartAssemblyComponent"/>
/// </summary>
public sealed class PartAssemblySystem : EntitySystem
{
[Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly TagSystem _tag = default!;
/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<PartAssemblyComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<PartAssemblyComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<PartAssemblyComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
}
private void OnInit(EntityUid uid, PartAssemblyComponent component, ComponentInit args)
{
component.PartsContainer = _container.EnsureContainer<Container>(uid, component.ContainerId);
}
private void OnInteractUsing(EntityUid uid, PartAssemblyComponent component, InteractUsingEvent args)
{
if (!TryInsertPart(args.Used, uid, component))
return;
args.Handled = true;
}
private void OnEntRemoved(EntityUid uid, PartAssemblyComponent component, EntRemovedFromContainerMessage args)
{
if (args.Container.ID != component.ContainerId)
return;
if (component.PartsContainer.ContainedEntities.Count != 0)
return;
component.CurrentAssembly = null;
}
/// <summary>
/// Attempts to insert a part into the current assembly, starting one if there is none.
/// </summary>
public bool TryInsertPart(EntityUid part, EntityUid uid, PartAssemblyComponent? component = null)
{
if (!Resolve(uid, ref component))
return false;
string? assemblyId = null;
assemblyId ??= component.CurrentAssembly;
if (assemblyId == null)
{
foreach (var (id, tags) in component.Parts)
{
foreach (var tag in tags)
{
if (!_tag.HasTag(part, tag))
continue;
assemblyId = id;
break;
}
if (assemblyId != null)
break;
}
}
if (assemblyId == null)
return false;
if (!IsPartValid(uid, part, assemblyId, component))
return false;
component.CurrentAssembly = assemblyId;
component.PartsContainer.Insert(part);
var ev = new PartAssemblyPartInsertedEvent();
RaiseLocalEvent(uid, ev);
return true;
}
/// <summary>
/// Checks if the given entity is a valid item for the assembly.
/// </summary>
public bool IsPartValid(EntityUid uid, EntityUid part, string assemblyId, PartAssemblyComponent? component = null)
{
if (!Resolve(uid, ref component, false))
return true;
if (!component.Parts.TryGetValue(assemblyId, out var tags))
return false;
var openTags = new List<string>(tags);
var contained = new List<EntityUid>(component.PartsContainer.ContainedEntities);
foreach (var tag in tags)
{
foreach (var ent in component.PartsContainer.ContainedEntities)
{
if (!contained.Contains(ent) || !_tag.HasTag(ent, tag))
continue;
openTags.Remove(tag);
contained.Remove(ent);
break;
}
}
foreach (var tag in openTags)
{
if (_tag.HasTag(part, tag))
return true;
}
return false;
}
public bool IsAssemblyFinished(EntityUid uid, string assemblyId, PartAssemblyComponent? component = null)
{
if (!Resolve(uid, ref component, false))
return true;
if (!component.Parts.TryGetValue(assemblyId, out var parts))
return false;
var contained = new List<EntityUid>(component.PartsContainer.ContainedEntities);
foreach (var tag in parts)
{
var valid = false;
foreach (var ent in new List<EntityUid>(contained))
{
if (!_tag.HasTag(ent, tag))
continue;
valid = true;
contained.Remove(ent);
break;
}
if (!valid)
return false;
}
return true;
}
}

View File

@@ -41,6 +41,11 @@ namespace Content.Shared.Construction.Steps
return typeof(TemperatureConstructionGraphStep);
}
if (node.Has("assemblyId") || node.Has("guideString"))
{
return typeof(PartAssemblyConstructionGraphStep);
}
return null;
}

View File

@@ -0,0 +1,39 @@
using Content.Shared.Construction.Components;
using Content.Shared.Examine;
using JetBrains.Annotations;
namespace Content.Shared.Construction.Steps;
[DataDefinition]
public sealed class PartAssemblyConstructionGraphStep : ConstructionGraphStep
{
/// <summary>
/// A valid ID on <see cref="PartAssemblyComponent"/>'s dictionary of strings to part lists.
/// </summary>
[DataField("assemblyId")]
public string AssemblyId = string.Empty;
/// <summary>
/// A localization string used for
/// </summary>
[DataField("guideString")]
public string GuideString = "construction-guide-condition-part-assembly";
public bool Condition(EntityUid uid, IEntityManager entityManager)
{
return entityManager.System<PartAssemblySystem>().IsAssemblyFinished(uid, AssemblyId);
}
public override void DoExamine(ExaminedEvent args)
{
args.PushMarkup(Loc.GetString(GuideString));
}
public override ConstructionGuideEntry GenerateGuideEntry()
{
return new ConstructionGuideEntry
{
Localization = GuideString,
};
}
}