Beispiel #1
0
        PeEntity CreadteDoodad(DoodadSpawnPoint point, bool is_save)
        {
            PeEntity entity = null;

            if (is_save)
            {
                if (point.EntityID == -1)
                {
                    int id = Pathea.WorldInfoMgr.Instance.FetchRecordAutoId();
                    entity         = CreatureMgr.Instance.CreateDoodad(CustomGameData.Mgr.Instance.curGameData.WorldIndex, id, point.Prototype);
                    point.EntityID = entity.Id;

                    _initDoodad(entity, point);
                }
                else
                {
                    //PeEntity ent = EntityMgr.Instance.Get(point.EntityID);
                    entity = CreatureMgr.Instance.CreateDoodad(CustomGameData.Mgr.Instance.curGameData.WorldIndex, point.EntityID, point.Prototype);
                    if (entity == null)
                    {
                        Debug.LogError("Cant Find the Entity [ID " + point.EntityID.ToString() + "]");
                    }
                }
            }
            else
            {
                Pathea.WorldInfoMgr.Instance.FetchNonRecordAutoId();
                entity         = PeEntityCreator.Instance.CreateDoodad(Pathea.WorldInfoMgr.Instance.FetchNonRecordAutoId(), point.Prototype, Vector3.zero, Quaternion.identity, Vector3.one);
                point.EntityID = entity.Id;

                _initDoodad(entity, point);
            }

            if (entity != null)
            {
                entity.scenarioId = point.ID;
                PeScenarioEntity pse = entity.gameObject.GetComponent <PeScenarioEntity>();
                if (pse == null)
                {
                    pse = entity.gameObject.AddComponent <PeScenarioEntity>();
                }
                pse.spawnPoint = point;
            }

            return(entity);
        }