Line data Source code
1 : /* Copyright (C) 2026 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 : 22 : #include "lib/debug.h" 23 : #include "simulation2/system/InterfaceScripted.h" 24 : 25 : 26 0 : std::string ICmpObstruction::CheckFoundation_wrapper(const std::string& className, bool onlyCenterPoint) const 27 : { 28 0 : EFoundationCheck check = CheckFoundation(className, onlyCenterPoint); 29 : 30 0 : switch (check) 31 : { 32 0 : case FOUNDATION_CHECK_SUCCESS: 33 0 : return "success"; 34 0 : case FOUNDATION_CHECK_FAIL_ERROR: 35 0 : return "fail_error"; 36 0 : case FOUNDATION_CHECK_FAIL_NO_OBSTRUCTION: 37 0 : return "fail_no_obstruction"; 38 0 : case FOUNDATION_CHECK_FAIL_OBSTRUCTS_FOUNDATION: 39 0 : return "fail_obstructs_foundation"; 40 0 : case FOUNDATION_CHECK_FAIL_TERRAIN_CLASS: 41 0 : return "fail_terrain_class"; 42 0 : default: 43 0 : debug_warn(L"Unexpected result from CheckFoundation"); 44 0 : return ""; 45 : } 46 : } 47 : 48 0 : CFixedVector2D ICmpObstruction::GetObstructionHalfSizes_wrapper() const 49 : { 50 0 : ICmpObstructionManager::ObstructionSquare square; 51 0 : if (!GetObstructionSquare(square)) 52 0 : return CFixedVector2D(entity_pos_t::FromInt(-1), entity_pos_t::FromInt(-1)); 53 0 : return CFixedVector2D(square.hw, square.hh); 54 : } 55 : 56 : BEGIN_INTERFACE_WRAPPER(Obstruction) 57 : DEFINE_INTERFACE_METHOD("GetSize", ICmpObstruction, GetSize) 58 : DEFINE_INTERFACE_METHOD("CheckShorePlacement", ICmpObstruction, CheckShorePlacement) 59 0 : DEFINE_INTERFACE_METHOD("CheckFoundation", ICmpObstruction, CheckFoundation_wrapper) 60 : DEFINE_INTERFACE_METHOD("CheckDuplicateFoundation", ICmpObstruction, CheckDuplicateFoundation) 61 : DEFINE_INTERFACE_METHOD("GetEntitiesBlockingMovement", ICmpObstruction, GetEntitiesBlockingMovement) 62 : DEFINE_INTERFACE_METHOD("GetEntitiesBlockingConstruction", ICmpObstruction, GetEntitiesBlockingConstruction) 63 : DEFINE_INTERFACE_METHOD("GetEntitiesDeletedUponConstruction", ICmpObstruction, GetEntitiesDeletedUponConstruction) 64 : DEFINE_INTERFACE_METHOD("SetActive", ICmpObstruction, SetActive) 65 0 : DEFINE_INTERFACE_METHOD("SetDisableBlockMovementPathfinding", ICmpObstruction, SetDisableBlockMovementPathfinding) 66 0 : DEFINE_INTERFACE_METHOD("GetObstructionHalfSizes", ICmpObstruction, GetObstructionHalfSizes_wrapper) 67 : DEFINE_INTERFACE_METHOD("GetBlockMovementFlag", ICmpObstruction, GetBlockMovementFlag) 68 : DEFINE_INTERFACE_METHOD("SetControlGroup", ICmpObstruction, SetControlGroup) 69 : DEFINE_INTERFACE_METHOD("GetControlGroup", ICmpObstruction, GetControlGroup) 70 : DEFINE_INTERFACE_METHOD("SetControlGroup2", ICmpObstruction, SetControlGroup2) 71 : DEFINE_INTERFACE_METHOD("GetControlGroup2", ICmpObstruction, GetControlGroup2) 72 137 : END_INTERFACE_WRAPPER(Obstruction)