Esempio n. 1
0
        public void SetItem(Entity item)
        {
            CleanUpCurrentItem();
            if (item == null)
            {
                DisableSlotDetails();
                return;
            }
            Data          = item;
            _tooltip      = item.Get <TooltipComponent>();
            InventoryItem = Data.Get <InventoryItem>();
            SetSprite(item.Get <IconComponent>()?.Sprite);
            var action = item.Get <Action>();

            if (action != null && action.Ammo != null)
            {
                _currentAmmo = action.Ammo.Amount;
                _currentAmmo.OnResourceChanged += CheckAmmo;
                CheckAmmo();
            }
            if (_cooldownImage != null)
            {
                Data.AddObserver(EntitySignals.CooldownTimerChanged, CheckCooldown);
            }
            Data.AddObserver(this);
            CheckContent(Data);
        }
Esempio n. 2
0
 public void Clear()
 {
     CleanUpCurrentItem();
     DisableSlotDetails();
     _currentAmmo = null;
     _entity      = null;
     _tooltip     = null;
 }
Esempio n. 3
0
 public IntValueHolder GetHolder(string id)
 {
     if (!_valueCollections.TryGetValue(id, out var holder))
     {
         holder = new IntValueHolder();
         _valueCollections.Add(id, holder);
     }
     return(holder);
 }
Esempio n. 4
0
 private void RemoveAmmo()
 {
     _statSlider.value = 0;
     if (_currentAmmo != null)
     {
         _currentAmmo.OnResourceChanged -= CheckAmmo;
     }
     _currentAmmo = null;
 }
Esempio n. 5
0
 public AmmoComponent(SerializationInfo info, StreamingContext context)
 {
     Amount             = info.GetValue(nameof(Amount), Amount);
     Config             = ItemFactory.GetData(info.GetValue(nameof(Config), Config.ID)) as AmmoConfig;
     RepairSpeedPercent = info.GetValue(nameof(RepairSpeedPercent), RepairSpeedPercent);
     DamageModStat      = info.GetValue(nameof(DamageModStat), DamageModStat);
     DamagePercent      = info.GetValue(nameof(DamagePercent), DamagePercent);
     DamageModId        = info.GetValue(nameof(DamageModId), DamageModId);
     Skill = info.GetValue(nameof(Skill), Skill);
 }
Esempio n. 6
0
 public AmmoComponent(SerializationInfo info, StreamingContext context)
 {
     Amount             = info.GetValue(nameof(Amount), Amount);
     Template           = AmmoFactory.GetTemplate(info.GetValue(nameof(Template), Template.ID));
     RepairSpeedPercent = info.GetValue(nameof(RepairSpeedPercent), RepairSpeedPercent);
     _damageModStat     = info.GetValue(nameof(_damageModStat), _damageModStat);
     _damagePercent     = info.GetValue(nameof(_damagePercent), _damagePercent);
     _damageModId       = info.GetValue(nameof(_damageModId), _damageModId);
     _skill             = info.GetValue(nameof(_skill), _skill);
 }
Esempio n. 7
0
        public void Handle(ReadyActionsChanged arg)
        {
            if (arg.Index != _targetUsable)
            {
                return;
            }
            RemoveAmmo();
            var ammo = arg.Action.Entity.Get <AmmoComponent>();

            if (ammo != null)
            {
                _currentAmmo = ammo.Amount;
                _currentAmmo.OnResourceChanged += CheckAmmo;
            }
        }
Esempio n. 8
0
        public void Handle(CurrentActionsChanged arg)
        {
            if (arg.Index != _targetUsable)
            {
                return;
            }
            RemoveAmmo();
            var usable = arg.Action;

            if (usable != null)
            {
                _currentAmmo = usable.Ammo.Amount;
                _currentAmmo.OnResourceChanged += CheckAmmo;
            }
        }
Esempio n. 9
0
        public void SetNewTarget(CharacterTemplate actor)
        {
            if (_actor != null)
            {
                RemoveActor();
            }
            _actor = actor;
            if (_actor == null)
            {
                return;
            }
            _actor.Entity.AddObserver(this);
            var ammo = _actor.ReadyActions.GetAction(_targetUsable)?.Entity.Get <AmmoComponent>();

            if (ammo != null)
            {
                _currentAmmo = ammo.Amount;
                _currentAmmo.OnResourceChanged += CheckAmmo;
                _statSlider.value = _currentAmmo.CurrentPercent;
            }
        }
Esempio n. 10
0
        public void SetNewTarget(CharacterNode actor)
        {
            if (_actor != null)
            {
                RemoveActor();
            }
            _actor = actor;
            if (_actor == null)
            {
                return;
            }
            _actor.Entity.AddObserver(this);
            var action = _actor.CurrentActions.GetAction(_targetUsable);

            if (action != null)
            {
                _currentAmmo = action.Ammo.Amount;
                _currentAmmo.OnResourceChanged += CheckAmmo;
                _statSlider.value = _currentAmmo.CurrentPercent;
            }
        }
Esempio n. 11
0
        private void SetItem(Entity item)
        {
            CleanUpCurrentItem();
            _entity              = item;
            _tooltip             = item.Get <TooltipComponent>();
            _iconDisplay.sprite  = item.Get <IconComponent>().Sprite;
            _iconDisplay.enabled = _iconDisplay.sprite != null;
            var ammo = item.Get <AmmoComponent>();

            if (ammo != null)
            {
                _currentAmmo = ammo.Amount;
                _currentAmmo.OnResourceChanged += CheckAmmo;
                CheckAmmo();
            }
            if (_cooldownImage != null)
            {
                item.AddObserver(EntitySignals.CooldownTimerChanged, CheckCooldown);
            }
            item.AddObserver(this);
            RefreshItem();
        }