Inline UID

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 15:53:09 +01:00
parent 2654775bf0
commit 5cd42c9ad6
803 changed files with 3613 additions and 3577 deletions

View File

@@ -60,7 +60,7 @@ namespace Content.Server.Light.Components
/// </summary>
public void UpdateState()
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver))
{
return;
}
@@ -80,7 +80,7 @@ namespace Content.Server.Light.Components
public void OnUpdate(float frameTime)
{
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(Owner.Uid) || !IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out BatteryComponent? battery) || IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityPaused))
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(Owner) || !IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out BatteryComponent? battery) || IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityPaused))
{
return;
}
@@ -98,7 +98,7 @@ namespace Content.Server.Light.Components
battery.CurrentCharge += _chargingWattage * frameTime * _chargingEfficiency;
if (battery.IsFullyCharged)
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver))
{
receiver.Load = 1;
}
@@ -110,23 +110,23 @@ namespace Content.Server.Light.Components
private void TurnOff()
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out PointLightComponent? light))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out PointLightComponent? light))
{
light.Enabled = false;
}
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance))
appearance.SetData(EmergencyLightVisuals.On, false);
}
private void TurnOn()
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out PointLightComponent? light))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out PointLightComponent? light))
{
light.Enabled = true;
}
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance))
appearance.SetData(EmergencyLightVisuals.On, true);
}

View File

@@ -36,14 +36,14 @@ namespace Content.Server.Light.Components
{
base.Initialize();
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<ItemComponent?>(Owner.Uid, out var item))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<ItemComponent?>(Owner, out var item))
{
item.EquippedPrefix = "unlit";
}
CurrentState = ExpendableLightState.BrandNew;
Owner.EnsureComponent<PointLightComponent>();
IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out _appearance);
IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out _appearance);
}
/// <summary>
@@ -53,7 +53,7 @@ namespace Content.Server.Light.Components
{
if (!Activated && CurrentState == ExpendableLightState.BrandNew)
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<ItemComponent?>(Owner.Uid, out var item))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<ItemComponent?>(Owner, out var item))
{
item.EquippedPrefix = "lit";
}
@@ -92,7 +92,7 @@ namespace Content.Server.Light.Components
private void UpdateSpriteAndSounds(bool on)
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out SpriteComponent? sprite))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out SpriteComponent? sprite))
{
switch (CurrentState)
{
@@ -126,7 +126,7 @@ namespace Content.Server.Light.Components
}
}
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ClothingComponent? clothing))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ClothingComponent? clothing))
{
clothing.ClothingEquippedPrefix = on ? "Activated" : string.Empty;
}
@@ -155,13 +155,13 @@ namespace Content.Server.Light.Components
case ExpendableLightState.Fading:
CurrentState = ExpendableLightState.Dead;
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityName = SpentName;
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityDescription = SpentDesc;
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityName = SpentName;
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityDescription = SpentDesc;
UpdateSpriteAndSounds(Activated);
UpdateVisualizer();
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<ItemComponent?>(Owner.Uid, out var item))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<ItemComponent?>(Owner, out var item))
{
item.EquippedPrefix = "unlit";
}

View File

@@ -77,7 +77,7 @@ namespace Content.Server.Light.Components
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
{
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(eventArgs.User.Uid)) return false;
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(eventArgs.User)) return false;
if (!_cellSlot.InsertCell(eventArgs.Using)) return false;
Dirty();
return true;
@@ -106,7 +106,7 @@ namespace Content.Server.Light.Components
/// <returns>True if the light's status was toggled, false otherwise.</returns>
public bool ToggleStatus(IEntity user)
{
if (!EntitySystem.Get<ActionBlockerSystem>().CanUse(user.Uid)) return false;
if (!EntitySystem.Get<ActionBlockerSystem>().CanUse(user)) return false;
return Activated ? TurnOff() : TurnOn(user);
}
@@ -167,22 +167,22 @@ namespace Content.Server.Light.Components
private void SetState(bool on)
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out SpriteComponent? sprite))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out SpriteComponent? sprite))
{
sprite.LayerSetVisible(1, on);
}
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out PointLightComponent? light))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out PointLightComponent? light))
{
light.Enabled = on;
}
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ClothingComponent? clothing))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ClothingComponent? clothing))
{
clothing.ClothingEquippedPrefix = Loc.GetString(on ? "on" : "off");
}
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ItemComponent? item))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ItemComponent? item))
{
item.EquippedPrefix = Loc.GetString(on ? "on" : "off");
}
@@ -201,7 +201,7 @@ namespace Content.Server.Light.Components
return;
}
var appearanceComponent = IoCManager.Resolve<IEntityManager>().GetComponent<AppearanceComponent>(Owner.Uid);
var appearanceComponent = IoCManager.Resolve<IEntityManager>().GetComponent<AppearanceComponent>(Owner);
if (Cell.MaxCharge - Cell.CurrentCharge < Cell.MaxCharge * 0.70)
{
@@ -254,7 +254,7 @@ namespace Content.Server.Light.Components
{
public bool DoToggleAction(ToggleItemActionEventArgs args)
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<HandheldLightComponent?>(args.Item.Uid, out var lightComponent)) return false;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<HandheldLightComponent?>(args.Item, out var lightComponent)) return false;
if (lightComponent.Activated == args.ToggledOn) return false;
return lightComponent.ToggleStatus(args.Performer);
}

