Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using VoidwalkerEngine.Framework.Collections;
- using VoidwalkerEngine.Framework.Interfaces;
- using VoidwalkerEngine.Framework.Logic;
- using VoidwalkerEngine.Framework.Maths;
- using VoidwalkerEngine.Framework.Systems.Items.Base;
- namespace VoidwalkerEngine.Framework.Systems.Items
- {
- public class Weapon : GameItem, IEquippable, IDamageProvider,
- IDynamicModifierProvider, IDurabilityProvider, ISocketable
- {
- public WeaponCategory Category { get; set; }
- public Range BaseDamage { get; set; }
- public ItemModifierList ImplicitModifiers { get; set; }
- public ItemModifierList ExplicitModifiers { get; set; }
- public int BaseDurability { get; set; }
- public int Durability { get; set; }
- public List<IAugmentation> Augmentations { get; set; }
- public int BaseMaximumSocketCount { get; set; }
- public Weapon()
- {
- }
- public double AttackSpeed
- {
- get
- {
- return Category.GetAttackSpeed();
- }
- }
- public bool IsBroken
- {
- get
- {
- return this.Durability == 0;
- }
- }
- public override void Copy(GameItem other)
- {
- if (other is Weapon item)
- {
- base.Copy(other);
- this.Category = item.Category;
- this.BaseDamage = item.BaseDamage;
- }
- }
- public Range GetMaximumDamage()
- {
- double multiplier = 1.0;
- ItemModifierList modifiers = this.GetModifiers();
- if (modifiers != null)
- {
- if (modifiers.Contains(ItemModifierTrait.EnhancedWeaponDamage, out int value))
- {
- multiplier += value / 100D;
- }
- if (modifiers.Contains(ItemModifierTrait.Ethereal))
- {
- multiplier += 0.25D;
- }
- }
- return new Range(
- (int)Math.Floor(this.BaseDamage.Minimum * multiplier),
- (int)Math.Floor(this.BaseDamage.Maximum * multiplier));
- }
- public ItemModifierList GetModifiers()
- {
- ItemModifierList results = new ItemModifierList();
- if (this.ImplicitModifiers != null)
- {
- results.Add(this.ImplicitModifiers);
- }
- if (this.ExplicitModifiers != null)
- {
- results.Add(this.ExplicitModifiers);
- }
- if (this.Augmentations != null)
- {
- foreach (IAugmentation augmentation in this.Augmentations)
- {
- switch (augmentation)
- {
- case IModifierProvider modifierProvider:
- if (modifierProvider.Modifiers != null)
- {
- results.Add(modifierProvider.Modifiers);
- }
- break;
- case IConditionalModifierProvider conditionalProvider:
- if (conditionalProvider.WeaponModifiers != null)
- {
- results.Add(conditionalProvider.WeaponModifiers);
- }
- break;
- }
- }
- }
- return results;
- }
- public EquipmentSlot GetEquipmentSlot()
- {
- switch (this.Category)
- {
- case WeaponCategory.Dagger:
- return EquipmentSlot.Ambidextrious;
- case WeaponCategory.Sickle:
- return EquipmentSlot.MainHand;
- case WeaponCategory.Fist:
- return EquipmentSlot.Ambidextrious;
- case WeaponCategory.OneHandedAxe:
- return EquipmentSlot.Ambidextrious;
- case WeaponCategory.OneHandedMace:
- return EquipmentSlot.Ambidextrious;
- case WeaponCategory.OneHandedSword:
- return EquipmentSlot.Ambidextrious;
- case WeaponCategory.Scythe:
- case WeaponCategory.Staff:
- case WeaponCategory.TwoHandedAxe:
- case WeaponCategory.TwoHandedMace:
- case WeaponCategory.TwoHandedSword:
- case WeaponCategory.Bow:
- return EquipmentSlot.Bimanual;
- case WeaponCategory.Wand:
- return EquipmentSlot.MainHand;
- default:
- return EquipmentSlot.None;
- }
- }
- public void Break()
- {
- this.Durability = 0;
- }
- public void Repair()
- {
- this.Durability = GetMaximumDurability();
- }
- public int GetMaximumDurability()
- {
- double multiplier = 1.0;
- ItemModifierList modifiers = this.GetModifiers();
- if (modifiers != null)
- {
- if (modifiers.Contains(ItemModifierTrait.EnhancedDurability, out int value))
- {
- multiplier += value / 100D;
- }
- if (modifiers.Contains(ItemModifierTrait.Ethereal))
- {
- multiplier += 0.25D;
- }
- }
- return (int)Math.Round(this.BaseDurability * multiplier);
- }
- /// <summary>
- /// Gets the total number of sockets that are currently
- /// available on this item, regardless if they're currently filled
- /// with augmentations.
- /// </summary>
- /// <returns></returns>
- public int GetAvailableSocketCount()
- {
- ItemModifierList modifiers = this.GetModifiers();
- if (modifiers.Contains(ItemModifierTrait.Socketed, out int value))
- {
- if (value <= this.BaseMaximumSocketCount)
- {
- return value;
- }
- return this.BaseMaximumSocketCount;
- }
- return 0;
- }
- public int GetEmptySocketCount()
- {
- if (this.Augmentations == null)
- {
- return this.GetAvailableSocketCount();
- }
- return this.GetAvailableSocketCount() - this.Augmentations.Count;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement