LCOV - code coverage report
Current view: top level - source/simulation2/components - ICmpFootprint.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 1 2 50.0 %
Date: 2022-06-14 00:41:00 Functions: 0 0 -

          Line data    Source code
       1             : /* Copyright (C) 2017 Wildfire Games.
       2             :  * This file is part of 0 A.D.
       3             :  *
       4             :  * 0 A.D. is free software: you can redistribute it and/or modify
       5             :  * it under the terms of the GNU General Public License as published by
       6             :  * the Free Software Foundation, either version 2 of the License, or
       7             :  * (at your option) any later version.
       8             :  *
       9             :  * 0 A.D. is distributed in the hope that it will be useful,
      10             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  * GNU General Public License for more details.
      13             :  *
      14             :  * You should have received a copy of the GNU General Public License
      15             :  * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
      16             :  */
      17             : 
      18             : #ifndef INCLUDED_ICMPFOOTPRINT
      19             : #define INCLUDED_ICMPFOOTPRINT
      20             : 
      21             : #include "simulation2/system/Interface.h"
      22             : 
      23             : #include "simulation2/helpers/Position.h"
      24             : 
      25             : class CFixedVector3D;
      26             : 
      27             : /**
      28             :  * Footprints - an approximation of the entity's shape, used for collision detection and for
      29             :  * rendering selection outlines.
      30             :  * A footprint is either a circle (of some radius) or square (of some width and depth (actually
      31             :  * it's a rectangle)), horizontally aligned, extruded to a given height.
      32             :  */
      33           0 : class ICmpFootprint : public IComponent
      34             : {
      35             : public:
      36             :     enum EShape
      37             :     {
      38             :         CIRCLE,
      39             :         SQUARE
      40             :     };
      41             : 
      42             :     /**
      43             :      * Return the shape of this footprint.
      44             :      * Shapes are horizontal circles or squares, extended vertically upwards to make cylinders or boxes.
      45             :      * @param[out] shape either CIRCLE or SQUARE
      46             :      * @param[out] size0 if CIRCLE then radius, else width (size in X axis)
      47             :      * @param[out] size1 if CIRCLE then radius, else depth (size in Z axis)
      48             :      * @param[out] height size in Y axis
      49             :      */
      50             :     virtual void GetShape(EShape& shape, entity_pos_t& size0, entity_pos_t& size1, entity_pos_t& height) const = 0;
      51             : 
      52             :     /**
      53             :      * GetShape wrapper for script calls.
      54             :      * Returns { "type": "circle", "radius": 5.0, "height": 1.0 }
      55             :      * or { "type": "square", "width": 5.0, "depth": 5.0, "height": 1.0 }
      56             :      */
      57             :     JS::Value GetShape_wrapper() const;
      58             : 
      59             :     /**
      60             :      * Pick a sensible position to place a newly-spawned entity near this footprint,
      61             :      * such that it won't be in an invalid (obstructed) location regardless of the spawned unit's
      62             :      * orientation.
      63             :      * @return the X and Z coordinates of the spawn point, with Y = 0; or the special value (-1, -1, -1) if there's no space
      64             :      */
      65             :     virtual CFixedVector3D PickSpawnPoint(entity_id_t spawned) const = 0;
      66             : 
      67             :     /**
      68             :      * Pick a sensible position to place a newly-spawned entity near this footprint,
      69             :      * at the intersection between the footprint passability and the entity one.
      70             :      * @return the X and Z coordinates of the spawn point, with Y = 0; or the special value (-1, -1, -1) if there's no space
      71             :      */
      72             :     virtual CFixedVector3D PickSpawnPointBothPass(entity_id_t spawned) const = 0;
      73             : 
      74         115 :     DECLARE_INTERFACE_TYPE(Footprint)
      75             : };
      76             : 
      77             : #endif // INCLUDED_ICMPFOOTPRINT

Generated by: LCOV version 1.13