001package com.fs.starfarer.api.combat;
002
003import java.util.Iterator;
004
005import org.lwjgl.util.vector.Vector2f;
006
007/**
008 * Bin-lattice with combat entities - ships, missiles, asteroids, projectiles, beams, etc -
009 * sorted into buckets based on their location. May only have a subset of these objects in it,
010 * depending on this grid's role.
011 * 
012 * Used to fulfill "all objects in area" queries without having to iterate through every object.
013 * 
014 * Occasionally just getting a list of the entities - i.e. via CombatEngineAPI.getShips() may be a bit faster than using the grid.
015 * In particular, this will more often be the case when using the grid for a large area. For something very performance
016 * intensive, it makes sense to try each way to see which is faster in a given situation.
017 * 
018 * @author Alex Mosolov
019 *
020 * Copyright 2018 Fractal Softworks, LLC
021 */
022public interface CollisionGridAPI {
023
024        /**
025         * Adds the object to every bucket that the area overlaps.
026         * @param object
027         * @param loc
028         * @param objWidth
029         * @param objHeight
030         */
031        void addObject(Object object, Vector2f loc, float objWidth, float objHeight);
032        
033        /**
034         * Removes the object from every bucket that the area overlaps.
035         * @param object
036         * @param loc
037         * @param objWidth
038         * @param objHeight
039         */
040        void removeObject(Object object, Vector2f loc, float objWidth, float objHeight);
041        
042        /**
043         * Returns an iterator for all the objects in this grid that are in the specified area.
044         * @param loc
045         * @param checkWidth
046         * @param checkHeight
047         * @return
048         */
049        Iterator<Object> getCheckIterator(Vector2f loc, float checkWidth, float checkHeight);
050
051}
052
053
054
055