diff --git a/ModPatches/Miho Race/Patches/Miho Race/ThingDefs_Races/AlienRace_Miho.xml b/ModPatches/Miho Race/Patches/Miho Race/ThingDefs_Races/AlienRace_Miho.xml index 7285d4bebb..86f263df73 100644 --- a/ModPatches/Miho Race/Patches/Miho Race/ThingDefs_Races/AlienRace_Miho.xml +++ b/ModPatches/Miho Race/Patches/Miho Race/ThingDefs_Races/AlienRace_Miho.xml @@ -5,9 +5,6 @@ Defs/AlienRace.ThingDef_AlienRace[defName="Alien_Miho"]/comps -
  • - CombatExtended.CompPawnGizmo -
  • 500 @@ -22,9 +19,6 @@ Defs/AlienRace.ThingDef_AlienRace[defName="Alien_Miho"] -
  • - CombatExtended.CompPawnGizmo -
  • 500 diff --git a/Source/CombatExtended/CombatExtended/Comps_CCL/CompPawnGizmo.cs b/Source/CombatExtended/CombatExtended/Comps_CCL/CompPawnGizmo.cs index e788dedcb8..33f222d45b 100644 --- a/Source/CombatExtended/CombatExtended/Comps_CCL/CompPawnGizmo.cs +++ b/Source/CombatExtended/CombatExtended/Comps_CCL/CompPawnGizmo.cs @@ -5,35 +5,52 @@ namespace CombatExtended { public class CompPawnGizmo : ThingComp { - public override IEnumerable CompGetGizmosExtra() + bool duplicate = false; + + public override void Initialize(CompProperties props) { - var pawn = parent as Pawn; - var equip = pawn != null - ? pawn.equipment.Primary - : null; + base.Initialize(props); + foreach (var comp in parent.comps) + { + if (comp is CompPawnGizmo && comp != this) + { + duplicate = true; + Log.ErrorOnce($"{parent.def.defName} has multiple CompPawnGizmo, duplicates has been deactivated. Please report this to the patch provider of {parent.def.modContentPack.Name} or CE team if the patch is integrated in CE.", parent.def.GetHashCode()); + } + } + } - if ( - (equip != null) && - (!equip.AllComps.NullOrEmpty()) - ) + + public override IEnumerable CompGetGizmosExtra() + { + if (!duplicate) { - foreach (var comp in equip.AllComps) + var pawn = parent as Pawn; + var equip = pawn != null + ? pawn.equipment.Primary + : null; + + if ( + (equip != null) && + (!equip.AllComps.NullOrEmpty()) + ) { - var gizmoGiver = comp as CompRangedGizmoGiver; - if ( - (gizmoGiver != null) && - (gizmoGiver.isRangedGiver) - ) + foreach (var comp in equip.AllComps) { - foreach (var gizmo in gizmoGiver.CompGetGizmosExtra()) + var gizmoGiver = comp as CompRangedGizmoGiver; + if ( + (gizmoGiver != null) && + (gizmoGiver.isRangedGiver) + ) { - yield return gizmo; + foreach (var gizmo in gizmoGiver.CompGetGizmosExtra()) + { + yield return gizmo; + } } } } - } + }; } - } - }