public static ItemBaseProjectileInfo Load(BaseEntity heldent) { var bProjectile = heldent as BaseProjectile; if (bProjectile == null || bProjectile.primaryMagazine == null) { return(null); } var ibpInfo = new ItemBaseProjectileInfo(); var imProjectile = bProjectile.primaryMagazine.ammoType.GetComponent <ItemModProjectile>(); var projectile = imProjectile.projectileObject.Get().GetComponent <Projectile>(); ibpInfo.Damage = projectile?.damageTypes.Sum(p => p.amount) ?? 200; ibpInfo.AmmoTypes = (ProjectileAmmoTypes)(int)bProjectile.primaryMagazine.definition.ammoTypes; ibpInfo.ProjectilesPerShot = imProjectile.numProjectiles; return(ibpInfo); }
public static ItemInformation Load(Item item) { var iteminfo = new ItemInformation(); iteminfo.ItemID = item.info.itemid; iteminfo.Shortname = item.info.shortname; iteminfo.MaxStack = item.info.stackable; iteminfo.MaxCondition = item.info.condition.max; var heldent = item.GetHeldEntity(); if (heldent != null) { iteminfo.HeldEntity = ItemHeldEntity.Load(heldent); var heldtype = heldent.GetType(); if (heldtype == typeof(HeldEntity)) { iteminfo.HeldType = ItemHeldType.HeldEntity; } else if (heldtype == typeof(AttackEntity)) { iteminfo.HeldType = ItemHeldType.AttackEntity; } else if (heldtype == typeof(BaseProjectile)) { iteminfo.HeldType = ItemHeldType.BaseProjectile; } else if (heldtype == typeof(BaseMelee)) { iteminfo.HeldType = ItemHeldType.BaseMelee; } iteminfo.HeldEntity = ItemHeldEntity.Load(heldent); iteminfo.BaseProjectile = ItemBaseProjectileInfo.Load(heldent); iteminfo.BaseMelee = ItemBaseMelee.Load(heldent); } return(iteminfo); }