//正在进行的行为使用 //返回值 Ture 当前type可以执行 public static bool CanDoing(PeEntity entity, EThinkingType _newtThink) { NpcCmpt npc = entity.NpcCmpt; if (npc == null) { return(true); } if (!npc.ThinkAgent.CanDo(_newtThink)) { EThinkingType _curThinkType = npc.ThinkAgent.GetNowDo(); //NpcThinking curthink = Get(_curThinkType); NpcThinking newthink = Get(_newtThink); //1:阻塞当前行为,执行新加入行为 if (newthink.GetMask(_curThinkType) == EThinkingMask.Block) { npc.ThinkAgent.RemoveThink(_curThinkType); npc.ThinkAgent.RemoveThink(_newtThink); npc.ThinkAgent.AddThink(_curThinkType); npc.ThinkAgent.AddThink(_newtThink); return(true); } //-1:阻塞新加入行为,执行当前行为 if (newthink.GetMask(_curThinkType) == EThinkingMask.Blocked) { npc.ThinkAgent.RemoveThink(_newtThink); npc.ThinkAgent.RemoveThink(_curThinkType); npc.ThinkAgent.AddThink(_newtThink); npc.ThinkAgent.AddThink(_curThinkType); return(false); } //接受新的行为,删除当前行为 if (newthink.GetMask(_curThinkType) == EThinkingMask.Delete) { npc.ThinkAgent.RemoveThink(_curThinkType); npc.ThinkAgent.AddThink(_newtThink); return(true); } //不接收新的 if (newthink.GetMask(_curThinkType) == EThinkingMask.Deleted) { //no noth return(false); } } return(true); }
public static void LoadData() { Mono.Data.SqliteClient.SqliteDataReader reader = LocalDatabase.Instance.ReadFullTable("NPCThinking"); // int fieldCount = reader.FieldCount - 2; _sThinking = new Dictionary <EThinkingType, NpcThinking>(); while (reader.Read()) { NpcThinking think = new NpcThinking(); think.ID = reader.GetInt32(0); think.Type = (EThinkingType)think.ID; think.Name = reader.GetString(1); for (int i = 2; i < reader.FieldCount; i++) { think.mThinkInfo.Add((EThinkingType)(i - 1), (EThinkingMask)reader.GetInt32(i)); } _sThinking.Add(think.Type, think); } }