private void OnCellSlotInit(EntityUid uid, PowerCellSlotComponent component, ComponentInit args) { _itemSlotsSystem.AddItemSlot(uid, "cellslot_cell_container", component.CellSlot); if (string.IsNullOrWhiteSpace(component.CellSlot.Name) && !string.IsNullOrWhiteSpace(component.SlotName)) { component.CellSlot.Name = component.SlotName; } if (component.StartEmpty) { return; } if (!string.IsNullOrWhiteSpace(component.CellSlot.StartingItem)) { return; } // set default starting cell based on cell-type component.CellSlot.StartingItem = component.SlotSize switch { PowerCellSize.Small => "PowerCellSmallStandard", PowerCellSize.Medium => "PowerCellMediumStandard", PowerCellSize.Large => "PowerCellLargeStandard", _ => throw new ArgumentOutOfRangeException() }; }
protected override void Initialize() { base.Initialize(); Owner.EnsureComponent <PointLightComponent>(); _cellSlot = Owner.EnsureComponent <PowerCellSlotComponent>(); Dirty(); }
private void OnSlotMicrowaved(EntityUid uid, PowerCellSlotComponent component, BeingMicrowavedEvent args) { if (component.CellSlot.Item == null) { return; } RaiseLocalEvent(component.CellSlot.Item.Value, args, false); }
private void OnCellRemoved(EntityUid uid, PowerCellSlotComponent component, EntRemovedFromContainerMessage args) { if (args.Container.ID != component.CellSlot.ID) { return; } RaiseLocalEvent(uid, new PowerCellChangedEvent(true), false); }
private void OnCellSlotInit(EntityUid uid, PowerCellSlotComponent component, ComponentInit args) { _itemSlotsSystem.AddItemSlot(uid, CellSlotContainer, component.CellSlot); if (string.IsNullOrWhiteSpace(component.CellSlot.Name) && !string.IsNullOrWhiteSpace(component.SlotName)) { component.CellSlot.Name = component.SlotName; } }
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); }
private void OnSlotExamined(EntityUid uid, PowerCellSlotComponent component, ExaminedEvent args) { if (!args.IsInDetailsRange || string.IsNullOrWhiteSpace(component.DescFormatString)) { return; } var sizeText = Loc.GetString(component.SlotSize switch { PowerCellSize.Small => "power-cell-slot-component-description-size-small", PowerCellSize.Medium => "power-cell-slot-component-description-size-medium", PowerCellSize.Large => "power-cell-slot-component-description-size-large", _ => "???" });
private void OnCellInsertAttempt(EntityUid uid, PowerCellSlotComponent component, ContainerIsInsertingAttemptEvent args) { if (!component.Initialized) { return; } if (args.Container.ID != component.CellSlot.ID) { return; } if (!HasComp <PowerCellComponent>(args.EntityUid)) { args.Cancel(); } }
private void OnCellInsertAttempt(EntityUid uid, PowerCellSlotComponent component, ContainerIsInsertingAttemptEvent args) { if (!component.Initialized) { return; } if (args.Container.ID != component.CellSlot.ID) { return; } if (!TryComp(args.EntityUid, out PowerCellComponent? cell) || cell.CellSize != component.SlotSize) { args.Cancel(); } }
// TODO VERBS EJECTABLES Standardize eject/insert verbs into a single system? private void AddEjectVerb(EntityUid uid, PowerCellSlotComponent component, GetAlternativeVerbsEvent args) { if (args.Hands == null || !args.CanAccess || !args.CanInteract || !component.ShowVerb || !component.HasCell || !_actionBlockerSystem.CanPickup(args.User)) { return; } Verb verb = new(); verb.Text = component.Cell !.Name; verb.Category = VerbCategory.Eject; verb.Act = () => component.EjectCell(args.User); args.Verbs.Add(verb); }
private void AddInsertVerb(EntityUid uid, PowerCellSlotComponent component, GetInteractionVerbsEvent args) { if (args.Using == null || !args.CanAccess || !args.CanInteract || component.HasCell || !args.Using.HasComponent <PowerCellComponent>() || !_actionBlockerSystem.CanDrop(args.User)) { return; } Verb verb = new(); verb.Text = args.Using.Name; verb.Category = VerbCategory.Insert; verb.Act = () => component.InsertCell(args.Using); args.Verbs.Add(verb); }
private void AddInsertVerb(EntityUid uid, PowerCellSlotComponent component, GetInteractionVerbsEvent args) { if (args.Using is not { Valid : true } @using || !args.CanAccess || !args.CanInteract || component.HasCell || !EntityManager.HasComponent <PowerCellComponent>(@using) || !_actionBlockerSystem.CanDrop(args.User)) { return; } Verb verb = new(); verb.Text = EntityManager.GetComponent <MetaDataComponent>(@using).EntityName; verb.Category = VerbCategory.Insert; verb.Act = () => component.InsertCell(@using); args.Verbs.Add(verb); }
public override void Initialize() { base.Initialize(); _cellSlot = Owner.EnsureComponent <PowerCellSlotComponent>(); }
private void OnCellSlotRemove(EntityUid uid, PowerCellSlotComponent component, ComponentRemove args) { _itemSlotsSystem.RemoveItemSlot(uid, component.CellSlot); }