Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
ICmpFootprint.h
Go to the documentation of this file.
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
22
24
25class 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 */
34{
35public:
36 enum EShape
37 {
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 */
73
74 DECLARE_INTERFACE_TYPE(Footprint)
75};
76
77#endif // INCLUDED_ICMPFOOTPRINT
#define DECLARE_INTERFACE_TYPE(iname)
Definition: Interface.h:23
Entity coordinate types.
Definition: FixedVector3D.h:25
A simple fixed-point number class.
Definition: Fixed.h:120
Footprints - an approximation of the entity's shape, used for collision detection and for rendering s...
Definition: ICmpFootprint.h:34
JS::Value GetShape_wrapper() const
GetShape wrapper for script calls.
Definition: ICmpFootprint.cpp:27
virtual void GetShape(EShape &shape, entity_pos_t &size0, entity_pos_t &size1, entity_pos_t &height) const =0
Return the shape of this footprint.
virtual CFixedVector3D PickSpawnPointBothPass(entity_id_t spawned) const =0
Pick a sensible position to place a newly-spawned entity near this footprint, at the intersection bet...
virtual CFixedVector3D PickSpawnPoint(entity_id_t spawned) const =0
Pick a sensible position to place a newly-spawned entity near this footprint, such that it won't be i...
EShape
Definition: ICmpFootprint.h:37
@ CIRCLE
Definition: ICmpFootprint.h:38
@ SQUARE
Definition: ICmpFootprint.h:39
Definition: IComponent.h:33
u32 entity_id_t
Entity ID type.
Definition: Entity.h:29