Add basic PDA/Syndicate Uplink. (#942)

Co-authored-by: FL-OZ <anotherscuffed@gmail.com>
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
FL-OZ
2020-05-28 06:22:47 -05:00
committed by GitHub
parent 0171c3bd93
commit 4c20a504a5
117 changed files with 1569 additions and 41 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Content.Server.Interfaces;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -6,16 +7,26 @@ using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Access
{
[RegisterComponent]
public class AccessComponent : Component
[ComponentReference(typeof(IAccess))]
public class AccessComponent : Component, IAccess
{
public override string Name => "Access";
[ViewVariables]
public List<string> Tags;
private List<string> _tags;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _tags, "tags", new List<string>());
}
serializer.DataField(ref Tags, "tags", new List<string>());
public List<string> GetTags()
{
return _tags;
}
public void SetTags(List<string> newTags)
{
_tags = newTags;
}
}
}

View File

@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using Content.Server.Interfaces;
using Content.Server.Interfaces.GameObjects;
using Content.Shared.GameObjects.Components.Inventory;
using JetBrains.Annotations;
@@ -26,22 +28,22 @@ namespace Content.Server.GameObjects.Components.Access
/// <param name="entity">The entity to be searched for access.</param>
public bool IsAllowed(IEntity entity)
{
var accessProvider = FindAccessProvider(entity);
return accessProvider != null && IsAllowed(accessProvider);
var tags = FindAccessTags(entity);
return tags != null && IsAllowed(tags);
}
private bool IsAllowed(AccessComponent accessProvider)
private bool IsAllowed(List<string> accessTags)
{
foreach (var sufficient in _sufficientTags)
{
if (accessProvider.Tags.Contains(sufficient))
if (accessTags.Contains(sufficient))
{
return true;
}
}
foreach (var necessary in _necessaryTags)
{
if (!accessProvider.Tags.Contains(necessary))
if (!accessTags.Contains(necessary))
{
return false;
}
@@ -50,20 +52,20 @@ namespace Content.Server.GameObjects.Components.Access
}
[CanBeNull]
private static AccessComponent FindAccessProvider(IEntity entity)
private static List<string> FindAccessTags(IEntity entity)
{
if (entity.TryGetComponent(out AccessComponent accessComponent))
if (entity.TryGetComponent(out IAccess accessComponent))
{
return accessComponent;
return accessComponent.GetTags();
}
if (entity.TryGetComponent(out IHandsComponent handsComponent))
{
var activeHandEntity = handsComponent.GetActiveHand?.Owner;
if (activeHandEntity != null &&
activeHandEntity.TryGetComponent(out AccessComponent handAccessComponent))
activeHandEntity.TryGetComponent(out IAccess handAccessComponent))
{
return handAccessComponent;
return handAccessComponent.GetTags();
}
}
else
@@ -74,10 +76,10 @@ namespace Content.Server.GameObjects.Components.Access
{
if (inventoryComponent.HasSlot(EquipmentSlotDefines.Slots.IDCARD) &&
inventoryComponent.TryGetSlotItem(EquipmentSlotDefines.Slots.IDCARD, out ItemComponent item) &&
item.Owner.TryGetComponent(out AccessComponent idAccessComponent)
item.Owner.TryGetComponent(out IAccess idAccessComponent)
)
{
return idAccessComponent;
return idAccessComponent.GetTags();
}
}
return null;

View File

@@ -101,7 +101,7 @@ namespace Content.Server.GameObjects.Components.Access
return;
}
var targetIdAccess = targetIdEntity.GetComponent<AccessComponent>();
targetIdAccess.Tags = newAccessList;
targetIdAccess.SetTags(newAccessList);
}
/// <summary>
@@ -180,7 +180,7 @@ namespace Content.Server.GameObjects.Components.Access
true,
targetIdComponent.FullName,
targetIdComponent.JobTitle,
targetAccessComponent.Tags,
targetAccessComponent.GetTags(),
_privilegedIdContainer.ContainedEntity?.Name ?? "",
_targetIdContainer.ContainedEntity?.Name ?? "");
}