public static void RunFrame() { try { Entity.RunAll(entity => entity.ProcessNotifications()); Entity.RunAll(entity => entity.ProcessTimers()); ScriptProcessor.RunAll(script => script.RunFrame()); } catch (Exception ex) { Log.Write(LogLevel.Critical, ex.ToString()); Environment.Exit(0); } }
public static void InitializeLevel() { // load scripts try { ScriptProcessor.ClearScripts(); ScriptLoader.InitializeLevel(); } catch (Exception ex) { Log.Write(LogLevel.Critical, ex.ToString()); Environment.Exit(0); } }
public static void RunFrame() { try { Entity.RunAll(entity => entity.ProcessNotifications()); Entity.RunAll(entity => entity.ProcessTimers()); ScriptProcessor.RunAll(script => script.RunFrame()); } catch (Exception ex) { Log.Write(LogLevel.Critical, ex.ToString()); Environment.Exit(0); } //GameInterface.Script_PushString("Hello!"); //GameInterface.Script_PushInt(1337); //GameInterface.Script_Call(362, 0, 1); }
public static bool HandleServerCommand(string commandName) { string[] args = new string[GameInterface.Cmd_Argc()]; for (int i = 0; i < args.Length; i++) { args[i] = GameInterface.Cmd_Argv(i); } bool eat = false; ScriptProcessor.RunAll(script => { eat = script.OnServerCommand(commandName.ToLowerInvariant(), args); }); return(eat); }
public static void HandleCall(int entityRef, CallType funcID) { var entity = Entity.GetEntity(entityRef); int numArgs = GameInterface.Notify_NumArgs(); var paras = CollectParameters(numArgs); switch (funcID) { case CallType.StartGameType: ScriptProcessor.RunAll(script => script.OnStartGameType()); break; case CallType.PlayerConnect: //ScriptProcessor.RunAll(script => script.OnPlayerConnect(entity)); break; case CallType.PlayerDisconnect: ScriptProcessor.RunAll(script => script.OnPlayerDisconnect(entity)); break; case CallType.PlayerDamage: if (paras[6].IsNull) { paras[6] = new Vector3(0, 0, 0); } if (paras[7].IsNull) { paras[7] = new Vector3(0, 0, 0); } ScriptProcessor.RunAll(script => script.OnPlayerDamage(entity, paras[0].As <Entity>(), paras[1].As <Entity>(), paras[2].As <int>(), paras[3].As <int>(), paras[4].As <string>(), paras[5].As <string>(), paras[6].As <Vector3>(), paras[7].As <Vector3>(), paras[8].As <string>())); break; case CallType.PlayerKilled: if (paras[5].IsNull) { paras[5] = new Vector3(0, 0, 0); } ScriptProcessor.RunAll(script => script.OnPlayerKilled(entity, paras[0].As <Entity>(), paras[1].As <Entity>(), paras[2].As <int>(), paras[3].As <string>(), paras[4].As <string>(), paras[5].As <Vector3>(), paras[6].As <string>())); break; } }
public static bool HandleSay(int clientNum, string clientName, ref string message, int team) { Entity entity = Entity.GetEntity(clientNum); bool eatgame = false; bool eatscript = false; string messageTemp = message; ScriptProcessor.RunAll(script => { // Run Script.OnSay3 (by reference, with team and eat) if (eatscript) { return; } EventEat handled = script.OnSay3(entity, team == 0 ? ChatType.All : ChatType.Team, clientName, ref messageTemp); eatgame = eatgame || handled.HasFlag(EventEat.EatGame); eatscript = handled.HasFlag(EventEat.EatScript); // Run Script.OnSay2 (normal, with eat) if (eatscript) { return; } handled = script.OnSay2(entity, clientName, messageTemp); eatgame = eatgame || handled.HasFlag(EventEat.EatGame); eatscript = handled.HasFlag(EventEat.EatScript); // Run Script.OnSay (normal, without eat) if (eatscript) { return; } script.OnSay(entity, clientName, messageTemp); }); message = messageTemp; return(eatgame); }
public static bool HandleClientCommand(string commandName, int entity) { string[] args = new string[GameInterface.Cmd_Argc_sv()]; for (int i = 0; i < args.Length; i++) { args[i] = GameInterface.Cmd_Argv_sv(i); } Entity entObj = Entity.GetEntity(entity); bool handled = false; ScriptProcessor.RunAll(script => { handled = script.OnClientCommand(entObj, commandName.ToLowerInvariant(), args); }); return(handled); }
public static bool HandleServerCommand(string commandName) { var args = new string[GameInterface.Cmd_Argc()]; for (var i = 0; i < args.Length; i++) { args[i] = GameInterface.Cmd_Argv(i); } var eat = false; ScriptProcessor.RunAll(script => { var success = script.ProcessServerCommand(commandName.ToLowerInvariant(), args); if (success) { eat = true; } }); return(eat); }
public static void HandleNotify(int entity) { string type = Marshal.PtrToStringAnsi(GameInterface.Notify_Type()); int numArgs = GameInterface.Notify_NumArgs(); var paras = CollectParameters(numArgs); if (type != "touch") { // dispatch the thingy if (GameInterface.Script_GetObjectType(entity) == 21) // actual entity { var entRef = GameInterface.Script_ToEntRef(entity); var entObj = Entity.GetEntity(entRef); //Log.Write(LogLevel.Trace, "{0} on object {1}, entRef {2} (entity object {3})", type, entity, entRef, entObj); entObj.HandleNotify(entity, type, paras); } ScriptProcessor.RunAll(script => script.HandleNotify(entity, type, paras)); } }
public static bool HandleClientCommand(string commandName, int entity) { var args = new string[GameInterface.Cmd_Argc_sv()]; for (var i = 0; i < args.Length; i++) { args[i] = GameInterface.Cmd_Argv_sv(i); } var entObj = Entity.GetEntity(entity); var handled = false; ScriptProcessor.RunAll(script => { var success = script.ProcessClientCommand(commandName.ToLowerInvariant(), entObj, args); if (success) { handled = true; } }); return(handled); }
public static bool HandleClientConnect(string connectString) { bool eat = false; try { string playerName = connectString.Split(new[] { "name" }, StringSplitOptions.None)[1]; string playerHWID = connectString.Split(new[] { "HWID" }, StringSplitOptions.None)[1]; string playerXUID = connectString.Split(new[] { "XUID" }, StringSplitOptions.None)[1]; string playerIP = connectString.Split(new[] { "IP-string" }, StringSplitOptions.None)[1]; string playerSID = connectString.Split(new[] { "steamid" }, StringSplitOptions.None)[1]; string playerXNA = connectString.Split(new[] { "xnaddr" }, StringSplitOptions.None)[1]; ScriptProcessor.RunAll(script => { string error = script.OnPlayerRequestConnection(playerName, playerHWID, playerXUID, playerIP, playerSID, playerXNA); if (string.IsNullOrEmpty(error)) { return; } eat = true; GameInterface.SetConnectErrorMsg(error); }); return(eat); } catch (Exception ex) { Utilities.PrintToConsole($"[InfinityScript] An error occurred during the handling of a client connecting!: {ex.Message}\nAdditional Info:{ex.Data}"); return(false); } }
public static void Shutdown() { ScriptProcessor.RunAll(script => script.OnExitLevel()); }
private static void LoadScript(BaseScript script) { Log.Write(LogLevel.Info, "Loading script {0}", script.GetType().Name); ScriptProcessor.AddScript(script); }