else
{
var request = new RequestPerformActionEvent(GetNetEntity(action));
- EntityManager.RaisePredictiveEvent(request);
+ RaisePredictiveEvent(request);
}
}
_targetTime = _gameTiming.CurTime + TimeSpan.FromSeconds(_cooldown);
var player = _playerManager.LocalEntity;
- if (!EntityManager.TryGetComponent(player, out TransformComponent? xform))
+ if (!TryComp(player, out TransformComponent? xform))
{
ClearSounds();
return;
if (!CheckConstructionConditions(prototype, loc, dir, user, showPopup: true))
return false;
- ghost = EntityManager.SpawnEntity("constructionghost", loc);
- var comp = EntityManager.GetComponent<ConstructionGhostComponent>(ghost.Value);
+ ghost = Spawn("constructionghost", loc);
+ var comp = Comp<ConstructionGhostComponent>(ghost.Value);
comp.Prototype = prototype;
comp.GhostId = ghost.GetHashCode();
- EntityManager.GetComponent<TransformComponent>(ghost.Value).LocalRotation = dir.ToAngle();
+ Comp<TransformComponent>(ghost.Value).LocalRotation = dir.ToAngle();
_ghosts.Add(comp.GhostId, ghost.Value);
- var sprite = EntityManager.GetComponent<SpriteComponent>(ghost.Value);
+ var sprite = Comp<SpriteComponent>(ghost.Value);
_sprite.SetColor((ghost.Value, sprite), new Color(48, 255, 48, 128));
if (targetProto.TryGetComponent(out IconComponent? icon, EntityManager.ComponentFactory))
else if (targetProto.Components.TryGetValue("Sprite", out _))
{
var dummy = EntityManager.SpawnEntity(targetProtoId, MapCoordinates.Nullspace);
- var targetSprite = EntityManager.EnsureComponent<SpriteComponent>(dummy);
+ var targetSprite = EnsureComp<SpriteComponent>(dummy);
EntityManager.System<AppearanceSystem>().OnChangeData(dummy, targetSprite);
for (var i = 0; i < targetSprite.AllLayers.Count(); i++)
_sprite.LayerSetVisible((ghost.Value, sprite), i, true);
}
- EntityManager.DeleteEntity(dummy);
+ Del(dummy);
}
else
return false;
{
foreach (var ghost in _ghosts)
{
- if (EntityManager.GetComponent<TransformComponent>(ghost.Value).Coordinates.Equals(loc))
+ if (Comp<TransformComponent>(ghost.Value).Coordinates.Equals(loc))
return true;
}
throw new ArgumentException($"Can't start construction for a ghost with no prototype. Ghost id: {ghostId}");
}
- var transform = EntityManager.GetComponent<TransformComponent>(ghostId);
+ var transform = Comp<TransformComponent>(ghostId);
var msg = new TryStartStructureConstructionMessage(GetNetCoordinates(transform.Coordinates), ghostComp.Prototype.ID, transform.LocalRotation, ghostId.GetHashCode());
RaiseNetworkEvent(msg);
}
if (!_ghosts.TryGetValue(ghostId, out var ghost))
return;
- EntityManager.QueueDeleteEntity(ghost);
+ QueueDel(ghost);
_ghosts.Remove(ghostId);
}
{
foreach (var ghost in _ghosts.Values)
{
- EntityManager.QueueDeleteEntity(ghost);
+ QueueDel(ghost);
}
_ghosts.Clear();
{
var entity = args.EntityUid;
- if (!args.EntityUid.IsValid() || !EntityManager.EntityExists(entity))
+ if (!args.EntityUid.IsValid() || !Exists(entity))
{
return false;
}
vBox.AddChild(hBox);
- if (EntityManager.HasComponent<SpriteComponent>(target))
+ if (HasComp<SpriteComponent>(target))
{
var spriteView = new SpriteView
{
private void OnProximityInit(EntityUid uid, TriggerOnProximityComponent component, ComponentInit args)
{
- EntityManager.EnsureComponent<AnimationPlayerComponent>(uid);
+ EnsureComp<AnimationPlayerComponent>(uid);
}
private void OnProxAppChange(EntityUid uid, TriggerOnProximityComponent component, ref AppearanceChangeEvent args)
{
// use item in hand
// it will always be attack_self() in my heart.
- EntityManager.RaisePredictiveEvent(new RequestUseInHandEvent());
+ RaisePredictiveEvent(new RequestUseInHandEvent());
return;
}
if (handName != hands.ActiveHandId && pressedEntity == null)
{
// change active hand
- EntityManager.RaisePredictiveEvent(new RequestSetHandEvent(handName));
+ RaisePredictiveEvent(new RequestSetHandEvent(handName));
return;
}
if (handName != hands.ActiveHandId && pressedEntity != null && activeEntity != null)
{
// use active item on held item
- EntityManager.RaisePredictiveEvent(new RequestHandInteractUsingEvent(handName));
+ RaisePredictiveEvent(new RequestHandInteractUsingEvent(handName));
return;
}
if (handName != hands.ActiveHandId && pressedEntity != null && activeEntity == null)
{
// move the item to the active hand
- EntityManager.RaisePredictiveEvent(new RequestMoveHandItemEvent(handName));
+ RaisePredictiveEvent(new RequestMoveHandItemEvent(handName));
}
}
/// </summary>
public void UIHandActivate(string handName)
{
- EntityManager.RaisePredictiveEvent(new RequestActivateInHandEvent(handName));
+ RaisePredictiveEvent(new RequestActivateInHandEvent(handName));
}
public void UIInventoryExamine(string handName)
private void OnCvarChanged(bool value)
{
- var humanoidQuery = EntityManager.AllEntityQueryEnumerator<HumanoidAppearanceComponent, SpriteComponent>();
+ var humanoidQuery = AllEntityQuery<HumanoidAppearanceComponent, SpriteComponent>();
while (humanoidQuery.MoveNext(out var uid, out var humanoidComp, out var spriteComp))
{
UpdateSprite((uid, humanoidComp, spriteComp));
public void UIInventoryActivate(string slot)
{
- EntityManager.RaisePredictiveEvent(new UseSlotNetworkMessage(slot));
+ RaisePredictiveEvent(new UseSlotNetworkMessage(slot));
}
public void UIInventoryStorageActivate(string slot)
{
- EntityManager.RaisePredictiveEvent(new OpenSlotStorageNetworkMessage(slot));
+ RaisePredictiveEvent(new OpenSlotStorageNetworkMessage(slot));
}
public void UIInventoryExamine(string slot, EntityUid uid)
if (!TryGetSlotEntity(uid, slot, out var item))
return;
- EntityManager.RaisePredictiveEvent(
+ RaisePredictiveEvent(
new InteractInventorySlotEvent(GetNetEntity(item.Value), altInteract: false));
}
if (!TryGetSlotEntity(uid, slot, out var item))
return;
- EntityManager.RaisePredictiveEvent(new InteractInventorySlotEvent(GetNetEntity(item.Value), altInteract: true));
+ RaisePredictiveEvent(new InteractInventorySlotEvent(GetNetEntity(item.Value), altInteract: true));
}
protected override void UpdateInventoryTemplate(Entity<InventoryComponent> ent)
/// </summary>
private void CopyLightSettings(Entity<LightBehaviourComponent> entity, string property)
{
- if (EntityManager.TryGetComponent(entity, out PointLightComponent? light))
+ if (TryComp(entity, out PointLightComponent? light))
{
var propertyValue = AnimationHelper.GetAnimatableProperty(light, property);
if (propertyValue != null)
}
else
{
- Log.Warning($"{EntityManager.GetComponent<MetaDataComponent>(entity).EntityName} has a {nameof(LightBehaviourComponent)} but it has no {nameof(PointLightComponent)}! Check the prototype!");
+ Log.Warning($"{Comp<MetaDataComponent>(entity).EntityName} has a {nameof(LightBehaviourComponent)} but it has no {nameof(PointLightComponent)}! Check the prototype!");
}
}
/// </summary>
public void StartLightBehaviour(Entity<LightBehaviourComponent> entity, string id = "")
{
- if (!EntityManager.TryGetComponent(entity, out AnimationPlayerComponent? animation))
+ if (!TryComp(entity, out AnimationPlayerComponent? animation))
{
return;
}
/// <param name="resetToOriginalSettings">Should the light have its original settings applied?</param>
public void StopLightBehaviour(Entity<LightBehaviourComponent> entity, string id = "", bool removeBehaviour = false, bool resetToOriginalSettings = false)
{
- if (!EntityManager.TryGetComponent(entity, out AnimationPlayerComponent? animation))
+ if (!TryComp(entity, out AnimationPlayerComponent? animation))
{
return;
}
comp.Animations.Remove(container);
}
- if (resetToOriginalSettings && EntityManager.TryGetComponent(entity, out PointLightComponent? light))
+ if (resetToOriginalSettings && TryComp(entity, out PointLightComponent? light))
{
foreach (var (property, value) in comp.OriginalPropertyValues)
{
public bool HasRunningBehaviours(Entity<LightBehaviourComponent> entity)
{
//var uid = Owner;
- if (!EntityManager.TryGetComponent(entity, out AnimationPlayerComponent? animation))
+ if (!TryComp(entity, out AnimationPlayerComponent? animation))
{
return false;
}
private void UpdateVisibility(EntityUid uid)
{
- if (EntityManager.TryGetComponent(uid, out SpriteComponent? sprite))
+ if (TryComp(uid, out SpriteComponent? sprite))
{
_sprite.SetVisible((uid, sprite), MarkersVisible);
}
{
base.FrameUpdate(frameTime);
- var query = EntityManager.EntityQueryEnumerator<OrbitVisualsComponent, SpriteComponent>();
+ var query = EntityQueryEnumerator<OrbitVisualsComponent, SpriteComponent>();
while (query.MoveNext(out var uid, out var orbit, out var sprite))
{
var progress = (float)(_timing.CurTime.TotalSeconds / orbit.OrbitLength) % 1;
// Try copy entity.
if (uid.IsValid()
- && EntityManager.TryGetComponent(uid, out MetaDataComponent? comp)
+ && TryComp(uid, out MetaDataComponent? comp)
&& !comp.EntityDeleted)
{
if (comp.EntityPrototype == null || comp.EntityPrototype.HideSpawnMenu || comp.EntityPrototype.Abstract)
// Get the camera entity that the server has created for us
var camera = GetEntity(msg.CameraUid);
- if (!EntityManager.TryGetComponent<EyeComponent>(camera, out var eyeComponent))
+ if (!TryComp<EyeComponent>(camera, out var eyeComponent))
{
// If there is no eye, print error and do not open any window
Log.Error("Camera entity does not have eye component!");
private void StopDragging(bool broadcast = true)
{
// Set the dragging player on the component to noone
- if (broadcast && _draggedEntity != null && EntityManager.HasComponent<TabletopDraggableComponent>(_draggedEntity.Value))
+ if (broadcast && _draggedEntity != null && HasComp<TabletopDraggableComponent>(_draggedEntity.Value))
{
RaisePredictiveEvent(new TabletopMoveEvent(GetNetEntity(_draggedEntity.Value), Transforms.GetMapCoordinates(_draggedEntity.Value), GetNetEntity(_table!.Value)));
RaisePredictiveEvent(new TabletopDraggingPlayerChangedEvent(GetNetEntity(_draggedEntity.Value), false));
// is this a client exclusive (gui) verb?
ExecuteVerb(verb, user, GetEntity(target));
else
- EntityManager.RaisePredictiveEvent(new ExecuteVerbEvent(target, verb));
+ RaisePredictiveEvent(new ExecuteVerbEvent(target, verb));
}
private void HandleVerbResponse(VerbsResponseEvent msg)
if (_inputSystem.CmdStates.GetState(useKey) != BoundKeyState.Down && !gun.BurstActivated)
{
if (gun.ShotCounter != 0)
- EntityManager.RaisePredictiveEvent(new RequestStopShootEvent { Gun = GetNetEntity(gunUid) });
+ RaisePredictiveEvent(new RequestStopShootEvent { Gun = GetNetEntity(gunUid) });
return;
}
if (mousePos.MapId == MapId.Nullspace)
{
if (gun.ShotCounter != 0)
- EntityManager.RaisePredictiveEvent(new RequestStopShootEvent { Gun = GetNetEntity(gunUid) });
+ RaisePredictiveEvent(new RequestStopShootEvent { Gun = GetNetEntity(gunUid) });
return;
}
Log.Debug($"Sending shoot request tick {Timing.CurTick} / {Timing.CurTime}");
- EntityManager.RaisePredictiveEvent(new RequestShootEvent
+ RaisePredictiveEvent(new RequestShootEvent
{
Target = target,
Coordinates = GetNetCoordinates(coordinates),
SubscribeLocalEvent<DoInsertDisposalUnitEvent>(ev =>
{
var (_, toInsert, unit) = ev;
- var insertTransform = EntityManager.GetComponent<TransformComponent>(toInsert);
+ var insertTransform = Comp<TransformComponent>(toInsert);
// Not in a tube yet
Assert.That(insertTransform.ParentUid, Is.EqualTo(unit));
}, after: new[] { typeof(SharedDisposalUnitSystem) });
{
var uid = GetEntity(message.Uid);
- var component = EntityManager.GetComponent<PredictionTestComponent>(uid);
+ var component = Comp<PredictionTestComponent>(uid);
var old = component.Foo;
if (Allow)
{
if (component.TargetAccessReaderId is { Valid: true } accessReader)
{
- targetLabel = Loc.GetString("access-overrider-window-target-label") + " " + EntityManager.GetComponent<MetaDataComponent>(component.TargetAccessReaderId).EntityName;
+ targetLabel = Loc.GetString("access-overrider-window-target-label") + " " + Comp<MetaDataComponent>(component.TargetAccessReaderId).EntityName;
targetLabelColor = Color.White;
if (!_accessReader.GetMainAccessReader(accessReader, out var accessReaderEnt))
if (component.PrivilegedIdSlot.Item is { Valid: true } idCard)
{
- privilegedIdName = EntityManager.GetComponent<MetaDataComponent>(idCard).EntityName;
+ privilegedIdName = Comp<MetaDataComponent>(idCard).EntityName;
if (component.TargetAccessReaderId is { Valid: true })
{
List<ProtoId<AccessLevelPrototype>>? possibleAccess = null;
if (component.PrivilegedIdSlot.Item is { Valid: true } item)
{
- privilegedIdName = EntityManager.GetComponent<MetaDataComponent>(item).EntityName;
+ privilegedIdName = Comp<MetaDataComponent>(item).EntityName;
possibleAccess = _accessReader.FindAccessTags(item).ToList();
}
}
else
{
- var targetIdComponent = EntityManager.GetComponent<IdCardComponent>(targetId);
- var targetAccessComponent = EntityManager.GetComponent<AccessComponent>(targetId);
+ var targetIdComponent = Comp<IdCardComponent>(targetId);
+ var targetAccessComponent = Comp<AccessComponent>(targetId);
var jobProto = targetIdComponent.JobPrototype ?? new ProtoId<AccessLevelPrototype>(string.Empty);
if (TryComp<StationRecordKeyStorageComponent>(targetId, out var keyStorage)
{
_popupSystem.PopupCoordinates(Loc.GetString("id-card-component-microwave-burnt", ("id", uid)),
transformComponent.Coordinates, PopupType.Medium);
- EntityManager.SpawnEntity("FoodBadRecipe",
+ Spawn("FoodBadRecipe",
transformComponent.Coordinates);
}
_adminLogger.Add(LogType.Action, LogImpact.Medium,
$"{ToPrettyString(args.Microwave)} burnt {ToPrettyString(uid):entity}");
- EntityManager.QueueDeleteEntity(uid);
+ QueueDel(uid);
return;
}
// Visible (identity) name can be different from real name
if (session?.AttachedEntity != null)
{
- entityName = EntityManager.GetComponent<MetaDataComponent>(session.AttachedEntity.Value).EntityName;
+ entityName = Comp<MetaDataComponent>(session.AttachedEntity.Value).EntityName;
identityName = Identity.Name(session.AttachedEntity.Value, EntityManager);
}
// All smite verbs have names so invokeverb works.
private void AddSmiteVerbs(GetVerbsEvent<Verb> args)
{
- if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
+ if (!TryComp(args.User, out ActorComponent? actor))
return;
var player = actor.PlayerSession;
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Objects/Materials/materials.rsi"), "ash"),
Act = () =>
{
- EntityManager.QueueDeleteEntity(args.Target);
+ QueueDel(args.Target);
Spawn("Ash", Transform(args.Target).Coordinates);
_popupSystem.PopupEntity(Loc.GetString("admin-smite-turned-ash-other", ("name", args.Target)), args.Target, PopupType.LargeCaution);
},
private void AddTricksVerbs(GetVerbsEvent<Verb> args)
{
- if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
+ if (!TryComp(args.User, out ActorComponent? actor))
return;
var player = actor.PlayerSession;
private void AddAdminVerbs(GetVerbsEvent<Verb> args)
{
- if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
+ if (!TryComp(args.User, out ActorComponent? actor))
return;
var player = actor.PlayerSession;
private void AddDebugVerbs(GetVerbsEvent<Verb> args)
{
- if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
+ if (!TryComp(args.User, out ActorComponent? actor))
return;
var player = actor.PlayerSession;
Text = Loc.GetString("delete-verb-get-data-text"),
Category = VerbCategory.Debug,
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/delete_transparent.svg.192dpi.png")),
- Act = () => EntityManager.DeleteEntity(args.Target),
+ Act = () => Del(args.Target),
Impact = LogImpact.Medium,
ConfirmationPopup = true
};
// Make Sentient verb
if (_groupController.CanCommand(player, "makesentient") &&
args.User != args.Target &&
- !EntityManager.HasComponent<MindContainerComponent>(args.Target))
+ !HasComp<MindContainerComponent>(args.Target))
{
Verb verb = new()
{
// Get Disposal tube direction verb
if (_groupController.CanCommand(player, "tubeconnections") &&
- EntityManager.TryGetComponent(args.Target, out DisposalTubeComponent? tube))
+ TryComp(args.Target, out DisposalTubeComponent? tube))
{
Verb verb = new()
{
}
if (_groupController.CanAdminMenu(player) &&
- EntityManager.TryGetComponent(args.Target, out ConfigurationComponent? config))
+ TryComp(args.Target, out ConfigurationComponent? config))
{
Verb verb = new()
{
// Add verb to open Solution Editor
if (_groupController.CanCommand(player, "addreagent") &&
- EntityManager.HasComponent<SolutionContainerManagerComponent>(args.Target))
+ HasComp<SolutionContainerManagerComponent>(args.Target))
{
Verb verb = new()
{
return;
var humanReadableState = value ? "Inject" : "Not inject";
- _adminLogger.Add(LogType.Action, LogImpact.Medium, $"{EntityManager.ToPrettyString(user.Value):player} has set the AME to {humanReadableState}");
+ _adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(user.Value):player} has set the AME to {humanReadableState}");
}
public void ToggleInjecting(EntityUid uid, EntityUid? user = null, AmeControllerComponent? controller = null)
var logImpact = (oldValue <= safeLimit && value > safeLimit) ? LogImpact.Extreme : LogImpact.Medium;
- _adminLogger.Add(LogType.Action, logImpact, $"{EntityManager.ToPrettyString(user.Value):player} has set the AME to inject {controller.InjectionAmount} while set to {humanReadableState}");
+ _adminLogger.Add(LogType.Action, logImpact, $"{ToPrettyString(user.Value):player} has set the AME to inject {controller.InjectionAmount} while set to {humanReadableState}");
}
public void AdjustInjectionAmount(EntityUid uid, int delta, EntityUid? user = null, AmeControllerComponent? controller = null)
public override void Update(float frameTime)
{
- var query = EntityManager.EntityQueryEnumerator<BlockGameArcadeComponent>();
+ var query = EntityQueryEnumerator<BlockGameArcadeComponent>();
while (query.MoveNext(out var _, out var blockGame))
{
blockGame.Game?.GameTick(frameTime);
if (arcade.RewardAmount <= 0)
return;
- EntityManager.SpawnEntity(_random.Pick(arcade.PossibleRewards), xform.Coordinates);
+ Spawn(_random.Pick(arcade.PossibleRewards), xform.Coordinates);
arcade.RewardAmount--;
}
if (component.NavMapBlip == null)
return;
- var netEntity = EntityManager.GetNetEntity(uid);
+ var netEntity = GetNetEntity(uid);
var query = AllEntityQuery<AtmosMonitoringConsoleComponent, TransformComponent>();
while (query.MoveNext(out var ent, out var entConsole, out var entXform))
if (component.NavMapBlip == null)
return;
- var netEntity = EntityManager.GetNetEntity(uid);
+ var netEntity = GetNetEntity(uid);
var query = AllEntityQuery<AtmosMonitoringConsoleComponent>();
while (query.MoveNext(out var ent, out var entConsole))
public void InvalidatePosition(Entity<MapGridComponent?> grid, Vector2i pos)
{
- var query = EntityManager.GetEntityQuery<AirtightComponent>();
+ var query = GetEntityQuery<AirtightComponent>();
_explosionSystem.UpdateAirtightMap(grid, pos, grid, query);
_atmosphereSystem.InvalidateTile(grid.Owner, pos);
}
// Note: This is still processed even if space wind is turned off since this handles playing the sounds.
var number = 0;
- var bodies = EntityManager.GetEntityQuery<PhysicsComponent>();
- var xforms = EntityManager.GetEntityQuery<TransformComponent>();
- var metas = EntityManager.GetEntityQuery<MetaDataComponent>();
- var pressureQuery = EntityManager.GetEntityQuery<MovedByPressureComponent>();
+ var bodies = GetEntityQuery<PhysicsComponent>();
+ var xforms = GetEntityQuery<TransformComponent>();
+ var metas = GetEntityQuery<MetaDataComponent>();
+ var pressureQuery = GetEntityQuery<MovedByPressureComponent>();
while (atmosphere.CurrentRunTiles.TryDequeue(out var tile))
{
var otherEnt = args.OtherEntity;
- if (!EntityManager.TryGetComponent(otherEnt, out FlammableComponent? flammable))
+ if (!TryComp(otherEnt, out FlammableComponent? flammable))
return;
//Only ignite when the colliding fixture is projectile or ignition.
{
if (component.IgnoreAlarms) return;
- if (!EntityManager.TryGetComponent(uid, out DeviceNetworkComponent? netConn))
+ if (!TryComp(uid, out DeviceNetworkComponent? netConn))
return;
if (!args.Data.TryGetValue(DeviceNetworkConstants.Command, out string? cmd)
private void OnExamined(Entity<GasRecyclerComponent> ent, ref ExaminedEvent args)
{
var comp = ent.Comp;
- if (!EntityManager.GetComponent<TransformComponent>(ent).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
+ if (!Comp<TransformComponent>(ent).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
return;
if (!_nodeContainer.TryGetNode(ent.Owner, comp.InletName, out PipeNode? inlet))
private void OnStartup(EntityUid uid, AtmosPipeColorComponent component, ComponentStartup args)
{
- if (!EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
+ if (!TryComp(uid, out AppearanceComponent? appearance))
return;
_appearance.SetData(uid, PipeColorVisuals.Color, component.Color, appearance);
private void OnShutdown(EntityUid uid, AtmosPipeColorComponent component, ComponentShutdown args)
{
- if (!EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
+ if (!TryComp(uid, out AppearanceComponent? appearance))
return;
_appearance.SetData(uid, PipeColorVisuals.Color, Color.White, appearance);
{
component.Color = color;
- if (!EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
+ if (!TryComp(uid, out AppearanceComponent? appearance))
return;
_appearance.SetData(uid, PipeColorVisuals.Color, color, appearance);
private void OnUnanchorAttempt(EntityUid uid, AtmosUnsafeUnanchorComponent component, UnanchorAttemptEvent args)
{
- if (!component.Enabled || !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodes))
+ if (!component.Enabled || !TryComp(uid, out NodeContainerComponent? nodes))
return;
if (_atmosphere.GetContainingMixture(uid, true) is not {} environment)
/// </summary>
public void LeakGas(EntityUid uid, bool removeFromPipe = true)
{
- if (!EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodes))
+ if (!TryComp(uid, out NodeContainerComponent? nodes))
return;
if (_atmosphere.GetContainingMixture(uid, true, true) is not { } environment)
if (args.Handled || !args.Complex)
return;
- if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
+ if (!TryComp(args.User, out ActorComponent? actor))
return;
- if (EntityManager.GetComponent<TransformComponent>(uid).Anchored)
+ if (Comp<TransformComponent>(uid).Anchored)
{
_userInterfaceSystem.OpenUi(uid, GasFilterUiKey.Key, actor.PlayerSession);
DirtyUI(uid, filter);
if (args.Handled || !args.Complex)
return;
- if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
+ if (!TryComp(args.User, out ActorComponent? actor))
return;
if (Transform(uid).Anchored)
return;
_userInterfaceSystem.SetUiState(uid, GasMixerUiKey.Key,
- new GasMixerBoundUserInterfaceState(EntityManager.GetComponent<MetaDataComponent>(uid).EntityName, mixer.TargetPressure, mixer.Enabled, mixer.InletOneConcentration));
+ new GasMixerBoundUserInterfaceState(Comp<MetaDataComponent>(uid).EntityName, mixer.TargetPressure, mixer.Enabled, mixer.InletOneConcentration));
}
private void UpdateAppearance(EntityUid uid, GasMixerComponent? mixer = null, AppearanceComponent? appearance = null)
mixer.InletOneConcentration = nodeOne;
mixer.InletTwoConcentration = 1.0f - mixer.InletOneConcentration;
_adminLogger.Add(LogType.AtmosRatioChanged, LogImpact.Medium,
- $"{EntityManager.ToPrettyString(args.Actor):player} set the ratio on {EntityManager.ToPrettyString(uid):device} to {mixer.InletOneConcentration}:{mixer.InletTwoConcentration}");
+ $"{ToPrettyString(args.Actor):player} set the ratio on {ToPrettyString(uid):device} to {mixer.InletOneConcentration}:{mixer.InletTwoConcentration}");
DirtyUI(uid, mixer);
}
private void OnPortableAnchorAttempt(EntityUid uid, GasPortableComponent component, AnchorAttemptEvent args)
{
- if (!EntityManager.TryGetComponent(uid, out TransformComponent? transform))
+ if (!TryComp(uid, out TransformComponent? transform))
return;
// If we can't find any ports, cancel the anchoring.
foreach (var entityUid in _mapSystem.GetLocal(gridId.Value, grid, coordinates))
{
- if (EntityManager.TryGetComponent(entityUid, out port))
+ if (TryComp(entityUid, out port))
{
return true;
}
private void OnPacketRecv(EntityUid uid, GasVentPumpComponent component, DeviceNetworkPacketEvent args)
{
- if (!EntityManager.TryGetComponent(uid, out DeviceNetworkComponent? netConn)
+ if (!TryComp(uid, out DeviceNetworkComponent? netConn)
|| !args.Data.TryGetValue(DeviceNetworkConstants.Command, out var cmd))
return;
private void OnPacketRecv(EntityUid uid, GasVentScrubberComponent component, DeviceNetworkPacketEvent args)
{
- if (!EntityManager.TryGetComponent(uid, out DeviceNetworkComponent? netConn)
+ if (!TryComp(uid, out DeviceNetworkComponent? netConn)
|| !args.Data.TryGetValue(DeviceNetworkConstants.Command, out var cmd))
return;
// Clean up the old body
if (summonableComp.Summon != null)
{
- EntityManager.DeleteEntity(summonableComp.Summon.Value);
+ Del(summonableComp.Summon.Value);
summonableComp.Summon = null;
}
summonableComp.AlreadySummoned = false;
return;
// Make this familiar the component's summon
- var familiar = EntityManager.SpawnEntity(component.SpecialItemPrototype, position.Coordinates);
+ var familiar = Spawn(component.SpecialItemPrototype, position.Coordinates);
component.Summon = familiar;
// If this is going to use a ghost role mob spawner, attach it to the bible.
_transformSystem.Unanchor(item, Transform(item));
// Create a sheet of paper to write the order details on
- var printed = EntityManager.SpawnEntity(paperProto, spawn);
+ var printed = Spawn(paperProto, spawn);
if (TryComp<PaperComponent>(printed, out var paper))
{
// fill in the order data
{
return;
}
- if (!EntityManager.TryGetComponent<NanoTaskPrintedComponent>(args.Used, out var printed))
+ if (!TryComp<NanoTaskPrintedComponent>(args.Used, out var printed))
{
return;
}
{
program.Tasks.Add(new(program.Counter++, printed.Task));
args.Handled = true;
- EntityManager.DeleteEntity(args.Used);
+ Del(args.Used);
UpdateUiState(new Entity<NanoTaskCartridgeComponent>(uid.Value, program), ent.Owner);
}
}
if (!TryComp<MobStateComponent>(victim, out var mobState) || _mobState.IsDead(victim, mobState))
return false;
- _adminLogger.Add(LogType.Mind, $"{EntityManager.ToPrettyString(victim):player} is attempting to suicide");
+ _adminLogger.Add(LogType.Mind, $"{ToPrettyString(victim):player} is attempting to suicide");
ICommonSession? session = null;
}
else
{
- _adminLogger.Add(LogType.Mind, $"{EntityManager.ToPrettyString(victim):player} suicided.");
+ _adminLogger.Add(LogType.Mind, $"{ToPrettyString(victim):player} suicided.");
}
return true;
}
return;
}
- if (!EntityManager.TryGetComponent<StationDataComponent>(station, out var stationDataComp)) return;
+ if (!TryComp<StationDataComponent>(station, out var stationDataComp)) return;
var filter = _stationSystem.GetInStation(stationDataComp);
if (_solutionContainerSystem.TryGetSolution((entity.Owner, solutions), entity.Comp.Solution, out _, out var solution))
if (solution.Volume <= 0)
- EntityManager.QueueDeleteEntity(entity);
+ QueueDel(entity);
}
}
}
if (injector.Comp.ToggleState == InjectorToggleMode.Inject)
{
AdminLogger.Add(LogType.ForceFeed,
- $"{EntityManager.ToPrettyString(user):user} is attempting to inject {EntityManager.ToPrettyString(target):target} with a solution {SharedSolutionContainerSystem.ToPrettyString(solution):solution}");
+ $"{ToPrettyString(user):user} is attempting to inject {ToPrettyString(target):target} with a solution {SharedSolutionContainerSystem.ToPrettyString(solution):solution}");
}
else
{
AdminLogger.Add(LogType.ForceFeed,
- $"{EntityManager.ToPrettyString(user):user} is attempting to draw {injector.Comp.TransferAmount.ToString()} units from {EntityManager.ToPrettyString(target):target}");
+ $"{ToPrettyString(user):user} is attempting to draw {injector.Comp.TransferAmount.ToString()} units from {ToPrettyString(target):target}");
}
}
else
if (injector.Comp.ToggleState == InjectorToggleMode.Inject)
{
AdminLogger.Add(LogType.Ingestion,
- $"{EntityManager.ToPrettyString(user):user} is attempting to inject themselves with a solution {SharedSolutionContainerSystem.ToPrettyString(solution):solution}.");
+ $"{ToPrettyString(user):user} is attempting to inject themselves with a solution {SharedSolutionContainerSystem.ToPrettyString(solution):solution}.");
}
else
{
AdminLogger.Add(LogType.ForceFeed,
- $"{EntityManager.ToPrettyString(user):user} is attempting to draw {injector.Comp.TransferAmount.ToString()} units from themselves.");
+ $"{ToPrettyString(user):user} is attempting to draw {injector.Comp.TransferAmount.ToString()} units from themselves.");
}
}
private void HandleCollide(Entity<VaporComponent> entity, ref StartCollideEvent args)
{
- if (!EntityManager.TryGetComponent(entity.Owner, out SolutionContainerManagerComponent? contents)) return;
+ if (!TryComp(entity.Owner, out SolutionContainerManagerComponent? contents)) return;
foreach (var (_, soln) in _solutionContainerSystem.EnumerateSolutions((entity.Owner, contents)))
{
// Check for collision with a impassable object (e.g. wall) and stop
if ((args.OtherFixture.CollisionLayer & (int)CollisionGroup.Impassable) != 0 && args.OtherFixture.Hard)
{
- EntityManager.QueueDeleteEntity(entity);
+ QueueDel(entity);
}
}
despawn.Lifetime = aliveTime;
// Set Move
- if (EntityManager.TryGetComponent(vapor, out PhysicsComponent? physics))
+ if (TryComp(vapor, out PhysicsComponent? physics))
{
_physics.SetLinearDamping(vapor, physics, 0f);
_physics.SetAngularDamping(vapor, physics, 0f);
// Delete the vapor entity if it has no contents
if (contents.Volume == 0)
- EntityManager.QueueDeleteEntity(uid);
+ QueueDel(uid);
}
internal void TransferMindToClone(EntityUid mindId, MindComponent mind)
{
if (!ClonesWaitingForMind.TryGetValue(mind, out var entity) ||
- !EntityManager.EntityExists(entity) ||
+ !Exists(entity) ||
!TryComp<MindContainerComponent>(entity, out var mindComp) ||
mindComp.Mind != null)
return;
private void HandleMindAdded(EntityUid uid, BeingClonedComponent clonedComponent, MindAddedMessage message)
{
if (clonedComponent.Parent == EntityUid.Invalid ||
- !EntityManager.EntityExists(clonedComponent.Parent) ||
+ !Exists(clonedComponent.Parent) ||
!TryComp<CloningPodComponent>(clonedComponent.Parent, out var cloningPodComponent) ||
uid != cloningPodComponent.BodyContainer.ContainedEntity)
{
- EntityManager.RemoveComponent<BeingClonedComponent>(uid);
+ RemComp<BeingClonedComponent>(uid);
return;
}
UpdateStatus(clonedComponent.Parent, CloningPodStatus.Cloning, cloningPodComponent);
var mind = mindEnt.Comp;
if (ClonesWaitingForMind.TryGetValue(mind, out var clone))
{
- if (EntityManager.EntityExists(clone) &&
+ if (Exists(clone) &&
!_mobStateSystem.IsDead(clone) &&
TryComp<MindContainerComponent>(clone, out var cloneMindComp) &&
(cloneMindComp.Mind == null || cloneMindComp.Mind == mindEnt))
return false;
}
- var cloneMindReturn = EntityManager.AddComponent<BeingClonedComponent>(mob.Value);
+ var cloneMindReturn = AddComp<BeingClonedComponent>(mob.Value);
cloneMindReturn.Mind = mind;
cloneMindReturn.Parent = uid;
_containerSystem.Insert(mob.Value, clonePod.BodyContainer);
if (clonePod.BodyContainer.ContainedEntity is not { Valid: true } entity || clonePod.CloningProgress < clonePod.CloningTime)
return;
- EntityManager.RemoveComponent<BeingClonedComponent>(entity);
+ RemComp<BeingClonedComponent>(entity);
_containerSystem.Remove(entity, clonePod.BodyContainer);
clonePod.CloningProgress = 0f;
clonePod.UsedBiomass = 0;
if (prototype == null)
return null;
- var spawned = EntityManager.SpawnAtPosition(prototype, coords);
+ var spawned = SpawnAtPosition(prototype, coords);
// copy over important component data
var ev = new CloningItemEvent(spawned);
var factionProto = _prototypeManager.Index<CodewordFactionPrototype>(faction.Id);
var codewords = GenerateCodewords(factionProto.Generator);
- var codewordsContainer = EntityManager.Spawn(protoName:null, MapCoordinates.Nullspace);
+ var codewordsContainer = Spawn(prototype: null, MapCoordinates.Nullspace);
EnsureComp<CodewordComponent>(codewordsContainer)
.Codewords = codewords;
manager.Codewords[faction] = codewordsContainer;
if (container.ContainedEntities.Count != 0)
return;
- var board = EntityManager.SpawnEntity(component.BoardPrototype, Transform(ent).Coordinates);
+ var board = Spawn(component.BoardPrototype, Transform(ent).Coordinates);
if (!_container.Insert(board, container))
Log.Warning($"Couldn't insert board {board} to computer {ent}!");
var newUid = EntityManager.CreateEntityUninitialized(newEntity, transform.Coordinates);
// Construction transferring.
- var newConstruction = EntityManager.EnsureComponent<ConstructionComponent>(newUid);
+ var newConstruction = EnsureComp<ConstructionComponent>(newUid);
// Transfer all construction-owned containers.
newConstruction.Containers.UnionWith(construction.Containers);
if (containerManager != null)
{
// Ensure the new entity has a container manager. Also for resolve goodness.
- var newContainerManager = EntityManager.EnsureComponent<ContainerManagerComponent>(newUid);
+ var newContainerManager = EnsureComp<ContainerManagerComponent>(newUid);
// Transfer all construction-owned containers from the old entity to the new one.
foreach (var container in construction.Containers)
if(!containerSlot.ContainedEntity.HasValue)
continue;
- if (EntityManager.TryGetComponent(containerSlot.ContainedEntity.Value, out StorageComponent? storage))
+ if (TryComp(containerSlot.ContainedEntity.Value, out StorageComponent? storage))
{
foreach (var storedEntity in storage.Container.ContainedEntities)
{
}
var newEntityProto = graph.Nodes[edge.Target].Entity.GetId(null, user, new(EntityManager));
- var newEntity = EntityManager.SpawnAttachedTo(newEntityProto, coords, rotation: angle);
+ var newEntity = SpawnAttachedTo(newEntityProto, coords, rotation: angle);
if (!TryComp(newEntity, out ConstructionComponent? construction))
{
}
if (!_actionBlocker.CanInteract(user, null)
- || !EntityManager.TryGetComponent(user, out HandsComponent? hands) || _handsSystem.GetActiveItem((user, hands)) == null)
+ || !TryComp(user, out HandsComponent? hands) || _handsSystem.GetActiveItem((user, hands)) == null)
{
Cleanup();
return;
var construction = ent.Comp;
if (GetCurrentGraph(ent, construction) is not {} graph)
{
- Log.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid graph specified.");
+ Log.Warning($"Prototype {Comp<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid graph specified.");
return;
}
if (GetNodeFromGraph(graph, construction.Node) is not {} node)
{
- Log.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid node specified.");
+ Log.Warning($"Prototype {Comp<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid node specified.");
return;
}
{
if (GetEdgeFromNode(node, edgeIndex) is not {} currentEdge)
{
- Log.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid edge index specified.");
+ Log.Warning($"Prototype {Comp<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid edge index specified.");
return;
}
{
if (GetNodeFromGraph(graph, targetNodeId) is not { } targetNode)
{
- Log.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid target node specified.");
+ Log.Warning($"Prototype {Comp<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid target node specified.");
return;
}
component.Charges--;
Dirty(uid, component);
- _adminLogger.Add(LogType.CrayonDraw, LogImpact.Low, $"{EntityManager.ToPrettyString(args.User):user} drew a {component.Color:color} {component.SelectedState}");
+ _adminLogger.Add(LogType.CrayonDraw, LogImpact.Low, $"{ToPrettyString(args.User):user} drew a {component.Color:color} {component.SelectedState}");
args.Handled = true;
if (component.DeleteEmpty && component.Charges <= 0)
private void UseUpCrayon(EntityUid uid, EntityUid user)
{
_popup.PopupEntity(Loc.GetString("crayon-interact-used-up-text", ("owner", uid)), user, user);
- EntityManager.QueueDeleteEntity(uid);
+ QueueDel(uid);
}
}
return;
if (component.WeldingDamage is {} weldingDamage
- && EntityManager.TryGetComponent(args.Used, out WelderComponent? welder)
+ && TryComp(args.Used, out WelderComponent? welder)
&& itemToggle.Activated
&& !welder.TankSafe)
{
/// </summary>
private void OnBeforePacketSent(EntityUid uid, ApcNetworkComponent receiver, BeforePacketSentEvent args)
{
- if (!EntityManager.TryGetComponent(args.Sender, out ApcNetworkComponent? sender)) return;
+ if (!TryComp(args.Sender, out ApcNetworkComponent? sender)) return;
if (sender.ConnectedNode?.NodeGroup == null || !sender.ConnectedNode.NodeGroup.Equals(receiver.ConnectedNode?.NodeGroup))
{
private void OnProviderConnected(EntityUid uid, ApcNetworkComponent component, ExtensionCableSystem.ProviderConnectedEvent args)
{
- if (!EntityManager.TryGetComponent(args.Provider.Owner, out NodeContainerComponent? nodeContainer)) return;
+ if (!TryComp(args.Provider.Owner, out NodeContainerComponent? nodeContainer)) return;
if (_nodeContainer.TryGetNode(nodeContainer, "power", out CableNode? node))
{
/// </summary>
private void OnInteracted(EntityUid uid, ApcNetSwitchComponent component, InteractHandEvent args)
{
- if (!EntityManager.TryGetComponent(uid, out DeviceNetworkComponent? networkComponent)) return;
+ if (!TryComp(uid, out DeviceNetworkComponent? networkComponent)) return;
component.State = !component.State;
/// </summary>
private void OnPackedReceived(EntityUid uid, ApcNetSwitchComponent component, DeviceNetworkPacketEvent args)
{
- if (!EntityManager.TryGetComponent(uid, out DeviceNetworkComponent? networkComponent) || args.SenderAddress == networkComponent.Address) return;
+ if (!TryComp(uid, out DeviceNetworkComponent? networkComponent) || args.SenderAddress == networkComponent.Address) return;
if (!args.Data.TryGetValue(DeviceNetworkConstants.Command, out string? command) || command != DeviceNetworkConstants.CmdSetState) return;
if (!args.Data.TryGetValue(DeviceNetworkConstants.StateEnabled, out bool enabled)) return;
/// <param name="msg">A user interface message from the client.</param>
private void OnUiAction(EntityUid uid, DisposalRouterComponent router, SharedDisposalRouterComponent.UiActionMessage msg)
{
- if (!EntityManager.EntityExists(msg.Actor))
+ if (!Exists(msg.Actor))
return;
if (TryComp<PhysicsComponent>(uid, out var physBody) && physBody.BodyType != BodyType.Static)
holder.Air.Clear();
}
- EntityManager.DeleteEntity(uid);
+ Del(uid);
}
// Note: This function will cause an ExitDisposals on any failure that does not make an ExitDisposals impossible.
holder.TimeLeft -= time;
frameTime -= time;
- if (!EntityManager.EntityExists(holder.CurrentTube))
+ if (!Exists(holder.CurrentTube))
{
ExitDisposals(uid, holder);
break;
// Find next tube
var nextTube = _disposalTubeSystem.NextTubeFor(currentTube, holder.CurrentDirection);
- if (!EntityManager.EntityExists(nextTube))
+ if (!Exists(nextTube))
{
ExitDisposals(uid, holder);
break;
if (component.Deleted || !IsTileClear())
return;
- if (EntityManager.TryGetComponent(uid, out StackComponent? stackComp)
+ if (TryComp(uid, out StackComponent? stackComp)
&& component.RemoveOnInteract && !_stackSystem.Use(uid, 1, stackComp))
{
return;
}
- EntityManager.SpawnEntity(component.Prototype, args.ClickLocation.SnapToGrid(grid));
+ Spawn(component.Prototype, args.ClickLocation.SnapToGrid(grid));
if (component.RemoveOnInteract && stackComp == null)
TryQueueDel(uid);
var spreadAmount = (int) Math.Max(0, Math.Ceiling((reagentArgs.Quantity / args.Effect.OverflowThreshold).Float()));
var splitSolution = reagentArgs.Source.SplitSolution(reagentArgs.Source.Volume);
- var transform = EntityManager.GetComponent<TransformComponent>(reagentArgs.TargetEntity);
+ var transform = Comp<TransformComponent>(reagentArgs.TargetEntity);
var mapCoords = _xform.GetMapCoordinates(reagentArgs.TargetEntity, xform: transform);
if (!_mapManager.TryFindGridAt(mapCoords, out var gridUid, out var grid) ||
return;
var coords = _map.MapToGrid(gridUid, mapCoords);
- var ent = EntityManager.SpawnEntity(args.Effect.PrototypeId, coords.SnapToGrid());
+ var ent = Spawn(args.Effect.PrototypeId, coords.SnapToGrid());
_smoke.StartSmoke(ent, splitSolution, args.Effect.Duration, spreadAmount);
private void OnExecuteEmpReactionEffect(ref ExecuteEntityEffectEvent<EmpReactionEffect> args)
{
- var transform = EntityManager.GetComponent<TransformComponent>(args.Args.TargetEntity);
+ var transform = Comp<TransformComponent>(args.Args.TargetEntity);
var range = args.Effect.EmpRangePerUnit;
private void OnExecuteFlashReactionEffect(ref ExecuteEntityEffectEvent<FlashReactionEffect> args)
{
- var transform = EntityManager.GetComponent<TransformComponent>(args.Args.TargetEntity);
+ var transform = Comp<TransformComponent>(args.Args.TargetEntity);
var range = 1f;
ghostRole = AddComp<GhostRoleComponent>(uid);
EnsureComp<GhostTakeoverAvailableComponent>(uid);
- var entityData = EntityManager.GetComponent<MetaDataComponent>(uid);
+ var entityData = Comp<MetaDataComponent>(uid);
ghostRole.RoleName = entityData.EntityName;
ghostRole.RoleDescription = Loc.GetString("ghost-role-information-cognizine-description");
}
private void OnExecutePlantMutateChemicals(ref ExecuteEntityEffectEvent<PlantMutateChemicals> args)
{
- var plantholder = EntityManager.GetComponent<PlantHolderComponent>(args.Args.TargetEntity);
+ var plantholder = Comp<PlantHolderComponent>(args.Args.TargetEntity);
if (plantholder.Seed == null)
return;
private void OnExecutePlantMutateConsumeGasses(ref ExecuteEntityEffectEvent<PlantMutateConsumeGasses> args)
{
- var plantholder = EntityManager.GetComponent<PlantHolderComponent>(args.Args.TargetEntity);
+ var plantholder = Comp<PlantHolderComponent>(args.Args.TargetEntity);
if (plantholder.Seed == null)
return;
private void OnExecutePlantMutateExudeGasses(ref ExecuteEntityEffectEvent<PlantMutateExudeGasses> args)
{
- var plantholder = EntityManager.GetComponent<PlantHolderComponent>(args.Args.TargetEntity);
+ var plantholder = Comp<PlantHolderComponent>(args.Args.TargetEntity);
if (plantholder.Seed == null)
return;
private void OnExecutePlantMutateHarvest(ref ExecuteEntityEffectEvent<PlantMutateHarvest> args)
{
- var plantholder = EntityManager.GetComponent<PlantHolderComponent>(args.Args.TargetEntity);
+ var plantholder = Comp<PlantHolderComponent>(args.Args.TargetEntity);
if (plantholder.Seed == null)
return;
private void OnExecutePlantSpeciesChange(ref ExecuteEntityEffectEvent<PlantSpeciesChange> args)
{
- var plantholder = EntityManager.GetComponent<PlantHolderComponent>(args.Args.TargetEntity);
+ var plantholder = Comp<PlantHolderComponent>(args.Args.TargetEntity);
if (plantholder.Seed == null)
return;
var entity = GetEntity(request.NetEntity);
if (session.AttachedEntity is not {Valid: true} playerEnt
- || !EntityManager.EntityExists(entity))
+ || !Exists(entity))
{
RaiseNetworkEvent(new ExamineSystemMessages.ExamineInfoResponseMessage(
request.NetEntity, request.Id, _entityNotFoundMessage), channel);
if (!_airtightMap.ContainsKey(gridId))
_airtightMap[gridId] = new();
- query ??= EntityManager.GetEntityQuery<AirtightComponent>();
- var damageQuery = EntityManager.GetEntityQuery<DamageableComponent>();
- var destructibleQuery = EntityManager.GetEntityQuery<DestructibleComponent>();
+ query ??= GetEntityQuery<AirtightComponent>();
+ var damageQuery = GetEntityQuery<DamageableComponent>();
+ var destructibleQuery = GetEntityQuery<DestructibleComponent>();
var anchoredEnumerator = _mapSystem.GetAnchoredEntitiesEnumerator(gridId, grid, tile);
while (anchoredEnumerator.MoveNext(out var uid))
if (!airtight.AirBlocked)
return;
- if (!EntityManager.TryGetComponent(uid, out TransformComponent? transform) || !transform.Anchored)
+ if (!TryComp(uid, out TransformComponent? transform) || !transform.Anchored)
return;
if (!TryComp<MapGridComponent>(transform.GridUid, out var grid))
continue;
}
- var xforms = EntityManager.GetEntityQuery<TransformComponent>();
+ var xforms = GetEntityQuery<TransformComponent>();
var xform = xforms.GetComponent(gridToTransform);
var (_, gridWorldRotation, gridWorldMatrix, invGridWorldMatrid) = _transformSystem.GetWorldPositionRotationMatrixWithInv(xform, xforms);
user);
if (explosive.DeleteAfterExplosion ?? delete)
- EntityManager.QueueDeleteEntity(uid);
+ QueueDel(uid);
}
/// <summary>
private void SetProximityAppearance(EntityUid uid, TriggerOnProximityComponent component)
{
- if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
+ if (TryComp(uid, out AppearanceComponent? appearance))
{
_appearance.SetData(uid, ProximityTriggerVisualState.State, component.Enabled ? ProximityTriggerVisuals.Inactive : ProximityTriggerVisuals.Off, appearance);
}
// Queue a visual update for when the animation is complete.
component.NextVisualUpdate = curTime + component.AnimationDuration;
- if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
+ if (TryComp(uid, out AppearanceComponent? appearance))
{
_appearance.SetData(uid, ProximityTriggerVisualState.State, ProximityTriggerVisuals.Active, appearance);
}
private void HandleDeleteTrigger(EntityUid uid, DeleteOnTriggerComponent component, TriggerEvent args)
{
- EntityManager.QueueDeleteEntity(uid);
+ QueueDel(uid);
args.Handled = true;
}
RemComp(uid, c);
_serializationManager.CopyTo(entry.Component, ref temp);
- EntityManager.AddComponent(uid, comp);
+ AddComp(uid, comp);
}
component.ComponentsIsLoaded = true;
}
var printout = component.PrintingQueue.Dequeue();
var entityToSpawn = printout.PrototypeId.Length == 0 ? component.PrintPaperId.ToString() : printout.PrototypeId;
- var printed = EntityManager.SpawnEntity(entityToSpawn, Transform(uid).Coordinates);
+ var printed = Spawn(entityToSpawn, Transform(uid).Coordinates);
if (TryComp<PaperComponent>(printed, out var paper))
{
// but queuedelete should be pretty safe.
if (!_solutionContainerSystem.ResolveSolution(puddle.Owner, puddle.Comp.SolutionName, ref puddle.Comp.Solution, out var puddleSolution))
{
- EntityManager.QueueDeleteEntity(puddle);
+ QueueDel(puddle);
continue;
}
if (session.AttachedEntity is not { Valid: true } entity)
continue;
- var transform = EntityManager.GetComponent<TransformComponent>(entity);
+ var transform = Comp<TransformComponent>(entity);
var worldBounds = Box2.CenteredAround(_transform.GetWorldPosition(transform),
}
var coords = _map.GridTileToLocal(gridId, mapGrid, tileRef.GridIndices);
- puddleUid = EntityManager.SpawnEntity("Puddle", coords);
+ puddleUid = Spawn("Puddle", coords);
EnsureComp<PuddleComponent>(puddleUid);
if (TryAddSolution(puddleUid, solution, sound))
{
if (args.Handled || args.Cancelled)
return;
- if (!EntityManager.TryGetComponent(uid, out ForensicScannerComponent? scanner))
+ if (!TryComp(uid, out ForensicScannerComponent? scanner))
return;
if (args.Args.Target != null)
}
// Spawn a piece of paper.
- var printed = EntityManager.SpawnEntity(component.MachineOutput, Transform(uid).Coordinates);
+ var printed = Spawn(component.MachineOutput, Transform(uid).Coordinates);
_handsSystem.PickupOrDrop(args.Actor, printed, checkActionBlocker: false);
if (!TryComp<PaperComponent>(printed, out var paperComp))
if (player.UserId == new Guid("{e887eb93-f503-4b65-95b6-2f282c014192}"))
{
- EntityManager.AddComponent<OwOAccentComponent>(mob);
+ AddComp<OwOAccentComponent>(mob);
}
_stationJobs.TryAssignJob(station, jobPrototype, player.UserId);
public EntityCoordinates GetObserverSpawnPoint()
{
_possiblePositions.Clear();
- var spawnPointQuery = EntityManager.EntityQueryEnumerator<SpawnPointComponent, TransformComponent>();
+ var spawnPointQuery = EntityQueryEnumerator<SpawnPointComponent, TransformComponent>();
while (spawnPointQuery.MoveNext(out var uid, out var point, out var transform))
{
if (point.SpawnType != SpawnPointType.Observer
if (playerEntity != null && viaCommand)
{
if (forced)
- _adminLog.Add(LogType.Mind, $"{EntityManager.ToPrettyString(playerEntity.Value):player} was forced to ghost via command");
+ _adminLog.Add(LogType.Mind, $"{ToPrettyString(playerEntity.Value):player} was forced to ghost via command");
else
- _adminLog.Add(LogType.Mind, $"{EntityManager.ToPrettyString(playerEntity.Value):player} is attempting to ghost via command");
+ _adminLog.Add(LogType.Mind, $"{ToPrettyString(playerEntity.Value):player} is attempting to ghost via command");
}
var handleEv = new GhostAttemptHandleEvent(mind, canReturnGlobal);
}
if (playerEntity != null)
- _adminLog.Add(LogType.Mind, $"{EntityManager.ToPrettyString(playerEntity.Value):player} ghosted{(!canReturn ? " (non-returnable)" : "")}");
+ _adminLog.Add(LogType.Mind, $"{ToPrettyString(playerEntity.Value):player} ghosted{(!canReturn ? " (non-returnable)" : "")}");
var ghost = SpawnGhost((mindId, mind), position, canReturn);
public void OpenEui(ICommonSession session)
{
if (session.AttachedEntity is not { Valid: true } attached ||
- !EntityManager.HasComponent<GhostComponent>(attached))
+ !HasComp<GhostComponent>(attached))
return;
if (_openUis.ContainsKey(session))
DebugTools.AssertNotNull(player.ContentData());
var newMind = _mindSystem.CreateMind(player.UserId,
- EntityManager.GetComponent<MetaDataComponent>(mob).EntityName);
+ Comp<MetaDataComponent>(mob).EntityName);
_mindSystem.SetUserId(newMind, player.UserId);
_mindSystem.TransferTo(newMind, mob);
return false;
hands.NextThrowTime = _timing.CurTime + hands.ThrowCooldown;
- if (EntityManager.TryGetComponent(throwEnt, out StackComponent? stack) && stack.Count > 1 && stack.ThrowIndividually)
+ if (TryComp(throwEnt, out StackComponent? stack) && stack.Count > 1 && stack.ThrowIndividually)
{
- var splitStack = _stackSystem.Split(throwEnt.Value, 1, EntityManager.GetComponent<TransformComponent>(player).Coordinates, stack);
+ var splitStack = _stackSystem.Split(throwEnt.Value, 1, Comp<TransformComponent>(player).Coordinates, stack);
if (splitStack is not {Valid: true})
return false;
// places the holographic sign at the click location, snapped to grid.
// overlapping of the same holo on one tile remains allowed to allow holofan refreshes
- var holoUid = EntityManager.SpawnEntity(component.SignProto, args.ClickLocation.SnapToGrid(EntityManager));
+ var holoUid = Spawn(component.SignProto, args.ClickLocation.SnapToGrid(EntityManager));
var xform = Transform(holoUid);
if (!xform.Anchored)
_transform.AnchorEntity(holoUid, xform); // anchor to prevent any tempering with (don't know what could even interact with it)
foreach (var entry in prototype.Components.Values)
{
var comp = (Component)_serialization.CreateCopy(entry.Component, notNullableOverride: true);
- EntityManager.RemoveComponent(humanoid, comp.GetType());
- EntityManager.AddComponent(humanoid, comp);
+ RemComp(humanoid, comp.GetType());
+ AddComp(humanoid, comp);
}
}
base.Update(frameTime);
// we are deliberately including paused entities. rod hungers for all
- foreach (var (rod, trans) in EntityManager.EntityQuery<ImmovableRodComponent, TransformComponent>(true))
+ foreach (var (rod, trans) in EntityQuery<ImmovableRodComponent, TransformComponent>(true))
{
if (!rod.DestroyTiles)
continue;
private void OnMapInit(EntityUid uid, ImmovableRodComponent component, MapInitEvent args)
{
- if (EntityManager.TryGetComponent(uid, out PhysicsComponent? phys))
+ if (TryComp(uid, out PhysicsComponent? phys))
{
_physics.SetLinearDamping(uid, phys, 0f);
_physics.SetFriction(uid, phys, 0f);
public (NetEntity, string)[] GetBands(EntityUid uid)
{
- var metadataQuery = EntityManager.GetEntityQuery<MetaDataComponent>();
+ var metadataQuery = GetEntityQuery<MetaDataComponent>();
if (Deleted(uid))
return Array.Empty<(NetEntity, string)>();
var list = new ValueList<(NetEntity, string)>();
- var instrumentQuery = EntityManager.GetEntityQuery<InstrumentComponent>();
+ var instrumentQuery = GetEntityQuery<InstrumentComponent>();
if (!TryComp(uid, out InstrumentComponent? originInstrument)
|| originInstrument.InstrumentPlayer is not {} originPlayer)
return Array.Empty<(NetEntity, string)>();
// It's probably faster to get all possible active instruments than all entities in range
- var activeEnumerator = EntityManager.EntityQueryEnumerator<ActiveInstrumentComponent>();
+ var activeEnumerator = EntityQueryEnumerator<ActiveInstrumentComponent>();
while (activeEnumerator.MoveNext(out var entity, out _))
{
if (entity == uid)
_bandRequestQueue.Clear();
}
- var activeQuery = EntityManager.GetEntityQuery<ActiveInstrumentComponent>();
- var transformQuery = EntityManager.GetEntityQuery<TransformComponent>();
+ var activeQuery = GetEntityQuery<ActiveInstrumentComponent>();
+ var transformQuery = GetEntityQuery<TransformComponent>();
var query = AllEntityQuery<ActiveInstrumentComponent, InstrumentComponent>();
while (query.MoveNext(out var uid, out _, out var instrument))
private void OnActiveMicrowaveRemove(Entity<ActiveMicrowaveComponent> ent, ref EntRemovedFromContainerMessage args)
{
- EntityManager.RemoveComponentDeferred<ActivelyMicrowavedComponent>(args.Entity);
+ RemCompDeferred<ActivelyMicrowavedComponent>(args.Entity);
}
// Stop items from transforming through constructiongraphs while being microwaved.
if (!HasContents(ent.Comp) || HasComp<ActiveMicrowaveComponent>(ent))
return;
- _container.Remove(EntityManager.GetEntity(args.EntityID), ent.Comp.Storage);
+ _container.Remove(GetEntity(args.EntityID), ent.Comp.Storage);
UpdateUserInterfaceState(ent, ent.Comp);
}
args.Handled = true;
_adminLogger.Add(LogType.Gib,
- $"{EntityManager.ToPrettyString(args.User):user} " +
- $"has butchered {EntityManager.ToPrettyString(args.Target):target} " +
- $"with {EntityManager.ToPrettyString(args.Used):knife}");
+ $"{ToPrettyString(args.User):user} " +
+ $"has butchered {ToPrettyString(args.Target):target} " +
+ $"with {ToPrettyString(args.Used):knife}");
}
private void OnGetInteractionVerbs(EntityUid uid, ButcherableComponent component, GetVerbsEvent<InteractionVerb> args)
component.CurrentState = ExpendableLightState.BrandNew;
component.StateExpiryTime = (float)component.GlowDuration.TotalSeconds;
- EntityManager.EnsureComponent<PointLightComponent>(uid);
+ EnsureComp<PointLightComponent>(uid);
}
private void OnExpLightUse(Entity<ExpendableLightComponent> ent, ref UseInHandEvent args)
// TODO: Use ContainerFill dog
if (light.HasLampOnSpawn != null)
{
- var entity = EntityManager.SpawnEntity(light.HasLampOnSpawn, EntityManager.GetComponent<TransformComponent>(uid).Coordinates);
+ var entity = Spawn(light.HasLampOnSpawn, Comp<TransformComponent>(uid).Coordinates);
_containerSystem.Insert(entity, light.LightBulbContainer);
}
// need this to update visualizers
return false;
// check if bulb fits
- if (!EntityManager.TryGetComponent(bulbUid, out LightBulbComponent? lightBulb))
+ if (!TryComp(bulbUid, out LightBulbComponent? lightBulb))
return false;
if (lightBulb.Type != light.BulbType)
return false;
// check bulb state
var bulbUid = GetBulb(uid, light);
- if (bulbUid == null || !EntityManager.TryGetComponent(bulbUid.Value, out LightBulbComponent? lightBulb))
+ if (bulbUid == null || !TryComp(bulbUid.Value, out LightBulbComponent? lightBulb))
return false;
if (lightBulb.State == LightBulbState.Broken)
return false;
// check if light has bulb
var bulbUid = GetBulb(uid, light);
- if (bulbUid == null || !EntityManager.TryGetComponent(bulbUid.Value, out LightBulbComponent? lightBulb))
+ if (bulbUid == null || !TryComp(bulbUid.Value, out LightBulbComponent? lightBulb))
{
SetLight(uid, false, light: light);
powerReceiver.Load = 0;
light.IsBlinking = isNowBlinking;
- if (!EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
+ if (!TryComp(uid, out AppearanceComponent? appearance))
return;
_appearance.SetData(uid, PoweredLightVisuals.Blinking, isNowBlinking, appearance);
light.CurrentLit = value;
_ambientSystem.SetAmbience(uid, value);
- if (EntityManager.TryGetComponent(uid, out PointLightComponent? pointLight))
+ if (TryComp(uid, out PointLightComponent? pointLight))
{
_pointLight.SetEnabled(uid, value, pointLight);
if (_webhookSendDuringRound)
return;
- var query = EntityManager.EntityQueryEnumerator<StationNewsComponent>();
+ var query = EntityQueryEnumerator<StationNewsComponent>();
while (query.MoveNext(out _, out var comp))
{
return;
}
Spawn(component.FinishedPrototype, Transform(uid).Coordinates);
- EntityManager.DeleteEntity(uid);
+ Del(uid);
}
}
if (entity.Owner != args.User)
{
_adminLogger.Add(LogType.Healed,
- $"{EntityManager.ToPrettyString(args.User):user} healed {EntityManager.ToPrettyString(entity.Owner):target} for {total:damage} damage");
+ $"{ToPrettyString(args.User):user} healed {ToPrettyString(entity.Owner):target} for {total:damage} damage");
}
else
{
_adminLogger.Add(LogType.Healed,
- $"{EntityManager.ToPrettyString(args.User):user} healed themselves for {total:damage} damage");
+ $"{ToPrettyString(args.User):user} healed themselves for {total:damage} damage");
}
_audio.PlayPvs(healing.HealingEndSound, entity.Owner);
base.Update(frameTime);
var curTime = _gameTiming.CurTime;
- var sensors = EntityManager.EntityQueryEnumerator<SuitSensorComponent, DeviceNetworkComponent>();
+ var sensors = EntityQueryEnumerator<SuitSensorComponent, DeviceNetworkComponent>();
while (sensors.MoveNext(out var uid, out var sensor, out var device))
{
// get health mob state
var isAlive = false;
- if (EntityManager.TryGetComponent(sensor.User.Value, out MobStateComponent? mobState))
+ if (TryComp(sensor.User.Value, out MobStateComponent? mobState))
isAlive = !_mobStateSystem.IsDead(sensor.User.Value, mobState);
// get mob total damage
{
var item = storage.Contents.ContainedEntities[i];
_containers.Remove(item, storage.Contents);
- EntityManager.DeleteEntity(item);
+ Del(item);
}
var ash = Spawn("Ash", Transform(uid).Coordinates);
_containers.Insert(ash, storage.Contents);
}
else
{
- EntityManager.DeleteEntity(victim);
+ Del(victim);
}
_entityStorage.CloseStorage(uid);
Cremate(uid, component);
if (!Resolve(uid, ref component, false))
return;
- if (EntityManager.TryGetComponent(uid, out InputMoverComponent? controller))
+ if (TryComp(uid, out InputMoverComponent? controller))
{
controller.CurTickSprintMovement = Vector2.Zero;
var coordinates = Transform(uid).Coordinates;
_audio.PlayPvs(_audio.ResolveSound(creamPie.Sound), coordinates, AudioParams.Default.WithVariation(0.125f));
- if (EntityManager.TryGetComponent(uid, out FoodComponent? foodComp))
+ if (TryComp(uid, out FoodComponent? foodComp))
{
if (_solutions.TryGetSolution(uid, foodComp.Solution, out _, out var solution))
{
}
foreach (var trash in foodComp.Trash)
{
- EntityManager.SpawnEntity(trash, Transform(uid).Coordinates);
+ Spawn(trash, Transform(uid).Coordinates);
}
}
ActivatePayload(uid);
- EntityManager.QueueDeleteEntity(uid);
+ QueueDel(uid);
}
private void OnConsume(Entity<CreamPieComponent> entity, ref ConsumeDoAfterEvent args)
if (args.Handled || !args.Complex)
return;
- if (!EntityManager.TryGetComponent(entity, out SmokableComponent? smokable))
+ if (!TryComp(entity, out SmokableComponent? smokable))
return;
if (smokable.State != SmokableState.Lit)
if (args.Handled)
return;
- if (!EntityManager.TryGetComponent(entity, out SmokableComponent? smokable))
+ if (!TryComp(entity, out SmokableComponent? smokable))
return;
if (smokable.State != SmokableState.Unlit)
var targetEntity = args.Target;
if (targetEntity == null ||
!args.CanReach ||
- !EntityManager.TryGetComponent(entity, out SmokableComponent? smokable) ||
+ !TryComp(entity, out SmokableComponent? smokable) ||
smokable.State == SmokableState.Lit)
return;
if (args.Handled)
return;
- if (!EntityManager.TryGetComponent(entity, out SmokableComponent? smokable))
+ if (!TryComp(entity, out SmokableComponent? smokable))
return;
if (smokable.State != SmokableState.Unlit)
var targetEntity = args.Target;
if (targetEntity == null ||
!args.CanReach ||
- !EntityManager.TryGetComponent(entity, out SmokableComponent? smokable) ||
+ !TryComp(entity, out SmokableComponent? smokable) ||
smokable.State == SmokableState.Lit)
return;
_solutionContainerSystem.TryAddSolution(pipeSolution.Value, reagentSolution);
}
- EntityManager.DeleteEntity(contents);
+ Del(contents);
_itemSlotsSystem.SetLock(entity.Owner, entity.Comp.BowlSlot, true); //no inserting more until current runs out
if (entity.Comp.ExplodeOnUse || _emag.CheckFlag(entity, EmagType.Interaction))
{
_explosionSystem.QueueExplosion(entity.Owner, "Default", entity.Comp.ExplosionIntensity, 0.5f, 3, canCreateVacuum: false);
- EntityManager.DeleteEntity(entity);
+ Del(entity);
exploded = true;
}
else
{
exploded = true;
_explosionSystem.QueueExplosion(entity.Owner, "Default", entity.Comp.ExplosionIntensity, 0.5f, 3, canCreateVacuum: false);
- EntityManager.DeleteEntity(entity);
+ Del(entity);
break;
}
}
public void CheckSolutions(Entity<TrashOnSolutionEmptyComponent> entity)
{
- if (!EntityManager.HasComponent<SolutionContainerManagerComponent>(entity))
+ if (!HasComp<SolutionContainerManagerComponent>(entity))
return;
if (_solutionContainerSystem.TryGetSolution(entity.Owner, entity.Comp.Solution, out _, out var solution))
var temp = (object) component;
_serializationManager.CopyTo(data.Component, ref temp);
- EntityManager.AddComponent(uid, (Component) temp!);
+ AddComp(uid, (Component) temp!);
trigger.GrantedComponents.Add(registration.Type);
}
foreach (var type in trigger.GrantedComponents)
{
- EntityManager.RemoveComponent(uid, type);
+ RemComp(uid, type);
}
trigger.GrantedComponents.Clear();
var query = EntityQueryEnumerator<RandomWalkComponent, PhysicsComponent>();
while (query.MoveNext(out var uid, out var randomWalk, out var physics))
{
- if (EntityManager.HasComponent<ActorComponent>(uid)
- || EntityManager.HasComponent<ThrownItemComponent>(uid)
- || EntityManager.HasComponent<FollowerComponent>(uid))
+ if (HasComp<ActorComponent>(uid)
+ || HasComp<ThrownItemComponent>(uid)
+ || HasComp<FollowerComponent>(uid))
continue;
var curTime = _timing.CurTime;
return;
var target = pinpointer.Target;
- if (target == null || !EntityManager.EntityExists(target.Value))
+ if (target == null || !Exists(target.Value))
{
SetDistance(uid, Distance.Unknown, pinpointer);
return;
var mapCoordsPointed = _transform.ToMapCoordinates(coordsPointed);
_rotateToFaceSystem.TryFaceCoordinates(player, mapCoordsPointed.Position);
- var arrow = EntityManager.SpawnEntity("PointingArrow", coordsPointed);
+ var arrow = Spawn("PointingArrow", coordsPointed);
if (TryComp<PointingArrowComponent>(arrow, out var pointing))
{
var layer = (int) VisibilityFlags.Normal;
if (TryComp(player, out VisibilityComponent? playerVisibility))
{
- var arrowVisibility = EntityManager.EnsureComponent<VisibilityComponent>(arrow);
+ var arrowVisibility = EnsureComp<VisibilityComponent>(arrow);
layer = playerVisibility.Layer;
_visibilitySystem.SetLayer((arrow, arrowVisibility), (ushort) layer);
}
if (component.Chasing is not {Valid: true} chasing || Deleted(chasing))
{
- EntityManager.QueueDeleteEntity(uid);
+ QueueDel(uid);
continue;
}
_explosion.QueueExplosion(uid, ExplosionSystem.DefaultExplosionPrototypeId, 50, 3, 10);
- EntityManager.QueueDeleteEntity(uid);
+ QueueDel(uid);
}
}
}
if (TryComp<StackComponent>(placer, out var stack) && !_stack.Use(placer, 1, stack))
return;
- var newCable = EntityManager.SpawnEntity(component.CablePrototypeId, _map.GridTileToLocal(gridUid, grid, snapPos));
+ var newCable = Spawn(component.CablePrototypeId, _map.GridTileToLocal(gridUid, grid, snapPos));
_adminLogger.Add(LogType.Construction, LogImpact.Low,
$"{ToPrettyString(args.User):player} placed {ToPrettyString(newCable):cable} at {Transform(newCable).Coordinates}");
args.Handled = true;
private void OnReceiverStarted(Entity<ExtensionCableReceiverComponent> receiver, ref ComponentStartup args)
{
- if (EntityManager.TryGetComponent(receiver.Owner, out PhysicsComponent? physicsComponent))
+ if (TryComp(receiver.Owner, out PhysicsComponent? physicsComponent))
{
receiver.Comp.Connectable = physicsComponent.BodyType == BodyType.Static;
}
private void OnPowerMonitoringConsoleMessage(EntityUid uid, PowerMonitoringConsoleComponent component, PowerMonitoringConsoleMessage args)
{
- var focus = EntityManager.GetEntity(args.FocusDevice);
+ var focus = GetEntity(args.FocusDevice);
var group = args.FocusGroup;
// Update this if the focus device has changed
if (!args.Anchored)
{
- entConsole.PowerMonitoringDeviceMetaData.Remove(EntityManager.GetNetEntity(uid));
+ entConsole.PowerMonitoringDeviceMetaData.Remove(GetNetEntity(uid));
Dirty(ent, entConsole);
continue;
}
var name = MetaData(uid).EntityName;
- var coords = EntityManager.GetNetCoordinates(xform.Coordinates);
+ var coords = GetNetCoordinates(xform.Coordinates);
var metaData = new PowerMonitoringDeviceMetaData(name, coords, component.Group, component.SpritePath, component.SpriteState);
- entConsole.PowerMonitoringDeviceMetaData.TryAdd(EntityManager.GetNetEntity(uid), metaData);
+ entConsole.PowerMonitoringDeviceMetaData.TryAdd(GetNetEntity(uid), metaData);
Dirty(ent, entConsole);
}
continue;
// Generate a new console entry with which to populate the UI
- var entry = new PowerMonitoringConsoleEntry(EntityManager.GetNetEntity(ent), device.Group, powerStats.PowerValue, powerStats.BatteryLevel);
+ var entry = new PowerMonitoringConsoleEntry(GetNetEntity(ent), device.Group, powerStats.PowerValue, powerStats.BatteryLevel);
allEntries.Add(entry);
}
continue;
}
- indexedSources.Add(ent, new PowerMonitoringConsoleEntry(EntityManager.GetNetEntity(ent), entDevice.Group, powerSupplier.CurrentSupply, GetBatteryLevel(ent)));
+ indexedSources.Add(ent, new PowerMonitoringConsoleEntry(GetNetEntity(ent), entDevice.Group, powerSupplier.CurrentSupply, GetBatteryLevel(ent)));
}
}
continue;
}
- indexedSources.Add(ent, new PowerMonitoringConsoleEntry(EntityManager.GetNetEntity(ent), entDevice.Group, entBattery.CurrentSupply, GetBatteryLevel(ent)));
+ indexedSources.Add(ent, new PowerMonitoringConsoleEntry(GetNetEntity(ent), entDevice.Group, entBattery.CurrentSupply, GetBatteryLevel(ent)));
}
}
continue;
}
- indexedLoads.Add(ent, new PowerMonitoringConsoleEntry(EntityManager.GetNetEntity(ent), entDevice.Group, powerConsumer.ReceivedPower, GetBatteryLevel(ent)));
+ indexedLoads.Add(ent, new PowerMonitoringConsoleEntry(GetNetEntity(ent), entDevice.Group, powerConsumer.ReceivedPower, GetBatteryLevel(ent)));
}
}
continue;
}
- indexedLoads.Add(ent, new PowerMonitoringConsoleEntry(EntityManager.GetNetEntity(ent), entDevice.Group, battery.CurrentReceiving, GetBatteryLevel(ent)));
+ indexedLoads.Add(ent, new PowerMonitoringConsoleEntry(GetNetEntity(ent), entDevice.Group, battery.CurrentReceiving, GetBatteryLevel(ent)));
}
}
private void UpdateCollectionChildMetaData(EntityUid child, EntityUid master)
{
- var netEntity = EntityManager.GetNetEntity(child);
+ var netEntity = GetNetEntity(child);
var xform = Transform(child);
var query = AllEntityQuery<PowerMonitoringConsoleComponent, TransformComponent>();
if (!entConsole.PowerMonitoringDeviceMetaData.TryGetValue(netEntity, out var metaData))
continue;
- metaData.CollectionMaster = EntityManager.GetNetEntity(master);
+ metaData.CollectionMaster = GetNetEntity(master);
entConsole.PowerMonitoringDeviceMetaData[netEntity] = metaData;
Dirty(ent, entConsole);
private void UpdateCollectionMasterMetaData(EntityUid master, int childCount)
{
- var netEntity = EntityManager.GetNetEntity(master);
+ var netEntity = GetNetEntity(master);
var xform = Transform(master);
var query = AllEntityQuery<PowerMonitoringConsoleComponent, TransformComponent>();
if (grid != entXform.GridUid)
continue;
- var netEntity = EntityManager.GetNetEntity(ent);
+ var netEntity = GetNetEntity(ent);
var name = MetaData(ent).EntityName;
- var netCoords = EntityManager.GetNetCoordinates(entXform.Coordinates);
+ var netCoords = GetNetCoordinates(entXform.Coordinates);
var metaData = new PowerMonitoringDeviceMetaData(name, netCoords, entDevice.Group, entDevice.SpritePath, entDevice.SpriteState);
{
if (!entDevice.IsCollectionMaster)
{
- metaData.CollectionMaster = EntityManager.GetNetEntity(entDevice.CollectionMaster);
+ metaData.CollectionMaster = GetNetEntity(entDevice.CollectionMaster);
}
else if (entDevice.ChildDevices.Count > 0)
foreach (var (entity, component) in toRemove)
{
_explosionSystem.QueueExplosion(entity, "PowerSink", 2000f, 4f, 20f, canCreateVacuum: true);
- EntityManager.RemoveComponent(entity, component);
+ RemComp(entity, component);
}
}
private void AddPrayVerb(EntityUid uid, PrayableComponent comp, GetVerbsEvent<ActivationVerb> args)
{
// if it doesn't have an actor and we can't reach it then don't add the verb
- if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
+ if (!TryComp(args.User, out ActorComponent? actor))
return;
// this is to prevent ghosts from using it
Icon = comp.VerbImage,
Act = () =>
{
- if (comp.BibleUserOnly && !EntityManager.TryGetComponent<BibleUserComponent>(args.User, out var bibleUser))
+ if (comp.BibleUserOnly && !TryComp<BibleUserComponent>(args.User, out var bibleUser))
{
_popupSystem.PopupEntity(Loc.GetString("prayer-popup-notify-pray-locked"), uid, actor.PlayerSession, PopupType.Large);
return;
if (!TryComp<MapGridComponent>(dungeonUid, out var dungeonGrid))
{
dungeonUid = EntityManager.CreateEntityUninitialized(null, new EntityCoordinates(dungeonUid, position));
- dungeonGrid = EntityManager.AddComponent<MapGridComponent>(dungeonUid);
+ dungeonGrid = AddComp<MapGridComponent>(dungeonUid);
EntityManager.InitializeAndStartEntity(dungeonUid, mapId);
// If we created a grid (e.g. space dungen) then offset it so we don't double-apply positions
position = Vector2i.Zero;
var modifiedDamage = _damageableSystem.TryChangeDamage(target, ev.Damage, component.IgnoreResistances, damageable: damageableComponent, origin: component.Shooter);
var deleted = Deleted(target);
- if (modifiedDamage is not null && EntityManager.EntityExists(component.Shooter))
+ if (modifiedDamage is not null && Exists(component.Shooter))
{
if (modifiedDamage.AnyPositive() && !deleted)
{
stopwatch.Start();
_sources.Clear();
- _sources.EnsureCapacity(EntityManager.Count<RadiationSourceComponent>());
+ _sources.EnsureCapacity(Count<RadiationSourceComponent>());
var sources = EntityQueryEnumerator<RadiationSourceComponent, TransformComponent>();
var destinations = EntityQueryEnumerator<RadiationReceiverComponent, TransformComponent>();
if (args.Cancelled)
return;
- if (!EntityManager.TryGetComponent(uid, out DamageableComponent? damageable) || damageable.TotalDamage == 0)
+ if (!TryComp(uid, out DamageableComponent? damageable) || damageable.TotalDamage == 0)
return;
if (component.Damage != null)
_research.ModifyServerPoints(args.Target.Value, component.Points, server);
_popupSystem.PopupEntity(Loc.GetString("research-disk-inserted", ("points", component.Points)), args.Target.Value, args.User);
- EntityManager.QueueDeleteEntity(uid);
+ QueueDel(uid);
args.Handled = true;
}
return;
// Check if the object is anchored.
- if (EntityManager.TryGetComponent(uid, out PhysicsComponent? physics) && physics.BodyType == BodyType.Static)
+ if (TryComp(uid, out PhysicsComponent? physics) && physics.BodyType == BodyType.Static)
return;
Verb verb = new()
// Check if the object is anchored, and whether we are still allowed to rotate it.
if (!component.RotateWhileAnchored &&
- EntityManager.TryGetComponent(uid, out PhysicsComponent? physics) &&
+ TryComp(uid, out PhysicsComponent? physics) &&
physics.BodyType == BodyType.Static)
return;
Verb resetRotation = new()
{
DoContactInteraction = true,
- Act = () => EntityManager.GetComponent<TransformComponent>(uid).LocalRotation = Angle.Zero,
+ Act = () => Comp<TransformComponent>(uid).LocalRotation = Angle.Zero,
Category = VerbCategory.Rotate,
Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/refresh.svg.192dpi.png")),
Text = "Reset",
// rotate clockwise
Verb rotateCW = new()
{
- Act = () => EntityManager.GetComponent<TransformComponent>(uid).LocalRotation -= component.Increment,
+ Act = () => Comp<TransformComponent>(uid).LocalRotation -= component.Increment,
Category = VerbCategory.Rotate,
Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/rotate_cw.svg.192dpi.png")),
Priority = -1,
// rotate counter-clockwise
Verb rotateCCW = new()
{
- Act = () => EntityManager.GetComponent<TransformComponent>(uid).LocalRotation += component.Increment,
+ Act = () => Comp<TransformComponent>(uid).LocalRotation += component.Increment,
Category = VerbCategory.Rotate,
Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/rotate_ccw.svg.192dpi.png")),
Priority = 0,
/// </summary>
public void Flip(EntityUid uid, FlippableComponent component)
{
- var oldTransform = EntityManager.GetComponent<TransformComponent>(uid);
- var entity = EntityManager.SpawnEntity(component.MirrorEntity, oldTransform.Coordinates);
- var newTransform = EntityManager.GetComponent<TransformComponent>(entity);
+ var oldTransform = Comp<TransformComponent>(uid);
+ var entity = Spawn(component.MirrorEntity, oldTransform.Coordinates);
+ var newTransform = Comp<TransformComponent>(entity);
newTransform.LocalRotation = oldTransform.LocalRotation;
_transform.Unanchor(entity, newTransform);
- EntityManager.DeleteEntity(uid);
+ Del(uid);
}
public bool HandleRotateObjectClockwise(ICommonSession? playerSession, EntityCoordinates coordinates, EntityUid entity)
return false;
// Check if the object is anchored, and whether we are still allowed to rotate it.
- if (!rotatableComp.RotateWhileAnchored && EntityManager.TryGetComponent(entity, out PhysicsComponent? physics) &&
+ if (!rotatableComp.RotateWhileAnchored && TryComp(entity, out PhysicsComponent? physics) &&
physics.BodyType == BodyType.Static)
{
_popup.PopupEntity(Loc.GetString("rotatable-component-try-rotate-stuck"), entity, player);
return false;
// Check if the object is anchored, and whether we are still allowed to rotate it.
- if (!rotatableComp.RotateWhileAnchored && EntityManager.TryGetComponent(entity, out PhysicsComponent? physics) &&
+ if (!rotatableComp.RotateWhileAnchored && TryComp(entity, out PhysicsComponent? physics) &&
physics.BodyType == BodyType.Static)
{
_popup.PopupEntity(Loc.GetString("rotatable-component-try-rotate-stuck"), entity, player);
return false;
// Check if the object is anchored.
- if (EntityManager.TryGetComponent(entity, out PhysicsComponent? physics) && physics.BodyType == BodyType.Static)
+ if (TryComp(entity, out PhysicsComponent? physics) && physics.BodyType == BodyType.Static)
{
_popup.PopupEntity(Loc.GetString("flippable-component-try-flip-is-stuck"), entity, player);
return false;
private void OnShutdown(EntityUid uid, DockingComponent component, ComponentShutdown args)
{
if (component.DockedWith == null ||
- EntityManager.GetComponent<MetaDataComponent>(uid).EntityLifeStage > EntityLifeStage.MapInitialized)
+ Comp<MetaDataComponent>(uid).EntityLifeStage > EntityLifeStage.MapInitialized)
{
return;
}
dockA.DockJointId = null;
// If these grids are ever null then need to look at fixing ordering for unanchored events elsewhere.
- var gridAUid = EntityManager.GetComponent<TransformComponent>(dockAUid).GridUid;
- var gridBUid = EntityManager.GetComponent<TransformComponent>(dockBUid.Value).GridUid;
+ var gridAUid = Comp<TransformComponent>(dockAUid).GridUid;
+ var gridBUid = Comp<TransformComponent>(dockBUid.Value).GridUid;
var msg = new UndockEvent
{
var component = entity.Comp;
// Use startup so transform already initialized
- if (!EntityManager.GetComponent<TransformComponent>(uid).Anchored)
+ if (!Comp<TransformComponent>(uid).Anchored)
return;
// This little gem is for docking deserialization
if (MetaData(component.DockedWith.Value).EntityLifeStage < EntityLifeStage.Initialized)
return;
- var otherDock = EntityManager.GetComponent<DockingComponent>(component.DockedWith.Value);
+ var otherDock = Comp<DockingComponent>(component.DockedWith.Value);
DebugTools.Assert(otherDock.DockedWith != null);
Dock((uid, component), (component.DockedWith.Value, otherDock));
// https://gamedev.stackexchange.com/questions/98772/b2distancejoint-with-frequency-equal-to-0-vs-b2weldjoint
// We could also potentially use a prismatic joint? Depending if we want clamps that can extend or whatever
- var dockAXform = EntityManager.GetComponent<TransformComponent>(dockAUid);
- var dockBXform = EntityManager.GetComponent<TransformComponent>(dockBUid);
+ var dockAXform = Comp<TransformComponent>(dockAUid);
+ var dockBXform = Comp<TransformComponent>(dockBUid);
DebugTools.Assert(dockAXform.GridUid != null);
DebugTools.Assert(dockBXform.GridUid != null);
SharedJointSystem.LinearStiffness(
2f,
0.7f,
- EntityManager.GetComponent<PhysicsComponent>(gridA).Mass,
- EntityManager.GetComponent<PhysicsComponent>(gridB).Mass,
+ Comp<PhysicsComponent>(gridA).Mass,
+ Comp<PhysicsComponent>(gridB).Mass,
out var stiffness,
out var damping);
joint = _jointSystem.GetOrCreateWeldJoint(gridA, gridB, DockingJoint + dockAUid);
}
- var gridAXform = EntityManager.GetComponent<TransformComponent>(gridA);
- var gridBXform = EntityManager.GetComponent<TransformComponent>(gridB);
+ var gridAXform = Comp<TransformComponent>(gridA);
+ var gridBXform = Comp<TransformComponent>(gridB);
var anchorA = dockAXform.LocalPosition + dockAXform.LocalRotation.ToWorldVec() / 2f;
var anchorB = dockBXform.LocalPosition + dockBXform.LocalRotation.ToWorldVec() / 2f;
public void AddPilot(EntityUid uid, EntityUid entity, ShuttleConsoleComponent component)
{
- if (!EntityManager.TryGetComponent(entity, out PilotComponent? pilotComponent)
+ if (!TryComp(entity, out PilotComponent? pilotComponent)
|| component.SubscribedPilots.Contains(entity))
{
return;
pilotComponent.Console = uid;
ActionBlockerSystem.UpdateCanMove(entity);
- pilotComponent.Position = EntityManager.GetComponent<TransformComponent>(entity).Coordinates;
+ pilotComponent.Position = Comp<TransformComponent>(entity).Coordinates;
Dirty(entity, pilotComponent);
}
_popup.PopupEntity(Loc.GetString("shuttle-pilot-end"), pilotUid, pilotUid);
if (pilotComponent.LifeStage < ComponentLifeStage.Stopping)
- EntityManager.RemoveComponent<PilotComponent>(pilotUid);
+ RemComp<PilotComponent>(pilotUid);
}
public void RemovePilot(EntityUid entity)
{
- if (!EntityManager.TryGetComponent(entity, out PilotComponent? pilotComponent))
+ if (!TryComp(entity, out PilotComponent? pilotComponent))
return;
RemovePilot(entity, pilotComponent);
private void OnShuttleStartup(EntityUid uid, ShuttleComponent component, ComponentStartup args)
{
- if (!EntityManager.HasComponent<MapGridComponent>(uid))
+ if (!HasComp<MapGridComponent>(uid))
{
return;
}
- if (!EntityManager.TryGetComponent(uid, out PhysicsComponent? physicsComponent))
+ if (!TryComp(uid, out PhysicsComponent? physicsComponent))
{
return;
}
public void Toggle(EntityUid uid, ShuttleComponent component)
{
- if (!EntityManager.TryGetComponent(uid, out PhysicsComponent? physicsComponent))
+ if (!TryComp(uid, out PhysicsComponent? physicsComponent))
return;
component.Enabled = !component.Enabled;
private void OnShuttleShutdown(EntityUid uid, ShuttleComponent component, ComponentShutdown args)
{
// None of the below is necessary for any cleanup if we're just deleting.
- if (EntityManager.GetComponent<MetaDataComponent>(uid).EntityLifeStage >= EntityLifeStage.Terminating)
+ if (Comp<MetaDataComponent>(uid).EntityLifeStage >= EntityLifeStage.Terminating)
return;
Disable(uid);
args.PushMarkup(enabled);
if (component.Type == ThrusterType.Linear &&
- EntityManager.TryGetComponent(uid, out TransformComponent? xform) &&
+ TryComp(uid, out TransformComponent? xform) &&
xform.Anchored)
{
var nozzleLocalization = ContentLocalizationManager.FormatDirection(xform.LocalRotation.Opposite().ToWorldVec().GetDir()).ToLower();
// TODO: Don't make them rotatable and make it require anchoring.
if (!component.Enabled ||
- !EntityManager.TryGetComponent(uid, out TransformComponent? xform) ||
- !EntityManager.TryGetComponent(xform.GridUid, out ShuttleComponent? shuttleComponent))
+ !TryComp(uid, out TransformComponent? xform) ||
+ !TryComp(xform.GridUid, out ShuttleComponent? shuttleComponent))
{
return;
}
component.IsOn = true;
- if (!EntityManager.TryGetComponent(xform.GridUid, out ShuttleComponent? shuttleComponent))
+ if (!TryComp(xform.GridUid, out ShuttleComponent? shuttleComponent))
return;
// Logger.DebugS("thruster", $"Enabled thruster {uid}");
shuttleComponent.LinearThrusters[direction].Add(uid);
// Don't just add / remove the fixture whenever the thruster fires because perf
- if (EntityManager.TryGetComponent(uid, out PhysicsComponent? physicsComponent) &&
+ if (TryComp(uid, out PhysicsComponent? physicsComponent) &&
component.BurnPoly.Count > 0)
{
var shape = new PolygonShape();
throw new ArgumentOutOfRangeException();
}
- if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
+ if (TryComp(uid, out AppearanceComponent? appearance))
{
_appearance.SetData(uid, ThrusterVisualState.State, true, appearance);
}
component.IsOn = false;
- if (!EntityManager.TryGetComponent(gridId, out ShuttleComponent? shuttleComponent))
+ if (!TryComp(gridId, out ShuttleComponent? shuttleComponent))
return;
// Logger.DebugS("thruster", $"Disabled thruster {uid}");
throw new ArgumentOutOfRangeException();
}
- if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
+ if (TryComp(uid, out AppearanceComponent? appearance))
{
_appearance.SetData(uid, ThrusterVisualState.State, false, appearance);
}
_ambient.SetAmbience(uid, false);
- if (EntityManager.TryGetComponent(uid, out PhysicsComponent? physicsComponent))
+ if (TryComp(uid, out PhysicsComponent? physicsComponent))
{
_fixtureSystem.DestroyFixture(uid, BurnFixture, body: physicsComponent);
}
var sourcePos = _xforms.GetWorldPosition(sourceXform, xformQuery);
// This function ensures that chat popups appear on camera views that have connected microphones.
- var query = EntityManager.EntityQueryEnumerator<StationAiCoreComponent, TransformComponent>();
+ var query = EntityQueryEnumerator<StationAiCoreComponent, TransformComponent>();
while (query.MoveNext(out var ent, out var entStationAiCore, out var entXform))
{
var stationAiCore = new Entity<StationAiCoreComponent?>(ent, entStationAiCore);
_adminLogger.Add(LogType.EntityDelete, LogImpact.High, $"{ToPrettyString(morsel):player} entered the event horizon of {ToPrettyString(hungry)} and was deleted");
}
- EntityManager.QueueDeleteEntity(morsel);
+ QueueDel(morsel);
var evSelf = new EntityConsumedByEventHorizonEvent(morsel, hungry, eventHorizon, outerContainer);
var evEaten = new EventHorizonConsumedEntityEvent(morsel, hungry, eventHorizon, outerContainer);
RaiseLocalEvent(hungry, ref evSelf);
private void OnEventHorizonContained(EventHorizonContainedEvent args)
{
var uid = args.Entity;
- if (!EntityManager.EntityExists(uid))
+ if (!Exists(uid))
return;
var comp = args.EventHorizon;
if (comp.BeingConsumedByAnotherEventHorizon)
return;
var containerEntity = args.Args.Container.Owner;
- if (!EntityManager.EntityExists(containerEntity))
+ if (!Exists(containerEntity))
return;
if (AttemptConsumeEntity(uid, containerEntity, comp))
return; // If we consume the entity we also consume everything in the containers it has.
if (!_containerSystem.TryGetContainer(uid, GasTankContainer, out var container) || container.ContainedEntities.Count == 0)
return false;
- if (!EntityManager.TryGetComponent(container.ContainedEntities.First(), out gasTankComponent))
+ if (!TryComp(container.ContainedEntities.First(), out gasTankComponent))
return false;
return true;
return;
SetPower(uid, 0, comp);
- EntityManager.SpawnEntity(comp.SpawnPrototype, Transform(uid).Coordinates);
+ Spawn(comp.SpawnPrototype, Transform(uid).Coordinates);
}
#region Getters/Setters
/// <param name="args">The state of the beginning of the collision.</param>
private void HandleParticleCollide(EntityUid uid, ParticleProjectileComponent component, ref StartCollideEvent args)
{
- if (!EntityManager.TryGetComponent<SingularityGeneratorComponent>(args.OtherEntity, out var generatorComp))
+ if (!TryComp<SingularityGeneratorComponent>(args.OtherEntity, out var generatorComp))
return;
if (_timing.CurTime < _metadata.GetPauseTime(uid) + generatorComp.NextFailsafe && !generatorComp.FailsafeDisabled)
{
- EntityManager.QueueDeleteEntity(uid);
+ QueueDel(uid);
return;
}
);
}
- EntityManager.QueueDeleteEntity(uid);
+ QueueDel(uid);
}
#endregion Event Handlers
private void OnConsumed(EntityUid uid, SingularityComponent comp, ref EventHorizonConsumedEntityEvent args)
{
// Should be slightly more efficient than checking literally everything we consume for a singularity component and doing the reverse.
- if (EntityManager.TryGetComponent<SingularityComponent>(args.EventHorizonUid, out var singulo))
+ if (TryComp<SingularityComponent>(args.EventHorizonUid, out var singulo))
{
AdjustEnergy(args.EventHorizonUid, comp.Energy, singularity: singulo);
SetEnergy(uid, 0.0f, comp);
/// <param name="args">The event arguments.</param>
public void OnConsumed(EntityUid uid, SinguloFoodComponent comp, ref EventHorizonConsumedEntityEvent args)
{
- if (EntityManager.TryGetComponent<SingularityComponent>(args.EventHorizonUid, out var singulo))
+ if (TryComp<SingularityComponent>(args.EventHorizonUid, out var singulo))
{
// Calculate the percentage change (positive or negative)
var percentageChange = singulo.Energy * (comp.EnergyFactor - 1f);
private void UpdatePanelCoverage(Entity<SolarPanelComponent> panel)
{
var entity = panel.Owner;
- var xform = EntityManager.GetComponent<TransformComponent>(entity);
+ var xform = Comp<TransformComponent>(entity);
// So apparently, and yes, I *did* only find this out later,
// this is just a really fancy way of saying "Lambert's law of cosines".
}
if (!Deleted(uid))
- EntityManager.SpawnEntity(_robustRandom.Pick(component.Prototypes), Transform(uid).Coordinates);
+ Spawn(_robustRandom.Pick(component.Prototypes), Transform(uid).Coordinates);
}
private void Spawn(EntityUid uid, RandomSpawnerComponent component)
{
if (component.RarePrototypes.Count > 0 && (component.RareChance == 1.0f || _robustRandom.Prob(component.RareChance)))
{
- EntityManager.SpawnEntity(_robustRandom.Pick(component.RarePrototypes), Transform(uid).Coordinates);
+ Spawn(_robustRandom.Pick(component.RarePrototypes), Transform(uid).Coordinates);
return;
}
var coordinates = Transform(uid).Coordinates.Offset(new Vector2(xOffset, yOffset));
- EntityManager.SpawnEntity(_robustRandom.Pick(component.Prototypes), coordinates);
+ Spawn(_robustRandom.Pick(component.Prototypes), coordinates);
}
private void Spawn(Entity<EntityTableSpawnerComponent> ent)
// Get the organs' position & spawn a nymph there
var coords = Transform(uid).Coordinates;
- var nymph = EntityManager.SpawnAtPosition(entityProto.ID, coords);
+ var nymph = SpawnAtPosition(entityProto.ID, coords);
if (HasComp<ZombieComponent>(args.OldBody)) // Zombify the new nymph if old one is a zombie
_zombie.ZombifyEntity(nymph);
// try to remove accent
var componentType = Factory.GetRegistration(component.Accent).Type;
- EntityManager.RemoveComponent(args.Wearer, componentType);
+ RemComp(args.Wearer, componentType);
component.IsActive = false;
}
component.GrowthLevel = 3;
component.GrowthLevel = Math.Max(1, component.GrowthLevel - growthDamage);
- if (EntityManager.TryGetComponent<AppearanceComponent>(uid, out var appearance))
+ if (TryComp<AppearanceComponent>(uid, out var appearance))
{
_appearance.SetData(uid, KudzuVisuals.GrowthLevel, component.GrowthLevel, appearance);
}
private void SetupKudzu(EntityUid uid, KudzuComponent component, ComponentStartup args)
{
- if (!EntityManager.TryGetComponent<AppearanceComponent>(uid, out var appearance))
+ if (!TryComp<AppearanceComponent>(uid, out var appearance))
{
return;
}
if (prototype?.JobEntity != null)
{
DebugTools.Assert(entity is null);
- var jobEntity = EntityManager.SpawnEntity(prototype.JobEntity, coordinates);
+ var jobEntity = Spawn(prototype.JobEntity, coordinates);
MakeSentientCommand.MakeSentient(jobEntity, EntityManager);
// Make sure custom names get handled, what is gameticker control flow whoopy.
.Where(x => !x.Abstract)
.Select(x => x.ID).ToList();
- foreach (var (_, transform) in EntityManager.EntityQuery<GasVentPumpComponent, TransformComponent>())
+ foreach (var (_, transform) in EntityQuery<GasVentPumpComponent, TransformComponent>())
{
if (CompOrNull<StationMemberComponent>(transform.GridUid)?.Station != chosenStation)
{
if (component.BehaviorProperties.TransportEntities || component.BehaviorProperties.TransportSentient)
foreach (var entity in target.Value.storageComponent.Contents.ContainedEntities.ToArray())
{
- if (EntityManager.HasComponent<MindContainerComponent>(entity))
+ if (HasComp<MindContainerComponent>(entity))
{
if (!component.BehaviorProperties.TransportSentient)
continue;
if (component.BehaviorProperties.TransportEntities || component.BehaviorProperties.TransportSentient)
foreach (var entity in entityStorageComponent.Contents.ContainedEntities.ToArray())
{
- if (EntityManager.HasComponent<MindContainerComponent>(entity))
+ if (HasComp<MindContainerComponent>(entity))
{
if (!component.BehaviorProperties.TransportSentient)
continue;
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
protected override int? GetCount(ContainerModifiedMessage msg, ItemCounterComponent itemCounter)
{
- if (!EntityManager.TryGetComponent(msg.Container.Owner, out StorageComponent? component))
+ if (!TryComp(msg.Container.Owner, out StorageComponent? component))
{
return null;
}
// Calculate the average price of the possible spawned items
args.Price += _pricing.GetPrice(protUid) * entry.SpawnProbability * entry.GetAmount(getAverage: true);
- EntityManager.DeleteEntity(protUid);
+ Del(protUid);
}
foreach (var group in orGroups)
(entry.SpawnProbability / group.CumulativeProbability) *
entry.GetAmount(getAverage: true);
- EntityManager.DeleteEntity(protUid);
+ Del(protUid);
}
}
_actionContainer.RemoveAction(purchase, logMissing: false);
- EntityManager.DeleteEntity(purchase);
+ Del(purchase);
}
component.BoughtEntities.Clear();
private void TryDoCollideStun(EntityUid uid, StunOnCollideComponent component, EntityUid target)
{
- if (EntityManager.TryGetComponent<StatusEffectsComponent>(target, out var status))
+ if (TryComp<StatusEffectsComponent>(target, out var status))
{
_stunSystem.TryStun(target, TimeSpan.FromSeconds(component.StunAmount), true, status);
if (monitor.LastHeartbeat > _maxHeartbeatTime)
{
DisconnectCamera(uid, true, monitor);
- EntityManager.RemoveComponent<ActiveSurveillanceCameraMonitorComponent>(uid);
+ RemComp<ActiveSurveillanceCameraMonitorComponent>(uid);
}
}
}
monitor.ActiveCamera = null;
monitor.ActiveCameraAddress = string.Empty;
- EntityManager.RemoveComponent<ActiveSurveillanceCameraMonitorComponent>(uid);
+ RemComp<ActiveSurveillanceCameraMonitorComponent>(uid);
UpdateUserInterface(uid, monitor);
}
TabletopMap = mapId;
_tabletops = 0;
- var mapComp = EntityManager.GetComponent<MapComponent>(mapUid);
+ var mapComp = Comp<MapComponent>(mapUid);
// Lighting is always disabled in tabletop world.
mapComp.LightingEnabled = false;
/// <param name="uid">The UID of the tabletop game entity.</param>
public void CleanupSession(EntityUid uid)
{
- if (!EntityManager.TryGetComponent(uid, out TabletopGameComponent? tabletop))
+ if (!TryComp(uid, out TabletopGameComponent? tabletop))
return;
if (tabletop.Session is not { } session)
foreach (var euid in session.Entities)
{
- EntityManager.QueueDeleteEntity(euid);
+ QueueDel(euid);
}
tabletop.Session = null;
/// <param name="uid">The UID of the tabletop game entity.</param>
public void OpenSessionFor(ICommonSession player, EntityUid uid)
{
- if (!EntityManager.TryGetComponent(uid, out TabletopGameComponent? tabletop) || player.AttachedEntity is not {Valid: true} attachedEntity)
+ if (!TryComp(uid, out TabletopGameComponent? tabletop) || player.AttachedEntity is not {Valid: true} attachedEntity)
return;
// Make sure we have a session, and add the player to it if not added already.
if (session.Players.ContainsKey(player))
return;
- if(EntityManager.TryGetComponent(attachedEntity, out TabletopGamerComponent? gamer))
+ if(TryComp(attachedEntity, out TabletopGamerComponent? gamer))
CloseSessionFor(player, gamer.Tabletop, false);
// Set the entity as an absolute GAMER.
/// <param name="removeGamerComponent">Whether to remove the <see cref="TabletopGamerComponent"/> from the player's attached entity.</param>
public void CloseSessionFor(ICommonSession player, EntityUid uid, bool removeGamerComponent = true)
{
- if (!EntityManager.TryGetComponent(uid, out TabletopGameComponent? tabletop) || tabletop.Session is not { } session)
+ if (!TryComp(uid, out TabletopGameComponent? tabletop) || tabletop.Session is not { } session)
return;
if (!session.Players.TryGetValue(player, out var data))
return;
- if(removeGamerComponent && player.AttachedEntity is {} attachedEntity && EntityManager.TryGetComponent(attachedEntity, out TabletopGamerComponent? gamer))
+ if(removeGamerComponent && player.AttachedEntity is {} attachedEntity && TryComp(attachedEntity, out TabletopGamerComponent? gamer))
{
// We invalidate this to prevent an infinite feedback from removing the component.
gamer.Tabletop = EntityUid.Invalid;
// You stop being a gamer.......
- EntityManager.RemoveComponent<TabletopGamerComponent>(attachedEntity);
+ RemComp<TabletopGamerComponent>(attachedEntity);
}
session.Players.Remove(player);
session.Entities.Remove(data.Camera);
// Deleting the view subscriber automatically cleans up subscriptions, no need to do anything else.
- EntityManager.QueueDeleteEntity(data.Camera);
+ QueueDel(data.Camera);
}
/// <summary>
if (!_cfg.GetCVar(CCVars.GameTabletopPlace))
return;
- if (!EntityManager.TryGetComponent(args.User, out HandsComponent? hands))
+ if (!TryComp(args.User, out HandsComponent? hands))
return;
if (component.Session is not { } session)
if (!args.CanAccess || !args.CanInteract)
return;
- if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
+ if (!TryComp(args.User, out ActorComponent? actor))
return;
var playVerb = new ActivationVerb()
return;
// Check that a player is attached to the entity.
- if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
+ if (!TryComp(args.User, out ActorComponent? actor))
return;
OpenSessionFor(actor.PlayerSession, uid);
private void OnGamerShutdown(EntityUid uid, TabletopGamerComponent component, ComponentShutdown args)
{
- if (!EntityManager.TryGetComponent(uid, out ActorComponent? actor))
+ if (!TryComp(uid, out ActorComponent? actor))
return;
if(component.Tabletop.IsValid())
if (!TryComp(uid, out ActorComponent? actor))
{
- EntityManager.RemoveComponent<TabletopGamerComponent>(uid);
+ RemComp<TabletopGamerComponent>(uid);
return;
}
{
base.Update(frameTime);
- var query = EntityManager.EntityQueryEnumerator<TelephoneComponent>();
+ var query = EntityQueryEnumerator<TelephoneComponent>();
while (query.MoveNext(out var uid, out var telephone))
{
var entity = new Entity<TelephoneComponent>(uid, telephone);
continue;
var coords = Transform(args.Mob).Coordinates;
- var inhandEntity = EntityManager.SpawnEntity(traitPrototype.TraitGear, coords);
+ var inhandEntity = Spawn(traitPrototype.TraitGear, coords);
_sharedHandsSystem.TryPickup(args.Mob,
inhandEntity,
checkActionBlocker: false,
{
var player = eventArgs.SenderSession;
- if (!EntityManager.EntityExists(GetEntity(args.EntityUid)))
+ if (!Exists(GetEntity(args.EntityUid)))
{
Log.Warning($"{nameof(HandleVerbRequest)} called on a non-existent entity with id {args.EntityUid} by player {player}.");
return;
{
var player = args.Actor;
- if (!EntityManager.TryGetComponent(player, out HandsComponent? handsComponent))
+ if (!TryComp(player, out HandsComponent? handsComponent))
{
_popupSystem.PopupEntity(Loc.GetString("wires-component-ui-on-receive-message-no-hands"), uid, player);
return;
if (!_hands.TryGetActiveItem((player, handsComponent), out var heldEntity))
return;
- if (!EntityManager.TryGetComponent(heldEntity, out ToolComponent? tool))
+ if (!TryComp(heldEntity, out ToolComponent? tool))
return;
TryDoWireAction(uid, player, heldEntity.Value, args.Id, args.Action, component, tool);
if (_inventorySystem.TryGetSlotEntity(uid, "id", out var idUid))
{
// PDA
- if (EntityManager.TryGetComponent(idUid, out PdaComponent? pda) &&
+ if (TryComp(idUid, out PdaComponent? pda) &&
TryComp<IdCardComponent>(pda.ContainedId, out var id))
{
return GetNameAndJob(id);
}
// ID Card
- if (EntityManager.TryGetComponent(idUid, out id))
+ if (TryComp(idUid, out id))
{
return GetNameAndJob(id);
}
// TODO: Preserve ordering of actions
- _entityManager.DeleteEntity(uid);
+ Del(uid);
}
public bool TryUpgradeAction(EntityUid? actionId, out EntityUid? upgradeActionId, ActionUpgradeComponent? actionUpgradeComponent = null, int newLevel = 0)
// TODO: Preserve ordering of actions
- _entityManager.DeleteEntity(actionId);
+ Del(actionId);
return upgradedActionId.Value;
}
public IReadOnlyDictionary<AlertKey, AlertState>? GetActiveAlerts(EntityUid euid)
{
- return EntityManager.TryGetComponent(euid, out AlertsComponent? comp)
+ return TryComp(euid, out AlertsComponent? comp)
? comp.Alerts
: null;
}
public bool IsShowingAlert(EntityUid euid, ProtoId<AlertPrototype> alertType)
{
- if (!EntityManager.TryGetComponent(euid, out AlertsComponent? alertsComponent))
+ if (!TryComp(euid, out AlertsComponent? alertsComponent))
return false;
if (TryGet(alertType, out var alert))
/// <returns>true iff an alert of the indicated alert category is currently showing</returns>
public bool IsShowingAlertCategory(EntityUid euid, ProtoId<AlertCategoryPrototype> alertCategory)
{
- return EntityManager.TryGetComponent(euid, out AlertsComponent? alertsComponent)
+ return TryComp(euid, out AlertsComponent? alertsComponent)
&& alertsComponent.Alerts.ContainsKey(AlertKey.ForCategory(alertCategory));
}
public bool TryGetAlertState(EntityUid euid, AlertKey key, out AlertState alertState)
{
- if (EntityManager.TryGetComponent(euid, out AlertsComponent? alertsComponent))
+ if (TryComp(euid, out AlertsComponent? alertsComponent))
return alertsComponent.Alerts.TryGetValue(key, out alertState);
alertState = default;
if (_timing.ApplyingState)
return;
- if (!EntityManager.TryGetComponent(euid, out AlertsComponent? alertsComponent))
+ if (!TryComp(euid, out AlertsComponent? alertsComponent))
return;
if (TryGet(alertType, out var alert))
private void HandleClickAlert(ClickAlertEvent msg, EntitySessionEventArgs args)
{
var player = args.SenderSession.AttachedEntity;
- if (player is null || !EntityManager.HasComponent<AlertsComponent>(player))
+ if (player is null || !HasComp<AlertsComponent>(player))
return;
if (!IsShowingAlert(player.Value, msg.Type))
{
Log.Debug("User {0} attempted to" +
" click alert {1} which is not currently showing for them",
- EntityManager.GetComponent<MetaDataComponent>(player.Value).EntityName, msg.Type);
+ Comp<MetaDataComponent>(player.Value).EntityName, msg.Type);
return;
}
continue;
// Actually there is food digestion so no problem with instant reagent generation "OnFeed"
- if (EntityManager.TryGetComponent(uid, out HungerComponent? hunger))
+ if (TryComp(uid, out HungerComponent? hunger))
{
// Is there enough nutrition to produce reagent?
if (_hunger.GetHungerThreshold(hunger) < HungerThreshold.Okay)
{
if (args.Using == null ||
!args.CanInteract ||
- !EntityManager.HasComponent<RefillableSolutionComponent>(args.Using.Value))
+ !HasComp<RefillableSolutionComponent>(args.Using.Value))
return;
var uid = entity.Owner;
continue;
// Actually there is food digestion so no problem with instant reagent generation "OnFeed"
- if (EntityManager.TryGetComponent(uid, out HungerComponent? hunger))
+ if (TryComp(uid, out HungerComponent? hunger))
{
// Is there enough nutrition to produce reagent?
if (_hunger.GetHungerThreshold(hunger) < HungerThreshold.Okay)
if (PausedMap == null || !Exists(PausedMap))
return;
- EntityManager.DeleteEntity(PausedMap.Value);
+ Del(PausedMap.Value);
PausedMap = null;
}
RaiseLocalEvent(target, ref ev);
// same LogType as syringes...
- _adminLogger.Add(LogType.ForceFeed, $"{EntityManager.ToPrettyString(user):user} injected {EntityManager.ToPrettyString(target):target} with a solution {SharedSolutionContainerSystem.ToPrettyString(removedSolution):removedSolution} using a {EntityManager.ToPrettyString(uid):using}");
+ _adminLogger.Add(LogType.ForceFeed, $"{ToPrettyString(user):user} injected {ToPrettyString(target):target} with a solution {SharedSolutionContainerSystem.ToPrettyString(removedSolution):removedSolution} using a {ToPrettyString(uid):using}");
return true;
}
public FixedPoint2 GetTotalPrototypeQuantity(EntityUid owner, string reagentId)
{
var reagentQuantity = FixedPoint2.New(0);
- if (EntityManager.EntityExists(owner)
- && EntityManager.TryGetComponent(owner, out SolutionContainerManagerComponent? managerComponent))
+ if (Exists(owner)
+ && TryComp(owner, out SolutionContainerManagerComponent? managerComponent))
{
foreach (var (_, soln) in EnumerateSolutions((owner, managerComponent)))
{
var (uid, comp, appearanceComponent) = soln;
var solution = comp.Solution;
- if (!EntityManager.EntityExists(uid) || !Resolve(uid, ref appearanceComponent, false))
+ if (!Exists(uid) || !Resolve(uid, ref appearanceComponent, false))
return;
AppearanceSystem.SetData(uid, SolutionContainerVisuals.FillFraction, solution.FillFraction, appearanceComponent);
continue;
_components.RemoveAt(i);
- EntityManager.RemoveComponent<MovespeedModifierMetabolismComponent>(metabolism);
+ RemComp<MovespeedModifierMetabolismComponent>(metabolism);
_movespeed.RefreshMovementSpeedModifiers(metabolism);
}
_adminLogger.Add(
LogType.Unanchor,
LogImpact.Low,
- $"{EntityManager.ToPrettyString(args.User):user} unanchored {EntityManager.ToPrettyString(uid):anchored} using {EntityManager.ToPrettyString(used):using}"
+ $"{ToPrettyString(args.User):user} unanchored {ToPrettyString(uid):anchored} using {ToPrettyString(used):using}"
);
}
_adminLogger.Add(
LogType.Anchor,
LogImpact.Low,
- $"{EntityManager.ToPrettyString(args.User):user} anchored {EntityManager.ToPrettyString(uid):anchored} using {EntityManager.ToPrettyString(used):using}"
+ $"{ToPrettyString(args.User):user} anchored {ToPrettyString(uid):anchored} using {ToPrettyString(used):using}"
);
}
var ent = Spawn(proto, coords);
if (!_containerSystem.Insert(ent, container, containerXform: xform))
{
- var alreadyContained = container.ContainedEntities.Count > 0 ? string.Join("\n", container.ContainedEntities.Select(e => $"\t - {EntityManager.ToPrettyString(e)}")) : "< empty >";
+ var alreadyContained = container.ContainedEntities.Count > 0 ? string.Join("\n", container.ContainedEntities.Select(e => $"\t - {ToPrettyString(e)}")) : "< empty >";
Log.Error($"Entity {ToPrettyString(uid)} with a {nameof(ContainerFillComponent)} failed to insert an entity: {ToPrettyString(ent)}.\nCurrent contents:\n{alreadyContained}");
_transform.AttachToGridOrMap(ent);
break;
var spawn = Spawn(proto, coords);
if (!_containerSystem.Insert(spawn, container, containerXform: xform))
{
- var alreadyContained = container.ContainedEntities.Count > 0 ? string.Join("\n", container.ContainedEntities.Select(e => $"\t - {EntityManager.ToPrettyString(e)}")) : "< empty >";
+ var alreadyContained = container.ContainedEntities.Count > 0 ? string.Join("\n", container.ContainedEntities.Select(e => $"\t - {ToPrettyString(e)}")) : "< empty >";
Log.Error($"Entity {ToPrettyString(ent)} with a {nameof(EntityTableContainerFillComponent)} failed to insert an entity: {ToPrettyString(spawn)}.\nCurrent contents:\n{alreadyContained}");
_transform.AttachToGridOrMap(spawn);
break;
{
if (existing.Local)
Log.Error(
- $"Duplicate item slot key. Entity: {EntityManager.GetComponent<MetaDataComponent>(uid).EntityName} ({uid}), key: {id}");
+ $"Duplicate item slot key. Entity: {Comp<MetaDataComponent>(uid).EntityName} ({uid}), key: {id}");
else
// server state takes priority
slot.CopyFrom(existing);
itemSlots.Slots.Remove(slot.ContainerSlot.ID);
if (itemSlots.Slots.Count == 0)
- EntityManager.RemoveComponent(uid, itemSlots);
+ RemComp(uid, itemSlots);
else
Dirty(uid, itemSlots);
}
if (args.Handled)
return;
- if (!EntityManager.TryGetComponent(args.User, out HandsComponent? hands))
+ if (!TryComp(args.User, out HandsComponent? hands))
return;
if (itemSlots.Slots.Count == 0)
var verbSubject = slot.Name != string.Empty
? Loc.GetString(slot.Name)
- : EntityManager.GetComponent<MetaDataComponent>(slot.Item.Value).EntityName ?? string.Empty;
+ : Comp<MetaDataComponent>(slot.Item.Value).EntityName ?? string.Empty;
AlternativeVerb verb = new()
{
private void HandleMoveAttempt(EntityUid uid, CuffableComponent component, UpdateCanMoveEvent args)
{
- if (component.CanStillInteract || !EntityManager.TryGetComponent(uid, out PullableComponent? pullable) || !pullable.BeingPulled)
+ if (component.CanStillInteract || !TryComp(uid, out PullableComponent? pullable) || !pullable.BeingPulled)
return;
args.Cancel();
if (!args.OurFixture.Hard || !args.OtherFixture.Hard)
return;
- if (!EntityManager.HasComponent<DamageableComponent>(uid))
+ if (!HasComp<DamageableComponent>(uid))
return;
//TODO: This should solve after physics solves
private void OnRefreshMovespeed(EntityUid uid, SlowOnDamageComponent component, RefreshMovementSpeedModifiersEvent args)
{
- if (!EntityManager.TryGetComponent<DamageableComponent>(uid, out var damage))
+ if (!TryComp<DamageableComponent>(uid, out var damage))
return;
if (damage.TotalDamage == FixedPoint2.Zero)
if (args.Handled || !args.Complex)
return;
- if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
+ if (!TryComp(args.User, out ActorComponent? actor))
{
return;
}
if (!examinerComp.CheckInRangeUnOccluded)
return true;
- if (EntityManager.GetComponent<TransformComponent>(examiner).MapID != target.MapId)
+ if (Comp<TransformComponent>(examiner).MapID != target.MapId)
return false;
// Do target InRangeUnoccluded which has different checks.
private void OnGridInit(GridInitializeEvent ev)
{
- EntityManager.EnsureComponent<GravityComponent>(ev.EntityUid);
+ EnsureComp<GravityComponent>(ev.EntityUid);
}
[Serializable, NetSerializable]
private void OnEntInserted(EntityUid uid, ImplanterComponent component, EntInsertedIntoContainerMessage args)
{
- var implantData = EntityManager.GetComponent<MetaDataComponent>(args.Entity);
+ var implantData = Comp<MetaDataComponent>(args.Entity);
component.ImplantData = (implantData.EntityName, implantData.EntityDescription);
}
return false;
// Let's spawn this first...
- var item = EntityManager.SpawnEntity(prototype, Transform(uid).Coordinates);
+ var item = Spawn(prototype, Transform(uid).Coordinates);
// Helper method that deletes the item and returns false.
bool DeleteItem()
{
- EntityManager.DeleteEntity(item);
+ Del(item);
return false;
}
private void OnRejuvenate(EntityUid uid, JitteringComponent component, RejuvenateEvent args)
{
- EntityManager.RemoveComponentDeferred<JitteringComponent>(uid);
+ RemCompDeferred<JitteringComponent>(uid);
}
/// <summary>
if (StatusEffects.TryAddStatusEffect<JitteringComponent>(uid, "Jitter", time, refresh, status))
{
- var jittering = EntityManager.GetComponent<JitteringComponent>(uid);
+ var jittering = Comp<JitteringComponent>(uid);
if(forceValueChange || jittering.Amplitude < amplitude)
jittering.Amplitude = amplitude;
var component = (Component)Factory.GetComponent(name);
var temp = (object)component;
_seriMan.CopyTo(data.Component, ref temp);
- EntityManager.AddComponent(target, (Component)temp!);
+ AddComp(target, (Component)temp!);
}
}
if (component.Pulling != args.BlockingEntity)
return;
- if (EntityManager.TryGetComponent(args.BlockingEntity, out PullableComponent? comp))
+ if (TryComp(args.BlockingEntity, out PullableComponent? comp))
{
TryStopPull(args.BlockingEntity, comp);
}
return false;
}
- if (!EntityManager.TryGetComponent<PhysicsComponent>(pullableUid, out var physics))
+ if (!TryComp<PhysicsComponent>(pullableUid, out var physics))
{
return false;
}
private void OnRefreshFrictionModifiers(Entity<FrictionModifiedByContactComponent> entity, ref RefreshFrictionModifiersEvent args)
{
- if (!EntityManager.TryGetComponent<PhysicsComponent>(entity, out var physicsComponent))
+ if (!TryComp<PhysicsComponent>(entity, out var physicsComponent))
return;
var friction = 0.0f;
private void OnRefreshMovementSpeedModifiers(EntityUid uid, SpeedModifiedByContactComponent component, RefreshMovementSpeedModifiersEvent args)
{
- if (!EntityManager.TryGetComponent<PhysicsComponent>(uid, out var physicsComponent))
+ if (!TryComp<PhysicsComponent>(uid, out var physicsComponent))
return;
var walkSpeed = 0.0f;
creamPied.CreamPied = value;
- if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
+ if (TryComp(uid, out AppearanceComponent? appearance))
{
_appearance.SetData(uid, CreamPiedVisuals.Creamed, value, appearance);
}
private void OnCreamPiedHitBy(EntityUid uid, CreamPiedComponent creamPied, ThrowHitByEvent args)
{
- if (!EntityManager.EntityExists(args.Thrown) || !EntityManager.TryGetComponent(args.Thrown, out CreamPieComponent? creamPie)) return;
+ if (!Exists(args.Thrown) || !TryComp(args.Thrown, out CreamPieComponent? creamPie)) return;
SetCreamPied(uid, creamPied, true);
public (bool Success, bool Handled) TryUseUtensil(EntityUid user, EntityUid target, Entity<UtensilComponent> utensil)
{
- if (!EntityManager.TryGetComponent(target, out FoodComponent? food))
+ if (!TryComp(target, out FoodComponent? food))
return (false, false);
//Prevents food usage with a wrong utensil
if (_robustRandom.Prob(component.BreakChance))
{
_audio.PlayPredicted(component.BreakSound, userUid, userUid, AudioParams.Default.WithVolume(-2f));
- EntityManager.DeleteEntity(uid);
+ Del(uid);
}
}
}
{
if (!_paperQuery.TryComp(ent, out var paperComp))
{
- Log.Warning($"{EntityManager.ToPrettyString(ent)} has a {nameof(RandomPaperContentComponent)} but no {nameof(PaperComponent)}!");
+ Log.Warning($"{ToPrettyString(ent)} has a {nameof(RandomPaperContentComponent)} but no {nameof(PaperComponent)}!");
RemCompDeferred(ent, ent.Comp);
return;
}
// Try to start the do after
var effect = Spawn(effectPrototype, location);
- var ev = new RCDDoAfterEvent(GetNetCoordinates(location), component.ConstructionDirection, component.ProtoId, cost, EntityManager.GetNetEntity(effect));
+ var ev = new RCDDoAfterEvent(GetNetCoordinates(location), component.ConstructionDirection, component.ProtoId, cost, GetNetEntity(effect));
var doAfterArgs = new DoAfterArgs(EntityManager, user, delay, ev, uid, target: args.Target, used: uid)
{
{
// Delete the effect entity if the do-after was cancelled (server-side only)
if (_net.IsServer)
- QueueDel(EntityManager.GetEntity(args.Effect));
+ QueueDel(GetEntity(args.Effect));
return;
}
_physics.SetHard(uid, collider, true, fixtures);
}
- EntityManager.Dirty(uid, fixtures);
+ Dirty(uid, fixtures);
}
#endregion Getters/Setters
var equipmentStr = startingGear.GetGear(slot.Name);
if (!string.IsNullOrEmpty(equipmentStr))
{
- var equipmentEntity = EntityManager.SpawnEntity(equipmentStr, xform.Coordinates);
+ var equipmentEntity = Spawn(equipmentStr, xform.Coordinates);
InventorySystem.TryEquip(entity, equipmentEntity, slot.Name, silent: true, force: true);
}
}
var coords = xform.Coordinates;
foreach (var prototype in inhand)
{
- var inhandEntity = EntityManager.SpawnEntity(prototype, coords);
+ var inhandEntity = Spawn(prototype, coords);
if (_handsSystem.TryGetEmptyHand((entity, handsComponent), out var emptyHand))
{
if (HasComp<T>(uid))
return true;
- EntityManager.AddComponent<T>(uid);
+ AddComp<T>(uid);
status.ActiveEffects[key].RelevantComponent = Factory.GetComponentName<T>();
return true;
if (TryAddStatusEffect(uid, key, time, refresh, status))
{
// If they already have the comp, we just won't bother updating anything.
- if (!EntityManager.HasComponent(uid, Factory.GetRegistration(component).Type))
+ if (!HasComp(uid, Factory.GetRegistration(component).Type))
{
var newComponent = (Component) Factory.GetComponent(component);
- EntityManager.AddComponent(uid, newComponent);
+ AddComp(uid, newComponent);
status.ActiveEffects[key].RelevantComponent = component;
}
return true;
&& Factory.TryGetRegistration(state.RelevantComponent, out var registration))
{
var type = registration.Type;
- EntityManager.RemoveComponent(uid, type);
+ RemComp(uid, type);
}
if (proto.Alert != null)
private void CounterEntityInserted(EntityUid uid, ItemCounterComponent itemCounter,
EntInsertedIntoContainerMessage args)
{
- if (!EntityManager.TryGetComponent(uid, out AppearanceComponent? appearanceComponent))
+ if (!TryComp(uid, out AppearanceComponent? appearanceComponent))
return;
var count = GetCount(args, itemCounter);
private void CounterEntityRemoved(EntityUid uid, ItemCounterComponent itemCounter,
EntRemovedFromContainerMessage args)
{
- if (!EntityManager.TryGetComponent(uid, out AppearanceComponent? appearanceComponent))
+ if (!TryComp(uid, out AppearanceComponent? appearanceComponent))
return;
var count = GetCount(args, itemCounter);
val.Layer = layerName;
}
- if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearanceComponent))
+ if (TryComp(uid, out AppearanceComponent? appearanceComponent))
{
var list = new List<string>(component.MapLayers.Keys);
_appearance.SetData(uid, StorageMapVisuals.InitLayers, new ShowLayerData(list), appearanceComponent);
if (!Resolve(uid, ref itemMapper))
return;
- if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearanceComponent)
+ if (TryComp(uid, out AppearanceComponent? appearanceComponent)
&& TryGetLayers(uid, itemMapper, out var containedLayers))
{
_appearance.SetData(uid,
{
UpdateFloorCover(uid, component);
UpdateAppearance(uid, component);
- EntityManager.EnsureComponent<CollideOnAnchorComponent>(uid);
+ EnsureComp<CollideOnAnchorComponent>(uid);
}
private void OnSubFloorTerminating(EntityUid uid, SubFloorHideComponent component, ComponentShutdown _)
{
// If component is being deleted don't need to worry about updating any component stuff because it won't matter very shortly.
- if (EntityManager.GetComponent<MetaDataComponent>(uid).EntityLifeStage >= EntityLifeStage.Terminating)
+ if (Comp<MetaDataComponent>(uid).EntityLifeStage >= EntityLifeStage.Terminating)
return;
// Regardless of whether we're on a subfloor or not, unhide.
return;
// Move the entity and dirty it (we use the map ID from the entity so noone can try to be funny and move the item to another map)
- var transform = EntityManager.GetComponent<TransformComponent>(moved);
+ var transform = Comp<TransformComponent>(moved);
Transforms.SetParent(moved, transform, _mapSystem.GetMapOrInvalid(transform.MapID));
Transforms.SetLocalPositionNoLerp(moved, msg.Coordinates.Position, transform);
}
private void ThrowItem(EntityUid uid, ThrownItemComponent component, ref ThrownEvent @event)
{
- if (!EntityManager.TryGetComponent(uid, out FixturesComponent? fixturesComponent) ||
+ if (!TryComp(uid, out FixturesComponent? fixturesComponent) ||
fixturesComponent.Fixtures.Count != 1 ||
!TryComp<PhysicsComponent>(uid, out var body))
{
private void HandlePullStarted(PullStartedMessage message)
{
// TODO: this isn't directed so things have to be done the bad way
- if (EntityManager.TryGetComponent(message.PulledUid, out ThrownItemComponent? thrownItemComponent))
+ if (TryComp(message.PulledUid, out ThrownItemComponent? thrownItemComponent))
StopThrow(message.PulledUid, thrownItemComponent);
}
_broadphase.RegenerateContacts((uid, physics));
}
- if (EntityManager.TryGetComponent(uid, out FixturesComponent? manager))
+ if (TryComp(uid, out FixturesComponent? manager))
{
var fixture = _fixtures.GetFixtureOrNull(uid, ThrowingFixture, manager: manager);
private void OnMultipleToolStartup(EntityUid uid, MultipleToolComponent multiple, ComponentStartup args)
{
// Only set the multiple tool if we have a tool component.
- if (EntityManager.TryGetComponent(uid, out ToolComponent? tool))
+ if (TryComp(uid, out ToolComponent? tool))
SetMultipleTool(uid, multiple, tool);
}
{
// Make sure the entity is a weapon AND it doesn't need
// to be equipped to be used (E.g boxing gloves).
- if (EntityManager.TryGetComponent(held, out melee) &&
+ if (TryComp(held, out melee) &&
!melee.MustBeEquippedToUse)
{
weaponUid = held.Value;
return false;
// If it's a speedloader try to get ammo from it.
- if (EntityManager.HasComponent<SpeedLoaderComponent>(uid))
+ if (HasComp<SpeedLoaderComponent>(uid))
{
var freeSlots = 0;
if (melee.NextAttack > component.NextFire)
{
component.NextFire = melee.NextAttack;
- EntityManager.DirtyField(uid, component, nameof(GunComponent.NextFire));
+ DirtyField(uid, component, nameof(GunComponent.NextFire));
}
}
gun.ShotCounter = 0;
gun.ShootCoordinates = null;
gun.Target = null;
- EntityManager.DirtyField(uid, gun, nameof(GunComponent.ShotCounter));
+ DirtyField(uid, gun, nameof(GunComponent.ShotCounter));
}
/// <summary>
gun.ShootCoordinates = toCoordinates;
AttemptShoot(user, gunUid, gun);
gun.ShotCounter = 0;
- EntityManager.DirtyField(gunUid, gun, nameof(GunComponent.ShotCounter));
+ DirtyField(gunUid, gun, nameof(GunComponent.ShotCounter));
}
/// <summary>
}
// NextFire has been touched regardless so need to dirty the gun.
- EntityManager.DirtyField(gunUid, gun, nameof(GunComponent.NextFire));
+ DirtyField(gunUid, gun, nameof(GunComponent.NextFire));
// Get how many shots we're actually allowed to make, due to clip size or otherwise.
// Don't do this in the loop so we still reset NextFire.
// Even if we don't actually shoot update the ShotCounter. This is to avoid spamming empty sounds
// where the gun may be SemiAuto or Burst.
gun.ShotCounter += shots;
- EntityManager.DirtyField(gunUid, gun, nameof(GunComponent.ShotCounter));
+ DirtyField(gunUid, gun, nameof(GunComponent.ShotCounter));
if (ev.Ammo.Count <= 0)
{
foreach (var registry in ent.Comp.Components)
{
var componentType = registry.Value.Component.GetType();
- if (!ent.Comp.ApplyIfAlreadyHave && EntityManager.HasComponent(artifact, componentType))
+ if (!ent.Comp.ApplyIfAlreadyHave && HasComp(artifact, componentType))
{
continue;
}
if (ent.Comp.RefreshOnReactivate)
{
- EntityManager.RemoveComponent(artifact, componentType);
+ RemComp(artifact, componentType);
}
var clone = EntityManager.ComponentFactory.GetComponent(registry.Value);
- EntityManager.AddComponent(artifact, clone);
+ AddComp(artifact, clone);
}
}
}