public void RemoveTargetingProgram(IGeoTargeting targetingSystem)
 {
     if (targetingSystem != null)
     {
         targetingPrograms.Remove(targetingSystem);
     }
 }
        /// <summary>
        /// In case the user plays around with the settings on the inspector and changes thins this needs to be run.
        /// It checks that the targeting system implementations are correct.
        /// </summary>
        /// <param name="targetingInstructionsIn"></param>
        /// <param name="gameObjectProcessing"></param>
        /// <param name="entityBasedProcessing"></param>
        /// <param name="entityWorld"></param>
        public static List <TargetingInstruction> ValidateTargetingSystems(
            List <TargetingInstruction> targetingInstructionsIn, bool gameObjectProcessing, bool entityBasedProcessing,
            World entityWorld)
        {
            ValidatePresentTargetingInstructions();

            void ValidatePresentTargetingInstructions()
            {
                foreach (var targetingInstruction in targetingInstructionsIn)
                {
                    if (gameObjectProcessing == true)
                    {
                        targetingInstruction.TargetingSystemGameObjects =
                            AssignNewTargetingSystemToTargetingInstruction(targetingInstruction,
                                                                           new GeometryObjectTargeting(), new GeometryLineTargeting());
                    }

                    if (entityBasedProcessing == true && Application.isPlaying)
                    {
                        if (entityWorld == null)
                        {
                            entityWorld = World.DefaultGameObjectInjectionWorld;
                        }

                        var newObjectTargeting = entityWorld.CreateSystem <GeometryEntitiesObjectTargeting>();
                        var newLineTargeting   = entityWorld.CreateSystem <GeometryEntitiesLineTargeting>();

                        targetingInstruction.TargetingSystemEntities =
                            AssignNewTargetingSystemToTargetingInstruction(targetingInstruction, newObjectTargeting,
                                                                           newLineTargeting);
                    }
                }
            }

            return(targetingInstructionsIn);

            // Local functions

            IGeoTargeting AssignNewTargetingSystemToTargetingInstruction(TargetingInstruction targetingInstruction,
                                                                         IGeoTargeting newObjectTargeting,
                                                                         IGeoTargeting newLineTargeting)
            {
                IGeoTargeting targetingToReturn = null;

                if (targetingInstruction.GeometryType == GeometryType.Objects)
                {
                    targetingToReturn = newObjectTargeting;
                }

                if (targetingInstruction.GeometryType == GeometryType.Lines)
                {
                    targetingToReturn = newLineTargeting;
                }

                return(targetingToReturn);
            }
        }
 public void AddTargetingProgram(IGeoTargeting targetingSystem)
 {
     targetingPrograms.Add(targetingSystem);
 }