コード例 #1
0
ファイル: EntityManager.cs プロジェクト: dogfood1/UServer3
        public static bool OnEntity(Entity entity)
        {
            var ent = BaseNetworkable.Get(entity.baseNetworkable.uid);

            if (ent != null)
            {
                ent.OnEntityUpdate(entity);
                return(ent.OnEntity(entity));
            }
            var prefabId = entity.baseNetworkable.prefabID;

            if (prefabId == (UInt32)EPrefabUID.BasePlayer)
            {
                ent = new BasePlayer();
            }
            else if (prefabId == (UInt32)EPrefabUID.OreBonus)
            {
                ent = new OreBonus();
            }
            else if (entity.resource != null && Database.IsOreResource(prefabId))
            {
                ent = new OreResource();
            }
            else if (entity.heldEntity != null)
            {
                ent = new BaseHeldEntity();
            }
            else if (OpCodes.IsStorage(entity.baseNetworkable.prefabID))
            {
                ent = new StorageContainer();
            }
            else if (Database.IsCollectible(prefabId))
            {
                ent = new CollectibleEntity();
            }
            else if (Database.IsBaseResource(prefabId))
            {
                ent = new BaseResource();
            }
            else if (entity.worldItem != null && Database.IsComponent(entity.worldItem.item.itemid))
            {
                //new WorldItem();
            }

            if (ent == null)
            {
                return(false);
            }
            ent.OnEntityCreate(entity);
            return(ent.OnEntity(entity));
        }