View File

@@ -39,7 +39,7 @@ namespace Content.Server.Light.Components
public void OnBreak(BreakageEventArgs eventArgs)
{
EntitySystem.Get<LightBulbSystem>()
.SetState(Owner.Uid, LightBulbState.Broken, this);
.SetState(Owner, LightBulbState.Broken, this);
}
}
}

View File

@@ -44,20 +44,20 @@ namespace Content.Server.Light.EntitySystems
return;
// standard interaction checks
if (!_blocker.CanUse(eventArgs.User.Uid)) return;
if (!_blocker.CanUse(eventArgs.User)) return;
if (!eventArgs.CanReach) return;
// behaviour will depends on target type
if (eventArgs.Target != null)
{
var targetUid = eventArgs.Target.Uid;
var targetUid = (EntityUid) eventArgs.Target;
// replace broken light in fixture?
if (EntityManager.TryGetComponent(targetUid, out PoweredLightComponent? fixture))
eventArgs.Handled = TryReplaceBulb(uid, targetUid, eventArgs.User.Uid, component, fixture);
eventArgs.Handled = TryReplaceBulb(uid, targetUid, eventArgs.User, component, fixture);
// add new bulb to light replacer container?
else if (EntityManager.TryGetComponent(targetUid, out LightBulbComponent? bulb))
eventArgs.Handled = TryInsertBulb(uid, targetUid, eventArgs.User.Uid, true, component, bulb);
eventArgs.Handled = TryInsertBulb(uid, targetUid, eventArgs.User, true, component, bulb);
}
}
@@ -67,18 +67,18 @@ namespace Content.Server.Light.EntitySystems
return;
// standard interaction checks
if (!_blocker.CanInteract(eventArgs.User.Uid)) return;
if (!_blocker.CanInteract(eventArgs.User)) return;
if (eventArgs.Used != null)
{
var usedUid = eventArgs.Used.Uid;
var usedUid = (EntityUid) eventArgs.Used;
// want to insert a new light bulb?
if (EntityManager.TryGetComponent(usedUid, out LightBulbComponent ? bulb))
eventArgs.Handled = TryInsertBulb(uid, usedUid, eventArgs.User.Uid, true, component, bulb);
eventArgs.Handled = TryInsertBulb(uid, usedUid, eventArgs.User, true, component, bulb);
// add bulbs from storage?
else if (EntityManager.TryGetComponent(usedUid, out ServerStorageComponent? storage))
eventArgs.Handled = TryInsertBulbsFromStorage(uid, usedUid, eventArgs.User.Uid, component, storage);
eventArgs.Handled = TryInsertBulbsFromStorage(uid, usedUid, eventArgs.User, component, storage);
}
}
@@ -96,7 +96,7 @@ namespace Content.Server.Light.EntitySystems
return false;
// check if light bulb is broken or missing
var fixtureBulbUid = _poweredLight.GetBulb(fixture.Owner.Uid, fixture);
var fixtureBulbUid = _poweredLight.GetBulb(fixture.Owner, fixture);
if (fixtureBulbUid != null)
{
if (!EntityManager.TryGetComponent(fixtureBulbUid.Value, out LightBulbComponent? fixtureBulb))
@@ -107,7 +107,7 @@ namespace Content.Server.Light.EntitySystems
// try get first inserted bulb of the same type as targeted light fixtutre
var bulb = replacer.InsertedBulbs.ContainedEntities.FirstOrDefault(
(e) => IoCManager.Resolve<IEntityManager>().GetComponentOrNull<LightBulbComponent>(e.Uid)?.Type == fixture.BulbType);
(e) => IoCManager.Resolve<IEntityManager>().GetComponentOrNull<LightBulbComponent>(e)?.Type == fixture.BulbType);
// found bulb in inserted storage
if (bulb != null)
@@ -125,7 +125,7 @@ namespace Content.Server.Light.EntitySystems
// found right bulb, let's spawn it
if (bulbEnt != null)
{
bulb = EntityManager.SpawnEntity(bulbEnt.PrototypeName, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(replacer.Owner.Uid).Coordinates);
bulb = EntityManager.SpawnEntity(bulbEnt.PrototypeName, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(replacer.Owner).Coordinates);
bulbEnt.Amount--;
}
// not found any light bulbs
@@ -142,7 +142,7 @@ namespace Content.Server.Light.EntitySystems
}
// insert it into fixture
var wasReplaced = _poweredLight.ReplaceBulb(fixtureUid, bulb.Uid, fixture);
var wasReplaced = _poweredLight.ReplaceBulb(fixtureUid, bulb, fixture);
if (wasReplaced)
{
SoundSystem.Play(Filter.Pvs(replacerUid), replacer.Sound.GetSound(),
@@ -211,9 +211,9 @@ namespace Content.Server.Light.EntitySystems
var storagedEnts = storage.StoredEntities.ToArray();
foreach (var ent in storagedEnts)
{
if (EntityManager.TryGetComponent(ent.Uid, out LightBulbComponent? bulb))
if (EntityManager.TryGetComponent(ent, out LightBulbComponent? bulb))
{
if (TryInsertBulb(replacerUid, ent.Uid, userUid, false, replacer, bulb))
if (TryInsertBulb(replacerUid, ent, userUid, false, replacer, bulb))
insertedBulbs++;
}
}

View File

@@ -17,7 +17,7 @@ namespace Content.Server.Light.EntitySystems
private void OnInteractUsing(EntityUid uid, MatchboxComponent component, InteractUsingEvent args)
{
if (!args.Handled
&& IoCManager.Resolve<IEntityManager>().TryGetComponent<MatchstickComponent?>(args.Used.Uid, out var matchstick)
&& IoCManager.Resolve<IEntityManager>().TryGetComponent<MatchstickComponent?>(args.Used, out var matchstick)
&& matchstick.CurrentState == SmokableState.Unlit)
{
Get<MatchstickSystem>().Ignite(matchstick, args.User);

View File

@@ -34,7 +34,7 @@ namespace Content.Server.Light.EntitySystems
if (match.CurrentState != SmokableState.Lit)
continue;
_atmosphereSystem.HotspotExpose(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(match.Owner.Uid).Coordinates, 400, 50, true);
_atmosphereSystem.HotspotExpose(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(match.Owner).Coordinates, 400, 50, true);
}
}
@@ -44,7 +44,7 @@ namespace Content.Server.Light.EntitySystems
return;
var isHotEvent = new IsHotEvent();
RaiseLocalEvent(args.Used.Uid, isHotEvent, false);
RaiseLocalEvent(args.Used, isHotEvent, false);
if (!isHotEvent.IsHot)
return;
@@ -84,7 +84,7 @@ namespace Content.Server.Light.EntitySystems
component.PointLightComponent.Enabled = component.CurrentState == SmokableState.Lit;
}
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out ItemComponent? item))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out ItemComponent? item))
{
switch (component.CurrentState)
{
@@ -97,7 +97,7 @@ namespace Content.Server.Light.EntitySystems
}
}
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out AppearanceComponent? appearance))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out AppearanceComponent? appearance))
{
appearance.SetData(SmokingVisuals.Smoking, component.CurrentState);
}

