style
This commit is contained in:
parent
db8e7de58e
commit
302173daff
@ -20,7 +20,7 @@ namespace IcyClawz.CustomInteractions
|
||||
}
|
||||
}
|
||||
|
||||
public class ItemUiContextPatch : ModulePatch
|
||||
internal class ItemUiContextPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod() =>
|
||||
typeof(ItemUiContext).GetMethod("GetItemContextInteractions", BindingFlags.Public | BindingFlags.Instance);
|
||||
@ -42,7 +42,7 @@ namespace IcyClawz.CustomInteractions
|
||||
}
|
||||
}
|
||||
|
||||
public class InteractionButtonsContainerPatch : ModulePatch
|
||||
internal class InteractionButtonsContainerPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod() =>
|
||||
typeof(InteractionButtonsContainer).GetMethod("method_3", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
@ -14,7 +14,7 @@ namespace IcyClawz.ItemAttributeFix
|
||||
}
|
||||
}
|
||||
|
||||
public class CompactCharacteristicPanelPatch : ModulePatch
|
||||
internal class CompactCharacteristicPanelPatch : ModulePatch
|
||||
{
|
||||
private static readonly FieldInfo ItemAttributeField =
|
||||
typeof(CompactCharacteristicPanel).GetField("ItemAttribute", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
@ -29,7 +29,7 @@ namespace IcyClawz.ItemContextMenuExt
|
||||
((ILightTemplate)component.Item.Template).ModesCount;
|
||||
}
|
||||
|
||||
public sealed class CustomInteractionsProvider : IItemCustomInteractionsProvider
|
||||
internal sealed class CustomInteractionsProvider : IItemCustomInteractionsProvider
|
||||
{
|
||||
internal const string IconsPrefix = "Characteristics/Icons/";
|
||||
internal static StaticIcons StaticIcons => EFTHardSettings.Instance.StaticIcons;
|
||||
|
@ -12,7 +12,32 @@ using CurrencyUtil = GClass2181;
|
||||
|
||||
namespace IcyClawz.ItemSellPrice
|
||||
{
|
||||
public static class ItemSellPrice
|
||||
internal static class TraderClassExtensions
|
||||
{
|
||||
private static ISession Session => ClientAppUtils.GetMainApp().GetClientBackEndSession();
|
||||
|
||||
private static readonly FieldInfo SupplyDataField =
|
||||
typeof(TraderClass).GetField("supplyData_0", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
public static SupplyData GetSupplyData(this TraderClass trader) =>
|
||||
SupplyDataField.GetValue(trader) as SupplyData;
|
||||
|
||||
public static void SetSupplyData(this TraderClass trader, SupplyData supplyData) =>
|
||||
SupplyDataField.SetValue(trader, supplyData);
|
||||
|
||||
public static async void UpdateSupplyData(this TraderClass trader)
|
||||
{
|
||||
Result<SupplyData> result = await Session.GetSupplyData(trader.Id);
|
||||
if (result.Failed)
|
||||
{
|
||||
Debug.LogError("Failed to download supply data");
|
||||
return;
|
||||
}
|
||||
trader.SetSupplyData(result.Value);
|
||||
}
|
||||
}
|
||||
|
||||
internal static class ItemExtensions
|
||||
{
|
||||
private static readonly Dictionary<string, string[]> DisplayNames = new Dictionary<string, string[]>()
|
||||
{
|
||||
@ -34,42 +59,76 @@ namespace IcyClawz.ItemSellPrice
|
||||
{ "tu", new[] { "Satış fiyatı ({0})", "Tüccarlara satılamaz" } }
|
||||
};
|
||||
|
||||
private static readonly FieldInfo SupplyDataField =
|
||||
typeof(TraderClass).GetField("supplyData_0", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
private static ISession Session => ClientAppUtils.GetMainApp().GetClientBackEndSession();
|
||||
|
||||
public static async void UpdateSupplyData(this TraderClass trader)
|
||||
{
|
||||
Result<SupplyData> result = await Session.GetSupplyData(trader.Id);
|
||||
if (result.Failed)
|
||||
{
|
||||
Debug.LogError("Failed to download supply data");
|
||||
return;
|
||||
}
|
||||
trader.SetSupplyData(result.Value);
|
||||
}
|
||||
|
||||
public static SupplyData GetSupplyData(this TraderClass trader) =>
|
||||
SupplyDataField.GetValue(trader) as SupplyData;
|
||||
|
||||
public static void SetSupplyData(this TraderClass trader, SupplyData supplyData) =>
|
||||
SupplyDataField.SetValue(trader, supplyData);
|
||||
|
||||
public static void AddTraderOfferAttribute(this Item item)
|
||||
{
|
||||
List<ItemAttributeClass> attributes = new List<ItemAttributeClass>
|
||||
ItemAttributeClass attribute = new ItemAttributeClass(EItemAttributeId.MoneySum)
|
||||
{
|
||||
new ItemAttributeClass(EItemAttributeId.MoneySum)
|
||||
Name = EItemAttributeId.MoneySum.GetName(),
|
||||
DisplayNameFunc = () =>
|
||||
{
|
||||
Name = EItemAttributeId.MoneySum.GetName(),
|
||||
DisplayNameFunc = () => GetDisplayName(item),
|
||||
Base = () => GetBase(item),
|
||||
StringValue = () => GetStringValue(item),
|
||||
FullStringValue = () => GetFullStringValue(item),
|
||||
DisplayType = () => EItemAttributeDisplayType.Compact
|
||||
}
|
||||
string language = Singleton<SharedGameSettingsClass>.Instance?.Game?.Settings?.Language?.GetValue();
|
||||
if (language == null || !DisplayNames.ContainsKey(language))
|
||||
{
|
||||
language = "en";
|
||||
}
|
||||
if (GetBestTraderOffer(item) is TraderOffer offer)
|
||||
{
|
||||
return string.Format(DisplayNames[language][0], offer.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return DisplayNames[language][1];
|
||||
}
|
||||
},
|
||||
Base = () =>
|
||||
{
|
||||
if (GetBestTraderOffer(item) is TraderOffer offer)
|
||||
{
|
||||
return offer.Price;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.01f;
|
||||
}
|
||||
},
|
||||
StringValue = () =>
|
||||
{
|
||||
if (GetBestTraderOffer(item) is TraderOffer offer)
|
||||
{
|
||||
string value = $"{offer.Currency} {offer.Price}";
|
||||
if (offer.Count > 1)
|
||||
{
|
||||
value += $" ({offer.Count})";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
},
|
||||
FullStringValue = () =>
|
||||
{
|
||||
if (GetAllTraderOffers(item) is List<TraderOffer> offers)
|
||||
{
|
||||
string[] lines = new string[offers.Count];
|
||||
for (int i = 0; i < offers.Count; i++)
|
||||
{
|
||||
TraderOffer offer = offers[i];
|
||||
lines[i] = $"{offer.Name}: {offer.Currency} {offer.Price}";
|
||||
}
|
||||
return string.Join(Environment.NewLine, lines);
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
},
|
||||
DisplayType = () => EItemAttributeDisplayType.Compact
|
||||
};
|
||||
List<ItemAttributeClass> attributes = new List<ItemAttributeClass> { attribute };
|
||||
attributes.AddRange(item.Attributes);
|
||||
item.Attributes = attributes;
|
||||
}
|
||||
@ -149,69 +208,5 @@ namespace IcyClawz.ItemSellPrice
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetDisplayName(Item item)
|
||||
{
|
||||
string language = Singleton<SharedGameSettingsClass>.Instance?.Game?.Settings?.Language?.GetValue();
|
||||
if (language == null || !DisplayNames.ContainsKey(language))
|
||||
{
|
||||
language = "en";
|
||||
}
|
||||
if (GetBestTraderOffer(item) is TraderOffer offer)
|
||||
{
|
||||
return string.Format(DisplayNames[language][0], offer.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return DisplayNames[language][1];
|
||||
}
|
||||
}
|
||||
|
||||
public static float GetBase(Item item)
|
||||
{
|
||||
if (GetBestTraderOffer(item) is TraderOffer offer)
|
||||
{
|
||||
return offer.Price;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.01f;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetStringValue(Item item)
|
||||
{
|
||||
if (GetBestTraderOffer(item) is TraderOffer offer)
|
||||
{
|
||||
string value = $"{offer.Currency} {offer.Price}";
|
||||
if (offer.Count > 1)
|
||||
{
|
||||
value += $" ({offer.Count})";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetFullStringValue(Item item)
|
||||
{
|
||||
if (GetAllTraderOffers(item) is List<TraderOffer> offers)
|
||||
{
|
||||
string[] lines = new string[offers.Count];
|
||||
for (int i = 0; i < offers.Count; i++)
|
||||
{
|
||||
TraderOffer offer = offers[i];
|
||||
lines[i] = $"{offer.Name}: {offer.Currency} {offer.Price}";
|
||||
}
|
||||
return string.Join(Environment.NewLine, lines);
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -8,9 +8,6 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Aki.Common">
|
||||
<HintPath>..\Shared\Aki.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Aki.Reflection">
|
||||
<HintPath>..\Shared\Aki.Reflection.dll</HintPath>
|
||||
</Reference>
|
||||
|
@ -18,7 +18,7 @@ namespace IcyClawz.ItemSellPrice
|
||||
}
|
||||
}
|
||||
|
||||
public class TraderPatch : ModulePatch
|
||||
internal class TraderPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod() =>
|
||||
typeof(TraderClass).GetConstructors()[0];
|
||||
@ -30,7 +30,7 @@ namespace IcyClawz.ItemSellPrice
|
||||
}
|
||||
}
|
||||
|
||||
public class ItemPatch : ModulePatch
|
||||
internal class ItemPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod() =>
|
||||
typeof(Item).GetConstructors()[0];
|
||||
@ -42,7 +42,7 @@ namespace IcyClawz.ItemSellPrice
|
||||
}
|
||||
}
|
||||
|
||||
public class AmmoPatch : ModulePatch
|
||||
internal class AmmoPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod() =>
|
||||
typeof(BulletClass).GetConstructors()[0];
|
||||
@ -54,7 +54,7 @@ namespace IcyClawz.ItemSellPrice
|
||||
}
|
||||
}
|
||||
|
||||
public class GrenadePatch : ModulePatch
|
||||
internal class GrenadePatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod() =>
|
||||
typeof(GrenadeClass).GetConstructors()[0];
|
||||
@ -66,7 +66,7 @@ namespace IcyClawz.ItemSellPrice
|
||||
}
|
||||
}
|
||||
|
||||
public class SecureContainerPatch : ModulePatch
|
||||
internal class SecureContainerPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod() =>
|
||||
typeof(ItemContainerClass).GetConstructors()[0];
|
||||
|
@ -11,7 +11,7 @@ using InGameStatus = GClass1756;
|
||||
|
||||
namespace IcyClawz.MagazineInspector
|
||||
{
|
||||
public static class MagazineInspector
|
||||
internal static class MagazineClassExtensions
|
||||
{
|
||||
private static readonly Dictionary<string, string> DisplayNames = new Dictionary<string, string>()
|
||||
{
|
||||
@ -35,7 +35,7 @@ namespace IcyClawz.MagazineInspector
|
||||
|
||||
private static ISession Session => ClientAppUtils.GetMainApp().GetClientBackEndSession();
|
||||
|
||||
private static Profile ActiveProfile => InGameStatus.InRaid ? ClientPlayerOwner.MyPlayer.Profile : Session.Profile;
|
||||
private static Profile ActiveProfile => InGameStatus.InRaid ? GamePlayerOwner.MyPlayer.Profile : Session.Profile;
|
||||
|
||||
public static void AddAmmoCountAttribute(this MagazineClass magazine)
|
||||
{
|
||||
@ -44,10 +44,77 @@ namespace IcyClawz.MagazineInspector
|
||||
{
|
||||
return;
|
||||
}
|
||||
attribute.DisplayNameFunc = GetDisplayName;
|
||||
attribute.Base = () => GetBase(magazine);
|
||||
attribute.StringValue = () => GetStringValue(magazine);
|
||||
attribute.FullStringValue = () => GetFullStringValue(magazine);
|
||||
attribute.DisplayNameFunc = () =>
|
||||
{
|
||||
string language = Singleton<SharedGameSettingsClass>.Instance?.Game?.Settings?.Language?.GetValue();
|
||||
if (language == null || !DisplayNames.ContainsKey(language))
|
||||
{
|
||||
language = "en";
|
||||
}
|
||||
return DisplayNames[language];
|
||||
};
|
||||
attribute.Base = () =>
|
||||
{
|
||||
if (GetAmmoCount(magazine, ActiveProfile, out _) is int ammoCount)
|
||||
{
|
||||
return ammoCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
};
|
||||
attribute.StringValue = () =>
|
||||
{
|
||||
string value;
|
||||
if (GetAmmoCount(magazine, ActiveProfile, out _) is int ammoCount)
|
||||
{
|
||||
value = ammoCount.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "?";
|
||||
}
|
||||
return $"{value}/{magazine.MaxCount}";
|
||||
};
|
||||
attribute.FullStringValue = () =>
|
||||
{
|
||||
Profile profile = ActiveProfile;
|
||||
int? ammoCount = GetAmmoCount(magazine, profile, out bool magChecked);
|
||||
if (magChecked)
|
||||
{
|
||||
List<Item> cartridges = new List<Item>(magazine.Cartridges.Items);
|
||||
string[] lines = new string[cartridges.Count];
|
||||
int i = cartridges.Count - 1;
|
||||
foreach (Item cartridge in cartridges)
|
||||
{
|
||||
string count;
|
||||
if (ammoCount != null)
|
||||
{
|
||||
count = cartridge.StackObjectsCount.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
count = "?";
|
||||
}
|
||||
string name;
|
||||
if (profile.Examined(cartridge))
|
||||
{
|
||||
name = cartridge.LocalizedName();
|
||||
}
|
||||
else
|
||||
{
|
||||
name = "Unknown item".Localized();
|
||||
}
|
||||
lines[i--] = $"{count} × {name}";
|
||||
}
|
||||
return string.Join(Environment.NewLine, lines);
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static int? GetAmmoCount(MagazineClass magazine, Profile profile, out bool magChecked)
|
||||
@ -77,81 +144,5 @@ namespace IcyClawz.MagazineInspector
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetDisplayName()
|
||||
{
|
||||
string language = Singleton<SharedGameSettingsClass>.Instance?.Game?.Settings?.Language?.GetValue();
|
||||
if (language == null || !DisplayNames.ContainsKey(language))
|
||||
{
|
||||
language = "en";
|
||||
}
|
||||
return DisplayNames[language];
|
||||
}
|
||||
|
||||
public static float GetBase(MagazineClass magazine)
|
||||
{
|
||||
if (GetAmmoCount(magazine, ActiveProfile, out _) is int ammoCount)
|
||||
{
|
||||
return ammoCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetStringValue(MagazineClass magazine)
|
||||
{
|
||||
string value;
|
||||
if (GetAmmoCount(magazine, ActiveProfile, out _) is int ammoCount)
|
||||
{
|
||||
value = ammoCount.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "?";
|
||||
}
|
||||
return $"{value}/{magazine.MaxCount}";
|
||||
}
|
||||
|
||||
|
||||
public static string GetFullStringValue(MagazineClass magazine)
|
||||
{
|
||||
Profile profile = ActiveProfile;
|
||||
int? ammoCount = GetAmmoCount(magazine, profile, out bool magChecked);
|
||||
if (magChecked)
|
||||
{
|
||||
List<Item> cartridges = new List<Item>(magazine.Cartridges.Items);
|
||||
string[] lines = new string[cartridges.Count];
|
||||
int i = cartridges.Count - 1;
|
||||
foreach (Item cartridge in cartridges)
|
||||
{
|
||||
string count;
|
||||
if (ammoCount != null)
|
||||
{
|
||||
count = cartridge.StackObjectsCount.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
count = "?";
|
||||
}
|
||||
string name;
|
||||
if (profile.Examined(cartridge))
|
||||
{
|
||||
name = cartridge.LocalizedName();
|
||||
}
|
||||
else
|
||||
{
|
||||
name = "Unknown item".Localized();
|
||||
}
|
||||
lines[i--] = $"{count} × {name}";
|
||||
}
|
||||
return string.Join(Environment.NewLine, lines);
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -8,9 +8,6 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Aki.Common">
|
||||
<HintPath>..\Shared\Aki.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Aki.Reflection">
|
||||
<HintPath>..\Shared\Aki.Reflection.dll</HintPath>
|
||||
</Reference>
|
||||
|
@ -13,7 +13,7 @@ namespace IcyClawz.MagazineInspector
|
||||
}
|
||||
}
|
||||
|
||||
public class MagazinePatch : ModulePatch
|
||||
internal class MagazinePatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod() =>
|
||||
typeof(MagazineClass).GetConstructors()[0];
|
||||
|
Loading…
x
Reference in New Issue
Block a user