public T GetBehaviour <T>() where T : class, INPCBehaviour { INPCBehaviour behaviour = null; m_behavioursByType.TryGetValue(typeof(T), out behaviour); return(behaviour as T); }
public NPCInstance CreateNPC(Fiber fiber, NPCSpawnModel spawn, MapData mapData) { NPCModel npc = m_npcRepository.GetNPCByID(spawn.NPCID); List <INPCBehaviour> behaviours = new List <INPCBehaviour>(); foreach (NPCBehaviourModel behaviourModel in m_npcRepository.GetNPCBehavioursByNPCID(spawn.NPCID).OrderBy(b => b.ExecutionOrder)) { INPCBehaviour behaviour = (INPCBehaviour)Activator.CreateInstance(m_behaviourTypes[behaviourModel.NPCBehaviourID]); IReadOnlyDictionary <string, string> behaviourVars = m_npcRepository.GetNPCBehaviourVarsByNPCBehaviourID(behaviourModel.NPCBehaviourID); behaviour.Initialise(behaviourVars); behaviours.Add(behaviour); } IReadOnlyDictionary <StatType, float> stats = m_npcRepository.GetNPCStatsByNPCID(spawn.NPCID).ToDictionary(kvp => (StatType)kvp.Key, kvp => kvp.Value); NPCInstance npcInstance = new NPCInstance(fiber, npc, spawn, behaviours, stats, mapData); return(npcInstance); }
public MineBlockNode(INPCBehaviour npc) : base(npc) { }