View File

@@ -75,7 +75,7 @@ namespace Content.Server.Light.EntitySystems
_ => throw new ArgumentOutOfRangeException()
};
var entity = EntityManager.SpawnEntity(prototype, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(light.Owner.Uid).Coordinates);
var entity = EntityManager.SpawnEntity(prototype, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(light.Owner).Coordinates);
light.LightBulbContainer.Insert(entity);
}
@@ -88,7 +88,7 @@ namespace Content.Server.Light.EntitySystems
if (args.Handled)
return;
args.Handled = InsertBulb(uid, args.Used.Uid, component);
args.Handled = InsertBulb(uid, args.Used, component);
}
private void OnInteractHand(EntityUid uid, PoweredLightComponent light, InteractHandEvent args)
@@ -102,7 +102,7 @@ namespace Content.Server.Light.EntitySystems
return;
// check if it's possible to apply burn damage to user
var userUid = args.User.Uid;
var userUid = (EntityUid) args.User;
if (EntityManager.TryGetComponent(userUid, out HeatResistanceComponent? heatResist) &&
EntityManager.TryGetComponent(bulbUid.Value, out LightBulbComponent? lightBulb))
{
@@ -213,7 +213,7 @@ namespace Content.Server.Light.EntitySystems
if (!Resolve(uid, ref light))
return null;
return light.LightBulbContainer.ContainedEntity?.Uid;
return light.LightBulbContainer.ContainedEntity;
}
/// <summary>
@@ -340,7 +340,7 @@ namespace Content.Server.Light.EntitySystems
light.IsBlinking = isNowBlinking;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(light.Owner.Uid, out AppearanceComponent? appearance))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(light.Owner, out AppearanceComponent? appearance))
return;
appearance.SetData(PoweredLightVisuals.Blinking, isNowBlinking);
}

View File

@@ -37,18 +37,18 @@ namespace Content.Server.Light.EntitySystems
public void ToggleLight(UnpoweredFlashlightComponent flashlight)
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(flashlight.Owner.Uid, out PointLightComponent? light))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(flashlight.Owner, out PointLightComponent? light))
return;
flashlight.LightOn = !flashlight.LightOn;
light.Enabled = flashlight.LightOn;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(flashlight.Owner.Uid, out AppearanceComponent? appearance))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(flashlight.Owner, out AppearanceComponent? appearance))
appearance.SetData(UnpoweredFlashlightVisuals.LightOn, flashlight.LightOn);
SoundSystem.Play(Filter.Pvs(light.Owner), flashlight.ToggleSound.GetSound(), flashlight.Owner);
RaiseLocalEvent(flashlight.Owner.Uid, new LightToggleEvent(flashlight.LightOn));
RaiseLocalEvent(flashlight.Owner, new LightToggleEvent(flashlight.LightOn));
}
}