Ejemplo n.º 1
0
        public override void Initialize()
        {
            base.Initialize();

            _itemContainer =
                ContainerManagerComponent.Ensure <ContainerSlot>("potted_plant_hide", Owner, out _);
        }
Ejemplo n.º 2
0
        public override void Initialize()
        {
            base.Initialize();
            _idSlot  = ContainerManagerComponent.Ensure <ContainerSlot>("pda_entity_container", Owner);
            _penSlot = ContainerManagerComponent.Ensure <ContainerSlot>("pda_pen_slot", Owner);

            if (UserInterface != null)
            {
                UserInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage;
            }

            if (!string.IsNullOrEmpty(_startingIdCard))
            {
                var idCard          = _entityManager.SpawnEntity(_startingIdCard, Owner.Transform.Coordinates);
                var idCardComponent = idCard.GetComponent <IdCardComponent>();
                _idSlot.Insert(idCardComponent.Owner);
                ContainedID = idCardComponent;
            }

            if (!string.IsNullOrEmpty(_startingPen))
            {
                var pen = _entityManager.SpawnEntity(_startingPen, Owner.Transform.Coordinates);
                _penSlot.Insert(pen);
            }

            UpdatePDAAppearance();
        }
        public override void Initialize()
        {
            base.Initialize();

            _itemContainer =
                ContainerManagerComponent.Ensure <ContainerSlot>("flashlight_cell_container", Owner, out _);
        }
        public override void Initialize()
        {
            base.Initialize();

            _ammoContainer =
                ContainerManagerComponent.Ensure <Container>($"{Name}-ammo-container", Owner, out var existing);

            if (existing)
            {
                foreach (var entity in _ammoContainer.ContainedEntities)
                {
                    _spawnedAmmo.Push(entity);
                    _unspawnedCount--;
                }
            }

            _chamberContainer =
                ContainerManagerComponent.Ensure <ContainerSlot>($"{Name}-chamber-container", Owner, out existing);
            if (existing)
            {
                _unspawnedCount--;
            }

            if (Owner.TryGetComponent(out AppearanceComponent appearanceComponent))
            {
                _appearanceComponent = appearanceComponent;
            }

            _appearanceComponent?.SetData(MagazineBarrelVisuals.MagLoaded, true);
            Dirty();
            UpdateAppearance();
        }
Ejemplo n.º 5
0
    public void Swap(ContainerSlot from, ContainerSlot to)
    {
        if (from == to)
        {
            return;
        }

        if (from.Container.containerItems[from.id].ItemId != to.Container.containerItems[to.id].ItemId)
        {
            from.Container.containerItems[from.id] = to.Container.containerItems[to.id];
            to.Container.containerItems[to.id]     = draggingItem;
        }
        else if (from.Container.containerItems[from.id].ItemId == to.Container.containerItems[to.id].ItemId &&
                 (to.Container.containerItems[to.id].IsStackable))
        {
            int leftToMax = to.Container.containerItems[to.id].MaxStack - to.Container.containerItems[to.id].ItemAmount;
            if (from.Container.containerItems[from.id].ItemAmount <= leftToMax)
            {
                to.Container.containerItems[to.id].ItemAmount += from.Container.containerItems[from.id].ItemAmount;
                from.Container.containerItems[from.id]         = new Item();
            }
            else if (from.Container.containerItems[from.id].ItemAmount > leftToMax)
            {
                to.Container.containerItems[to.id].ItemAmount     += leftToMax;
                from.Container.containerItems[from.id].ItemAmount -= leftToMax;
            }
        }
    }
Ejemplo n.º 6
0
        public override void Initialize()
        {
            base.Initialize();

            ItemContainer =
                ContainerManagerComponent.Ensure <ContainerSlot>("extinguisher_cabinet", Owner, out _);
        }
Ejemplo n.º 7
0
        public override void Initialize()
        {
            base.Initialize();

            ItemContainer =
                ContainerHelpers.EnsureContainer <ContainerSlot>(Owner, "extinguisher_cabinet", out _);
        }
        public override void Initialize()
        {
            base.Initialize();

            Owner.EnsureComponent <PowerReceiverComponent>().OnPowerStateChanged += UpdateLight;

            _lightBulbContainer = ContainerManagerComponent.Ensure <ContainerSlot>("light_bulb", Owner);
        }
Ejemplo n.º 9
0
        public override void Initialize()
        {
            base.Initialize();

            Owner.EnsureComponent <PowerReceiverComponent>();
            _container = ContainerManagerComponent.Ensure <ContainerSlot>($"{Name}-powerCellContainer", Owner);
            // Default state in the visualizer is OFF, so when this gets powered on during initialization it will generally show empty
        }
Ejemplo n.º 10
0
        protected override void Initialize()
        {
            base.Initialize();

            Owner.EnsureComponent <ApcPowerReceiverComponent>();
            _container = ContainerHelpers.EnsureContainer <ContainerSlot>(Owner, $"{Name}-powerCellContainer");
            // Default state in the visualizer is OFF, so when this gets powered on during initialization it will generally show empty
        }
