missionArea.cpp
Engine/source/T3D/missionArea.cpp
Public Functions
ConsoleDocClass(MissionArea , "@brief Level object which defines the boundaries of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">level.\n\n</a>" "This is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> simple box with starting points, width , depth , and height. It does not have " "any default functionality. Instead, when objects hit the boundaries certain " "script callbacks will be made allowing you <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">reaction.\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "<a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classmissionarea/">MissionArea</a>(GlobalMissionArea)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " Area=\"-152 -352 1008 864\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " flightCeiling = \"300\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " flightCeilingRange = \"20\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " canSaveDynamicFields = \"1\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " enabled = \"1\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " TypeBool locked = \"false\";\n" "};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">enviroMisc\n</a>" )
DefineEngineFunction(getMissionAreaServerObject , MissionArea * , () , "Get the <a href="/coding/class/classmissionarea/">MissionArea</a> object, <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">any.\n\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">enviroMisc\n\n</a>" )
DefineEngineMethod(MissionArea , getArea , const char * , () , "Returns 4 fields: starting x, starting y, extents x, extents <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">y.\n</a>" )
DefineEngineMethod(MissionArea , postApply , void , () , "Intended as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> helper <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> developers and editor <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">scripts.\n</a>" "Force trigger an inspectPostApply. This will transmit " "material and other fields ( not including nodes ) <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> client objects." )
DefineEngineMethod(MissionArea , setArea , void , (S32 x, S32 y, S32 width, S32 height) , "@brief - Defines the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1ab7d671599a7b25ca99a487fa341bc33a">size</a> of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">MissionArea\n\n</a>" "param x Starting X coordinate position <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">MissionArea\n</a>" "param y Starting Y coordinate position <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">MissionArea\n</a>" "param width New width of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">MissionArea\n</a>" "param height New height of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">MissionArea\n</a>" "@note Only the server object may be <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">set.\n</a>" )
Detailed Description
Public Functions
ConsoleDocClass(MissionArea , "@brief Level object which defines the boundaries of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">level.\n\n</a>" "This is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> simple box with starting points, width , depth , and height. It does not have " "any default functionality. Instead, when objects hit the boundaries certain " "script callbacks will be made allowing you <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">reaction.\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "<a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classmissionarea/">MissionArea</a>(GlobalMissionArea)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " Area=\"-152 -352 1008 864\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " flightCeiling = \"300\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " flightCeilingRange = \"20\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " canSaveDynamicFields = \"1\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " enabled = \"1\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " TypeBool locked = \"false\";\n" "};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">enviroMisc\n</a>" )
DefineEngineFunction(getMissionAreaServerObject , MissionArea * , () , "Get the <a href="/coding/class/classmissionarea/">MissionArea</a> object, <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">any.\n\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">enviroMisc\n\n</a>" )
DefineEngineMethod(MissionArea , getArea , const char * , () , "Returns 4 fields: starting x, starting y, extents x, extents <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">y.\n</a>" )
DefineEngineMethod(MissionArea , postApply , void , () , "Intended as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> helper <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> developers and editor <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">scripts.\n</a>" "Force trigger an inspectPostApply. This will transmit " "material and other fields ( not including nodes ) <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> client objects." )
DefineEngineMethod(MissionArea , setArea , void , (S32 x, S32 y, S32 width, S32 height) , "@brief - Defines the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1ab7d671599a7b25ca99a487fa341bc33a">size</a> of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">MissionArea\n\n</a>" "param x Starting X coordinate position <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">MissionArea\n</a>" "param y Starting Y coordinate position <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">MissionArea\n</a>" "param width New width of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">MissionArea\n</a>" "param height New height of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">MissionArea\n</a>" "@note Only the server object may be <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">set.\n</a>" )
IMPLEMENT_CO_NETOBJECT_V1(MissionArea )
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#include "T3D/missionArea.h" 25#include "console/consoleTypes.h" 26#include "core/stream/bitStream.h" 27#include "math/mathIO.h" 28#include "console/engineAPI.h" 29 30IMPLEMENT_CO_NETOBJECT_V1(MissionArea); 31 32ConsoleDocClass( MissionArea, 33 "@brief Level object which defines the boundaries of the level.\n\n" 34 35 "This is a simple box with starting points, width, depth, and height. It does not have " 36 "any default functionality. Instead, when objects hit the boundaries certain " 37 "script callbacks will be made allowing you to control the reaction.\n\n" 38 39 "@tsexample\n" 40 "new MissionArea(GlobalMissionArea)\n" 41 "{\n" 42 " Area = \"-152 -352 1008 864\";\n" 43 " flightCeiling = \"300\";\n" 44 " flightCeilingRange = \"20\";\n" 45 " canSaveDynamicFields = \"1\";\n" 46 " enabled = \"1\";\n" 47 " TypeBool locked = \"false\";\n" 48 "};\n" 49 "@endtsexample\n\n" 50 51 "@ingroup enviroMisc\n" 52); 53 54RectI MissionArea::smMissionArea(Point2I(768, 768), Point2I(512, 512)); 55 56MissionArea * MissionArea::smServerObject = NULL; 57 58//------------------------------------------------------------------------------ 59 60MissionArea::MissionArea() 61{ 62 mArea.set(Point2I(768, 768), Point2I(512, 512)); 63 mNetFlags.set(Ghostable | ScopeAlways); 64 65 mFlightCeiling = 2000; 66 mFlightCeilingRange = 50; 67} 68 69//------------------------------------------------------------------------------ 70 71void MissionArea::setArea(const RectI & area) 72{ 73 // set it 74 mArea = MissionArea::smMissionArea = area; 75 76 // pass along.. 77 if(isServerObject()) 78 mNetFlags.set(UpdateMask); 79} 80 81//------------------------------------------------------------------------------ 82 83MissionArea * MissionArea::getServerObject() 84{ 85 return smServerObject; 86} 87 88//------------------------------------------------------------------------------ 89 90bool MissionArea::onAdd() 91{ 92 if(isServerObject()) 93 { 94 if(MissionArea::getServerObject()) 95 { 96 Con::errorf(ConsoleLogEntry::General, "MissionArea::onAdd - MissionArea already instantiated!"); 97 return(false); 98 } 99 else 100 { 101 smServerObject = this; 102 } 103 } 104 105 if(!Parent::onAdd()) 106 return(false); 107 108 setArea(mArea); 109 return(true); 110} 111 112void MissionArea::onRemove() 113{ 114 if (smServerObject == this) 115 smServerObject = NULL; 116 117 Parent::onRemove(); 118} 119 120//------------------------------------------------------------------------------ 121 122void MissionArea::inspectPostApply() 123{ 124 // Set Parent. 125 Parent::inspectPostApply(); 126 127 setMaskBits(UpdateMask); 128} 129 130//------------------------------------------------------------------------------ 131 132void MissionArea::initPersistFields() 133{ 134 addGroup("Dimensions"); 135 addField("area", TypeRectI, Offset(mArea, MissionArea), "Four corners (X1, X2, Y1, Y2) that makes up the level's boundaries"); 136 addField("flightCeiling", TypeF32, Offset(mFlightCeiling, MissionArea), "Represents the top of the mission area, used by FlyingVehicle. "); 137 addField("flightCeilingRange", TypeF32, Offset(mFlightCeilingRange, MissionArea), "Distance from ceiling before FlyingVehicle thrust is cut off. "); 138 endGroup("Dimensions"); 139 140 Parent::initPersistFields(); 141} 142 143 144//------------------------------------------------------------------------------ 145 146void MissionArea::unpackUpdate(NetConnection *, BitStream * stream) 147{ 148 // ghost (initial) and regular updates share flag.. 149 if(stream->readFlag()) 150 { 151 mathRead(*stream, &mArea); 152 stream->read(&mFlightCeiling); 153 stream->read(&mFlightCeilingRange); 154 } 155} 156 157U32 MissionArea::packUpdate(NetConnection *, U32 mask, BitStream * stream) 158{ 159 if(stream->writeFlag(mask & UpdateMask)) 160 { 161 mathWrite(*stream, mArea); 162 stream->write(mFlightCeiling); 163 stream->write(mFlightCeilingRange); 164 } 165 return(0); 166} 167 168//----------------------------------------------------------------------------- 169 170DefineEngineFunction(getMissionAreaServerObject, MissionArea*, (),, 171 "Get the MissionArea object, if any.\n\n" 172 "@ingroup enviroMisc\n\n") 173{ 174 return MissionArea::getServerObject(); 175} 176 177DefineEngineMethod( MissionArea, getArea, const char *, (),, 178 "Returns 4 fields: starting x, starting y, extents x, extents y.\n") 179{ 180 static const U32 bufSize = 48; 181 char* returnBuffer = Con::getReturnBuffer(bufSize); 182 183 RectI area = object->getArea(); 184 dSprintf(returnBuffer, bufSize, "%d %d %d %d", area.point.x, area.point.y, area.extent.x, area.extent.y); 185 return(returnBuffer); 186} 187 188DefineEngineMethod( MissionArea, setArea, void, (S32 x, S32 y, S32 width, S32 height),, 189 "@brief - Defines the size of the MissionArea\n\n" 190 "param x Starting X coordinate position for MissionArea\n" 191 "param y Starting Y coordinate position for MissionArea\n" 192 "param width New width of the MissionArea\n" 193 "param height New height of the MissionArea\n" 194 "@note Only the server object may be set.\n" 195 ) 196{ 197 if(object->isClientObject()) 198 { 199 Con::errorf(ConsoleLogEntry::General, "MissionArea::cSetArea - cannot alter client object!"); 200 return; 201 } 202 203 RectI rect; 204 rect.point.x = x; 205 rect.point.y = y; 206 rect.extent.x = width; 207 rect.extent.y = height; 208 209 object->setArea(rect); 210} 211 212DefineEngineMethod( MissionArea, postApply, void, (),, 213 "Intended as a helper to developers and editor scripts.\n" 214 "Force trigger an inspectPostApply. This will transmit " 215 "material and other fields ( not including nodes ) to client objects." 216 ) 217{ 218 object->inspectPostApply(); 219} 220