VActor.cpp
Engine/source/Verve/VActor/VActor.cpp
Public Functions
Detailed Description
Public Functions
IMPLEMENT_CO_NETOBJECT_V1(VActor )
1 2//----------------------------------------------------------------------------- 3// Verve 4// Copyright (C) 2014 - Violent Tulip 5// 6// Permission is hereby granted, free of charge, to any person obtaining a copy 7// of this software and associated documentation files (the "Software"), to 8// deal in the Software without restriction, including without limitation the 9// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10// sell copies of the Software, and to permit persons to whom the Software is 11// furnished to do so, subject to the following conditions: 12// 13// The above copyright notice and this permission notice shall be included in 14// all copies or substantial portions of the Software. 15// 16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22// IN THE SOFTWARE. 23//----------------------------------------------------------------------------- 24#include "VActor.h" 25 26//----------------------------------------------------------------------------- 27IMPLEMENT_CO_NETOBJECT_V1( VActor ); 28//----------------------------------------------------------------------------- 29 30VActor::VActor( void ) : 31 mDataBlock( NULL ) 32{ 33 // Void. 34} 35 36VActor::~VActor( void ) 37{ 38 // Void. 39} 40 41 42 43 44//----------------------------------------------------------------------------- 45// 46// Initialisation Methods. 47// 48//----------------------------------------------------------------------------- 49 50//----------------------------------------------------------------------------- 51// 52// VActor::onAdd(); 53// 54// ... 55// 56//----------------------------------------------------------------------------- 57bool VActor::onAdd( void ) 58{ 59 if ( !Parent::onAdd() || !mDataBlock ) 60 { 61 return false; 62 } 63 64 // Add to Scene. 65 addToScene(); 66 67 if ( isServerObject() ) 68 { 69 // Script Callback. 70 scriptOnAdd(); 71 } 72 73 return true; 74} 75 76//----------------------------------------------------------------------------- 77// 78// VActor::onRemove(); 79// 80// ... 81// 82//----------------------------------------------------------------------------- 83void VActor::onRemove( void ) 84{ 85 // Script Callback. 86 scriptOnRemove(); 87 88 // Remove From Scene. 89 removeFromScene(); 90 91 Parent::onRemove(); 92} 93 94//----------------------------------------------------------------------------- 95// 96// VActor::onNewDataBlock( pDataBlock ); 97// 98// ... 99// 100//----------------------------------------------------------------------------- 101bool VActor::onNewDataBlock( GameBaseData *pDataBlock, bool pReload ) 102{ 103 // Store DataBlock Reference. 104 mDataBlock = dynamic_cast<VActorData*>( pDataBlock ); 105 106 if ( !mDataBlock ) 107 { 108 // Invalid Data. 109 return false; 110 } 111 112 // Parent Call. 113 return Parent::onNewDataBlock( pDataBlock, pReload ); 114} 115 116 117 118 119//----------------------------------------------------------------------------- 120// 121// Update Methods. 122// 123//----------------------------------------------------------------------------- 124 125//----------------------------------------------------------------------------- 126// 127// VActor::processTick( pMove ); 128// 129// ... 130// 131//----------------------------------------------------------------------------- 132void VActor::processTick( const Move *pMove ) 133{ 134 // Parent Call. 135 Parent::processTick( pMove ); 136 137 // Triggers? 138 if ( pMove && mDamageState == Enabled ) 139 { 140 // Handle each Image Trigger. 141 const U32 imageCount = getMin( ShapeBase::MaxMountedImages, MaxTriggerKeys ); 142 for ( U32 i = 0; i < imageCount; i++ ) 143 { 144 setImageTriggerState( i, pMove->trigger[i] ); 145 } 146 } 147} 148 149//----------------------------------------------------------------------------- 150// 151// VActor::packUpdate( pConnection, pMask, pStream ); 152// 153// ... 154// 155//----------------------------------------------------------------------------- 156U32 VActor::packUpdate( NetConnection *pConnection, U32 pMask, BitStream *pStream ) 157{ 158 // Parent Call. 159 return Parent::packUpdate( pConnection, pMask, pStream ); 160} 161 162//----------------------------------------------------------------------------- 163// 164// VActor::unpackUpdate( pConnection, pStream ); 165// 166// ... 167// 168//----------------------------------------------------------------------------- 169void VActor::unpackUpdate( NetConnection *pConnection, BitStream *pStream ) 170{ 171 // Parent Call. 172 Parent::unpackUpdate( pConnection, pStream ); 173} 174 175 176 177 178//----------------------------------------------------------------------------- 179// 180// Physics Methods. 181// 182//----------------------------------------------------------------------------- 183 184//----------------------------------------------------------------------------- 185// 186// VActor::setTransform( pMatrix ); 187// 188// ... 189// 190//----------------------------------------------------------------------------- 191void VActor::setTransform( const MatrixF &pMatrix ) 192{ 193 Parent::setTransform( pMatrix ); 194 195 // Server Object? 196 if ( isServerObject() ) 197 { 198 // Move Object. 199 setMaskBits( MoveMask ); 200 } 201} 202 203//----------------------------------------------------------------------------- 204// 205// VActor::onMount( pObject, pNode ); 206// 207// ... 208// 209//----------------------------------------------------------------------------- 210void VActor::onMount( SceneObject *pObject, S32 pNode ) 211{ 212 // Parent Call. 213 Parent::onMount( pObject, pNode ); 214 215 // Post Event. 216 mEventSignal.trigger( k_MountEvent ); 217} 218 219//----------------------------------------------------------------------------- 220// 221// VActor::onUnmount( pObject, pNode ); 222// 223// ... 224// 225//----------------------------------------------------------------------------- 226void VActor::onUnmount( SceneObject *pObject, S32 pNode ) 227{ 228 // Parent Call. 229 Parent::onUnmount( pObject, pNode ); 230 231 // Post Event. 232 mEventSignal.trigger( k_UnmountEvent ); 233} 234