Ejemplo n.º 11
0
 public override void Initialize()
 {
     base.Initialize();
     _appearance    = Owner.GetComponent <AppearanceComponent>();
     _userInterface = Owner.GetComponent <ServerUserInterfaceComponent>()
                      .GetBoundUserInterface(MedicalScannerUiKey.Key);
     _bodyContainer = ContainerManagerComponent.Ensure <ContainerSlot>($"{Name}-bodyContainer", Owner);
     UpdateUserInterface();
 }
Ejemplo n.º 12
0
 public override void Initialize()
 {
     base.Initialize();
     _powerReceiver       = Owner.GetComponent <PowerReceiverComponent>();
     _container           = ContainerManagerComponent.Ensure <ContainerSlot>($"{Name}-powerCellContainer", Owner);
     _appearanceComponent = Owner.GetComponent <AppearanceComponent>();
     // Default state in the visualizer is OFF, so when this gets powered on during initialization it will generally show empty
     _powerReceiver.OnPowerStateChanged += PowerUpdate;
 }
        public override void Initialize()
        {
            base.Initialize();

            Owner.EnsureComponent <PointLightComponent>();
            _cellContainer =
                ContainerManagerComponent.Ensure <ContainerSlot>("flashlight_cell_container", Owner, out _);

            Dirty();
        }
Ejemplo n.º 14
0
    public void DropItem(ContainerSlot itemToDrop)
    {
        itemDestroyPanel.SetActive(true);
        DestroyItemWindow destroyWindow = itemDestroyPanel.GetComponent <DestroyItemWindow>();

        destroyWindow.StopCoroutine("WindowTimer");
        destroyWindow.itemToDrop = itemToDrop;
        destroyWindow.SetUp();
        destroyWindow.StartCoroutine("WindowTimer");
    }
        public override void Initialize()
        {
            base.Initialize();

            _pointLight      = Owner.GetComponent <PointLightComponent>();
            _spriteComponent = Owner.GetComponent <SpriteComponent>();
            Owner.TryGetComponent(out _clothingComponent);
            _cellContainer =
                ContainerManagerComponent.Ensure <ContainerSlot>("flashlight_cell_container", Owner, out var existed);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Called once per instance of this component. Gets references to any other components needed
        /// by this component and initializes it's UI and other data.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();
            _userInterface = Owner.GetComponent <ServerUserInterfaceComponent>().GetBoundUserInterface(ReagentDispenserUiKey.Key);
            _userInterface.OnReceiveMessage += OnUiReceiveMessage;

            _beakerContainer = ContainerManagerComponent.Ensure <ContainerSlot>($"{Name}-reagentContainerContainer", Owner);

            InitializeFromPrototype();
            UpdateUserInterface();
        }
 /// <inheritdoc />
 protected override void Startup()
 {
     base.Startup();
     _magazineSlot = ContainerManagerComponent.Ensure <ContainerSlot>("ballistic_gun_magazine", Owner);
     if (Magazine != null)
     {
         // Already got magazine from loading a container.
         Magazine.GetComponent <BallisticMagazineComponent>().OnAmmoCountChanged += MagazineAmmoCountChanged;
     }
     UpdateAppearance();
 }
Ejemplo n.º 18
0
        public override void Initialize()
        {
            base.Initialize();

            if (Owner.TryGetComponent(out AppearanceComponent appearanceComponent))
            {
                _appearanceComponent = appearanceComponent;
            }

            _chamberContainer  = ContainerManagerComponent.Ensure <ContainerSlot>($"{Name}-chamber", Owner);
            _magazineContainer = ContainerManagerComponent.Ensure <ContainerSlot>($"{Name}-magazine", Owner);
        }
        private void PutIdInHand(ContainerSlot container, IHandsComponent hands)
        {
            var idEntity = container.ContainedEntity;

            if (idEntity == null || !container.Remove(idEntity))
            {
                return;
            }
            UpdateUserInterface();

            hands.PutInHand(idEntity.GetComponent <ItemComponent>());
        }
Ejemplo n.º 20
0
    public override void Use(ContainerSlot slot)
    {
        if (slot == null)
        {
            return;
        }

        Debug.Log("Trying to wear: " + this.ItemName);
        ContainerManager.Instance.Console.LogConsole("Trying to wear: " + this.ItemName);
        ContainerManager.Instance.DraggingItem = this;
        ContainerManager.Instance.WearItem(slot, null);
    }
Ejemplo n.º 21
0
        public override void Initialize()
        {
            base.Initialize();
            _idSlot  = ContainerManagerComponent.Ensure <ContainerSlot>("pda_entity_container", Owner);
            _penSlot = ContainerManagerComponent.Ensure <ContainerSlot>("pda_pen_slot", Owner);

            if (UserInterface != null)
            {
                UserInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage;
            }

            UpdatePDAAppearance();
        }
