AddEntity() публичный Метод

public AddEntity ( int unitId, int camp, TableConfig cfg, int ai ) : EntityInfo
unitId int
camp int
cfg TableConfig
ai int
Результат EntityInfo
Пример #1
0
 static public int AddEntity(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 6)
         {
             GameFramework.EntityManager self = (GameFramework.EntityManager)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             TableConfig.Actor a3;
             checkType(l, 4, out a3);
             System.String a4;
             checkType(l, 5, out a4);
             System.String[] a5;
             checkParams(l, 6, out a5);
             var ret = self.AddEntity(a1, a2, a3, a4, a5);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (argc == 7)
         {
             GameFramework.EntityManager self = (GameFramework.EntityManager)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             System.Int32 a3;
             checkType(l, 4, out a3);
             TableConfig.Actor a4;
             checkType(l, 5, out a4);
             System.String a5;
             checkType(l, 6, out a5);
             System.String[] a6;
             checkParams(l, 7, out a6);
             var ret = self.AddEntity(a1, a2, a3, a4, a5, a6);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
        private void LoadObjects()
        {
            LogSys.Log(LOG_TYPE.DEBUG, "Scene {0} start Running.", m_SceneResId);
            m_GameTime.Start();
            m_SceneContext.StartTime = m_GameTime.StartTime;

            for (int campId = (int)CampIdEnum.Friendly; campId <= (int)CampIdEnum.Red; ++campId)
            {
                int key = this.SceneResId * 10 + campId;
                List <TableConfig.LevelMonster> monsters;
                if (TableConfig.LevelMonsterProvider.Instance.TryGetValue(key, out monsters))
                {
                    for (int i = 0; i < monsters.Count; ++i)
                    {
                        TableConfig.LevelMonster monster = monsters[i];
                        if (null != monster)
                        {
                            TableConfig.Actor actor = TableConfig.ActorProvider.Instance.GetActor(monster.actorID);
                            if (null != actor)
                            {
                                int        unitId = campId * 10000 + i;
                                EntityInfo npc    = EntityManager.AddEntity(unitId, campId, actor, (int)AiStateLogicId.Entity_General);
                                if (null != npc)
                                {
                                    npc.IsPassive        = monster.passive;
                                    npc.LevelMonsterData = monster;
                                    npc.SetLevel(monster.level);
                                    npc.GetMovementStateInfo().SetPosition2D(monster.x, monster.y);
                                    npc.GetMovementStateInfo().SetFaceDir(Geometry.DegreeToRadian(monster.dir));
                                }
                            }
                        }
                    }
                }
            }

            ServerStorySystem.ThreadInitMask();
            m_StorySystem.ClearStoryInstancePool();
            m_StorySystem.PreloadSceneStories();
            m_StorySystem.StartStory("local_main");
            m_StorySystem.StartStory("story_main");
        }
Пример #3
0
        internal void ReloadObjects()
        {
            if (m_PreparedReloadMonsterCount > 0)
            {
                for (int i = 0; i < m_PreparedReloadMonsterCount; ++i)
                {
                    TableConfig.LevelMonster monster = m_PreparedReloadMonsters[i];
                    if (null != monster)
                    {
                        int campId = monster.camp;
                        TableConfig.Actor actor = TableConfig.ActorProvider.Instance.GetActor(monster.actorID);
                        if (null != actor)
                        {
                            int        unitId = campId * 10000 + i;
                            EntityInfo npc    = EntityManager.AddEntity(unitId, campId, actor, (int)AiStateLogicId.Entity_General);
                            if (null != npc)
                            {
                                npc.IsPassive        = monster.passive;
                                npc.LevelMonsterData = monster;
                                npc.SetLevel(monster.level);
                                npc.GetMovementStateInfo().SetPosition2D(monster.x, monster.y);
                                npc.GetMovementStateInfo().SetFaceDir(monster.dir);

                                Msg_RC_CreateNpc msg = DataSyncUtility.BuildCreateNpcMessage(npc);
                                NotifyAllUser(RoomMessageDefine.Msg_RC_CreateNpc, msg);

                                Msg_RC_SyncProperty msg2 = DataSyncUtility.BuildSyncPropertyMessage(npc);
                                NotifyAllUser(RoomMessageDefine.Msg_RC_SyncProperty, msg2);
                            }
                        }
                    }
                }
                m_PreparedReloadMonsterCount = 0;
            }
            while (m_ReloadMonstersQueue.Count > 0 && m_PreparedReloadMonsterCount < c_MaxReloadMonsterNum)
            {
                m_PreparedReloadMonsters[m_PreparedReloadMonsterCount++] = m_ReloadMonstersQueue.Dequeue();
            }
        }