Inline UID
This commit is contained in:
@@ -56,7 +56,7 @@ namespace Content.Server.Power.Components
|
||||
|
||||
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ApcUiKey.Key);
|
||||
|
||||
public BatteryComponent? Battery => IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out BatteryComponent? batteryComponent) ? batteryComponent : null;
|
||||
public BatteryComponent? Battery => IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out BatteryComponent? batteryComponent) ? batteryComponent : null;
|
||||
|
||||
[ComponentDependency] private AccessReader? _accessReader = null;
|
||||
|
||||
@@ -93,10 +93,10 @@ namespace Content.Server.Power.Components
|
||||
if (user == null) return;
|
||||
|
||||
var accessSystem = EntitySystem.Get<AccessReaderSystem>();
|
||||
if (_accessReader == null || accessSystem.IsAllowed(_accessReader, user.Uid))
|
||||
if (_accessReader == null || accessSystem.IsAllowed(_accessReader, user))
|
||||
{
|
||||
MainBreakerEnabled = !MainBreakerEnabled;
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(Owner.Uid).CanDischarge = MainBreakerEnabled;
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(Owner).CanDischarge = MainBreakerEnabled;
|
||||
|
||||
_uiDirty = true;
|
||||
SoundSystem.Play(Filter.Pvs(Owner), _onReceiveMessageSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f));
|
||||
@@ -117,12 +117,12 @@ namespace Content.Server.Power.Components
|
||||
_lastChargeState = newState;
|
||||
_lastChargeStateChange = _gameTiming.CurTime;
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance))
|
||||
{
|
||||
appearance.SetData(ApcVisuals.ChargeState, newState);
|
||||
}
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out SharedPointLightComponent? light))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out SharedPointLightComponent? light))
|
||||
{
|
||||
light.Color = newState switch
|
||||
{
|
||||
@@ -135,7 +135,7 @@ namespace Content.Server.Power.Components
|
||||
}
|
||||
}
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out BatteryComponent? battery);
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out BatteryComponent? battery);
|
||||
|
||||
var newCharge = battery?.CurrentCharge;
|
||||
if (newCharge != null && newCharge != _lastCharge && _lastChargeChange + TimeSpan.FromSeconds(VisualsChangeDelay) < _gameTiming.CurTime)
|
||||
@@ -162,7 +162,7 @@ namespace Content.Server.Power.Components
|
||||
|
||||
private ApcChargeState CalcChargeState()
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out BatteryComponent? battery))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out BatteryComponent? battery))
|
||||
{
|
||||
return ApcChargeState.Lack;
|
||||
}
|
||||
@@ -174,7 +174,7 @@ namespace Content.Server.Power.Components
|
||||
return ApcChargeState.Full;
|
||||
}
|
||||
|
||||
var netBattery = IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(Owner.Uid);
|
||||
var netBattery = IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(Owner);
|
||||
var delta = netBattery.CurrentSupply - netBattery.CurrentReceiving;
|
||||
|
||||
return delta < 0 ? ApcChargeState.Charging : ApcChargeState.Lack;
|
||||
@@ -186,7 +186,7 @@ namespace Content.Server.Power.Components
|
||||
if (bat == null)
|
||||
return ApcExternalPowerState.None;
|
||||
|
||||
var netBat = IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(Owner.Uid);
|
||||
var netBat = IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(Owner);
|
||||
if (netBat.CurrentReceiving == 0 && netBat.LoadingNetworkDemand != 0)
|
||||
{
|
||||
return ApcExternalPowerState.None;
|
||||
@@ -203,7 +203,7 @@ namespace Content.Server.Power.Components
|
||||
|
||||
void IActivate.Activate(ActivateEventArgs eventArgs)
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User, out ActorComponent? actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,9 +85,9 @@ namespace Content.Server.Power.Components
|
||||
#pragma warning disable 618
|
||||
SendMessage(new PowerChangedMessage(Powered));
|
||||
#pragma warning restore 618
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, new PowerChangedEvent(Powered, NetworkLoad.ReceivingPower));
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner, new PowerChangedEvent(Powered, NetworkLoad.ReceivingPower));
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<AppearanceComponent?>(Owner.Uid, out var appearance))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<AppearanceComponent?>(Owner, out var appearance))
|
||||
{
|
||||
appearance.SetData(PowerDeviceVisuals.Powered, Powered);
|
||||
}
|
||||
|
||||
@@ -98,12 +98,12 @@ namespace Content.Server.Power.Components
|
||||
|
||||
Container.Remove(heldItem);
|
||||
_heldBattery = null;
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(user.Uid, out HandsComponent? handsComponent))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out HandsComponent? handsComponent))
|
||||
{
|
||||
handsComponent.PutInHandOrDrop(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(heldItem.Uid));
|
||||
handsComponent.PutInHandOrDrop(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(heldItem));
|
||||
}
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(heldItem.Uid, out ServerBatteryBarrelComponent? batteryBarrelComponent))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(heldItem, out ServerBatteryBarrelComponent? batteryBarrelComponent))
|
||||
{
|
||||
batteryBarrelComponent.UpdateAppearance();
|
||||
}
|
||||
@@ -118,7 +118,7 @@ namespace Content.Server.Power.Components
|
||||
|
||||
private CellChargerStatus GetStatus()
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver) &&
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) &&
|
||||
!receiver.Powered)
|
||||
{
|
||||
return CellChargerStatus.Off;
|
||||
@@ -161,13 +161,13 @@ namespace Content.Server.Power.Components
|
||||
// Not called UpdateAppearance just because it messes with the load
|
||||
var status = GetStatus();
|
||||
if (_status == status ||
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver))
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_status = status;
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance);
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance);
|
||||
|
||||
switch (_status)
|
||||
{
|
||||
@@ -206,7 +206,7 @@ namespace Content.Server.Power.Components
|
||||
|
||||
private void TransferPower(float frameTime)
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver) &&
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) &&
|
||||
!receiver.Powered)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Content.Server.Power.Components
|
||||
|
||||
private bool TryFindNet([NotNullWhen(true)] out TNetType? foundNet)
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<NodeContainerComponent?>(Owner.Uid, out var container))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<NodeContainerComponent?>(Owner, out var container))
|
||||
{
|
||||
var compatibleNet = container.Nodes.Values
|
||||
.Where(node => (NodeId == null || NodeId == node.Name) && node.NodeGroupID == (NodeGroupID) Voltage)
|
||||
|
||||
@@ -43,16 +43,16 @@ namespace Content.Server.Power.Components
|
||||
if (_cableDroppedOnCutPrototype == null)
|
||||
return false;
|
||||
|
||||
if (!await EntitySystem.Get<ToolSystem>().UseTool(eventArgs.Using.Uid, eventArgs.User.Uid, Owner.Uid, 0f, 0.25f, _cuttingQuality)) return false;
|
||||
if (!await EntitySystem.Get<ToolSystem>().UseTool(eventArgs.Using, eventArgs.User, Owner, 0f, 0.25f, _cuttingQuality)) return false;
|
||||
|
||||
if (EntitySystem.Get<ElectrocutionSystem>().TryDoElectrifiedAct(Owner.Uid, eventArgs.User.Uid)) return false;
|
||||
if (EntitySystem.Get<ElectrocutionSystem>().TryDoElectrifiedAct(Owner, eventArgs.User)) return false;
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner.Uid);
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity((EntityUid) Owner);
|
||||
var droppedEnt = IoCManager.Resolve<IEntityManager>().SpawnEntity(_cableDroppedOnCutPrototype, eventArgs.ClickLocation);
|
||||
|
||||
// TODO: Literally just use a prototype that has a single thing in the stack, it's not that complicated...
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<StackComponent?>(droppedEnt.Uid, out var stack))
|
||||
EntitySystem.Get<StackSystem>().SetCount(droppedEnt.Uid, 1, stack);
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<StackComponent?>(droppedEnt, out var stack))
|
||||
EntitySystem.Get<StackSystem>().SetCount(droppedEnt, 1, stack);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Content.Server.Power.Components
|
||||
/// <inheritdoc />
|
||||
async Task<bool> IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
|
||||
{
|
||||
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(eventArgs.User.Uid))
|
||||
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(eventArgs.User))
|
||||
return false;
|
||||
|
||||
if (_cablePrototypeID == null)
|
||||
@@ -57,8 +57,8 @@ namespace Content.Server.Power.Components
|
||||
}
|
||||
}
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<StackComponent?>(Owner.Uid, out var stack)
|
||||
&& !EntitySystem.Get<StackSystem>().Use(Owner.Uid, 1, stack))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<StackComponent?>(Owner, out var stack)
|
||||
&& !EntitySystem.Get<StackSystem>().Use(Owner, 1, stack))
|
||||
return false;
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().SpawnEntity(_cablePrototypeID, grid.GridTileToLocal(snapPos));
|
||||
|
||||
@@ -39,11 +39,11 @@ namespace Content.Server.Power.EntitySystems
|
||||
!args.CanAccess ||
|
||||
!args.CanInteract ||
|
||||
!component.HasCell ||
|
||||
!_actionBlockerSystem.CanPickup(args.User.Uid))
|
||||
!_actionBlockerSystem.CanPickup(args.User))
|
||||
return;
|
||||
|
||||
Verb verb = new();
|
||||
verb.Text = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(component.Container.ContainedEntity!.Uid).EntityName;
|
||||
verb.Text = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(component.Container.ContainedEntity!).EntityName;
|
||||
verb.Category = VerbCategory.Eject;
|
||||
verb.Act = () => component.RemoveItem(args.User);
|
||||
args.Verbs.Add(verb);
|
||||
@@ -56,11 +56,11 @@ namespace Content.Server.Power.EntitySystems
|
||||
!args.CanInteract ||
|
||||
component.HasCell ||
|
||||
!component.IsEntityCompatible(args.Using) ||
|
||||
!_actionBlockerSystem.CanDrop(args.User.Uid))
|
||||
!_actionBlockerSystem.CanDrop(args.User))
|
||||
return;
|
||||
|
||||
Verb verb = new();
|
||||
verb.Text = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(args.Using.Uid).EntityName;
|
||||
verb.Text = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(args.Using).EntityName;
|
||||
verb.Category = VerbCategory.Insert;
|
||||
verb.Act = () => component.TryInsertItem(args.Using);
|
||||
args.Verbs.Add(verb);
|
||||
|
||||
@@ -43,12 +43,12 @@ namespace Content.Server.Power.EntitySystems
|
||||
if (args.IsInDetailsRange)
|
||||
{
|
||||
// Determine if they are holding a multitool.
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<HandsComponent?>(args.Examiner.Uid, out var hands) && hands.TryGetActiveHand(out var hand))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<HandsComponent?>(args.Examiner, out var hands) && hands.TryGetActiveHand(out var hand))
|
||||
{
|
||||
var held = hand.HeldEntity;
|
||||
// Pulsing is hardcoded here because I don't think it needs to be more complex than that right now.
|
||||
// Update if I'm wrong.
|
||||
if ((held != null) && _toolSystem.HasQuality(held.Uid, "Pulsing"))
|
||||
if ((held != null) && _toolSystem.HasQuality(held, "Pulsing"))
|
||||
{
|
||||
args.PushMarkup(GenerateCableMarkup(uid));
|
||||
// args.PushFancyUpdatingPowerGraphs(uid);
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Content.Server.Power.EntitySystems
|
||||
if (reachable is not CableNode)
|
||||
continue;
|
||||
|
||||
var otherTransform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(reachable.Owner.Uid);
|
||||
var otherTransform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(reachable.Owner);
|
||||
if (otherTransform.GridID != grid.Index)
|
||||
continue;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Content.Server.Power.EntitySystems
|
||||
receiver.Provider?.LinkedReceivers.Remove(receiver);
|
||||
receiver.Provider = provider;
|
||||
provider.LinkedReceivers.Add(receiver);
|
||||
RaiseLocalEvent(receiver.Owner.Uid, new ProviderConnectedEvent(provider), broadcast: false);
|
||||
RaiseLocalEvent(receiver.Owner, new ProviderConnectedEvent(provider), broadcast: false);
|
||||
RaiseLocalEvent(uid, new ReceiverConnectedEvent(receiver), broadcast: false);
|
||||
}
|
||||
}
|
||||
@@ -60,8 +60,8 @@ namespace Content.Server.Power.EntitySystems
|
||||
foreach (var receiver in receivers)
|
||||
{
|
||||
receiver.Provider = null;
|
||||
RaiseLocalEvent(receiver.Owner.Uid, new ProviderDisconnectedEvent(provider), broadcast: false);
|
||||
RaiseLocalEvent(provider.Owner.Uid, new ReceiverDisconnectedEvent(receiver), broadcast: false);
|
||||
RaiseLocalEvent(receiver.Owner, new ProviderDisconnectedEvent(provider), broadcast: false);
|
||||
RaiseLocalEvent(provider.Owner, new ReceiverDisconnectedEvent(receiver), broadcast: false);
|
||||
}
|
||||
|
||||
foreach (var receiver in receivers)
|
||||
@@ -84,10 +84,10 @@ namespace Content.Server.Power.EntitySystems
|
||||
|
||||
foreach (var entity in nearbyEntities)
|
||||
{
|
||||
if (EntityManager.TryGetComponent<ExtensionCableReceiverComponent>(entity.Uid, out var receiver) &&
|
||||
if (EntityManager.TryGetComponent<ExtensionCableReceiverComponent>(entity, out var receiver) &&
|
||||
receiver.Connectable &&
|
||||
receiver.Provider == null &&
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity.Uid).Coordinates.TryDistance(IoCManager.Resolve<IEntityManager>(), IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(owner.Uid).Coordinates, out var distance) &&
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates.TryDistance(IoCManager.Resolve<IEntityManager>(), IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(owner).Coordinates, out var distance) &&
|
||||
distance < Math.Min(range, receiver.ReceptionRange))
|
||||
{
|
||||
yield return receiver;
|
||||
@@ -110,7 +110,7 @@ namespace Content.Server.Power.EntitySystems
|
||||
|
||||
if (provider != null)
|
||||
{
|
||||
RaiseLocalEvent(provider.Owner.Uid, new ReceiverDisconnectedEvent(receiver), broadcast: false);
|
||||
RaiseLocalEvent(provider.Owner, new ReceiverDisconnectedEvent(receiver), broadcast: false);
|
||||
provider.LinkedReceivers.Remove(receiver);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace Content.Server.Power.EntitySystems
|
||||
|
||||
private void OnReceiverStarted(EntityUid uid, ExtensionCableReceiverComponent receiver, ComponentStartup args)
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(receiver.Owner.Uid, out PhysicsComponent? physicsComponent))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(receiver.Owner, out PhysicsComponent? physicsComponent))
|
||||
{
|
||||
receiver.Connectable = physicsComponent.BodyType == BodyType.Static;
|
||||
}
|
||||
@@ -137,7 +137,7 @@ namespace Content.Server.Power.EntitySystems
|
||||
|
||||
receiver.Provider.LinkedReceivers.Remove(receiver);
|
||||
RaiseLocalEvent(uid, new ProviderDisconnectedEvent(receiver.Provider), broadcast: false);
|
||||
RaiseLocalEvent(receiver.Provider.Owner.Uid, new ReceiverDisconnectedEvent(receiver), broadcast: false);
|
||||
RaiseLocalEvent(receiver.Provider.Owner, new ReceiverDisconnectedEvent(receiver), broadcast: false);
|
||||
}
|
||||
|
||||
private void AnchorStateChanged(EntityUid uid, ExtensionCableReceiverComponent receiver, ref AnchorStateChangedEvent args)
|
||||
@@ -156,7 +156,7 @@ namespace Content.Server.Power.EntitySystems
|
||||
RaiseLocalEvent(uid, new ProviderDisconnectedEvent(receiver.Provider), broadcast: false);
|
||||
if (receiver.Provider != null)
|
||||
{
|
||||
RaiseLocalEvent(receiver.Provider.Owner.Uid, new ReceiverDisconnectedEvent(receiver), broadcast: false);
|
||||
RaiseLocalEvent(receiver.Provider.Owner, new ReceiverDisconnectedEvent(receiver), broadcast: false);
|
||||
receiver.Provider.LinkedReceivers.Remove(receiver);
|
||||
}
|
||||
|
||||
@@ -170,8 +170,8 @@ namespace Content.Server.Power.EntitySystems
|
||||
|
||||
receiver.Provider = provider;
|
||||
provider.LinkedReceivers.Add(receiver);
|
||||
RaiseLocalEvent(receiver.Owner.Uid, new ProviderConnectedEvent(provider), broadcast: false);
|
||||
RaiseLocalEvent(provider.Owner.Uid, new ReceiverConnectedEvent(receiver), broadcast: false);
|
||||
RaiseLocalEvent(receiver.Owner, new ProviderConnectedEvent(provider), broadcast: false);
|
||||
RaiseLocalEvent(provider.Owner, new ReceiverConnectedEvent(receiver), broadcast: false);
|
||||
}
|
||||
|
||||
private static bool TryFindAvailableProvider(IEntity owner, float range, [NotNullWhen(true)] out ExtensionCableProviderComponent? foundProvider)
|
||||
@@ -181,11 +181,11 @@ namespace Content.Server.Power.EntitySystems
|
||||
|
||||
foreach (var entity in nearbyEntities)
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ExtensionCableProviderComponent?>(entity.Uid, out var provider)) continue;
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ExtensionCableProviderComponent?>(entity, out var provider)) continue;
|
||||
|
||||
if (!provider.Connectable) continue;
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity.Uid).Coordinates.TryDistance(IoCManager.Resolve<IEntityManager>(), IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(owner.Uid).Coordinates, out var distance)) continue;
|
||||
if (!IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates.TryDistance(IoCManager.Resolve<IEntityManager>(), IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(owner).Coordinates, out var distance)) continue;
|
||||
|
||||
if (!(distance < Math.Min(range, provider.TransferRange))) continue;
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ namespace Content.Server.Power.EntitySystems
|
||||
{
|
||||
lastRecv = newRecv;
|
||||
var msg = new PowerConsumerReceivedChanged(newRecv, consumer.DrawRate);
|
||||
RaiseLocalEvent(consumer.Owner.Uid, msg);
|
||||
RaiseLocalEvent(consumer.Owner, msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,11 +285,11 @@ namespace Content.Server.Power.EntitySystems
|
||||
|
||||
if (lastPowerSupply == 0f && currentSupply != 0f)
|
||||
{
|
||||
RaiseLocalEvent(powerNetBattery.Owner.Uid, new PowerNetBatterySupplyEvent {Supply = true});
|
||||
RaiseLocalEvent(powerNetBattery.Owner, new PowerNetBatterySupplyEvent {Supply = true});
|
||||
}
|
||||
else if (lastPowerSupply > 0f && currentSupply == 0f)
|
||||
{
|
||||
RaiseLocalEvent(powerNetBattery.Owner.Uid, new PowerNetBatterySupplyEvent {Supply = false});
|
||||
RaiseLocalEvent(powerNetBattery.Owner, new PowerNetBatterySupplyEvent {Supply = false});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ namespace Content.Server.Power.EntitySystems
|
||||
|
||||
foreach (var apc in net.Apcs)
|
||||
{
|
||||
var netBattery = IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(apc.Owner.Uid);
|
||||
var netBattery = IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(apc.Owner);
|
||||
netNode.BatteriesDischarging.Add(netBattery.NetworkBattery.Id);
|
||||
netBattery.NetworkBattery.LinkedNetworkDischarging = netNode.Id;
|
||||
}
|
||||
@@ -372,14 +372,14 @@ namespace Content.Server.Power.EntitySystems
|
||||
|
||||
foreach (var charger in net.Chargers)
|
||||
{
|
||||
var battery = IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(charger.Owner.Uid);
|
||||
var battery = IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(charger.Owner);
|
||||
netNode.BatteriesCharging.Add(battery.NetworkBattery.Id);
|
||||
battery.NetworkBattery.LinkedNetworkCharging = netNode.Id;
|
||||
}
|
||||
|
||||
foreach (var discharger in net.Dischargers)
|
||||
{
|
||||
var battery = IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(discharger.Owner.Uid);
|
||||
var battery = IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(discharger.Owner);
|
||||
netNode.BatteriesDischarging.Add(battery.NetworkBattery.Id);
|
||||
battery.NetworkBattery.LinkedNetworkDischarging = netNode.Id;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Content.Server.Power.EntitySystems
|
||||
|
||||
private void OnProviderConnected(EntityUid uid, ApcPowerReceiverComponent receiver, ExtensionCableSystem.ProviderConnectedEvent args)
|
||||
{
|
||||
var providerUid = args.Provider.Owner.Uid;
|
||||
var providerUid = (EntityUid) args.Provider.Owner;
|
||||
if (!EntityManager.TryGetComponent<ApcPowerProviderComponent>(providerUid, out var provider))
|
||||
return;
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Content.Server.Power.EntitySystems
|
||||
|
||||
private void OnReceiverConnected(EntityUid uid, ApcPowerProviderComponent provider, ExtensionCableSystem.ReceiverConnectedEvent args)
|
||||
{
|
||||
if (EntityManager.TryGetComponent(args.Receiver.Owner.Uid, out ApcPowerReceiverComponent receiver))
|
||||
if (EntityManager.TryGetComponent(args.Receiver.Owner, out ApcPowerReceiverComponent receiver))
|
||||
{
|
||||
provider.AddReceiver(receiver);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ namespace Content.Server.Power.EntitySystems
|
||||
|
||||
private void OnReceiverDisconnected(EntityUid uid, ApcPowerProviderComponent provider, ExtensionCableSystem.ReceiverDisconnectedEvent args)
|
||||
{
|
||||
if (EntityManager.TryGetComponent(args.Receiver.Owner.Uid, out ApcPowerReceiverComponent receiver))
|
||||
if (EntityManager.TryGetComponent(args.Receiver.Owner, out ApcPowerReceiverComponent receiver))
|
||||
{
|
||||
provider.RemoveReceiver(receiver);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Content.Server.Power.NodeGroups
|
||||
|
||||
public void AddApc(ApcComponent apc)
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(apc.Owner.Uid, out PowerNetworkBatteryComponent? netBattery))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(apc.Owner, out PowerNetworkBatteryComponent? netBattery))
|
||||
netBattery.NetworkBattery.LinkedNetworkDischarging = default;
|
||||
|
||||
QueueNetworkReconnect();
|
||||
@@ -76,7 +76,7 @@ namespace Content.Server.Power.NodeGroups
|
||||
|
||||
public void RemoveApc(ApcComponent apc)
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(apc.Owner.Uid, out PowerNetworkBatteryComponent? netBattery))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(apc.Owner, out PowerNetworkBatteryComponent? netBattery))
|
||||
netBattery.NetworkBattery.LinkedNetworkDischarging = default;
|
||||
|
||||
QueueNetworkReconnect();
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Content.Server.Power.NodeGroups
|
||||
|
||||
foreach (var node in groupNodes)
|
||||
{
|
||||
var newNetConnectorComponents = IoCManager.Resolve<IEntityManager>().GetComponents<IBaseNetConnectorComponent<TNetType>>(node.Owner.Uid)
|
||||
var newNetConnectorComponents = IoCManager.Resolve<IEntityManager>().GetComponents<IBaseNetConnectorComponent<TNetType>>(node.Owner)
|
||||
.Where(powerComp => (powerComp.NodeId == null || powerComp.NodeId == node.Name) &&
|
||||
(NodeGroupID) powerComp.Voltage == node.NodeGroupID)
|
||||
.ToList();
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Content.Server.Power.NodeGroups
|
||||
|
||||
public void AddDischarger(BatteryDischargerComponent discharger)
|
||||
{
|
||||
var battery = IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(discharger.Owner.Uid);
|
||||
var battery = IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(discharger.Owner);
|
||||
battery.NetworkBattery.LinkedNetworkCharging = default;
|
||||
Dischargers.Add(discharger);
|
||||
_powerNetSystem.QueueReconnectPowerNet(this);
|
||||
@@ -100,7 +100,7 @@ namespace Content.Server.Power.NodeGroups
|
||||
public void RemoveDischarger(BatteryDischargerComponent discharger)
|
||||
{
|
||||
// Can be missing if the entity is being deleted, not a big deal.
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(discharger.Owner.Uid, out PowerNetworkBatteryComponent? battery))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(discharger.Owner, out PowerNetworkBatteryComponent? battery))
|
||||
battery.NetworkBattery.LinkedNetworkCharging = default;
|
||||
|
||||
Dischargers.Remove(discharger);
|
||||
@@ -109,7 +109,7 @@ namespace Content.Server.Power.NodeGroups
|
||||
|
||||
public void AddCharger(BatteryChargerComponent charger)
|
||||
{
|
||||
var battery = IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(charger.Owner.Uid);
|
||||
var battery = IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(charger.Owner);
|
||||
battery.NetworkBattery.LinkedNetworkCharging = default;
|
||||
Chargers.Add(charger);
|
||||
_powerNetSystem.QueueReconnectPowerNet(this);
|
||||
@@ -118,7 +118,7 @@ namespace Content.Server.Power.NodeGroups
|
||||
public void RemoveCharger(BatteryChargerComponent charger)
|
||||
{
|
||||
// Can be missing if the entity is being deleted, not a big deal.
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(charger.Owner.Uid, out PowerNetworkBatteryComponent? battery))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(charger.Owner, out PowerNetworkBatteryComponent? battery))
|
||||
battery.NetworkBattery.LinkedNetworkCharging = default;
|
||||
|
||||
Chargers.Remove(charger);
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace Content.Server.Power.Nodes
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
// If we're in an invalid grid, such as grid 0, we cannot connect to anything.
|
||||
if(!IoCManager.Resolve<IMapManager>().TryGetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).GridID, out var grid))
|
||||
if(!IoCManager.Resolve<IMapManager>().TryGetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).GridID, out var grid))
|
||||
yield break;
|
||||
|
||||
var gridIndex = grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates);
|
||||
var gridIndex = grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
|
||||
foreach (var node in NodeHelpers.GetNodesInTile(entMan, grid, gridIndex))
|
||||
{
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace Content.Server.Power.Nodes
|
||||
yield break;
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
var grid = IoCManager.Resolve<IMapManager>().GetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).GridID);
|
||||
var gridIndex = grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates);
|
||||
var grid = IoCManager.Resolve<IMapManager>().GetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).GridID);
|
||||
var gridIndex = grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
|
||||
// While we go over adjacent nodes, we build a list of blocked directions due to
|
||||
// incoming or outgoing wire terminals.
|
||||
@@ -44,11 +44,11 @@ namespace Content.Server.Power.Nodes
|
||||
if (dir == Direction.Invalid)
|
||||
{
|
||||
// On own tile, block direction it faces
|
||||
terminalDirs |= 1 << (int) IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(node.Owner.Uid).LocalRotation.GetCardinalDir();
|
||||
terminalDirs |= 1 << (int) IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(node.Owner).LocalRotation.GetCardinalDir();
|
||||
}
|
||||
else
|
||||
{
|
||||
var terminalDir = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(node.Owner.Uid).LocalRotation.GetCardinalDir();
|
||||
var terminalDir = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(node.Owner).LocalRotation.GetCardinalDir();
|
||||
if (terminalDir.GetOpposite() == dir)
|
||||
{
|
||||
// Target tile has a terminal towards us, block the direction.
|
||||
@@ -73,7 +73,7 @@ namespace Content.Server.Power.Nodes
|
||||
{
|
||||
base.OnPostRebuild();
|
||||
|
||||
EntitySystem.Get<CableVisSystem>().QueueUpdate(Owner.Uid);
|
||||
EntitySystem.Get<CableVisSystem>().QueueUpdate(Owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,15 +12,15 @@ namespace Content.Server.Power.Nodes
|
||||
{
|
||||
public override IEnumerable<Node> GetReachableNodes()
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).GridID == GridId.Invalid)
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).GridID == GridId.Invalid)
|
||||
yield break; // No funny nodes in spess.
|
||||
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
var grid = IoCManager.Resolve<IMapManager>().GetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).GridID);
|
||||
var gridIndex = grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates);
|
||||
var grid = IoCManager.Resolve<IMapManager>().GetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).GridID);
|
||||
var gridIndex = grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
|
||||
var dir = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).LocalRotation.GetDir();
|
||||
var dir = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).LocalRotation.GetDir();
|
||||
var targetIdx = gridIndex + NodeHelpers.TileOffsetForDir(dir);
|
||||
|
||||
foreach (var node in NodeHelpers.GetNodesInTile(entMan, grid, targetIdx))
|
||||
|
||||
@@ -12,12 +12,12 @@ namespace Content.Server.Power.Nodes
|
||||
{
|
||||
public override IEnumerable<Node> GetReachableNodes()
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).GridID == GridId.Invalid)
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).GridID == GridId.Invalid)
|
||||
yield break; // No funny nodes in spess.
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
var grid = IoCManager.Resolve<IMapManager>().GetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).GridID);
|
||||
var gridIndex = grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates);
|
||||
var grid = IoCManager.Resolve<IMapManager>().GetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).GridID);
|
||||
var gridIndex = grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
|
||||
var nodes = NodeHelpers.GetCardinalNeighborNodes(entMan, grid, gridIndex, includeSameTile: false);
|
||||
foreach (var (_, node) in nodes)
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Content.Server.Power.SMES
|
||||
_lastChargeLevel = newLevel;
|
||||
_lastChargeLevelChange = _gameTiming.CurTime;
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance))
|
||||
{
|
||||
appearance.SetData(SmesVisuals.LastChargeLevel, newLevel);
|
||||
}
|
||||
@@ -59,7 +59,7 @@ namespace Content.Server.Power.SMES
|
||||
_lastChargeState = newChargeState;
|
||||
_lastChargeStateChange = _gameTiming.CurTime;
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance))
|
||||
{
|
||||
appearance.SetData(SmesVisuals.LastChargeState, newChargeState);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ namespace Content.Server.Power.SMES
|
||||
|
||||
private int GetNewChargeLevel()
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out BatteryComponent? battery))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out BatteryComponent? battery))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ namespace Content.Server.Power.SMES
|
||||
|
||||
private ChargeState GetNewChargeState()
|
||||
{
|
||||
var battery = IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(Owner.Uid);
|
||||
var battery = IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(Owner);
|
||||
return (battery.CurrentSupply - battery.CurrentReceiving) switch
|
||||
{
|
||||
> 0 => ChargeState.Discharging,
|
||||
|
||||
Reference in New Issue
Block a user