Ticket #1163: 1163.4.diff
File 1163.4.diff, 3.0 KB (added by , 9 years ago) |
---|
-
source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp
1 /* Copyright (C) 201 4Wildfire Games.1 /* Copyright (C) 2015 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify … … 48 48 #include "simulation2/components/ICmpSelectable.h" 49 49 #include "simulation2/components/ICmpTemplateManager.h" 50 50 #include "simulation2/components/ICmpVisual.h" 51 #include "simulation2/components/ICmpObstruction.h" 51 52 #include "simulation2/helpers/Selection.h" 52 53 #include "ps/XML/XMLWriter.h" 53 54 … … 61 62 } 62 63 } 63 64 65 //Helpers for object constraints 66 bool CanPlaceObjectEntityHelper(entity_id_t ent) 67 { 68 CmpPtr<ICmpObstruction> cmpObstruction(*g_Game->GetSimulation2(), ent); 69 if (cmpObstruction) 70 { 71 //use default passClasName. 72 ICmpObstruction::EFoundationCheck result = cmpObstruction->CheckFoundation("default"); 73 if (result != ICmpObstruction::FOUNDATION_CHECK_SUCCESS) 74 return false; 75 } 76 return true; 77 } 78 79 void CheckObstructionAndUpdateVisual(entity_id_t id) 80 { 81 //Check build Constraint 82 CmpPtr<ICmpVisual> cmpVisual(*g_Game->GetSimulation2(), id); 83 if (cmpVisual) 84 { 85 if (!CanPlaceObjectEntityHelper(id)) 86 cmpVisual->SetShadingColour(fixed::FromDouble(1.4), fixed::FromDouble(0.4), fixed::FromDouble(0.4), fixed::FromDouble(1)); 87 else 88 cmpVisual->SetShadingColour(fixed::FromDouble(1), fixed::FromDouble(1), fixed::FromDouble(1), fixed::FromDouble(1)); 89 } 90 } 91 64 92 QUERYHANDLER(GetObjectsList) 65 93 { 66 94 std::vector<sObjectsListItem> objects; … … 473 501 posFinal = posFixed + dir; 474 502 } 475 503 cmpPosition->JumpTo(posFinal.X, posFinal.Z); 504 505 //Check build Constraint 506 CheckObstructionAndUpdateVisual(id); 476 507 } 477 508 } 478 509 … … 543 574 CmpPtr<ICmpOwnership> cmpOwnership(*g_Game->GetSimulation2(), g_PreviewEntityID); 544 575 if (cmpOwnership) 545 576 cmpOwnership->SetOwner((player_id_t)msg->settings->player); 577 578 //Check build Constraint 579 CheckObstructionAndUpdateVisual(g_PreviewEntityID); 546 580 } 547 581 } 548 582 … … 599 633 if (cmpVisual) 600 634 { 601 635 cmpVisual->SetActorSeed(m_ActorSeed); 636 CheckObstructionAndUpdateVisual(m_EntityID); 602 637 // TODO: variation/selection strings 603 638 } 604 639 } … … 736 771 ObjectPositionMap::iterator it; 737 772 for (it = map.begin(); it != map.end(); ++it) 738 773 { 739 CmpPtr<ICmpPosition> cmpPosition(*g_Game->GetSimulation2(), (entity_id_t)it->first); 774 entity_id_t id = (entity_id_t)it->first; 775 CmpPtr<ICmpPosition> cmpPosition(*g_Game->GetSimulation2(), id); 740 776 if (!cmpPosition) 741 777 return; 742 778 … … 743 779 // Set 2D position, ignoring height 744 780 CVector3D pos = it->second; 745 781 cmpPosition->JumpTo(entity_pos_t::FromFloat(pos.X), entity_pos_t::FromFloat(pos.Z)); 782 783 //Check build Constraint 784 CheckObstructionAndUpdateVisual(id); 746 785 } 747 786 }