Ejemplo n.º 22
0
        protected override void Initialize()
        {
            base.Initialize();
            _idSlot  = ContainerHelpers.EnsureContainer <ContainerSlot>(Owner, "pda_entity_container");
            _penSlot = ContainerHelpers.EnsureContainer <ContainerSlot>(Owner, "pda_pen_slot");

            if (UserInterface != null)
            {
                UserInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage;
            }

            UpdatePDAAppearance();
        }
Ejemplo n.º 23
0
	public override void Use (ContainerSlot slot)
	{
		if(this.ItemAmount > 1)
		{
			ContainerManager.Instance.Console.LogConsole("Used one of " + this.ItemAmount + " " + this.ItemName);
			Debug.Log("Used one of " + this.ItemAmount + " " + this.ItemName);
		}		
		else
		{
			ContainerManager.Instance.Console.LogConsole("Used last " + this.ItemName);
			Debug.Log("Used last " + this.ItemName);
		}
		this.ItemAmount--;
	}
        protected override void Initialize()
        {
            base.Initialize();

            if (UserInterface != null)
            {
                UserInterface.OnReceiveMessage += OnUiReceiveMessage;
            }

            BodyContainer = ContainerHelpers.EnsureContainer <ContainerSlot>(Owner, $"{Name}-bodyContainer");

            //TODO: write this so that it checks for a change in power events for GORE POD cases
            EntitySystem.Get <CloningSystem>().UpdateUserInterface(this);
        }
Ejemplo n.º 25
0
        public override void Initialize()
        {
            base.Initialize();

            _privilegedIdContainer = ContainerManagerComponent.Ensure <ContainerSlot>($"{Name}-privilegedId", Owner);
            _targetIdContainer     = ContainerManagerComponent.Ensure <ContainerSlot>($"{Name}-targetId", Owner);

            _accessReader = Owner.GetComponent <AccessReader>();

            _userInterface = Owner.GetComponent <ServerUserInterfaceComponent>()
                             .GetBoundUserInterface(IdCardConsoleUiKey.Key);
            _userInterface.OnReceiveMessage += OnUiReceiveMessage;
            UpdateUserInterface();
        }
Ejemplo n.º 26
0
        public override void Initialize()
        {
            base.Initialize();

            _pointLight      = Owner.GetComponent <PointLightComponent>();
            _spriteComponent = Owner.GetComponent <SpriteComponent>();
            _cellContainer   =
                ContainerManagerComponent.Ensure <ContainerSlot>("flashlight_cell_container", Owner, out var existed);

            if (!existed)
            {
                var cell = Owner.EntityManager.SpawnEntity("PowerCellSmallHyper");
                _cellContainer.Insert(cell);
            }
        }
Ejemplo n.º 27
0
        private void InsertIdFromHand(IEntity user, ContainerSlot container, IHandsComponent hands)
        {
            var isId = hands.GetActiveHand?.Owner.HasComponent <IdCardComponent>();

            if (isId != true)
            {
                return;
            }
            if (!hands.Drop(hands.ActiveIndex, container))
            {
                _notifyManager.PopupMessage(Owner.Transform.GridPosition, user, _localizationManager.GetString("You can't let go of the ID card!"));
                return;
            }
            UpdateUserInterface();
        }
        protected override void Initialize()
        {
            base.Initialize();

            if (_ammoPrototype != null)
            {
                _ammoContainer = Owner.EnsureContainer <ContainerSlot>($"{Name}-ammo-container");
            }

            if (_entities.TryGetComponent(Owner, out AppearanceComponent? appearanceComponent))
            {
                _appearanceComponent = appearanceComponent;
            }
            Dirty();
        }
 public override void Initialize()
 {
     base.Initialize();
     _powerDevice = Owner.GetComponent <PowerDeviceComponent>();
     if (_powerDevice == null)
     {
         var exc = new InvalidOperationException("Chargers requires a PowerDevice to function");
         Logger.FatalS("charger", exc.Message);
         throw exc;
     }
     _container =
         ContainerManagerComponent.Ensure <ContainerSlot>($"{Name}-powerCellContainer", Owner);
     _appearanceComponent = Owner.GetComponent <AppearanceComponent>();
     // Default state in the visualizer is OFF, so when this gets powered on during initialization it will generally show empty
     _powerDevice.OnPowerStateChanged += PowerUpdate;
 }
        public override void Initialize()
        {
            base.Initialize();

            _privilegedIdContainer = ContainerManagerComponent.Ensure <ContainerSlot>($"{Name}-privilegedId", Owner);
            _targetIdContainer     = ContainerManagerComponent.Ensure <ContainerSlot>($"{Name}-targetId", Owner);

            Owner.EnsureComponentWarn <AccessReader>();
            Owner.EnsureComponentWarn <ServerUserInterfaceComponent>();

            if (UserInterface != null)
            {
                UserInterface.OnReceiveMessage += OnUiReceiveMessage;
            }

            UpdateUserInterface();
        }