void CIVDynamicEntity::SetDynamicEntity(IVDynamicEntity * pDynamicEntity) { #ifdef EXT_LOG CLogFile::Printf(__FUNCSIG__); #endif SetEntity((IVEntity *)pDynamicEntity); }
////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// HRESULT CUIEntity::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisStack, char *Name) { ////////////////////////////////////////////////////////////////////////// // GetEntity ////////////////////////////////////////////////////////////////////////// if (strcmp(Name, "GetEntity") == 0) { Stack->CorrectParams(0); if (m_Entity) Stack->PushNative(m_Entity, true); else Stack->PushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetEntity ////////////////////////////////////////////////////////////////////////// else if (strcmp(Name, "SetEntity") == 0) { Stack->CorrectParams(1); char *Filename = Stack->Pop()->GetString(); if (SUCCEEDED(SetEntity(Filename))) Stack->PushBool(true); else Stack->PushBool(false); return S_OK; } else return CUIObject::ScCallMethod(Script, Stack, ThisStack, Name); }
//----------------------------------------------------------------------------- // Purpose: // Input : id - // priority - // player - // entity - //----------------------------------------------------------------------------- C_TFBaseHint::C_TFBaseHint( int id, int priority, int entity, HINTCOMPLETIONFUNCTION pfn /*=NULL*/ ) : vgui::Panel( NULL, "TFBaseHint" ), m_CursorNone( vgui::dc_none ) { m_pObject = NULL; m_pClearLabel = NULL; m_pCaption = NULL; m_pfnCompletion = pfn; // Child of main panel SetParent( VGui_GetClientDLLRootPanel() ); // Put at top of z-order (happens in Think, too) // MoveToFront(); // No cursor SetCursor( m_CursorNone ); // Set to default size SetSize( TFBASEHINT_DEFAULT_WIDTH, TFBASEHINT_DEFAULT_HEIGHT ); // We'll expressly delete it SetAutoDelete( false ); // Set up default values SetID( id ); SetPriority( priority ); SetEntity( entity ); SetCompleted( false ); // Target panel m_hTarget = NULL; m_bMoving = false; m_flMoveRemaining = 0.0f; m_flMoveTotal = 0.0f; for ( int pt = 0; pt < 2; pt++ ) { m_nMoveStart[ pt ] = 0; m_nMoveEnd[ pt ] = 0; } vgui::ivgui()->AddTickSignal( GetVPanel() ); // Create clear label m_pClearLabel = new vgui::Label( this, "CLEAR", "[Enter] to remove, [Enter] twice quickly to remove all..." ); m_pClearLabel->SetContentAlignment( vgui::Label::a_west ); m_pClearLabel->SetTextInset( 3, 2 ); // Create window caption m_pCaption = new vgui::Label( this, "CAPTION", "" ); m_pCaption->SetContentAlignment( vgui::Label::a_west ); m_pCaption->SetTextInset( 3, 0 ); // See if the hint started out complete! CheckForCompletion(); // Always start out hidden SetVisible( false ); }
void AddSkyboxDialog::CommandExecuted(SceneEditor2 *scene, const Command2* command, bool redo) { BaseAddEntityDialog::CommandExecuted(scene, command, redo); if(NULL == GetSkybox(command->GetEntity())) { return; } int id = command->GetId(); if((id == CMDID_ENTITY_ADD && redo) || (id == CMDID_ENTITY_REMOVE && !redo)) { SetEntity(command->GetEntity()); } else if((id == CMDID_ENTITY_ADD && !redo) || (id == CMDID_ENTITY_REMOVE && redo)) { SetEntity(NULL); } }
void WBEvent::Set( const HashedString& Name, const WBParamEvaluator& PE ) { switch( PE.GetType() ) { case WBParamEvaluator::EPT_Bool: SetBool( Name, PE.GetBool() ); break; case WBParamEvaluator::EPT_Int: SetInt( Name, PE.GetInt() ); break; case WBParamEvaluator::EPT_Float: SetFloat( Name, PE.GetFloat() ); break; case WBParamEvaluator::EPT_String: SetHash( Name, PE.GetString() ); break; // Conversion to hash is the best we can do case WBParamEvaluator::EPT_Entity: SetEntity( Name, PE.GetEntity() ); break; case WBParamEvaluator::EPT_Vector: SetVector( Name, PE.GetVector() ); break; } }
SMJS_Entity::SMJS_Entity(CBaseEntity *ent){ this->ent = NULL; datamaps.entWrapper = this; netprops.entWrapper = this; isEdict = false; entIndex = -1; SetEntity(ent); keyvalues.entWrapper = this; }
void WBEvent::Set( const HashedString& Name, const SParameter* const pParameter ) { if( !pParameter ) { return; } switch( pParameter->GetType() ) { case EWBEPT_Bool: SetBool( Name, pParameter->GetBool() ); break; case EWBEPT_Int: SetInt( Name, pParameter->GetInt() ); break; case EWBEPT_Float: SetFloat( Name, pParameter->GetFloat() ); break; case EWBEPT_Hash: SetHash( Name, pParameter->GetHash() ); break; case EWBEPT_Vector: SetVector( Name, pParameter->GetVector() ); break; case EWBEPT_Angles: SetAngles( Name, pParameter->GetAngles() ); break; case EWBEPT_Entity: SetEntity( Name, pParameter->GetEntity() ); break; case EWBEPT_Pointer: SetPointer( Name, pParameter->GetPointer() ); break; } }
CIVEntity::CIVEntity( ) { // Set the entity SetEntity( NULL ); }
TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// HRESULT CUIEntity::LoadBuffer(byte *Buffer, bool Complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(ENTITY_CONTAINER) TOKEN_TABLE(TEMPLATE) TOKEN_TABLE(DISABLED) TOKEN_TABLE(VISIBLE) TOKEN_TABLE(X) TOKEN_TABLE(Y) TOKEN_TABLE(NAME) TOKEN_TABLE(ENTITY) TOKEN_TABLE(SCRIPT) TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE_END byte *params; int cmd = 2; CBParser parser(Game); if (Complete) { if (parser.GetCommand((char **)&Buffer, commands, (char **)¶ms) != TOKEN_ENTITY_CONTAINER) { Game->LOG(0, "'ENTITY_CONTAINER' keyword expected."); return E_FAIL; } Buffer = params; } while (cmd > 0 && (cmd = parser.GetCommand((char **)&Buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: if (FAILED(LoadFile((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_NAME: SetName((char *)params); break; case TOKEN_X: parser.ScanStr((char *)params, "%d", &m_PosX); break; case TOKEN_Y: parser.ScanStr((char *)params, "%d", &m_PosY); break; case TOKEN_DISABLED: parser.ScanStr((char *)params, "%b", &m_Disable); break; case TOKEN_VISIBLE: parser.ScanStr((char *)params, "%b", &m_Visible); break; case TOKEN_ENTITY: if (FAILED(SetEntity((char *)params))) cmd = PARSERR_GENERIC; break; case TOKEN_SCRIPT: AddScript((char *)params); break; case TOKEN_EDITOR_PROPERTY: ParseEditorProperty(params, false); break; } } if (cmd == PARSERR_TOKENNOTFOUND) { Game->LOG(0, "Syntax error in ENTITY_CONTAINER definition"); return E_FAIL; } if (cmd == PARSERR_GENERIC) { Game->LOG(0, "Error loading ENTITY_CONTAINER definition"); return E_FAIL; } CorrectSize(); if (Game->m_EditorMode) { m_Width = 50; m_Height = 50; } return S_OK; }
void SMJS_Client::ReattachEntity(){ auto tmp = edict->GetNetworkable(); if(tmp != NULL){ SetEntity(tmp->GetBaseEntity()); } }
void CLevel::IR_OnKeyboardPress (int key) { bool b_ui_exist = (pHUD && pHUD->GetUI()); if (!g_bDisableAllInput) { if (auto ui = HUD().GetUI()) { if (ui->UIMainIngameWnd) { ui->UIMainIngameWnd->HudAdjustMode(key); // Real Wolf. 07.09.2014. } } /************************************************** added by Ray Twitty (aka Shadows) START **************************************************/ // Колбек на нажатие клавиши if (g_actor) Actor()->callback(GameObject::eOnKeyPress)(key); /*************************************************** added by Ray Twitty (aka Shadows) END ***************************************************/ } EGameActions _curr = get_binded_action(key); switch ( _curr ) { case kSCREENSHOT: Render->Screenshot(); return; break; case kCONSOLE: Console->Show (); return; break; case kQUIT: { if(b_ui_exist && HUD().GetUI()->MainInputReceiver() ){ if(HUD().GetUI()->MainInputReceiver()->IR_OnKeyboardPress(key)) return;//special case for mp and main_menu HUD().GetUI()->StartStopMenu( HUD().GetUI()->MainInputReceiver(), true); }else Console->Execute ("main_menu"); return; }break; case kPAUSE: if(!g_block_pause) { if ( IsGameTypeSingle() ) { Device.Pause(!Device.Paused(), TRUE, TRUE, "li_pause_key"); } } return; break; }; if( g_bDisableAllInput ) return; if ( !b_ui_exist ) return; if ( b_ui_exist && pHUD->GetUI()->IR_OnKeyboardPress(key)) return; if( Device.Paused() ) return; if ( game && Game().IR_OnKeyboardPress(key) ) return; if(_curr == kQUICK_SAVE && IsGameTypeSingle()) { Console->Execute ("save"); return; } if(_curr == kQUICK_LOAD && IsGameTypeSingle()) { #ifdef DEBUG FS.get_path ("$game_config$")->m_Flags.set(FS_Path::flNeedRescan, TRUE); FS.get_path ("$game_scripts$")->m_Flags.set(FS_Path::flNeedRescan, TRUE); FS.rescan_pathes (); #endif // DEBUG string_path saved_game,command; strconcat (sizeof(saved_game),saved_game,Core.UserName,"_","quicksave"); if (!CSavedGameWrapper::valid_saved_game(saved_game)) return; strconcat (sizeof(command),command,"load ",saved_game); Console->Execute (command); return; } #ifndef MASTER_GOLD switch (key) { case DIK_NUMPAD5: { if (GameID() != GAME_SINGLE) { Msg("For this game type Demo Record is disabled."); /// return; }; Console->Hide (); Console->Execute("demo_record 1"); } break; #endif // MASTER_GOLD #ifdef DEBUG case DIK_RETURN: bDebug = !bDebug; return; case DIK_BACK: if (GameID() == GAME_SINGLE) HW.Caps.SceneMode = (HW.Caps.SceneMode+1)%3; return; case DIK_F4: { if (pInput->iGetAsyncKeyState(DIK_LALT)) break; if (pInput->iGetAsyncKeyState(DIK_RALT)) break; bool bOk = false; u32 i=0, j, n=Objects.o_count(); if (pCurrentEntity) for ( ; i<n; ++i) if (Objects.o_get_by_iterator(i) == pCurrentEntity) break; if (i < n) { j = i; bOk = false; for (++i; i <n; ++i) { CEntityAlive* tpEntityAlive = smart_cast<CEntityAlive*>(Objects.o_get_by_iterator(i)); if (tpEntityAlive) { bOk = true; break; } } if (!bOk) for (i = 0; i <j; ++i) { CEntityAlive* tpEntityAlive = smart_cast<CEntityAlive*>(Objects.o_get_by_iterator(i)); if (tpEntityAlive) { bOk = true; break; } } if (bOk) { CObject *tpObject = CurrentEntity(); CObject *__I = Objects.o_get_by_iterator(i); CObject **I = &__I; SetEntity(*I); if (tpObject != *I) { CActor* pActor = smart_cast<CActor*> (tpObject); if (pActor) pActor->inventory().Items_SetCurrentEntityHud(false); } if (tpObject) { Engine.Sheduler.Unregister (tpObject); Engine.Sheduler.Register (tpObject, TRUE); }; Engine.Sheduler.Unregister (*I); Engine.Sheduler.Register (*I, TRUE); CActor* pActor = smart_cast<CActor*> (*I); if (pActor) { pActor->inventory().Items_SetCurrentEntityHud(true); CHudItem* pHudItem = smart_cast<CHudItem*>(pActor->inventory().ActiveItem()); if (pHudItem) { pHudItem->OnStateSwitch(pHudItem->GetState()); } } } } return; } case MOUSE_1: { if (GameID() != GAME_SINGLE) break; if (pInput->iGetAsyncKeyState(DIK_LALT)) { if (CurrentEntity()->CLS_ID == CLSID_OBJECT_ACTOR) try_change_current_entity (); else restore_actor (); return; } break; } /**/ case DIK_DIVIDE: if( OnServer() ){ // float NewTimeFactor = pSettings->r_float("alife","time_factor"); if (GameID() == GAME_SINGLE) Server->game->SetGameTimeFactor(g_fTimeFactor); else { Server->game->SetEnvironmentGameTimeFactor(g_fTimeFactor); Server->game->SetGameTimeFactor(g_fTimeFactor); }; } break; case DIK_MULTIPLY: if( OnServer() ){ float NewTimeFactor = 1000.f; if (GameID() == GAME_SINGLE) Server->game->SetGameTimeFactor(NewTimeFactor); else { Server->game->SetEnvironmentGameTimeFactor(NewTimeFactor); // Server->game->SetGameTimeFactor(NewTimeFactor); }; } break; #endif #ifdef DEBUG case DIK_F9:{ // if (!ai().get_alife()) // break; // const_cast<CALifeSimulatorHeader&>(ai().alife().header()).set_state(ALife::eZoneStateSurge); if (GameID() != GAME_SINGLE) { extern INT g_sv_SendUpdate; g_sv_SendUpdate = 1; }; break; } return; // case DIK_F10:{ // ai().level_graph().set_dest_point(); // ai().level_graph().build_detail_path(); // if (!Objects.FindObjectByName("m_stalker_e0000") || !Objects.FindObjectByName("localhost/dima")) // return; // if (!m_bSynchronization) { // m_bSynchronization = true; // ai().level_graph().set_start_point(); // m_bSynchronization = false; // } // luabind::functor<void> functor; // ai().script_engine().functor("alife_test.set_switch_online",functor); // functor(0,false); // } // return; // case DIK_F11: // ai().level_graph().build_detail_path(); // if (!Objects.FindObjectByName("m_stalker_e0000") || !Objects.FindObjectByName("localhost/dima")) // return; // if (!m_bSynchronization) { // m_bSynchronization = true; // ai().level_graph().set_dest_point(); // ai().level_graph().select_cover_point(); // m_bSynchronization = false; // } // return; #endif // DEBUG #ifndef MASTER_GOLD } #endif // MASTER_GOLD if (bindConsoleCmds.execute(key)) return; if( b_ui_exist && HUD().GetUI()->MainInputReceiver() )return; if (CURRENT_ENTITY()) { IInputReceiver* IR = smart_cast<IInputReceiver*> (smart_cast<CGameObject*>(CURRENT_ENTITY())); if (IR) IR->IR_OnKeyboardPress(get_binded_action(key)); } #ifdef _DEBUG CObject *obj = Level().Objects.FindObjectByName("monster"); if (obj) { CBaseMonster *monster = smart_cast<CBaseMonster *>(obj); if (monster) monster->debug_on_key(key); } #endif }
void AddSkyboxDialog::OnSceneActivated(SceneEditor2 *sceneEditor) { SetEditorScene(sceneEditor); SetEntity(sceneEditor->skyboxSystem->GetSkyboxEntity()); }
void CDynamicEntity::SetDynamicEntity( IDynamicEntity * pDynamicEntity ) { SetEntity( (IEntity *)pDynamicEntity ); }
CIVEntity::CIVEntity( IVEntity * pEntity ) { // Set the entity SetEntity( pEntity ); }
void CLevel::IR_OnKeyboardPress (int key) { if(Device.dwPrecacheFrame) return; #ifdef INGAME_EDITOR if (Device.editor() && (pInput->iGetAsyncKeyState(DIK_LALT) || pInput->iGetAsyncKeyState(DIK_RALT))) return; #endif // #ifdef INGAME_EDITOR bool b_ui_exist = (!!CurrentGameUI()); EGameActions _curr = get_binded_action(key); if(_curr==kPAUSE) { #ifdef INGAME_EDITOR if (Device.editor()) return; #endif // INGAME_EDITOR if (!g_block_pause && (IsGameTypeSingle() || IsDemoPlay())) { #ifdef DEBUG if(psActorFlags.test(AF_NO_CLIP)) Device.Pause(!Device.Paused(), TRUE, TRUE, "li_pause_key_no_clip"); else #endif //DEBUG Device.Pause(!Device.Paused(), TRUE, TRUE, "li_pause_key"); } return; } if( g_bDisableAllInput ) return; switch ( _curr ) { case kSCREENSHOT: Render->Screenshot(); return; break; case kCONSOLE: Console->Show (); return; break; case kQUIT: { if(b_ui_exist && CurrentGameUI()->TopInputReceiver() ) { if(CurrentGameUI()->IR_UIOnKeyboardPress(key)) return;//special case for mp and main_menu CurrentGameUI()->TopInputReceiver()->HideDialog(); }else { Console->Execute("main_menu"); }return; }break; }; if ( !bReady || !b_ui_exist ) return; if ( b_ui_exist && CurrentGameUI()->IR_UIOnKeyboardPress(key)) return; if ( Device.Paused() && !IsDemoPlay() #ifdef DEBUG && !psActorFlags.test(AF_NO_CLIP) #endif //DEBUG ) return; if ( game && game->OnKeyboardPress(get_binded_action(key)) ) return; if(_curr == kQUICK_SAVE && IsGameTypeSingle()) { Console->Execute ("save"); return; } if(_curr == kQUICK_LOAD && IsGameTypeSingle()) { #ifdef DEBUG FS.get_path ("$game_config$")->m_Flags.set(FS_Path::flNeedRescan, TRUE); FS.get_path ("$game_scripts$")->m_Flags.set(FS_Path::flNeedRescan, TRUE); FS.rescan_pathes (); #endif // DEBUG string_path saved_game,command; strconcat (sizeof(saved_game),saved_game,Core.UserName," - ","quicksave"); if (!CSavedGameWrapper::valid_saved_game(saved_game)) return; strconcat (sizeof(command),command,"load ",saved_game); Console->Execute (command); return; } #ifndef MASTER_GOLD switch (key) { case DIK_F7: { if (GameID() != eGameIDSingle) return; FS.get_path ("$game_config$")->m_Flags.set(FS_Path::flNeedRescan, TRUE); FS.get_path ("$game_scripts$")->m_Flags.set(FS_Path::flNeedRescan, TRUE); FS.rescan_pathes (); NET_Packet net_packet; net_packet.w_begin (M_RELOAD_GAME); Send (net_packet,net_flags(TRUE)); return; } case DIK_DIVIDE: { if (!Server) break; SetGameTimeFactor (g_fTimeFactor); #ifdef DEBUG if(!m_bEnvPaused) SetEnvironmentGameTimeFactor(GetEnvironmentGameTime(), g_fTimeFactor); #else //DEBUG SetEnvironmentGameTimeFactor(GetEnvironmentGameTime(), g_fTimeFactor); #endif //DEBUG break; } case DIK_MULTIPLY: { if (!Server) break; SetGameTimeFactor (1000.f); #ifdef DEBUG if(!m_bEnvPaused) SetEnvironmentGameTimeFactor(GetEnvironmentGameTime(), 1000.f); #else //DEBUG SetEnvironmentGameTimeFactor(GetEnvironmentGameTime(), 1000.f); #endif //DEBUG break; } #ifdef DEBUG case DIK_SUBTRACT:{ if (!Server) break; if(m_bEnvPaused) SetEnvironmentGameTimeFactor(GetEnvironmentGameTime(), g_fTimeFactor); else SetEnvironmentGameTimeFactor(GetEnvironmentGameTime(), 0.00001f); m_bEnvPaused = !m_bEnvPaused; break; } #endif //DEBUG case DIK_NUMPAD5: { if (GameID()!=eGameIDSingle) { Msg("For this game type Demo Record is disabled."); /// return; }; if(!pInput->iGetAsyncKeyState(DIK_LSHIFT)) { Console->Hide (); Console->Execute("demo_record 1"); } } break; #ifdef DEBUG // Lain: added TEMP!!! case DIK_UP: { g_separate_factor /= 0.9f; break; } case DIK_DOWN: { g_separate_factor *= 0.9f; if ( g_separate_factor < 0.1f ) { g_separate_factor = 0.1f; } break; } case DIK_LEFT: { g_separate_radius *= 0.9f; if ( g_separate_radius < 0 ) { g_separate_radius = 0; } break; } case DIK_RIGHT: { g_separate_radius /= 0.9f; break; } case DIK_RETURN: { bDebug = !bDebug; return; } case DIK_BACK: if (GameID() == eGameIDSingle) DRender->NextSceneMode(); //HW.Caps.SceneMode = (HW.Caps.SceneMode+1)%3; return; case DIK_F4: { if (pInput->iGetAsyncKeyState(DIK_LALT)) break; if (pInput->iGetAsyncKeyState(DIK_RALT)) break; bool bOk = false; u32 i=0, j, n=Objects.o_count(); if (pCurrentEntity) for ( ; i<n; ++i) if (Objects.o_get_by_iterator(i) == pCurrentEntity) break; if (i < n) { j = i; bOk = false; for (++i; i <n; ++i) { CEntityAlive* tpEntityAlive = smart_cast<CEntityAlive*>(Objects.o_get_by_iterator(i)); if (tpEntityAlive) { bOk = true; break; } } if (!bOk) for (i = 0; i <j; ++i) { CEntityAlive* tpEntityAlive = smart_cast<CEntityAlive*>(Objects.o_get_by_iterator(i)); if (tpEntityAlive) { bOk = true; break; } } if (bOk) { CObject *tpObject = CurrentEntity(); CObject *__I = Objects.o_get_by_iterator(i); CObject **I = &__I; SetEntity(*I); if (tpObject != *I) { CActor* pActor = smart_cast<CActor*> (tpObject); if (pActor) pActor->inventory().Items_SetCurrentEntityHud(false); } if (tpObject) { Engine.Sheduler.Unregister (tpObject); Engine.Sheduler.Register (tpObject, TRUE); }; Engine.Sheduler.Unregister (*I); Engine.Sheduler.Register (*I, TRUE); CActor* pActor = smart_cast<CActor*> (*I); if (pActor) { pActor->inventory().Items_SetCurrentEntityHud(true); CHudItem* pHudItem = smart_cast<CHudItem*>(pActor->inventory().ActiveItem()); if (pHudItem) { pHudItem->OnStateSwitch(pHudItem->GetState()); } } } } return; } // Lain: added case DIK_F5: { if ( CBaseMonster* pBM = smart_cast<CBaseMonster*>(CurrentEntity())) { DBG().log_debug_info(); } break; } case MOUSE_1: { if (GameID() != eGameIDSingle) break; if (pInput->iGetAsyncKeyState(DIK_LALT)) { if (smart_cast<CActor*>(CurrentEntity())) try_change_current_entity (); else restore_actor (); return; } break; } /**/ #endif #ifdef DEBUG case DIK_F9:{ // if (!ai().get_alife()) // break; // const_cast<CALifeSimulatorHeader&>(ai().alife().header()).set_state(ALife::eZoneStateSurge); break; } return; // case DIK_F10:{ // ai().level_graph().set_dest_point(); // ai().level_graph().build_detail_path(); // if (!Objects.FindObjectByName("m_stalker_e0000") || !Objects.FindObjectByName("localhost/dima")) // return; // if (!m_bSynchronization) { // m_bSynchronization = true; // ai().level_graph().set_start_point(); // m_bSynchronization = false; // } // luabind::functor<void> functor; // ai().script_engine().functor("alife_test.set_switch_online",functor); // functor(0,false); // } // return; // case DIK_F11: // ai().level_graph().build_detail_path(); // if (!Objects.FindObjectByName("m_stalker_e0000") || !Objects.FindObjectByName("localhost/dima")) // return; // if (!m_bSynchronization) { // m_bSynchronization = true; // ai().level_graph().set_dest_point(); // ai().level_graph().select_cover_point(); // m_bSynchronization = false; // } // return; #endif // DEBUG } #endif // MASTER_GOLD if (bindConsoleCmds.execute(key)) return; if (CURRENT_ENTITY()) { IInputReceiver* IR = smart_cast<IInputReceiver*> (smart_cast<CGameObject*>(CURRENT_ENTITY())); if (IR) IR->IR_OnKeyboardPress(get_binded_action(key)); } #ifdef _DEBUG CObject *obj = Level().Objects.FindObjectByName("monster"); if (obj) { CBaseMonster *monster = smart_cast<CBaseMonster *>(obj); if (monster) monster->debug_on_key(key); } #endif }
//----------------------------------------------------------------------------- // Purpose: Converts the variant to a new type. This function defines which I/O // types can be automatically converted between. Connections that require // an unsupported conversion will cause an error message at runtime. // Input : newType - the type to convert to // Output : Returns true on success, false if the conversion is not legal //----------------------------------------------------------------------------- bool variant_t::Convert( fieldtype_t newType ) { if ( newType == fieldType ) { return true; } // // Converting to a null value is easy. // if ( newType == FIELD_VOID ) { Set( FIELD_VOID, NULL ); return true; } // // FIELD_INPUT accepts the variant type directly. // if ( newType == FIELD_INPUT ) { return true; } switch ( fieldType ) { case FIELD_INTEGER: { switch ( newType ) { case FIELD_FLOAT: { SetFloat( (float) iVal ); return true; } case FIELD_BOOLEAN: { SetBool( iVal != 0 ); return true; } } break; } case FIELD_FLOAT: { switch ( newType ) { case FIELD_INTEGER: { SetInt( (int) flVal ); return true; } case FIELD_BOOLEAN: { SetBool( flVal != 0 ); return true; } } break; } // // Everyone must convert from FIELD_STRING if possible, since // parameter overrides are always passed as strings. // case FIELD_STRING: { switch ( newType ) { case FIELD_INTEGER: { if (iszVal != NULL_STRING) { SetInt(atoi(STRING(iszVal))); } else { SetInt(0); } return true; } case FIELD_FLOAT: { if (iszVal != NULL_STRING) { SetFloat(atof(STRING(iszVal))); } else { SetFloat(0); } return true; } case FIELD_BOOLEAN: { if (iszVal != NULL_STRING) { SetBool( atoi(STRING(iszVal)) != 0 ); } else { SetBool(false); } return true; } case FIELD_VECTOR: { Vector tmpVec = vec3_origin; if (sscanf(STRING(iszVal), "[%f %f %f]", &tmpVec[0], &tmpVec[1], &tmpVec[2]) == 0) { // Try sucking out 3 floats with no []s sscanf(STRING(iszVal), "%f %f %f", &tmpVec[0], &tmpVec[1], &tmpVec[2]); } SetVector3D( tmpVec ); return true; } case FIELD_COLOR32: { int nRed = 0; int nGreen = 0; int nBlue = 0; int nAlpha = 255; sscanf(STRING(iszVal), "%d %d %d %d", &nRed, &nGreen, &nBlue, &nAlpha); SetColor32( nRed, nGreen, nBlue, nAlpha ); return true; } case FIELD_EHANDLE: { // convert the string to an entity by locating it by classname CBaseEntity *ent = NULL; if ( iszVal != NULL_STRING ) { // FIXME: do we need to pass an activator in here? ent = gEntList.FindEntityByName( NULL, iszVal ); } SetEntity( ent ); return true; } } break; } case FIELD_EHANDLE: { switch ( newType ) { case FIELD_STRING: { // take the entities targetname as the string string_t iszStr = NULL_STRING; if ( eVal != NULL ) { SetString( eVal->GetEntityName() ); } return true; } } break; } } // invalid conversion return false; }
void CLevel::g_sv_Spawn (CSE_Abstract* E) { #ifdef DEBUG_MEMORY_MANAGER u32 E_mem = 0; if (g_bMEMO) { lua_gc (ai().script_engine().lua(),LUA_GCCOLLECT,0); lua_gc (ai().script_engine().lua(),LUA_GCCOLLECT,0); E_mem = Memory.mem_usage(); Memory.stat_calls = 0; } #endif // DEBUG_MEMORY_MANAGER //----------------------------------------------------------------- // CTimer T(false); #ifdef DEBUG // Msg ("* CLIENT: Spawn: %s, ID=%d", *E->s_name, E->ID); #endif // Optimization for single-player only - minimize traffic between client and server if (GameID() == eGameIDSingle) psNET_Flags.set (NETFLAG_MINIMIZEUPDATES,TRUE); else psNET_Flags.set (NETFLAG_MINIMIZEUPDATES,FALSE); // Client spawn // T.Start (); CObject* O = Objects.Create (*E->s_name); // Msg ("--spawn--CREATE: %f ms",1000.f*T.GetAsync()); // T.Start (); #ifdef DEBUG_MEMORY_MANAGER mem_alloc_gather_stats (false); #endif // DEBUG_MEMORY_MANAGER if (0==O || (!O->net_Spawn (E))) { O->net_Destroy ( ); if(!g_dedicated_server) client_spawn_manager().clear(O->ID()); Objects.Destroy (O); Msg ("! Failed to spawn entity '%s'",*E->s_name); #ifdef DEBUG_MEMORY_MANAGER mem_alloc_gather_stats (!!psAI_Flags.test(aiDebugOnFrameAllocs)); #endif // DEBUG_MEMORY_MANAGER } else { #ifdef DEBUG_MEMORY_MANAGER mem_alloc_gather_stats (!!psAI_Flags.test(aiDebugOnFrameAllocs)); #endif // DEBUG_MEMORY_MANAGER if(!g_dedicated_server) client_spawn_manager().callback(O); //Msg ("--spawn--SPAWN: %f ms",1000.f*T.GetAsync()); if ((E->s_flags.is(M_SPAWN_OBJECT_LOCAL)) && (E->s_flags.is(M_SPAWN_OBJECT_ASPLAYER)) ) { if (IsDemoPlayStarted()) { if (E->s_flags.is(M_SPAWN_OBJECT_PHANTOM)) { SetControlEntity (O); SetEntity (O); //do not switch !!! SetDemoSpectator (O); } } else { if (CurrentEntity() != NULL) { CGameObject* pGO = smart_cast<CGameObject*>(CurrentEntity()); if (pGO) pGO->On_B_NotCurrentEntity(); } SetControlEntity (O); SetEntity (O); //do not switch !!! } } if (0xffff != E->ID_Parent) { /* // Generate ownership-event NET_Packet GEN; GEN.w_begin (M_EVENT); GEN.w_u32 (E->m_dwSpawnTime);//-NET_Latency); GEN.w_u16 (GE_OWNERSHIP_TAKE); GEN.w_u16 (E->ID_Parent); GEN.w_u16 (u16(O->ID())); game_events->insert (GEN); /*/ NET_Packet GEN; GEN.write_start(); GEN.read_start(); GEN.w_u16 (u16(O->ID())); cl_Process_Event(E->ID_Parent, GE_OWNERSHIP_TAKE, GEN); //*/ } } /*if (E->s_flags.is(M_SPAWN_UPDATE)) { NET_Packet temp; temp.B.count = 0; E->UPDATE_Write (temp); if (temp.B.count > 0) { temp.r_seek (0); O->net_Import (temp); } }*/ //:( //--------------------------------------------------------- Game().OnSpawn (O); //--------------------------------------------------------- #ifdef DEBUG_MEMORY_MANAGER if (g_bMEMO) { lua_gc (ai().script_engine().lua(),LUA_GCCOLLECT,0); lua_gc (ai().script_engine().lua(),LUA_GCCOLLECT,0); Msg ("* %20s : %d bytes, %d ops", *E->s_name,Memory.mem_usage()-E_mem, Memory.stat_calls ); } #endif // DEBUG_MEMORY_MANAGER }