/// <summary> /// Handle adding keys to the ignition, give stuff the InVehicleComponent so it can't be picked /// up by people not in the vehicle. /// </summary> private void OnEntInserted(EntityUid uid, VehicleComponent component, EntInsertedIntoContainerMessage args) { var inVehicle = AddComp <InVehicleComponent>(args.Entity); inVehicle.Vehicle = component; if (_tagSystem.HasTag(args.Entity, "VehicleKey")) { // Return if the slot is not the key slot // That slot ID should be inherited from basevehicle in the .yml if (args.Container.ID != "key_slot") { return; } // This lets the vehicle move EnsureComp <SharedPlayerInputMoverComponent>(uid); // This lets the vehicle open doors if (component.HasRider) { _tagSystem.AddTag(uid, "DoorBumpOpener"); } component.HasKey = true; // Audiovisual feedback _ambientSound.SetAmbience(uid, true); } }
private void MapperEntityInserted(EntityUid uid, ItemMapperComponent itemMapper, EntInsertedIntoContainerMessage args) { if (EntityManager.TryGetComponent(itemMapper.Owner, out AppearanceComponent? appearanceComponent) && TryGetLayers(args, itemMapper, out var containedLayers)) { appearanceComponent.SetData(StorageMapVisuals.LayerChanged, new ShowLayerData(containedLayers)); } }
private static void HandleEntityInsertedIntoContainer(EntInsertedIntoContainerMessage message) { var oldParentEntity = message.Container.Owner; if (oldParentEntity.TryGetComponent(out ServerStorageComponent storageComp)) { storageComp.HandleEntityMaybeInserted(message); } }
protected virtual void OnItemInserted(EntityUid uid, PDAComponent pda, EntInsertedIntoContainerMessage args) { if (args.Container.ID == PDAComponent.PDAIdSlotId) { pda.ContainedID = CompOrNull <IdCardComponent>(args.Entity); } UpdatePDAAppearance(pda); }
private void HandleEntityInsert(EntityUid uid, ItemCounterComponent itemCounter, EntInsertedIntoContainerMessage args) { if (itemCounter.Owner.TryGetComponent(out SharedAppearanceComponent? appearanceComponent) && TryGetContainer(args, itemCounter, out var containedLayers)) { appearanceComponent.SetData(StorageMapVisuals.LayerChanged, new ShowLayerData(containedLayers)); } }
private void OnItemInserted(EntityUid uid, PDAComponent pda, EntInsertedIntoContainerMessage args) { if (args.Container.ID == pda.IdSlot.ID) { pda.ContainedID = EntityManager.GetComponentOrNull <IdCardComponent>(args.Entity); } UpdatePDAAppearance(pda); UpdatePDAUserInterface(pda); }
internal void HandleEntityMaybeInserted(EntInsertedIntoContainerMessage message) { if (message.Container != storage) { return; } _ensureInitialCalculated(); Logger.DebugS("Storage", "Storage (UID {0}) had entity (UID {1}) inserted into it.", Owner.Uid, message.Entity.Uid); StorageUsed += message.Entity.GetComponent <StoreableComponent>().ObjectSize; UpdateClientInventories(); }
private void OnCellInserted(EntityUid uid, PowerCellSlotComponent component, EntInsertedIntoContainerMessage args) { if (!component.Initialized) { return; } if (args.Container.ID != component.CellSlot.ID) { return; } RaiseLocalEvent(uid, new PowerCellChangedEvent(false), false); }
protected virtual void OnItemInserted(EntityUid uid, PDAComponent pda, EntInsertedIntoContainerMessage args) { if (!pda.Initialized) { return; } if (args.Container.ID == pda.IdSlot.ID) { pda.ContainedID = CompOrNull <IdCardComponent>(args.Entity); } UpdatePDAAppearance(pda); }
public void HandleEntityMaybeInserted(EntInsertedIntoContainerMessage message) { if (message.Container != _storage) { return; } EnsureInitialCalculated(); Logger.DebugS(LoggerName, $"Storage (UID {Owner.Uid}) had entity (UID {message.Entity.Uid}) inserted into it."); _storageUsed += message.Entity.GetComponent <StorableComponent>().ObjectSize; UpdateClientInventories(); }
private void OnEntInserted(EntityUid uid, InventoryComponent component, EntInsertedIntoContainerMessage args) { if (!TryGetSlot(uid, args.Container.ID, out var slotDef, inventory: component)) { return; } var equippedEvent = new DidEquipEvent(uid, args.Entity, slotDef); RaiseLocalEvent(uid, equippedEvent); var gotEquippedEvent = new GotEquippedEvent(uid, args.Entity, slotDef); RaiseLocalEvent(args.Entity, gotEquippedEvent); }
private void OnEntityInserted(EntityUid uid, PayloadCaseComponent _, EntInsertedIntoContainerMessage args) { if (!TryComp(args.Entity, out PayloadTriggerComponent? trigger)) { return; } trigger.Active = true; if (trigger.Components == null) { return; } // ANY payload trigger that gets inserted can grant components. It is up to the construction graphs to determine trigger capacity. foreach (var(name, data) in trigger.Components) { if (!_componentFactory.TryGetRegistration(name, out var registration)) { continue; } if (HasComp(uid, registration.Type)) { continue; } if (_componentFactory.GetComponent(registration.Type) is not Component component) { continue; } component.Owner = uid; if (_serializationManager.Copy(data, component, null) is Component copied) { EntityManager.AddComponent(uid, copied); } trigger.GrantedComponents.Add(registration.Type); } }
/// <summary> /// Handle adding keys to the ignition, give stuff the InVehicleComponent so it can't be picked /// up by people not in the vehicle. /// </summary> private void OnEntInserted(EntityUid uid, VehicleComponent component, EntInsertedIntoContainerMessage args) { if (args.Container.ID != KeySlot || !_tagSystem.HasTag(args.Entity, "VehicleKey")) { return; } // Enable vehicle var inVehicle = AddComp <InVehicleComponent>(args.Entity); inVehicle.Vehicle = component; component.HasKey = true; // Audiovisual feedback _ambientSound.SetAmbience(uid, true); _tagSystem.AddTag(uid, "DoorBumpOpener"); _modifier.RefreshMovementSpeedModifiers(uid); }
private void CounterEntityInserted(EntityUid uid, ItemCounterComponent itemCounter, EntInsertedIntoContainerMessage args) { if (!EntityManager.TryGetComponent(itemCounter.Owner, out AppearanceComponent? appearanceComponent)) { return; } var count = GetCount(args, itemCounter); if (count == null) { return; } appearanceComponent.SetData(StackVisuals.Actual, count); if (itemCounter.MaxAmount != null) { appearanceComponent.SetData(StackVisuals.MaxCount, itemCounter.MaxAmount); } }
private void OnInserted(EntityUid uid, ChargerComponent component, EntInsertedIntoContainerMessage args) { if (!component.Initialized) { return; } if (args.Container.ID != component.ChargerSlot.ID) { return; } // try get a battery directly on the inserted entity if (!TryComp(args.Entity, out component.HeldBattery)) { // or by checking for a power cell slot on the inserted entity _cellSystem.TryGetBatteryFromSlot(args.Entity, out component.HeldBattery); } component.UpdateStatus(); }
/// Containers private void OnEntInserted(EntityUid uid, AntiRottingContainerComponent component, EntInsertedIntoContainerMessage args) { if (TryComp <PerishableComponent>(args.Entity, out var perishable)) { ModifyPreservationSource(args.Entity, true); ToggleDecomposition(args.Entity, false, perishable); } }
private void OnCanisterContainerInserted(EntityUid uid, GasCanisterComponent component, EntInsertedIntoContainerMessage args) { if (args.Container.ID != component.ContainerName) { return; } DirtyUI(uid); if (!ComponentManager.TryGetComponent(uid, out AppearanceComponent? appearance)) { return; } appearance.SetData(GasCanisterVisuals.TankInserted, true); }
private void OnCanisterContainerInserted(EntityUid uid, GasCanisterComponent component, EntInsertedIntoContainerMessage args) { if (args.Container.ID != component.ContainerName) { return; } DirtyUI(uid); if (!ComponentManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer) || !nodeContainer.TryGetNode(component.TankName, out PipeNode? tankNode)) { return; } tankNode.EnvironmentalAir = false; tankNode.ConnectToContainedEntities = true; tankNode.NodeGroup.RemakeGroup(); if (!ComponentManager.TryGetComponent(uid, out AppearanceComponent? appearance)) { return; } appearance.SetData(GasCanisterVisuals.TankInserted, true); }
protected override void OnItemInserted(EntityUid uid, PDAComponent pda, EntInsertedIntoContainerMessage args) { base.OnItemInserted(uid, pda, args); UpdatePDAUserInterface(pda); }
private void OnInserted(EntityUid uid, SuppressArtifactContainerComponent component, EntInsertedIntoContainerMessage args) { if (!TryComp(args.Entity, out ArtifactComponent? artifact)) { return; } artifact.IsSuppressed = true; }
private void HandleContainerInserted(EntityUid uid, SharedHandsComponent component, EntInsertedIntoContainerMessage args) { // un-rotate entities. needed for things like directional flashlights Transform(args.Entity).LocalRotation = 0; HandleContainerModified(uid, component, args); }
private void OnInserted(EntityUid uid, StorageFillVisualizerComponent component, EntInsertedIntoContainerMessage args) { UpdateAppearance(uid, component: component); }