Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ICmpObstruction.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2013 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 #include "precompiled.h"
19 
20 #include "ICmpObstruction.h"
21 
23 
25 
26 std::string ICmpObstruction::CheckFoundation_wrapper(std::string className, bool onlyCenterPoint)
27 {
28  EFoundationCheck check = CheckFoundation(className, onlyCenterPoint);
29 
30  switch (check)
31  {
33  return "success";
35  return "fail_error";
37  return "fail_no_obstruction";
39  return "fail_obstructs_foundation";
41  return "fail_terrain_class";
42  default:
43  debug_warn(L"Unexpected result from CheckFoundation");
44  return "";
45  }
46 }
47 
48 BEGIN_INTERFACE_WRAPPER(Obstruction)
49 DEFINE_INTERFACE_METHOD_0("GetUnitRadius", entity_pos_t, ICmpObstruction, GetUnitRadius)
50 DEFINE_INTERFACE_METHOD_2("CheckFoundation", std::string, ICmpObstruction, CheckFoundation_wrapper, std::string, bool)
51 DEFINE_INTERFACE_METHOD_0("CheckDuplicateFoundation", bool, ICmpObstruction, CheckDuplicateFoundation)
52 DEFINE_INTERFACE_METHOD_2("GetEntityCollisions", std::vector<entity_id_t>, ICmpObstruction, GetEntityCollisions, bool, bool)
53 DEFINE_INTERFACE_METHOD_1("SetActive", void, ICmpObstruction, SetActive, bool)
54 DEFINE_INTERFACE_METHOD_3("SetDisableBlockMovementPathfinding", void, ICmpObstruction, SetDisableBlockMovementPathfinding, bool, bool, int32_t)
55 DEFINE_INTERFACE_METHOD_0("GetBlockMovementFlag", bool, ICmpObstruction, GetBlockMovementFlag)
56 DEFINE_INTERFACE_METHOD_1("SetControlGroup", void, ICmpObstruction, SetControlGroup, entity_id_t)
57 DEFINE_INTERFACE_METHOD_0("GetControlGroup", entity_id_t, ICmpObstruction, GetControlGroup)
58 DEFINE_INTERFACE_METHOD_1("SetControlGroup2", void, ICmpObstruction, SetControlGroup2, entity_id_t)
59 DEFINE_INTERFACE_METHOD_0("GetControlGroup2", entity_id_t, ICmpObstruction, GetControlGroup2)
60 END_INTERFACE_WRAPPER(Obstruction)
A simple fixed-point number class.
Definition: Fixed.h:115
#define DEFINE_INTERFACE_METHOD_3(scriptname, rettype, classname, methodname, arg1, arg2, arg3)
#define DEFINE_INTERFACE_METHOD_2(scriptname, rettype, classname, methodname, arg1, arg2)
#define END_INTERFACE_WRAPPER(iname)
#define DEFINE_INTERFACE_METHOD_1(scriptname, rettype, classname, methodname, arg1)
Flags an entity as obstructing movement for other units, and handles the processing of collision quer...
#define DEFINE_INTERFACE_METHOD_0(scriptname, rettype, classname, methodname)
virtual EFoundationCheck CheckFoundation(std::string className)=0
Test whether this entity is colliding with any obstruction that are set to block the creation of foun...
#define debug_warn(expr)
display the error dialog with the given text.
Definition: debug.h:324
#define BEGIN_INTERFACE_WRAPPER(iname)
u32 entity_id_t
Entity ID type.
Definition: Entity.h:24
virtual std::string CheckFoundation_wrapper(std::string className, bool onlyCenterPoint)
CheckFoundation wrapper for script calls, to return friendly strings instead of an EFoundationCheck...