mirror of
https://github.com/ACEmulator/ACE
synced 2026-08-17 12:26:06 -04:00
This helps better visualize the manager usage between - server wide - world object localized I'm doing this because as I travel down the rabbit hole of server-wide thread safety, these types of separations help make it easier to understand what managers need more attention for thread safety vs world object localized managers that sould be thread safe because their parent wo should be thread safe (key word *should*) I'll be adding thread safety to these server-wide managers and want to organize them better first to reduce the size of the multi-threading PR. This makes it easier to read, and easier to roll back if needed. QuestManager remains in the server wide folder because it is used for both WorldObjects and Fellowships.
54 lines
2.2 KiB
C#
54 lines
2.2 KiB
C#
using System;
|
|
|
|
using ACE.Database.Models.Shard;
|
|
using ACE.Entity.Enum;
|
|
using ACE.Server.WorldObjects.Managers;
|
|
|
|
namespace ACE.Server.WorldObjects
|
|
{
|
|
public class Armor
|
|
{
|
|
public Player Player;
|
|
public WorldObject ArmorClothing;
|
|
public BiotaPropertiesBodyPart Biota;
|
|
|
|
// TODO: differntiate between auras
|
|
public EnchantmentManager EnchantmentManager => Player.EnchantmentManager;
|
|
|
|
public Armor(Player player, WorldObject armorClothing, BiotaPropertiesBodyPart biota)
|
|
{
|
|
Player = player;
|
|
ArmorClothing = armorClothing;
|
|
Biota = biota;
|
|
}
|
|
|
|
public int BaseArmorMod => Biota.BaseArmor + EnchantmentManager.GetArmorMod();
|
|
public int ArmorVsSlash => GetArmorVsType(DamageType.Slash, Biota.ArmorVsSlash);
|
|
public int ArmorVsPierce => GetArmorVsType(DamageType.Pierce, Biota.ArmorVsPierce);
|
|
public int ArmorVsBludgeon => GetArmorVsType(DamageType.Bludgeon, Biota.ArmorVsBludgeon);
|
|
public int ArmorVsFire => GetArmorVsType(DamageType.Fire, Biota.ArmorVsFire);
|
|
public int ArmorVsCold => GetArmorVsType(DamageType.Cold, Biota.ArmorVsCold);
|
|
public int ArmorVsAcid => GetArmorVsType(DamageType.Acid, Biota.ArmorVsAcid);
|
|
public int ArmorVsElectric => GetArmorVsType(DamageType.Electric, Biota.ArmorVsElectric);
|
|
public int ArmorVsNether => GetArmorVsType(DamageType.Nether, Biota.ArmorVsNether);
|
|
|
|
public int GetArmorVsType(DamageType damageType, int armorVsType)
|
|
{
|
|
var resistance = (float)armorVsType / Biota.BaseArmor;
|
|
var mod = EnchantmentManager.GetResistanceMod(damageType);
|
|
|
|
var baseArmorMod = BaseArmorMod;
|
|
|
|
var resistanceMod = resistance / mod;
|
|
if (baseArmorMod < 0)
|
|
resistanceMod = 1.0f + (1.0f - resistanceMod);
|
|
|
|
/*Console.WriteLine("BaseArmor: " + Biota.BaseArmor);
|
|
Console.WriteLine("BaseArmorMod: " + baseArmorMod);
|
|
Console.WriteLine("Resistance: " + resistance);
|
|
Console.WriteLine("ResistanceMod: " + resistanceMod);*/
|
|
|
|
return (int)Math.Round(baseArmorMod * resistanceMod);
|
|
}
|
|
}
|
|
}
|