private void MsgCallBack(MsgInformationEx MsgDTO) { Task.Factory.StartNew(() => { try { var bindAi = RestrictorSvc.AllocateBindAi(MsgDTO); IEnumerable <AIBase> groups; if (string.IsNullOrEmpty(bindAi)) { groups = AIGroup.Where(p => (int)p.PriorityLevel >= (int)AIPriority.System); } else { MsgDTO.BindAi = bindAi; groups = AIGroup; } foreach (var ai in groups) { if (ai.OnMsgReceived(MsgDTO)) { break; } } } catch (Exception ex) { Logger.Log(ex); } }); }
public AIGroup GetAIGroup(string id) { int key = CRC32.GetHashForAnsi(id); AIGroup aiGroup = null; m_aiGroup.TryGetValue(key, out aiGroup); return(aiGroup); }
public override NPC SpawnMinion(NPCEntry entry, ref Vector3 position, int durationMillis) { var minion = base.SpawnMinion(entry, ref position, durationMillis); if (Group == null) { Group = new AIGroup(this); } Group.Add(minion); return(minion); }
/// <summary> /// /// </summary> /// <param name="teamId"></param> /// <param name="agent"></param> public void AddAgent(string teamId, AIAgent agent) { int key = CRC32.GetHashForAnsi(teamId); AIGroup group = null; if (!m_aiGroup.TryGetValue(key, out group)) { m_aiGroup.Add(key, new AIGroup(teamId)); } RemoveAgent(agent); m_aiGroup[key].AddAgent(agent); }
public void OnGroupChange(AIGroup newGroup) { //if (newGroup != null) //{ // // now in new/different group // DefaultState = newGroup.DefaultState; // EnterDefaultState(); //} //else //{ // // left Group // DefaultState = DefaultBrainState; // if (m_currentAction != null && m_currentAction.IsGroupAction) // { // m_currentAction.Stop(); // EnterDefaultState(); // } //} }
public void SetCrosshair(Vector3 p, string id = "basic") { Vector3 ProposedPosition = p; //make sure it's not inside an obstacle for (int i = 0; i < m_Obstacles.Count; ++i) { AIObject curOb = m_Obstacles[i]; if (MathUtil.PointInCircle(curOb.VPos(), curOb.BRadius(), ProposedPosition)) { return; } } AIGroup aiGroup = GetAIGroup(id); if (aiGroup != null) { aiGroup.SetCrosshair(p); } }
/// <summary> /// 加载世界线 /// </summary> public void Load() { Logger.Log($"{Name} WorldLine is starting up..."); try { AIGroup = AIGroup.Where(a => a != null && a.Enable).OrderByDescending(a => a.PriorityLevel).ToList(); var count = AIGroup.Count; Logger.Log("AI 加载中..."); for (var i = 0; i < AIGroup.Count; i++) { AIGroup[i].Initialization(); Logger.Log($"{AIGroup[i].AIName}({i + 1}/{count})"); } CmdTag.CreateCmdTree(CmdTagTree, AllAvailableGroupCommands); } catch (Exception ex) { Logger.Log(ex); } }
public NPCSpawnPool(Map map, NPCSpawnPoolTemplate templ) : base(map, templ) { AIGroup = new AIGroup(); }
public T AIInstance <T>() where T : AIBase { return(AIGroup.FirstOrDefault(ai => ai.GetType().Name == typeof(T).Name) as T); }
/// <summary> /// 群成员变动事件 /// </summary> /// <param name="model"></param> public void OnGroupMemberChanged(GroupMemberChangeModel model) { if (AIGroup.Any(ai => ai.OnGroupMemberChanged(model))) { } }
/// <summary> /// 收款到账事件 /// </summary> /// <param name="model"></param> public void OnMoneyReceived(ChargeModel model) { if (AIGroup.Any(ai => ai.OnMoneyReceived(model))) { } }
public void OnGroupChange(AIGroup newGroup) { }
public void CreateGroup() { Group = new AIGroup(Owner); }
public void SetAIGroup(AIGroup aiGroup) { m_aiGroup = aiGroup; }