From 9bf10bdddfb7728890cf8a02bf2f4370e6f67359 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 06:51:23 +0100 Subject: [PATCH 01/22] Init --- .../Models/ItemEvents/HealItemEvent.cs | 23 +++++++++ .../Models/Profiles/HealthInfo.cs | 18 +++++++ .../ItemEvents/HealItemEventController.cs | 48 +++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 Fuyu.Backend.BSG/Models/ItemEvents/HealItemEvent.cs create mode 100644 Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs diff --git a/Fuyu.Backend.BSG/Models/ItemEvents/HealItemEvent.cs b/Fuyu.Backend.BSG/Models/ItemEvents/HealItemEvent.cs new file mode 100644 index 00000000..5633a9ed --- /dev/null +++ b/Fuyu.Backend.BSG/Models/ItemEvents/HealItemEvent.cs @@ -0,0 +1,23 @@ +using System.Runtime.Serialization; +using Fuyu.Backend.BSG.ItemTemplates; +using Fuyu.Backend.BSG.Models.Profiles.Health; +using Fuyu.Common.Hashing; + +namespace Fuyu.Backend.BSG.Models.ItemEvents +{ + [DataContract] + public class HealItemEvent : BaseItemEvent + { + [DataMember(Name = "item")] + public MongoId Item { get; set; } + + [DataMember(Name = "part")] + public EBodyPart BodyPart { get; set; } + + [DataMember(Name = "count")] + public int Count { get; set; } + + [DataMember(Name = "time")] + public int Time { get; set; } + } +} diff --git a/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs b/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs index 853c90f5..4c76279c 100644 --- a/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs +++ b/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs @@ -1,4 +1,6 @@ +using System; using System.Runtime.Serialization; +using Fuyu.Backend.BSG.ItemTemplates; using Fuyu.Backend.BSG.Models.Common; using Fuyu.Backend.BSG.Models.Profiles.Health; @@ -22,6 +24,22 @@ public class HealthInfo [DataMember] public int? UpdateTime { get; set; } + public BodyPart GetBodyPart(EBodyPart bodyPart) + { + return bodyPart switch + { + EBodyPart.Head => BodyParts.Head, + EBodyPart.Chest => BodyParts.Chest, + EBodyPart.Stomach => BodyParts.Stomach, + EBodyPart.LeftArm => BodyParts.LeftArm, + EBodyPart.RightArm => BodyParts.RightArm, + EBodyPart.LeftLeg => BodyParts.LeftLeg, + EBodyPart.RightLeg => BodyParts.RightLeg, + EBodyPart.Common => throw new NotImplementedException("Cannot use Common?"), + _ => null, + }; + } + // SKIPPED: Immortal // Reason: only used on BSG's internal server } diff --git a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs new file mode 100644 index 00000000..b536de4b --- /dev/null +++ b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs @@ -0,0 +1,48 @@ +using Fuyu.Backend.BSG.Models.ItemEvents; +using Fuyu.Backend.BSG.Models.Items; +using Fuyu.Backend.BSG.Networking; +using Fuyu.Common.IO; +using System.Threading.Tasks; + +namespace Fuyu.Backend.EFT.Controllers.ItemEvents +{ + public class HealItemEventController : AbstractItemEventController + { + private readonly EftOrm _eftOrm; + + public HealItemEventController() : base("Heal") + { + _eftOrm = EftOrm.Instance; + } + + // This method only finds the item, as well as the index. Actually consuming/deleting the item needs to be done. + public override Task RunAsync(ItemEventContext context, HealItemEvent request) + { + var profile = _eftOrm.GetActiveProfile(context.SessionId); + var item = profile.Pmc.Inventory.FindItem(request.Item); + + if (item == null) + { + Terminal.WriteLine($"Failed to find item {request.Item}"); + return Task.CompletedTask; + } + + var medKit = item.GetOrCreateUpdatable(); + if (medKit == null) + { + Terminal.WriteLine("Could not find medKit on item: " + request.Item); + return Task.CompletedTask; + } + + medKit.HpResource -= request.Count; + if (medKit.HpResource <= 0) + { + profile.Pmc.Inventory.RemoveItem(item); + } + + var bodyPart = profile.Pmc.Health.GetBodyPart(request.BodyPart); + + return Task.CompletedTask; + } + } +} From 3ccdcf01ba36dbc2fb78a1f9d7d90df666e5bbc3 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 07:20:41 +0100 Subject: [PATCH 02/22] Add HealthService --- .../ItemEvents/HealItemEventController.cs | 7 ++++++- Fuyu.Backend.EFT/Services/HealthService.cs | 21 +++++++++++++++++++ Fuyu.Common/IO/Resx.cs | 4 ++-- 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 Fuyu.Backend.EFT/Services/HealthService.cs diff --git a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs index b536de4b..40749d36 100644 --- a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs +++ b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs @@ -1,7 +1,9 @@ using Fuyu.Backend.BSG.Models.ItemEvents; using Fuyu.Backend.BSG.Models.Items; using Fuyu.Backend.BSG.Networking; +using Fuyu.Backend.EFT.Services; using Fuyu.Common.IO; +using System; using System.Threading.Tasks; namespace Fuyu.Backend.EFT.Controllers.ItemEvents @@ -9,10 +11,12 @@ namespace Fuyu.Backend.EFT.Controllers.ItemEvents public class HealItemEventController : AbstractItemEventController { private readonly EftOrm _eftOrm; + private readonly HealthService _healthService; public HealItemEventController() : base("Heal") { _eftOrm = EftOrm.Instance; + _healthService = HealthService.Instance; } // This method only finds the item, as well as the index. Actually consuming/deleting the item needs to be done. @@ -40,7 +44,8 @@ public override Task RunAsync(ItemEventContext context, HealItemEvent request) profile.Pmc.Inventory.RemoveItem(item); } - var bodyPart = profile.Pmc.Health.GetBodyPart(request.BodyPart); + var bodyPart = _healthService.GetBodyPart(profile.Pmc.Health, request.BodyPart); + bodyPart.Health.Current = MathF.Max(bodyPart.Health.Current + request.Count, bodyPart.Health.Maximum); return Task.CompletedTask; } diff --git a/Fuyu.Backend.EFT/Services/HealthService.cs b/Fuyu.Backend.EFT/Services/HealthService.cs new file mode 100644 index 00000000..829bc34d --- /dev/null +++ b/Fuyu.Backend.EFT/Services/HealthService.cs @@ -0,0 +1,21 @@ +using System; +using Fuyu.Backend.BSG.ItemTemplates; +using Fuyu.Backend.BSG.Models.Profiles; +using Fuyu.Backend.BSG.Models.Profiles.Health; + +namespace Fuyu.Backend.EFT.Services; +public class HealthService +{ + public static HealthService Instance => instance.Value; + private static readonly Lazy instance = new(() => new HealthService()); + + private HealthService() + { + + } + + public BodyPart GetBodyPart(HealthInfo health, EBodyPart bodyPart) + { + return health.GetBodyPart(bodyPart); + } +} diff --git a/Fuyu.Common/IO/Resx.cs b/Fuyu.Common/IO/Resx.cs index 23b229ed..2d5d1423 100644 --- a/Fuyu.Common/IO/Resx.cs +++ b/Fuyu.Common/IO/Resx.cs @@ -94,10 +94,10 @@ public static byte[] GetBytes(string id, string path) { var bytes = new byte[rs.Length]; -#if DOTNET_7_0_OR_GREATER +#if NET7_0_OR_GREATER rs.ReadExactly(bytes); #else - rs.ReadExactly(bytes); + rs.Read(bytes, 0, bytes.Length); #endif return bytes; From 90b861d0ff700626bf8b31baab1bb103aaf38791 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 07:41:57 +0100 Subject: [PATCH 03/22] Add note --- .../Controllers/ItemEvents/HealItemEventController.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs index 40749d36..f8de9695 100644 --- a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs +++ b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs @@ -47,6 +47,9 @@ public override Task RunAsync(ItemEventContext context, HealItemEvent request) var bodyPart = _healthService.GetBodyPart(profile.Pmc.Health, request.BodyPart); bodyPart.Health.Current = MathF.Max(bodyPart.Health.Current + request.Count, bodyPart.Health.Maximum); + // TODO: + // Check BackendConfig for 'HealExperience' and add to PMC profile + return Task.CompletedTask; } } From 469c5c7cbad5f6bfdf8c70eb2c7c49acbd3d595c Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 07:44:09 +0100 Subject: [PATCH 04/22] Add note --- .../Controllers/ItemEvents/HealItemEventController.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs index f8de9695..1e342c73 100644 --- a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs +++ b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs @@ -49,6 +49,7 @@ public override Task RunAsync(ItemEventContext context, HealItemEvent request) // TODO: // Check BackendConfig for 'HealExperience' and add to PMC profile + // Handle effects return Task.CompletedTask; } From b706190ff8d4baf1a398e234a8f791b473587223 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 08:03:46 +0100 Subject: [PATCH 05/22] Fix logic --- .../Controllers/ItemEvents/HealItemEventController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs index 1e342c73..42248428 100644 --- a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs +++ b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs @@ -45,7 +45,7 @@ public override Task RunAsync(ItemEventContext context, HealItemEvent request) } var bodyPart = _healthService.GetBodyPart(profile.Pmc.Health, request.BodyPart); - bodyPart.Health.Current = MathF.Max(bodyPart.Health.Current + request.Count, bodyPart.Health.Maximum); + bodyPart.Health.Current = Math.Clamp(bodyPart.Health.Current + request.Count, bodyPart.Health.Current, bodyPart.Health.Maximum); // TODO: // Check BackendConfig for 'HealExperience' and add to PMC profile From 90528a17dd6a12bb8e3675e5d32ce4526f7d4e2b Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 14:07:35 +0100 Subject: [PATCH 06/22] Update - Renamed CurrentMaximum to more suitable name - Clamped values inside renamed class - Added properties to HealthEffect and DamageEffect - Updated BodyPart to contain correct properties - Finalized handling of effects --- .../ItemTemplates/MedsItemProperties.cs | 39 ++++++++++++++---- .../Models/Common/ClampedValue.cs | 40 +++++++++++++++++++ .../Models/Common/CurrentMaximum.cs | 14 ------- .../Models/ItemEvents/HealItemEvent.cs | 1 - .../Models/Profiles/Health/BodyPart.cs | 6 ++- .../Models/Profiles/Health/BodyPartEffect.cs | 10 +++++ .../Models/Profiles/Health/BodyPartsInfo.cs | 20 +++++++++- .../Models/Profiles/HealthInfo.cs | 22 ++++++++-- .../ItemEvents/HealItemEventController.cs | 37 ++++++++++++----- 9 files changed, 152 insertions(+), 37 deletions(-) create mode 100644 Fuyu.Backend.BSG/Models/Common/ClampedValue.cs delete mode 100644 Fuyu.Backend.BSG/Models/Common/CurrentMaximum.cs create mode 100644 Fuyu.Backend.BSG/Models/Profiles/Health/BodyPartEffect.cs diff --git a/Fuyu.Backend.BSG/ItemTemplates/MedsItemProperties.cs b/Fuyu.Backend.BSG/ItemTemplates/MedsItemProperties.cs index fc4653be..15c06f99 100644 --- a/Fuyu.Backend.BSG/ItemTemplates/MedsItemProperties.cs +++ b/Fuyu.Backend.BSG/ItemTemplates/MedsItemProperties.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Runtime.Serialization; using Fuyu.Common.Collections; +using Newtonsoft.Json; namespace Fuyu.Backend.BSG.ItemTemplates { @@ -8,32 +9,56 @@ namespace Fuyu.Backend.BSG.ItemTemplates public class MedsItemProperties : ItemProperties { [DataMember(Name = "medUseTime")] - public float UseTime; + public float UseTime { get; set; } [DataMember(Name = "bodyPartTimeMults")] - public KeyValuePair[] BodyPartTimeMults; + public KeyValuePair[] BodyPartTimeMults { get; set; } [DataMember(Name = "effects_health")] - public Union, object[]> HealthEffects; + public Union, object[]> HealthEffects { get; set; } [DataMember(Name = "effects_damage")] - public Union, object[]> DamageEffects; + public Union, object[]> DamageEffects { get; set; } [DataMember(Name = "StimulatorBuffs")] - public string StimulatorBuffs; + public string StimulatorBuffs { get; set; } [DataMember(Name = "MaxHpResource")] - public int MaxHpResource; + public int MaxHpResource { get; set; } [DataMember(Name = "hpResourceRate")] - public float HpResourceRate; + public float HpResourceRate { get; set; } } + [DataContract] public class HealthEffect { + [DataMember(Name = "delay")] + public float Delay { get; set; } + + [DataMember(Name = "duration")] + public float Duration { get; set; } } + [DataContract] public class DamageEffect { + [DataMember(Name = "delay")] + public float Delay { get; set; } + + [DataMember(Name = "duration")] + public float Duration { get; set; } + + [DataMember(Name = "fadeOut")] + public float FadeOut { get; set; } + + [DataMember(Name = "cost")] + public int Cost { get; set; } + + [DataMember(Name = "healthPenaltyMin")] + public int HealthPenaltyMin { get; set; } + + [DataMember(Name = "healthPenaltyMax")] + public int HealthPenaltyMax { get; set; } } } \ No newline at end of file diff --git a/Fuyu.Backend.BSG/Models/Common/ClampedValue.cs b/Fuyu.Backend.BSG/Models/Common/ClampedValue.cs new file mode 100644 index 00000000..1f97e293 --- /dev/null +++ b/Fuyu.Backend.BSG/Models/Common/ClampedValue.cs @@ -0,0 +1,40 @@ +using System.Numerics; +using System.Runtime.Serialization; + +namespace Fuyu.Backend.BSG.Models.Common +{ + /// + /// Class used to automatically clamp and values + /// + /// + [DataContract] + public class ClampedValue where T : INumber + { + [DataMember] + public T Current + { + get + { + return _current; + } + set + { + _current = T.Clamp(value, Minimum, Maximum); + } + } + + private T _current; + + [DataMember] + public T Minimum { get; set; } + + [DataMember] + public T Maximum { get; set; } + + [DataMember] + public T OverDamageReceivedMultiplier { get; set; } + + [DataMember] + public T EnvironmentDamageMultiplier { get; set; } + } +} \ No newline at end of file diff --git a/Fuyu.Backend.BSG/Models/Common/CurrentMaximum.cs b/Fuyu.Backend.BSG/Models/Common/CurrentMaximum.cs deleted file mode 100644 index a88de8a2..00000000 --- a/Fuyu.Backend.BSG/Models/Common/CurrentMaximum.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Runtime.Serialization; - -namespace Fuyu.Backend.BSG.Models.Common -{ - [DataContract] - public class CurrentMaximum - { - [DataMember] - public T Current { get; set; } - - [DataMember] - public T Maximum { get; set; } - } -} \ No newline at end of file diff --git a/Fuyu.Backend.BSG/Models/ItemEvents/HealItemEvent.cs b/Fuyu.Backend.BSG/Models/ItemEvents/HealItemEvent.cs index 5633a9ed..d85cb4ae 100644 --- a/Fuyu.Backend.BSG/Models/ItemEvents/HealItemEvent.cs +++ b/Fuyu.Backend.BSG/Models/ItemEvents/HealItemEvent.cs @@ -1,6 +1,5 @@ using System.Runtime.Serialization; using Fuyu.Backend.BSG.ItemTemplates; -using Fuyu.Backend.BSG.Models.Profiles.Health; using Fuyu.Common.Hashing; namespace Fuyu.Backend.BSG.Models.ItemEvents diff --git a/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPart.cs b/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPart.cs index 9ad3f8b5..76d99de9 100644 --- a/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPart.cs +++ b/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPart.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Runtime.Serialization; using Fuyu.Backend.BSG.Models.Common; @@ -7,6 +8,9 @@ namespace Fuyu.Backend.BSG.Models.Profiles.Health public class BodyPart { [DataMember] - public CurrentMaximum Health { get; set; } + public ClampedValue Health { get; set; } + + [DataMember] + public Dictionary Effects { get; set; } } } \ No newline at end of file diff --git a/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPartEffect.cs b/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPartEffect.cs new file mode 100644 index 00000000..f07e9c48 --- /dev/null +++ b/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPartEffect.cs @@ -0,0 +1,10 @@ +using System.Runtime.Serialization; + +namespace Fuyu.Backend.BSG.Models.Profiles.Health; + +[DataContract] +public class BodyPartEffect +{ + [DataMember] + public float Time { get; set; } = -1f; +} \ No newline at end of file diff --git a/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPartsInfo.cs b/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPartsInfo.cs index 416ebfde..3c235761 100644 --- a/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPartsInfo.cs +++ b/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPartsInfo.cs @@ -1,9 +1,11 @@ +using System.Collections; +using System.Collections.Generic; using System.Runtime.Serialization; namespace Fuyu.Backend.BSG.Models.Profiles.Health { [DataContract] - public class BodyPartInfo + public class BodyPartInfo : IEnumerable { [DataMember] public BodyPart Head { get; set; } @@ -25,5 +27,21 @@ public class BodyPartInfo [DataMember] public BodyPart RightLeg { get; set; } + + public IEnumerator GetEnumerator() + { + yield return Head; + yield return Chest; + yield return Stomach; + yield return LeftArm; + yield return RightArm; + yield return LeftLeg; + yield return RightLeg; + } + + IEnumerator IEnumerable.GetEnumerator() + { + throw new System.NotImplementedException(); + } } } \ No newline at end of file diff --git a/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs b/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs index 4c76279c..7a94604d 100644 --- a/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs +++ b/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Runtime.Serialization; using Fuyu.Backend.BSG.ItemTemplates; using Fuyu.Backend.BSG.Models.Common; @@ -10,13 +11,16 @@ namespace Fuyu.Backend.BSG.Models.Profiles public class HealthInfo { [DataMember] - public CurrentMaximum Hydration { get; set; } + public ClampedValue Hydration { get; set; } [DataMember] - public CurrentMaximum Energy { get; set; } + public ClampedValue Energy { get; set; } [DataMember] - public CurrentMaximum Temperature { get; set; } + public ClampedValue Temperature { get; set; } + + [DataMember] + public ClampedValue Poison { get; set; } [DataMember] public BodyPartInfo BodyParts { get; set; } @@ -40,6 +44,18 @@ public BodyPart GetBodyPart(EBodyPart bodyPart) }; } + /// + /// Returns whether any bodyparts contain a + /// + [IgnoreDataMember] + public bool HasEffects + { + get + { + return BodyParts.Any(x => x.Effects.Count > 0); + } + } + // SKIPPED: Immortal // Reason: only used on BSG's internal server } diff --git a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs index 42248428..8a91b99e 100644 --- a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs +++ b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs @@ -1,10 +1,11 @@ -using Fuyu.Backend.BSG.Models.ItemEvents; +using System.Threading.Tasks; +using Fuyu.Backend.BSG.ItemTemplates; +using Fuyu.Backend.BSG.Models.ItemEvents; using Fuyu.Backend.BSG.Models.Items; using Fuyu.Backend.BSG.Networking; +using Fuyu.Backend.BSG.Services; using Fuyu.Backend.EFT.Services; using Fuyu.Common.IO; -using System; -using System.Threading.Tasks; namespace Fuyu.Backend.EFT.Controllers.ItemEvents { @@ -12,11 +13,13 @@ public class HealItemEventController : AbstractItemEventController(); - if (medKit == null) - { - Terminal.WriteLine("Could not find medKit on item: " + request.Item); - return Task.CompletedTask; - } medKit.HpResource -= request.Count; if (medKit.HpResource <= 0) @@ -45,11 +43,30 @@ public override Task RunAsync(ItemEventContext context, HealItemEvent request) } var bodyPart = _healthService.GetBodyPart(profile.Pmc.Health, request.BodyPart); - bodyPart.Health.Current = Math.Clamp(bodyPart.Health.Current + request.Count, bodyPart.Health.Current, bodyPart.Health.Maximum); + float toHeal = request.Count; + + if (profile.Pmc.Health.HasEffects) + { + var itemProperties = _itemFactoryService.ItemTemplates[item.TemplateId].Props.ToObject(); + bool itemCanRemove = itemProperties.DamageEffects.IsValue1 && itemProperties.DamageEffects.Value1.Count > 0; + + if (itemCanRemove) + { + foreach (var effectPair in itemProperties.DamageEffects.Value1) + { + if (bodyPart.Effects.ContainsKey(effectPair.Key)) + { + toHeal -= effectPair.Value.Cost = 0; + bodyPart.Effects.Remove(effectPair.Key); + } + } + } + } + + bodyPart.Health.Current += toHeal; // TODO: // Check BackendConfig for 'HealExperience' and add to PMC profile - // Handle effects return Task.CompletedTask; } From e7427210fa524986dec8cfe73c89095a03de394a Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 14:47:02 +0100 Subject: [PATCH 07/22] Change order of logic --- .../ItemEvents/HealItemEventController.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs index 8a91b99e..979f5a2f 100644 --- a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs +++ b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs @@ -34,13 +34,7 @@ public override Task RunAsync(ItemEventContext context, HealItemEvent request) return Task.CompletedTask; } - var medKit = item.GetOrCreateUpdatable(); - - medKit.HpResource -= request.Count; - if (medKit.HpResource <= 0) - { - profile.Pmc.Inventory.RemoveItem(item); - } + var medKit = item.GetOrCreateUpdatable(); var bodyPart = _healthService.GetBodyPart(profile.Pmc.Health, request.BodyPart); float toHeal = request.Count; @@ -52,18 +46,24 @@ public override Task RunAsync(ItemEventContext context, HealItemEvent request) if (itemCanRemove) { - foreach (var effectPair in itemProperties.DamageEffects.Value1) + foreach (var (effectName, effect) in itemProperties.DamageEffects.Value1) { - if (bodyPart.Effects.ContainsKey(effectPair.Key)) + if (bodyPart.Effects.ContainsKey(effectName)) { - toHeal -= effectPair.Value.Cost = 0; - bodyPart.Effects.Remove(effectPair.Key); + toHeal -= effect.Cost = 0; + bodyPart.Effects.Remove(effectName); } } } } bodyPart.Health.Current += toHeal; + medKit.HpResource -= request.Count; + + if (medKit.HpResource <= 0) + { + profile.Pmc.Inventory.RemoveItem(item); + } // TODO: // Check BackendConfig for 'HealExperience' and add to PMC profile From 6d066f21fc83fa844654372f6f3abc6f6e1e75d8 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 14:48:26 +0100 Subject: [PATCH 08/22] Remove incorrect assignment --- .../Controllers/ItemEvents/HealItemEventController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs index 979f5a2f..ee2c075c 100644 --- a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs +++ b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs @@ -50,7 +50,7 @@ public override Task RunAsync(ItemEventContext context, HealItemEvent request) { if (bodyPart.Effects.ContainsKey(effectName)) { - toHeal -= effect.Cost = 0; + toHeal -= effect.Cost; bodyPart.Effects.Remove(effectName); } } From bc7868b7dd1330124369a4c771ee77f1b79b4cc5 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:10:25 +0100 Subject: [PATCH 09/22] Add helper function to get ItemProperties --- Fuyu.Backend.BSG/Models/Profiles/InventoryInfo.cs | 10 +++++----- Fuyu.Backend.BSG/Services/ItemFactoryService.cs | 11 +++++++++++ .../Controllers/ItemEvents/HealItemEventController.cs | 5 ++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Fuyu.Backend.BSG/Models/Profiles/InventoryInfo.cs b/Fuyu.Backend.BSG/Models/Profiles/InventoryInfo.cs index 79a5ddbf..5cdaeb97 100644 --- a/Fuyu.Backend.BSG/Models/Profiles/InventoryInfo.cs +++ b/Fuyu.Backend.BSG/Models/Profiles/InventoryInfo.cs @@ -103,7 +103,7 @@ public ItemInstance GetStock(ItemInstance root) return null; } - var weaponItemProperties = rootItemTemplate.Props.ToObject(); + var weaponItemProperties = _itemFactoryService.GetItemProperties(root.TemplateId); var subItems = _itemService.GetItemAndChildren(Items, root).Skip(1); return subItems.FirstOrDefault(i => i.SlotId == weaponItemProperties.FoldedSlot); @@ -112,7 +112,7 @@ public ItemInstance GetStock(ItemInstance root) public Vector2 GetItemSize(ItemInstance root) { var rootTemplate = _itemFactoryService.ItemTemplates[root.TemplateId]; - var rootProperties = rootTemplate.Props.ToObject(); + var rootProperties = _itemFactoryService.GetItemProperties(root.TemplateId); var width = rootProperties.Width; var height = rootProperties.Height; @@ -129,7 +129,7 @@ public Vector2 GetItemSize(ItemInstance root) foreach (var child in children) { var itemTemplate = _itemFactoryService.ItemTemplates[child.TemplateId]; - var itemProperties = itemTemplate.Props.ToObject(); + var itemProperties = _itemFactoryService.GetItemProperties(root.TemplateId); if (itemProperties.ExtraSizeForceAdd) { forcedUp += itemProperties.ExtraSizeUp; @@ -180,7 +180,7 @@ public LocationInGrid GetNextFreeSlot(int width, int height, out string gridName } var stashItemTemplate = _itemFactoryService.ItemTemplates[stashItem.TemplateId]; - var stashItemProps = stashItemTemplate.Props.ToObject(); + var stashItemProps = _itemFactoryService.GetItemProperties(stashItem.TemplateId); foreach (var grid in stashItemProps.Grids) { @@ -198,7 +198,7 @@ public LocationInGrid GetNextFreeSlot(int width, int height, out string gridName } var itemTemplate = _itemFactoryService.ItemTemplates[itemInThisGrid.TemplateId]; - var itemProps = itemTemplate.Props.ToObject(); + var itemProps = _itemFactoryService.GetItemProperties(itemInThisGrid.TemplateId); var itemLocation = itemInThisGrid.Location.Value1; var itemSize = GetItemSize(itemInThisGrid); var itemWidth = itemSize.X; diff --git a/Fuyu.Backend.BSG/Services/ItemFactoryService.cs b/Fuyu.Backend.BSG/Services/ItemFactoryService.cs index 7a9e2adc..e3e2099f 100644 --- a/Fuyu.Backend.BSG/Services/ItemFactoryService.cs +++ b/Fuyu.Backend.BSG/Services/ItemFactoryService.cs @@ -32,6 +32,17 @@ public void Load() ItemTemplates = Json.Parse>>(itemsText).data; } + /// + /// Gets an from a TemplateId + /// + /// The class to return + /// + /// The class defined + public T GetItemProperties(MongoId templateId) where T : ItemProperties + { + return ItemTemplates[templateId].Props.ToObject(); + } + public ItemInstance CreateItem(MongoId tpl, MongoId? id = null) { var template = ItemTemplates[tpl]; diff --git a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs index ee2c075c..d42a94f9 100644 --- a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs +++ b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs @@ -41,10 +41,9 @@ public override Task RunAsync(ItemEventContext context, HealItemEvent request) if (profile.Pmc.Health.HasEffects) { - var itemProperties = _itemFactoryService.ItemTemplates[item.TemplateId].Props.ToObject(); - bool itemCanRemove = itemProperties.DamageEffects.IsValue1 && itemProperties.DamageEffects.Value1.Count > 0; + var itemProperties = _itemFactoryService.GetItemProperties(item.TemplateId); - if (itemCanRemove) + if (itemProperties.DamageEffects.IsValue1) { foreach (var (effectName, effect) in itemProperties.DamageEffects.Value1) { From 5cb579b165438be7049019166dd99a8d42e70823 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:14:45 +0100 Subject: [PATCH 10/22] Add missing param --- Fuyu.Backend.BSG/Services/ItemFactoryService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fuyu.Backend.BSG/Services/ItemFactoryService.cs b/Fuyu.Backend.BSG/Services/ItemFactoryService.cs index e3e2099f..fad3843c 100644 --- a/Fuyu.Backend.BSG/Services/ItemFactoryService.cs +++ b/Fuyu.Backend.BSG/Services/ItemFactoryService.cs @@ -36,7 +36,7 @@ public void Load() /// Gets an from a TemplateId /// /// The class to return - /// + /// The TemplateId to get the from /// The class defined public T GetItemProperties(MongoId templateId) where T : ItemProperties { From b28a088625135b10fd6ff9dd479d23b0bb59acc9 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 20:05:37 +0100 Subject: [PATCH 11/22] Remove comment --- .../Controllers/ItemEvents/HealItemEventController.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs index d42a94f9..6769e3d2 100644 --- a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs +++ b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs @@ -22,7 +22,6 @@ public HealItemEventController() : base("Heal") _itemFactoryService = ItemFactoryService.Instance; } - // This method only finds the item, as well as the index. Actually consuming/deleting the item needs to be done. public override Task RunAsync(ItemEventContext context, HealItemEvent request) { var profile = _eftOrm.GetActiveProfile(context.SessionId); From 09377f3bc203d71048cc6a93dd85185c6c5882b9 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 20:09:23 +0100 Subject: [PATCH 12/22] Update file --- .../ItemTemplates/MedsItemProperties.cs | 86 +++++++++---------- 1 file changed, 42 insertions(+), 44 deletions(-) diff --git a/Fuyu.Backend.BSG/ItemTemplates/MedsItemProperties.cs b/Fuyu.Backend.BSG/ItemTemplates/MedsItemProperties.cs index 15c06f99..95c4905d 100644 --- a/Fuyu.Backend.BSG/ItemTemplates/MedsItemProperties.cs +++ b/Fuyu.Backend.BSG/ItemTemplates/MedsItemProperties.cs @@ -1,64 +1,62 @@ using System.Collections.Generic; using System.Runtime.Serialization; using Fuyu.Common.Collections; -using Newtonsoft.Json; -namespace Fuyu.Backend.BSG.ItemTemplates +namespace Fuyu.Backend.BSG.ItemTemplates; + +[DataContract] +public class MedsItemProperties : ItemProperties { - [DataContract] - public class MedsItemProperties : ItemProperties - { - [DataMember(Name = "medUseTime")] - public float UseTime { get; set; } + [DataMember(Name = "medUseTime")] + public float UseTime { get; set; } - [DataMember(Name = "bodyPartTimeMults")] - public KeyValuePair[] BodyPartTimeMults { get; set; } + [DataMember(Name = "bodyPartTimeMults")] + public KeyValuePair[] BodyPartTimeMults { get; set; } - [DataMember(Name = "effects_health")] - public Union, object[]> HealthEffects { get; set; } + [DataMember(Name = "effects_health")] + public Union, object[]> HealthEffects { get; set; } - [DataMember(Name = "effects_damage")] - public Union, object[]> DamageEffects { get; set; } + [DataMember(Name = "effects_damage")] + public Union, object[]> DamageEffects { get; set; } - [DataMember(Name = "StimulatorBuffs")] - public string StimulatorBuffs { get; set; } + [DataMember(Name = "StimulatorBuffs")] + public string StimulatorBuffs { get; set; } - [DataMember(Name = "MaxHpResource")] - public int MaxHpResource { get; set; } + [DataMember(Name = "MaxHpResource")] + public int MaxHpResource { get; set; } - [DataMember(Name = "hpResourceRate")] - public float HpResourceRate { get; set; } - } + [DataMember(Name = "hpResourceRate")] + public float HpResourceRate { get; set; } +} - [DataContract] - public class HealthEffect - { - [DataMember(Name = "delay")] - public float Delay { get; set; } +[DataContract] +public class HealthEffect +{ + [DataMember(Name = "delay")] + public float Delay { get; set; } - [DataMember(Name = "duration")] - public float Duration { get; set; } - } + [DataMember(Name = "duration")] + public float Duration { get; set; } +} - [DataContract] - public class DamageEffect - { - [DataMember(Name = "delay")] - public float Delay { get; set; } +[DataContract] +public class DamageEffect +{ + [DataMember(Name = "delay")] + public float Delay { get; set; } - [DataMember(Name = "duration")] - public float Duration { get; set; } + [DataMember(Name = "duration")] + public float Duration { get; set; } - [DataMember(Name = "fadeOut")] - public float FadeOut { get; set; } + [DataMember(Name = "fadeOut")] + public float FadeOut { get; set; } - [DataMember(Name = "cost")] - public int Cost { get; set; } + [DataMember(Name = "cost")] + public int Cost { get; set; } - [DataMember(Name = "healthPenaltyMin")] - public int HealthPenaltyMin { get; set; } + [DataMember(Name = "healthPenaltyMin")] + public int HealthPenaltyMin { get; set; } - [DataMember(Name = "healthPenaltyMax")] - public int HealthPenaltyMax { get; set; } - } + [DataMember(Name = "healthPenaltyMax")] + public int HealthPenaltyMax { get; set; } } \ No newline at end of file From bac4e4b75c39246b408de6bbc20cad6a57233dfd Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 20:10:57 +0100 Subject: [PATCH 13/22] Update files --- .../Models/Profiles/Health/BodyPart.cs | 17 ++-- .../Models/Profiles/Health/BodyPartsInfo.cs | 47 +++++------ .../Models/Profiles/HealthInfo.cs | 79 +++++++++--------- .../ItemEvents/HealItemEventController.cs | 83 +++++++++---------- 4 files changed, 111 insertions(+), 115 deletions(-) diff --git a/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPart.cs b/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPart.cs index 76d99de9..793c7846 100644 --- a/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPart.cs +++ b/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPart.cs @@ -2,15 +2,14 @@ using System.Runtime.Serialization; using Fuyu.Backend.BSG.Models.Common; -namespace Fuyu.Backend.BSG.Models.Profiles.Health +namespace Fuyu.Backend.BSG.Models.Profiles.Health; + +[DataContract] +public class BodyPart { - [DataContract] - public class BodyPart - { - [DataMember] - public ClampedValue Health { get; set; } + [DataMember] + public ClampedValue Health { get; set; } - [DataMember] - public Dictionary Effects { get; set; } - } + [DataMember] + public Dictionary Effects { get; set; } } \ No newline at end of file diff --git a/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPartsInfo.cs b/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPartsInfo.cs index 19d58e20..ecab0a31 100644 --- a/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPartsInfo.cs +++ b/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPartsInfo.cs @@ -2,13 +2,13 @@ using System.Collections.Generic; using System.Runtime.Serialization; -namespace Fuyu.Backend.BSG.Models.Profiles.Health +namespace Fuyu.Backend.BSG.Models.Profiles.Health; + +[DataContract] +public class BodyPartInfo : IEnumerable { - [DataContract] - public class BodyPartInfo : IEnumerable - { - [DataMember] - public BodyPart Head { get; set; } + [DataMember] + public BodyPart Head { get; set; } [DataMember] public BodyPart Chest { get; set; } @@ -25,23 +25,22 @@ public class BodyPartInfo : IEnumerable [DataMember] public BodyPart LeftLeg { get; set; } - [DataMember] - public BodyPart RightLeg { get; set; } - - public IEnumerator GetEnumerator() - { - yield return Head; - yield return Chest; - yield return Stomach; - yield return LeftArm; - yield return RightArm; - yield return LeftLeg; - yield return RightLeg; - } - - IEnumerator IEnumerable.GetEnumerator() - { - throw new System.NotImplementedException(); - } + [DataMember] + public BodyPart RightLeg { get; set; } + + public IEnumerator GetEnumerator() + { + yield return Head; + yield return Chest; + yield return Stomach; + yield return LeftArm; + yield return RightArm; + yield return LeftLeg; + yield return RightLeg; + } + + IEnumerator IEnumerable.GetEnumerator() + { + throw new System.NotImplementedException(); } } \ No newline at end of file diff --git a/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs b/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs index b098940a..7c4dcd1f 100644 --- a/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs +++ b/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs @@ -5,58 +5,57 @@ using Fuyu.Backend.BSG.Models.Common; using Fuyu.Backend.BSG.Models.Profiles.Health; -namespace Fuyu.Backend.BSG.Models.Profiles +namespace Fuyu.Backend.BSG.Models.Profiles; + +[DataContract] +public class HealthInfo { - [DataContract] - public class HealthInfo - { - [DataMember] - public ClampedValue Hydration { get; set; } + [DataMember] + public ClampedValue Hydration { get; set; } - [DataMember] - public ClampedValue Energy { get; set; } + [DataMember] + public ClampedValue Energy { get; set; } - [DataMember] - public ClampedValue Temperature { get; set; } + [DataMember] + public ClampedValue Temperature { get; set; } - [DataMember] - public ClampedValue Poison { get; set; } + [DataMember] + public ClampedValue Poison { get; set; } - [DataMember] - public BodyPartInfo BodyParts { get; set; } + [DataMember] + public BodyPartInfo BodyParts { get; set; } [DataMember] public int? UpdateTime { get; set; } - public BodyPart GetBodyPart(EBodyPart bodyPart) + public BodyPart GetBodyPart(EBodyPart bodyPart) + { + return bodyPart switch { - return bodyPart switch - { - EBodyPart.Head => BodyParts.Head, - EBodyPart.Chest => BodyParts.Chest, - EBodyPart.Stomach => BodyParts.Stomach, - EBodyPart.LeftArm => BodyParts.LeftArm, - EBodyPart.RightArm => BodyParts.RightArm, - EBodyPart.LeftLeg => BodyParts.LeftLeg, - EBodyPart.RightLeg => BodyParts.RightLeg, - EBodyPart.Common => throw new NotImplementedException("Cannot use Common?"), - _ => null, - }; - } + EBodyPart.Head => BodyParts.Head, + EBodyPart.Chest => BodyParts.Chest, + EBodyPart.Stomach => BodyParts.Stomach, + EBodyPart.LeftArm => BodyParts.LeftArm, + EBodyPart.RightArm => BodyParts.RightArm, + EBodyPart.LeftLeg => BodyParts.LeftLeg, + EBodyPart.RightLeg => BodyParts.RightLeg, + EBodyPart.Common => throw new NotImplementedException("Cannot use Common?"), + _ => null, + }; + } - /// - /// Returns whether any bodyparts contain a - /// - [IgnoreDataMember] - public bool HasEffects + /// + /// Returns whether any bodyparts contain a + /// + [IgnoreDataMember] + public bool HasEffects + { + get { - get - { - return BodyParts.Any(x => x.Effects.Count > 0); - } + return BodyParts.Any(x => x.Effects.Count > 0); } - - // SKIPPED: Immortal - // Reason: only used on BSG's internal server } + + // SKIPPED: Immortal + // Reason: only used on BSG's internal server } \ No newline at end of file diff --git a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs index 6769e3d2..e67386cb 100644 --- a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs +++ b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs @@ -7,66 +7,65 @@ using Fuyu.Backend.EFT.Services; using Fuyu.Common.IO; -namespace Fuyu.Backend.EFT.Controllers.ItemEvents +namespace Fuyu.Backend.EFT.Controllers.ItemEvents; + +public class HealItemEventController : AbstractItemEventController { - public class HealItemEventController : AbstractItemEventController + private readonly EftOrm _eftOrm; + private readonly HealthService _healthService; + private readonly ItemFactoryService _itemFactoryService; + + public HealItemEventController() : base("Heal") { - private readonly EftOrm _eftOrm; - private readonly HealthService _healthService; - private readonly ItemFactoryService _itemFactoryService; + _eftOrm = EftOrm.Instance; + _healthService = HealthService.Instance; + _itemFactoryService = ItemFactoryService.Instance; + } - public HealItemEventController() : base("Heal") - { - _eftOrm = EftOrm.Instance; - _healthService = HealthService.Instance; - _itemFactoryService = ItemFactoryService.Instance; - } + public override Task RunAsync(ItemEventContext context, HealItemEvent request) + { + var profile = _eftOrm.GetActiveProfile(context.SessionId); + var item = profile.Pmc.Inventory.FindItem(request.Item); - public override Task RunAsync(ItemEventContext context, HealItemEvent request) + if (item == null) { - var profile = _eftOrm.GetActiveProfile(context.SessionId); - var item = profile.Pmc.Inventory.FindItem(request.Item); + Terminal.WriteLine($"Failed to find item {request.Item}"); + return Task.CompletedTask; + } - if (item == null) - { - Terminal.WriteLine($"Failed to find item {request.Item}"); - return Task.CompletedTask; - } + var medKit = item.GetOrCreateUpdatable(); - var medKit = item.GetOrCreateUpdatable(); + var bodyPart = _healthService.GetBodyPart(profile.Pmc.Health, request.BodyPart); + float toHeal = request.Count; - var bodyPart = _healthService.GetBodyPart(profile.Pmc.Health, request.BodyPart); - float toHeal = request.Count; + if (profile.Pmc.Health.HasEffects) + { + var itemProperties = _itemFactoryService.GetItemProperties(item.TemplateId); - if (profile.Pmc.Health.HasEffects) + if (itemProperties.DamageEffects.IsValue1) { - var itemProperties = _itemFactoryService.GetItemProperties(item.TemplateId); - - if (itemProperties.DamageEffects.IsValue1) + foreach (var (effectName, effect) in itemProperties.DamageEffects.Value1) { - foreach (var (effectName, effect) in itemProperties.DamageEffects.Value1) + if (bodyPart.Effects.ContainsKey(effectName)) { - if (bodyPart.Effects.ContainsKey(effectName)) - { - toHeal -= effect.Cost; - bodyPart.Effects.Remove(effectName); - } + toHeal -= effect.Cost; + bodyPart.Effects.Remove(effectName); } } } + } - bodyPart.Health.Current += toHeal; - medKit.HpResource -= request.Count; + bodyPart.Health.Current += toHeal; + medKit.HpResource -= request.Count; - if (medKit.HpResource <= 0) - { - profile.Pmc.Inventory.RemoveItem(item); - } + if (medKit.HpResource <= 0) + { + profile.Pmc.Inventory.RemoveItem(item); + } - // TODO: - // Check BackendConfig for 'HealExperience' and add to PMC profile + // TODO: + // Check BackendConfig for 'HealExperience' and add to PMC profile - return Task.CompletedTask; - } + return Task.CompletedTask; } } From c3c3b5ac7179bc7b33a006aa328d606acd53e383 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 20:11:18 +0100 Subject: [PATCH 14/22] Update docs --- Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs b/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs index 7c4dcd1f..03ebd732 100644 --- a/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs +++ b/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs @@ -45,7 +45,7 @@ public BodyPart GetBodyPart(EBodyPart bodyPart) } /// - /// Returns whether any bodyparts contain a + /// Returns whether any contain a /// [IgnoreDataMember] public bool HasEffects From 4422b960a157c1ddb28f714ff3a94b7d4c79c46a Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 20:13:40 +0100 Subject: [PATCH 15/22] Update namespace --- .../Models/ItemEvents/HealItemEvent.cs | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Fuyu.Backend.BSG/Models/ItemEvents/HealItemEvent.cs b/Fuyu.Backend.BSG/Models/ItemEvents/HealItemEvent.cs index d85cb4ae..e04138b4 100644 --- a/Fuyu.Backend.BSG/Models/ItemEvents/HealItemEvent.cs +++ b/Fuyu.Backend.BSG/Models/ItemEvents/HealItemEvent.cs @@ -2,21 +2,20 @@ using Fuyu.Backend.BSG.ItemTemplates; using Fuyu.Common.Hashing; -namespace Fuyu.Backend.BSG.Models.ItemEvents +namespace Fuyu.Backend.BSG.Models.ItemEvents; + +[DataContract] +public class HealItemEvent : BaseItemEvent { - [DataContract] - public class HealItemEvent : BaseItemEvent - { - [DataMember(Name = "item")] - public MongoId Item { get; set; } + [DataMember(Name = "item")] + public MongoId Item { get; set; } - [DataMember(Name = "part")] - public EBodyPart BodyPart { get; set; } + [DataMember(Name = "part")] + public EBodyPart BodyPart { get; set; } - [DataMember(Name = "count")] - public int Count { get; set; } + [DataMember(Name = "count")] + public int Count { get; set; } - [DataMember(Name = "time")] - public int Time { get; set; } - } + [DataMember(Name = "time")] + public int Time { get; set; } } From f5db8f8159582de9615aab06a40c05b2a99f328e Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 20:14:08 +0100 Subject: [PATCH 16/22] Cleanup file --- .../Models/Profiles/InventoryInfo.cs | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/Fuyu.Backend.BSG/Models/Profiles/InventoryInfo.cs b/Fuyu.Backend.BSG/Models/Profiles/InventoryInfo.cs index 6b8ca9ed..e6821913 100644 --- a/Fuyu.Backend.BSG/Models/Profiles/InventoryInfo.cs +++ b/Fuyu.Backend.BSG/Models/Profiles/InventoryInfo.cs @@ -103,18 +103,18 @@ public ItemInstance GetStock(ItemInstance root) return null; } - var weaponItemProperties = _itemFactoryService.GetItemProperties(root.TemplateId); - var subItems = _itemService.GetItemAndChildren(Items, root).Skip(1); + var weaponItemProperties = _itemFactoryService.GetItemProperties(root.TemplateId); + var subItems = _itemService.GetItemAndChildren(Items, root).Skip(1); return subItems.FirstOrDefault(i => i.SlotId == weaponItemProperties.FoldedSlot); } - public Vector2 GetItemSize(ItemInstance root) - { - var rootTemplate = _itemFactoryService.ItemTemplates[root.TemplateId]; - var rootProperties = _itemFactoryService.GetItemProperties(root.TemplateId); - var width = rootProperties.Width; - var height = rootProperties.Height; + public Vector2 GetItemSize(ItemInstance root) + { + var rootTemplate = _itemFactoryService.ItemTemplates[root.TemplateId]; + var rootProperties = _itemFactoryService.GetItemProperties(root.TemplateId); + var width = rootProperties.Width; + var height = rootProperties.Height; var sizeUp = 0; var sizeDown = 0; @@ -125,26 +125,26 @@ public Vector2 GetItemSize(ItemInstance root) var forcedLeft = 0; var forcedRight = 0; - var children = _itemService.GetItemAndChildren(Items, root).Skip(1); - foreach (var child in children) + var children = _itemService.GetItemAndChildren(Items, root).Skip(1); + foreach (var child in children) + { + var itemTemplate = _itemFactoryService.ItemTemplates[child.TemplateId]; + var itemProperties = _itemFactoryService.GetItemProperties(root.TemplateId); + if (itemProperties.ExtraSizeForceAdd) { - var itemTemplate = _itemFactoryService.ItemTemplates[child.TemplateId]; - var itemProperties = _itemFactoryService.GetItemProperties(root.TemplateId); - if (itemProperties.ExtraSizeForceAdd) - { - forcedUp += itemProperties.ExtraSizeUp; - forcedDown += itemProperties.ExtraSizeDown; - forcedLeft += itemProperties.ExtraSizeLeft; - forcedRight += itemProperties.ExtraSizeRight; - } - else - { - sizeUp = Math.Max(sizeUp, itemProperties.ExtraSizeUp); - sizeDown = Math.Max(sizeDown, itemProperties.ExtraSizeDown); - sizeLeft = Math.Max(sizeLeft, itemProperties.ExtraSizeLeft); - sizeRight = Math.Max(sizeRight, itemProperties.ExtraSizeRight); - } + forcedUp += itemProperties.ExtraSizeUp; + forcedDown += itemProperties.ExtraSizeDown; + forcedLeft += itemProperties.ExtraSizeLeft; + forcedRight += itemProperties.ExtraSizeRight; } + else + { + sizeUp = Math.Max(sizeUp, itemProperties.ExtraSizeUp); + sizeDown = Math.Max(sizeDown, itemProperties.ExtraSizeDown); + sizeLeft = Math.Max(sizeLeft, itemProperties.ExtraSizeLeft); + sizeRight = Math.Max(sizeRight, itemProperties.ExtraSizeRight); + } + } width += sizeLeft + sizeRight + forcedLeft + forcedRight; height += sizeUp + sizeDown + forcedUp + forcedDown; @@ -179,8 +179,8 @@ public LocationInGrid GetNextFreeSlot(int width, int height, out string gridName return null; } - var stashItemTemplate = _itemFactoryService.ItemTemplates[stashItem.TemplateId]; - var stashItemProps = _itemFactoryService.GetItemProperties(stashItem.TemplateId); + var stashItemTemplate = _itemFactoryService.ItemTemplates[stashItem.TemplateId]; + var stashItemProps = _itemFactoryService.GetItemProperties(stashItem.TemplateId); foreach (var grid in stashItemProps.Grids) { @@ -197,12 +197,12 @@ public LocationInGrid GetNextFreeSlot(int width, int height, out string gridName continue; } - var itemTemplate = _itemFactoryService.ItemTemplates[itemInThisGrid.TemplateId]; - var itemProps = _itemFactoryService.GetItemProperties(itemInThisGrid.TemplateId); - var itemLocation = itemInThisGrid.Location.Value1; - var itemSize = GetItemSize(itemInThisGrid); - var itemWidth = itemSize.X; - var itemHeight = itemSize.Y; + var itemTemplate = _itemFactoryService.ItemTemplates[itemInThisGrid.TemplateId]; + var itemProps = _itemFactoryService.GetItemProperties(itemInThisGrid.TemplateId); + var itemLocation = itemInThisGrid.Location.Value1; + var itemSize = GetItemSize(itemInThisGrid); + var itemWidth = itemSize.X; + var itemHeight = itemSize.Y; for (var y = 0; y < itemHeight; y++) { From 6d3fe410f93f9cb5e6ea8c621457f251ee777a81 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 20:16:34 +0100 Subject: [PATCH 17/22] Remove redundant function --- .../Controllers/ItemEvents/HealItemEventController.cs | 2 +- Fuyu.Backend.EFT/Services/HealthService.cs | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs index e67386cb..45581f09 100644 --- a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs +++ b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs @@ -35,7 +35,7 @@ public override Task RunAsync(ItemEventContext context, HealItemEvent request) var medKit = item.GetOrCreateUpdatable(); - var bodyPart = _healthService.GetBodyPart(profile.Pmc.Health, request.BodyPart); + var bodyPart = profile.Pmc.Health.GetBodyPart(request.BodyPart); float toHeal = request.Count; if (profile.Pmc.Health.HasEffects) diff --git a/Fuyu.Backend.EFT/Services/HealthService.cs b/Fuyu.Backend.EFT/Services/HealthService.cs index 829bc34d..05534eff 100644 --- a/Fuyu.Backend.EFT/Services/HealthService.cs +++ b/Fuyu.Backend.EFT/Services/HealthService.cs @@ -13,9 +13,4 @@ private HealthService() { } - - public BodyPart GetBodyPart(HealthInfo health, EBodyPart bodyPart) - { - return health.GetBodyPart(bodyPart); - } } From 23536dfba519281c201759480feee9097a4a5889 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 20:20:10 +0100 Subject: [PATCH 18/22] Remove unused field --- .../Controllers/ItemEvents/HealItemEventController.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs index 45581f09..78ef43d7 100644 --- a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs +++ b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs @@ -12,13 +12,11 @@ namespace Fuyu.Backend.EFT.Controllers.ItemEvents; public class HealItemEventController : AbstractItemEventController { private readonly EftOrm _eftOrm; - private readonly HealthService _healthService; private readonly ItemFactoryService _itemFactoryService; public HealItemEventController() : base("Heal") { _eftOrm = EftOrm.Instance; - _healthService = HealthService.Instance; _itemFactoryService = ItemFactoryService.Instance; } From 61b483e6b79fc277791c51eac315079f68c42f90 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 20:22:50 +0100 Subject: [PATCH 19/22] Update namespace / move classes --- .../Models/Common/ClampedValue.cs | 40 ------------------- .../Models/Profiles/Health/BodyPart.cs | 2 +- .../Profiles/Health/ClampedHealthStat.cs | 39 ++++++++++++++++++ .../Models/Profiles/HealthInfo.cs | 9 ++--- .../ItemEvents/HealItemEventController.cs | 3 +- 5 files changed, 45 insertions(+), 48 deletions(-) delete mode 100644 Fuyu.Backend.BSG/Models/Common/ClampedValue.cs create mode 100644 Fuyu.Backend.BSG/Models/Profiles/Health/ClampedHealthStat.cs diff --git a/Fuyu.Backend.BSG/Models/Common/ClampedValue.cs b/Fuyu.Backend.BSG/Models/Common/ClampedValue.cs deleted file mode 100644 index 1f97e293..00000000 --- a/Fuyu.Backend.BSG/Models/Common/ClampedValue.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Numerics; -using System.Runtime.Serialization; - -namespace Fuyu.Backend.BSG.Models.Common -{ - /// - /// Class used to automatically clamp and values - /// - /// - [DataContract] - public class ClampedValue where T : INumber - { - [DataMember] - public T Current - { - get - { - return _current; - } - set - { - _current = T.Clamp(value, Minimum, Maximum); - } - } - - private T _current; - - [DataMember] - public T Minimum { get; set; } - - [DataMember] - public T Maximum { get; set; } - - [DataMember] - public T OverDamageReceivedMultiplier { get; set; } - - [DataMember] - public T EnvironmentDamageMultiplier { get; set; } - } -} \ No newline at end of file diff --git a/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPart.cs b/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPart.cs index 793c7846..ada9b6e8 100644 --- a/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPart.cs +++ b/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPart.cs @@ -8,7 +8,7 @@ namespace Fuyu.Backend.BSG.Models.Profiles.Health; public class BodyPart { [DataMember] - public ClampedValue Health { get; set; } + public ClampedHealthStat Health { get; set; } [DataMember] public Dictionary Effects { get; set; } diff --git a/Fuyu.Backend.BSG/Models/Profiles/Health/ClampedHealthStat.cs b/Fuyu.Backend.BSG/Models/Profiles/Health/ClampedHealthStat.cs new file mode 100644 index 00000000..cedc785d --- /dev/null +++ b/Fuyu.Backend.BSG/Models/Profiles/Health/ClampedHealthStat.cs @@ -0,0 +1,39 @@ +using System.Numerics; +using System.Runtime.Serialization; + +namespace Fuyu.Backend.BSG.Models.Profiles.Health; + +/// +/// Class used to automatically clamp and values +/// +/// +[DataContract] +public class ClampedHealthStat where T : INumber +{ + [DataMember] + public T Current + { + get + { + return _current; + } + set + { + _current = T.Clamp(value, Minimum, Maximum); + } + } + + private T _current; + + [DataMember] + public T Minimum { get; set; } + + [DataMember] + public T Maximum { get; set; } + + [DataMember] + public T OverDamageReceivedMultiplier { get; set; } + + [DataMember] + public T EnvironmentDamageMultiplier { get; set; } +} \ No newline at end of file diff --git a/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs b/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs index 03ebd732..17e229d6 100644 --- a/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs +++ b/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs @@ -2,7 +2,6 @@ using System.Linq; using System.Runtime.Serialization; using Fuyu.Backend.BSG.ItemTemplates; -using Fuyu.Backend.BSG.Models.Common; using Fuyu.Backend.BSG.Models.Profiles.Health; namespace Fuyu.Backend.BSG.Models.Profiles; @@ -11,16 +10,16 @@ namespace Fuyu.Backend.BSG.Models.Profiles; public class HealthInfo { [DataMember] - public ClampedValue Hydration { get; set; } + public ClampedHealthStat Hydration { get; set; } [DataMember] - public ClampedValue Energy { get; set; } + public ClampedHealthStat Energy { get; set; } [DataMember] - public ClampedValue Temperature { get; set; } + public ClampedHealthStat Temperature { get; set; } [DataMember] - public ClampedValue Poison { get; set; } + public ClampedHealthStat Poison { get; set; } [DataMember] public BodyPartInfo BodyParts { get; set; } diff --git a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs index 78ef43d7..50455337 100644 --- a/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs +++ b/Fuyu.Backend.EFT/Controllers/ItemEvents/HealItemEventController.cs @@ -4,7 +4,6 @@ using Fuyu.Backend.BSG.Models.Items; using Fuyu.Backend.BSG.Networking; using Fuyu.Backend.BSG.Services; -using Fuyu.Backend.EFT.Services; using Fuyu.Common.IO; namespace Fuyu.Backend.EFT.Controllers.ItemEvents; @@ -31,7 +30,7 @@ public override Task RunAsync(ItemEventContext context, HealItemEvent request) return Task.CompletedTask; } - var medKit = item.GetOrCreateUpdatable(); + var medKit = item.GetOrCreateUpdatable(); var bodyPart = profile.Pmc.Health.GetBodyPart(request.BodyPart); float toHeal = request.Count; From b414a74506c3ee6c4a2fb5f2212f74adc55a2b6a Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 20:23:48 +0100 Subject: [PATCH 20/22] Update exception message --- Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs b/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs index 17e229d6..c6f59929 100644 --- a/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs +++ b/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs @@ -38,7 +38,7 @@ public BodyPart GetBodyPart(EBodyPart bodyPart) EBodyPart.RightArm => BodyParts.RightArm, EBodyPart.LeftLeg => BodyParts.LeftLeg, EBodyPart.RightLeg => BodyParts.RightLeg, - EBodyPart.Common => throw new NotImplementedException("Cannot use Common?"), + EBodyPart.Common => throw new NotImplementedException("Only used in client"), _ => null, }; } From dcbeaef1ae83e5a18af5da2bc359bd0dc06723c1 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 20:27:23 +0100 Subject: [PATCH 21/22] Update format --- .../Services/ItemFactoryService.cs | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Fuyu.Backend.BSG/Services/ItemFactoryService.cs b/Fuyu.Backend.BSG/Services/ItemFactoryService.cs index 9216d3ff..edab3d3c 100644 --- a/Fuyu.Backend.BSG/Services/ItemFactoryService.cs +++ b/Fuyu.Backend.BSG/Services/ItemFactoryService.cs @@ -32,22 +32,22 @@ public void Load() ItemTemplates = Json.Parse>>(itemsText).data; } - /// - /// Gets an from a TemplateId - /// - /// The class to return - /// The TemplateId to get the from - /// The class defined - public T GetItemProperties(MongoId templateId) where T : ItemProperties - { - return ItemTemplates[templateId].Props.ToObject(); - } + /// + /// Gets an from a TemplateId + /// + /// The class to return + /// The TemplateId to get the from + /// The class defined + public T GetItemProperties(MongoId templateId) where T : ItemProperties + { + return ItemTemplates[templateId].Props.ToObject(); + } - public ItemInstance CreateItem(MongoId tpl, MongoId? id = null) - { - var template = ItemTemplates[tpl]; - var itemId = id.GetValueOrDefault(new MongoId(true)); - ItemUpdatable upd = CreateItemUpdatable(template); + public ItemInstance CreateItem(MongoId tpl, MongoId? id = null) + { + var template = ItemTemplates[tpl]; + var itemId = id.GetValueOrDefault(new MongoId(true)); + ItemUpdatable upd = CreateItemUpdatable(template); var item = new ItemInstance { From 47e46870550c23cac15507c6e5e04504b82aa7c1 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 20:45:29 +0100 Subject: [PATCH 22/22] Update BodyPartInfo --- .../Models/Profiles/Health/BodyPart.cs | 3 +- .../Models/Profiles/Health/BodyPartsInfo.cs | 28 +++++++++---------- .../Models/Profiles/HealthInfo.cs | 2 +- Fuyu.Backend.EFT/Services/HealthService.cs | 16 ----------- 4 files changed, 16 insertions(+), 33 deletions(-) delete mode 100644 Fuyu.Backend.EFT/Services/HealthService.cs diff --git a/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPart.cs b/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPart.cs index ada9b6e8..cd04ebe9 100644 --- a/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPart.cs +++ b/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPart.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Runtime.Serialization; -using Fuyu.Backend.BSG.Models.Common; namespace Fuyu.Backend.BSG.Models.Profiles.Health; @@ -10,6 +9,6 @@ public class BodyPart [DataMember] public ClampedHealthStat Health { get; set; } - [DataMember] + [DataMember(EmitDefaultValue = false)] public Dictionary Effects { get; set; } } \ No newline at end of file diff --git a/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPartsInfo.cs b/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPartsInfo.cs index ecab0a31..10e3fb1a 100644 --- a/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPartsInfo.cs +++ b/Fuyu.Backend.BSG/Models/Profiles/Health/BodyPartsInfo.cs @@ -5,7 +5,7 @@ namespace Fuyu.Backend.BSG.Models.Profiles.Health; [DataContract] -public class BodyPartInfo : IEnumerable +public class BodyPartInfo { [DataMember] public BodyPart Head { get; set; } @@ -28,19 +28,19 @@ public class BodyPartInfo : IEnumerable [DataMember] public BodyPart RightLeg { get; set; } - public IEnumerator GetEnumerator() + // TODO: Refactor class to support IEnumerator? + [IgnoreDataMember] + public IEnumerable AllBodyParts { - yield return Head; - yield return Chest; - yield return Stomach; - yield return LeftArm; - yield return RightArm; - yield return LeftLeg; - yield return RightLeg; - } - - IEnumerator IEnumerable.GetEnumerator() - { - throw new System.NotImplementedException(); + get + { + yield return Head; + yield return Chest; + yield return Stomach; + yield return LeftArm; + yield return RightArm; + yield return LeftLeg; + yield return RightLeg; + } } } \ No newline at end of file diff --git a/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs b/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs index c6f59929..d9bb07d6 100644 --- a/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs +++ b/Fuyu.Backend.BSG/Models/Profiles/HealthInfo.cs @@ -51,7 +51,7 @@ public bool HasEffects { get { - return BodyParts.Any(x => x.Effects.Count > 0); + return BodyParts.AllBodyParts.Any(x => x.Effects.Count > 0); } } diff --git a/Fuyu.Backend.EFT/Services/HealthService.cs b/Fuyu.Backend.EFT/Services/HealthService.cs deleted file mode 100644 index 05534eff..00000000 --- a/Fuyu.Backend.EFT/Services/HealthService.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using Fuyu.Backend.BSG.ItemTemplates; -using Fuyu.Backend.BSG.Models.Profiles; -using Fuyu.Backend.BSG.Models.Profiles.Health; - -namespace Fuyu.Backend.EFT.Services; -public class HealthService -{ - public static HealthService Instance => instance.Value; - private static readonly Lazy instance = new(() => new HealthService()); - - private HealthService() - { - - } -}