1 /* 2 Copyright (c) 2013 yvt 3 4 This file is part of OpenSpades. 5 6 OpenSpades is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 OpenSpades is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with OpenSpades. If not, see <http://www.gnu.org/licenses/>. 18 19 */ 20 21 #include "ScriptManager.h" 22 #include "IGrenadeSkin.h" 23 #include <Core/Debug.h> 24 25 namespace spades{ 26 namespace client { ScriptIGrenadeSkin(asIScriptObject * obj)27 ScriptIGrenadeSkin::ScriptIGrenadeSkin(asIScriptObject *obj): 28 obj(obj){} 29 SetReadyState(float v)30 void ScriptIGrenadeSkin::SetReadyState(float v) { 31 SPADES_MARK_FUNCTION_DEBUG(); 32 static ScriptFunction func("IGrenadeSkin", 33 "void set_ReadyState(float)"); 34 ScriptContextHandle ctx = func.Prepare(); 35 int r; 36 r = ctx->SetObject((void *)obj); 37 ScriptManager::CheckError(r); 38 r = ctx->SetArgFloat(0, v); 39 ScriptManager::CheckError(r); 40 ctx.ExecuteChecked(); 41 } 42 SetCookTime(float v)43 void ScriptIGrenadeSkin::SetCookTime(float v) { 44 SPADES_MARK_FUNCTION_DEBUG(); 45 static ScriptFunction func("IGrenadeSkin", 46 "void set_CookTime(float)"); 47 ScriptContextHandle ctx = func.Prepare(); 48 int r; 49 r = ctx->SetObject((void *)obj); 50 ScriptManager::CheckError(r); 51 r = ctx->SetArgFloat(0, v); 52 ScriptManager::CheckError(r); 53 ctx.ExecuteChecked(); 54 } 55 56 class IGrenadeSkinRegistrar: public ScriptObjectRegistrar { 57 public: IGrenadeSkinRegistrar()58 IGrenadeSkinRegistrar(): 59 ScriptObjectRegistrar("IGrenadeSkin"){ 60 61 } Register(ScriptManager * manager,Phase phase)62 virtual void Register(ScriptManager *manager, Phase phase) { 63 asIScriptEngine *eng = manager->GetEngine(); 64 int r; 65 eng->SetDefaultNamespace("spades"); 66 switch(phase){ 67 case PhaseObjectType: 68 r = eng->RegisterInterface("IGrenadeSkin"); 69 manager->CheckError(r); 70 break; 71 case PhaseObjectMember: 72 r = eng->RegisterInterfaceMethod("IGrenadeSkin", 73 "void set_ReadyState(float)"); 74 manager->CheckError(r); 75 r = eng->RegisterInterfaceMethod("IGrenadeSkin", 76 "void set_CookTime(float)"); 77 manager->CheckError(r); 78 break; 79 default: 80 81 break; 82 } 83 } 84 }; 85 86 static IGrenadeSkinRegistrar registrar; 87 } 88 } 89 90