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); }
public void Clear() { CleanUpCurrentItem(); DisableSlotDetails(); _currentAmmo = null; _entity = null; _tooltip = null; }
public IntValueHolder GetHolder(string id) { if (!_valueCollections.TryGetValue(id, out var holder)) { holder = new IntValueHolder(); _valueCollections.Add(id, holder); } return(holder); }
private void RemoveAmmo() { _statSlider.value = 0; if (_currentAmmo != null) { _currentAmmo.OnResourceChanged -= CheckAmmo; } _currentAmmo = null; }
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); }
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); }
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; } }
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; } }
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; } }
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; } }
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(); }