Verb predict (#5638)
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Access.Components;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.PDA
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class PDAComponent : Component
|
||||
{
|
||||
public override string Name => "PDA";
|
||||
|
||||
[DataField("idSlot")]
|
||||
public ItemSlot IdSlot = new();
|
||||
|
||||
[DataField("penSlot")]
|
||||
public ItemSlot PenSlot = new();
|
||||
|
||||
// Really this should just be using ItemSlot.StartingItem. However, seeing as we have so many different starting
|
||||
// PDA's and no nice way to inherit the other fields from the ItemSlot data definition, this makes the yaml much
|
||||
// nicer to read.
|
||||
[DataField("idCard", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string? IdCard;
|
||||
|
||||
[ViewVariables] public IdCardComponent? ContainedID;
|
||||
[ViewVariables] public bool FlashlightOn;
|
||||
|
||||
[ViewVariables] public string? OwnerName;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Access.Components;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Inventory.Components;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.PDA;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Content.Server.Access.Components;
|
||||
using Content.Server.Light.Components;
|
||||
using Content.Server.Light.EntitySystems;
|
||||
using Content.Server.Light.Events;
|
||||
@@ -15,9 +14,8 @@ using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.PDA
|
||||
{
|
||||
public class PDASystem : EntitySystem
|
||||
public sealed class PDASystem : SharedPDASystem
|
||||
{
|
||||
[Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!;
|
||||
[Dependency] private readonly UplinkSystem _uplinkSystem = default!;
|
||||
[Dependency] private readonly UnpoweredFlashlightSystem _unpoweredFlashlight = default!;
|
||||
|
||||
@@ -25,36 +23,21 @@ namespace Content.Server.PDA
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<PDAComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<PDAComponent, ComponentRemove>(OnComponentRemove);
|
||||
|
||||
SubscribeLocalEvent<PDAComponent, ActivateInWorldEvent>(OnActivateInWorld);
|
||||
SubscribeLocalEvent<PDAComponent, UseInHandEvent>(OnUse);
|
||||
SubscribeLocalEvent<PDAComponent, EntInsertedIntoContainerMessage>(OnItemInserted);
|
||||
SubscribeLocalEvent<PDAComponent, EntRemovedFromContainerMessage>(OnItemRemoved);
|
||||
SubscribeLocalEvent<PDAComponent, LightToggleEvent>(OnLightToggle);
|
||||
|
||||
SubscribeLocalEvent<PDAComponent, UplinkInitEvent>(OnUplinkInit);
|
||||
SubscribeLocalEvent<PDAComponent, UplinkRemovedEvent>(OnUplinkRemoved);
|
||||
}
|
||||
|
||||
private void OnComponentInit(EntityUid uid, PDAComponent pda, ComponentInit args)
|
||||
protected override void OnComponentInit(EntityUid uid, PDAComponent pda, ComponentInit args)
|
||||
{
|
||||
base.OnComponentInit(uid, pda, args);
|
||||
|
||||
var ui = pda.Owner.GetUIOrNull(PDAUiKey.Key);
|
||||
if (ui != null)
|
||||
ui.OnReceiveMessage += (msg) => OnUIMessage(pda, msg);
|
||||
|
||||
if (pda.IdCard != null)
|
||||
pda.IdSlot.StartingItem = pda.IdCard;
|
||||
_itemSlotsSystem.AddItemSlot(uid, $"{pda.Name}-id", pda.IdSlot);
|
||||
_itemSlotsSystem.AddItemSlot(uid, $"{pda.Name}-pen", pda.PenSlot);
|
||||
}
|
||||
|
||||
private void OnComponentRemove(EntityUid uid, PDAComponent pda, ComponentRemove args)
|
||||
{
|
||||
_itemSlotsSystem.RemoveItemSlot(uid, pda.IdSlot);
|
||||
_itemSlotsSystem.RemoveItemSlot(uid, pda.PenSlot);
|
||||
}
|
||||
|
||||
|
||||
private void OnUse(EntityUid uid, PDAComponent pda, UseInHandEvent args)
|
||||
{
|
||||
@@ -70,21 +53,15 @@ namespace Content.Server.PDA
|
||||
args.Handled = OpenUI(pda, args.User);
|
||||
}
|
||||
|
||||
private void OnItemInserted(EntityUid uid, PDAComponent pda, EntInsertedIntoContainerMessage args)
|
||||
protected override void OnItemInserted(EntityUid uid, PDAComponent pda, EntInsertedIntoContainerMessage args)
|
||||
{
|
||||
if (args.Container.ID == pda.IdSlot.ID)
|
||||
pda.ContainedID = EntityManager.GetComponentOrNull<IdCardComponent>(args.Entity);
|
||||
|
||||
UpdatePDAAppearance(pda);
|
||||
base.OnItemInserted(uid, pda, args);
|
||||
UpdatePDAUserInterface(pda);
|
||||
}
|
||||
|
||||
private void OnItemRemoved(EntityUid uid, PDAComponent pda, EntRemovedFromContainerMessage args)
|
||||
protected override void OnItemRemoved(EntityUid uid, PDAComponent pda, EntRemovedFromContainerMessage args)
|
||||
{
|
||||
if (args.Container.ID == pda.IdSlot.ID)
|
||||
pda.ContainedID = null;
|
||||
|
||||
UpdatePDAAppearance(pda);
|
||||
base.OnItemRemoved(uid, pda, args);
|
||||
UpdatePDAUserInterface(pda);
|
||||
}
|
||||
|
||||
@@ -162,12 +139,12 @@ namespace Content.Server.PDA
|
||||
|
||||
case PDAEjectIDMessage _:
|
||||
{
|
||||
_itemSlotsSystem.TryEjectToHands(pda.Owner, pda.IdSlot, playerUid);
|
||||
ItemSlotsSystem.TryEjectToHands(pda.Owner, pda.IdSlot, playerUid);
|
||||
break;
|
||||
}
|
||||
case PDAEjectPenMessage _:
|
||||
{
|
||||
_itemSlotsSystem.TryEjectToHands(pda.Owner, pda.PenSlot, playerUid);
|
||||
ItemSlotsSystem.TryEjectToHands(pda.Owner, pda.PenSlot, playerUid);
|
||||
break;
|
||||
}
|
||||
case PDAShowUplinkMessage _:
|
||||
|
||||
Reference in New Issue
Block a user