// LUA可以调用 public AI_Command CreateAICommand(string aiName, string commandName = "") { if (string.IsNullOrEmpty(aiName)) { return(null); } if (string.IsNullOrEmpty(commandName)) { commandName = aiName; } AI_Command ret; if (m_AICmdMap == null) { m_AICmdMap = new Dictionary <string, AI_Command>(); ret = new AI_Command(); ret.name = aiName; ret.command = commandName; } else { if (!m_AICmdMap.TryGetValue(aiName, out ret)) { ret = new AI_Command(); ret.name = aiName; ret.command = commandName; } else { ret.command = commandName; } } m_AICmdMap[aiName] = ret; return(ret); }
public AI_Command GetAICommand(Cmd_Command command, PlayerDisplay display, out bool mustCheckTrigger) { mustCheckTrigger = true; if (command == null || m_AICmdMap == null) { return(null); } string aiName = command.aiName; if (!string.IsNullOrEmpty(aiName)) { AI_Command cmd; if (!m_AICmdMap.TryGetValue(aiName, out cmd)) { cmd = null; } return(cmd); } else { if (display == null || display.LuaPly == null) { return(null); } AI_Command finder = null; // 遍历所有条件,如果没有满足的再调用LUA的方法GetAIName var iter = m_AICmdMap.GetEnumerator(); while (iter.MoveNext()) { var aiCmd = iter.Current.Value; if (aiCmd != null && aiCmd.OnTriggerEvent != null) { if (aiCmd.CanTrigger(display, command.name)) { mustCheckTrigger = false; finder = aiCmd; break; } } } iter.Dispose(); if (finder != null) { return(finder); } aiName = display.Call_LuaPly_GetAIName(command.name); if (string.IsNullOrEmpty(aiName)) { return(null); } AI_Command cmd; if (!m_AICmdMap.TryGetValue(aiName, out cmd)) { cmd = null; } return(cmd); } }
static int CreateAICmd(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2) { LuaCnsConfig obj = (LuaCnsConfig)ToLua.CheckObject <LuaCnsConfig>(L, 1); string arg0 = ToLua.CheckString(L, 2); Mugen.AI_Command o = obj.CreateAICmd(arg0); ToLua.PushObject(L, o); return(1); } else if (count == 3) { LuaCnsConfig obj = (LuaCnsConfig)ToLua.CheckObject <LuaCnsConfig>(L, 1); string arg0 = ToLua.CheckString(L, 2); string arg1 = ToLua.CheckString(L, 3); Mugen.AI_Command o = obj.CreateAICmd(arg0, arg1); ToLua.PushObject(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: LuaCnsConfig.CreateAICmd")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetAICommand(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); LuaCnsConfig obj = (LuaCnsConfig)ToLua.CheckObject <LuaCnsConfig>(L, 1); string arg0 = ToLua.CheckString(L, 2); Mugen.AI_Command o = obj.GetAICommand(arg0); ToLua.PushObject(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int get_type(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); Mugen.AI_Command obj = (Mugen.AI_Command)o; Mugen.AI_Type ret = obj.type; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index type on a nil value")); } }
static int get_value(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); Mugen.AI_Command obj = (Mugen.AI_Command)o; string ret = obj.value; LuaDLL.lua_pushstring(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index value on a nil value")); } }
static int set_OnTriggerEvent(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); Mugen.AI_Command obj = (Mugen.AI_Command)o; System.Func <LuaInterface.LuaTable, string, bool> arg0 = (System.Func <LuaInterface.LuaTable, string, bool>)ToLua.CheckDelegate <System.Func <LuaInterface.LuaTable, string, bool> >(L, 2); obj.OnTriggerEvent = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index OnTriggerEvent on a nil value")); } }
static int set_command(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); Mugen.AI_Command obj = (Mugen.AI_Command)o; string arg0 = ToLua.CheckString(L, 2); obj.command = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index command on a nil value")); } }
static int set_type(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); Mugen.AI_Command obj = (Mugen.AI_Command)o; Mugen.AI_Type arg0 = (Mugen.AI_Type)ToLua.CheckObject(L, 2, typeof(Mugen.AI_Type)); obj.type = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index type on a nil value")); } }
static int get_OnTriggerEvent(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); Mugen.AI_Command obj = (Mugen.AI_Command)o; System.Func <LuaInterface.LuaTable, string, bool> ret = obj.OnTriggerEvent; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index OnTriggerEvent on a nil value")); } }
static int _CreateMugen_AI_Command(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 0) { Mugen.AI_Command obj = new Mugen.AI_Command(); ToLua.PushObject(L, obj); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: Mugen.AI_Command.New")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public bool LoadFromReader(ConfigReader reader) { Clear(); if (reader == null) { return(false); } ConfigSection section = reader.GetSection("Remap"); if (section != null) { m_Remap = new Cmd_Remap(); if (!section.GetPropertysValues(m_Remap)) { m_Remap = null; } } section = reader.GetSection("Defaults"); if (section != null) { for (int i = 0; i < section.ContentListCount; ++i) { string key, value; if (section.GetKeyValue(i, out key, out value)) { if (string.Compare(key, "command.time", true) == 0) { m_Command__Time = int.Parse(value); } else if (string.Compare(key, "command.buffer.time", true) == 0) { m_Command__Buffer__Time = int.Parse(value); } } } } // 创建Command for (int i = 0; i < reader.SectionCount; ++i) { section = reader.GetSections(i); if (section == null) { continue; } if (string.Compare(section.Tile, "Command", true) == 0) { Cmd_Command cmd = null; for (int j = 0; j < section.ContentListCount; ++j) { string key, value; if (section.GetKeyValue(j, out key, out value)) { if (string.Compare(key, "name", true) == 0) { if (cmd == null) { cmd = new Cmd_Command(); } cmd.name = value; } else if (string.Compare(key, "time", true) == 0) { if (cmd == null) { cmd = new Cmd_Command(); } cmd.time = int.Parse(value); } else if (string.Compare(key, "buffer.time", true) == 0) { if (cmd == null) { cmd = new Cmd_Command(); } cmd.buffer__time = int.Parse(value); } else if (string.Compare(key, "command", true) == 0) { if (cmd == null) { cmd = new Cmd_Command(); } cmd.keyCommands = ConfigSection.Split(value); } } } if (cmd != null && !string.IsNullOrEmpty(cmd.name)) { AddCommand(cmd); } } else if (section.Tile.StartsWith("State -1", StringComparison.CurrentCultureIgnoreCase)) { string[] names = ConfigSection.Split(section.Tile); if (names == null || names.Length < 2) { continue; } string aiName = names [1]; AI_Type aiType = AI_Type.none; AI_Command aiCmd = null; for (int j = 0; j < section.ContentListCount; ++j) { string key, value; if (section.GetKeyValue(j, out key, out value)) { if (string.Compare(key, "type", true) == 0) { if (string.Compare(value, "ChangeState", true) == 0) { aiType = AI_Type.ChangeState; if (aiCmd == null) { aiCmd = new AI_Command(); aiCmd.type = aiType; aiCmd.name = aiName; } } } else { if (aiCmd == null) { continue; } if (string.Compare(key, "value", true) == 0) { aiCmd.value = value; } else if (string.Compare(key, "triggerall", true) == 0) { if (value.StartsWith("command", StringComparison.CurrentCultureIgnoreCase)) { int idx = value.IndexOf("="); if (idx >= 0) { aiCmd.command = value.Substring(idx + 1, value.Length - idx - 1).Trim(); if (!string.IsNullOrEmpty(aiCmd.command)) { Cmd_Command cmdCmd = GetCommand(aiCmd.command); if (cmdCmd != null) { cmdCmd.aiName = aiCmd.name; } } } } } } } } if (aiCmd == null || aiCmd.type == AI_Type.none) { continue; } if (m_AICmdMap == null) { m_AICmdMap = new Dictionary <string, AI_Command> (); } m_AICmdMap [aiCmd.name] = aiCmd; } } return(true); }