コード例 #1
0
    private void OnRemoved(EntityUid uid, ChargerComponent component, EntRemovedFromContainerMessage args)
    {
        if (args.Container.ID != component.ChargerSlot.ID)
        {
            return;
        }

        component.UpdateStatus();
    }
コード例 #2
0
        public string GetDescription()
        {
            var descriptionBuilder = new StringBuilder();

            descriptionBuilder.AppendLine($"Screen Type: {Screen.ToString()}");
            descriptionBuilder.AppendLine($"Microphone Type: {Microphone.ToString()}");
            descriptionBuilder.AppendLine($"Battery Type: {Battery.ToString()}");
            descriptionBuilder.AppendLine($"Speaker Type: {Speaker.ToString()}");
            descriptionBuilder.AppendLine($"SimCard Type: {SimCard.ToString()}");
            descriptionBuilder.AppendLine($"AudioJack Type: {PlaybackComponent?.ToString() ?? "AudioJack is not set"}");
            descriptionBuilder.AppendLine($"Charger Type: {ChargerComponent?.ToString() ?? "Charger is not set"}");
            return(descriptionBuilder.ToString());
        }
コード例 #3
0
    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();
    }
コード例 #4
0
    /// <summary>
    ///     Verify that the entity being inserted is actually rechargeable.
    /// </summary>
    private void OnInsertAttempt(EntityUid uid, ChargerComponent component, ContainerIsInsertingAttemptEvent args)
    {
        if (!component.Initialized)
        {
            return;
        }

        if (args.Container.ID != component.ChargerSlot.ID)
        {
            return;
        }

        if (!TryComp(args.EntityUid, out PowerCellSlotComponent? cellSlot))
        {
            return;
        }

        if (!cellSlot.FitsInCharger || !cellSlot.CellSlot.HasItem)
        {
            args.Cancel();
        }
    }
コード例 #5
0
 public void Charge()
 {
     ChargerComponent.Charge();
 }
コード例 #6
0
 private void OnPowerChanged(EntityUid uid, ChargerComponent component, PowerChangedEvent args)
 {
     component.UpdateStatus();
 }
コード例 #7
0
 private void OnChargerRemove(EntityUid uid, ChargerComponent component, ComponentRemove args)
 {
     _itemSlotsSystem.RemoveItemSlot(uid, component.ChargerSlot);
 }
コード例 #8
0
 private void OnChargerInit(EntityUid uid, ChargerComponent component, ComponentInit args)
 {
     _itemSlotsSystem.AddItemSlot(uid, "charger-slot", component.ChargerSlot);
 }
コード例 #9
0
 private void OnChargerExamine(EntityUid uid, ChargerComponent component, ExaminedEvent args)
 {
     args.PushMarkup(Loc.GetString("charger-examine", ("color", "yellow"), ("chargeRate", component.ChargeRate)));
 }
コード例 #10
0
 public void Charge(object data)
 {
     ChargerComponent.Charge(data);
 }