Ejemplo n.º 1
0
        public void LoadInto(ResourceAssets resourceAssets)
        {
            foreach (GameObjectAsset placeholderGroup in GameObjectAssetParser.GameObjectsByAssetId.Values)
            {
                List <AssetIdentifier> prefabPlaceholders;

                if (!PrefabPlaceholdersGroupParser.PrefabPlaceholderIdsByGameObjectId.TryGetValue(placeholderGroup.Identifier, out prefabPlaceholders))
                {
                    continue;
                }

                string placeholderGroupClassId = PrefabIdentifierParser.ClassIdByGameObjectId[placeholderGroup.Identifier];

                List <PrefabAsset> spawnablePrefabs = new List <PrefabAsset>();

                foreach (AssetIdentifier prefabPlaceholderId in prefabPlaceholders)
                {
                    PrefabPlaceholderAsset prefabPlaceholderAsset = PrefabPlaceholderParser.PrefabPlaceholderIdToPlaceholderAsset[prefabPlaceholderId];
                    spawnablePrefabs.Add(CreatePrefabAsset(prefabPlaceholderAsset.GameObjectIdentifier, prefabPlaceholderAsset.ClassId));
                }

                GameObjectAsset gameObject     = GameObjectAssetParser.GameObjectsByAssetId[placeholderGroup.Identifier];
                TransformAsset  localTransform = GetTransform(gameObject);

                List <PrefabAsset> existingPrefabs = GetChildPrefabs(localTransform);

                resourceAssets.PrefabPlaceholderGroupsByGroupClassId[placeholderGroupClassId] = new PrefabPlaceholdersGroupAsset(spawnablePrefabs, existingPrefabs);
            }
        }
Ejemplo n.º 2
0
        public void LoadInto(ResourceAssets resourceAssets)
        {
            foreach (GameObjectAsset placeholderGroup in GameObjectAssetParser.GameObjectsByAssetId.Values)
            {
                List <AssetIdentifier> prefabPlaceholders;

                if (!PrefabPlaceholdersGroupParser.PrefabPlaceholderIdsByGameObjectId.TryGetValue(placeholderGroup.Identifier, out prefabPlaceholders))
                {
                    continue;
                }

                string placeholderGroupClassId = PrefabIdentifierParser.ClassIdByGameObjectId[placeholderGroup.Identifier];

                List <PrefabAsset> prefabs;

                if (!resourceAssets.PlaceholderPrefabsByGroupClassId.TryGetValue(placeholderGroupClassId, out prefabs))
                {
                    prefabs = new List <PrefabAsset>();
                    resourceAssets.PlaceholderPrefabsByGroupClassId[placeholderGroupClassId] = prefabs;
                }

                foreach (AssetIdentifier prefabPlaceholderId in prefabPlaceholders)
                {
                    PrefabPlaceholderAsset prefabPlaceholderAsset = PrefabPlaceholderParser.PrefabPlaceholderIdToPlaceholderAsset[prefabPlaceholderId];
                    GameObjectAsset        prefabPlaceholder      = GameObjectAssetParser.GameObjectsByAssetId[prefabPlaceholderAsset.GameObjectIdentifier];
                    TransformAsset         localTransform         = GetTransform(prefabPlaceholder);

                    prefabs.Add(new PrefabAsset(prefabPlaceholderAsset.ClassId, localTransform));
                }
            }
        }
Ejemplo n.º 3
0
        private Optional <NitroxEntitySlot> GetEntitySlot(string classId)
        {
            AssetIdentifier prefabId   = PrefabIdentifierParser.GameObjectIdByClassId[classId];
            GameObjectAsset gameObject = GameObjectAssetParser.GameObjectsByAssetId[prefabId];

            EntitySlotParser.EntitySlotsByIdentifier.TryGetValue(gameObject.Identifier, out NitroxEntitySlot entitySlot);

            return(Optional.OfNullable(entitySlot));
        }
Ejemplo n.º 4
0
        private PrefabAsset CreatePrefabAsset(AssetIdentifier gameObjectId, string classId)
        {
            GameObjectAsset gameObject     = GameObjectAssetParser.GameObjectsByAssetId[gameObjectId];
            TransformAsset  localTransform = GetTransform(gameObject);

            Optional <NitroxEntitySlot> entitySlot = (classId != null) ? GetEntitySlot(classId) : Optional.Empty;
            List <PrefabAsset>          children   = GetChildPrefabs(localTransform);

            return(new PrefabAsset(gameObject.Name, classId, localTransform, entitySlot, children));
        }
Ejemplo n.º 5
0
        private TransformAsset GetTransform(GameObjectAsset gameObjectAsset)
        {
            foreach (AssetIdentifier componentIdentifier in gameObjectAsset.Components)
            {
                if (TransformAssetParser.TransformsByAssetId.TryGetValue(componentIdentifier, out TransformAsset transform))
                {
                    return(transform);
                }
            }

            throw new Exception("No transform found for " + gameObjectAsset.Identifier);
        }
Ejemplo n.º 6
0
        public override void Parse(AssetIdentifier identifier, AssetsFileReader reader, ResourceAssets resourceAssets)
        {
            GameObjectAsset gameObjectAsset = new GameObjectAsset();

            gameObjectAsset.Identifier = identifier;

            uint componentCount = reader.ReadUInt32();

            for (int i = 0; i < componentCount; i++)
            {
                AssetIdentifier component = new AssetIdentifier(reader.ReadInt32(), reader.ReadInt64());
                gameObjectAsset.Components.Add(component);
            }

            GameObjectsByAssetId.Add(identifier, gameObjectAsset);
        }
        public override void Parse(AssetIdentifier identifier, AssetsFileReader reader, ResourceAssets resourceAssets, Dictionary <int, string> relativeFileIdToPath)
        {
            GameObjectAsset gameObjectAsset = new GameObjectAsset();

            gameObjectAsset.Identifier = identifier;

            uint componentCount = reader.ReadUInt32();

            for (int i = 0; i < componentCount; i++)
            {
                AssetIdentifier component = new AssetIdentifier(relativeFileIdToPath[reader.ReadInt32()], reader.ReadInt64());
                gameObjectAsset.Components.Add(component);
            }

            reader.ReadUInt32(); // Layer (not used)

            int length = reader.ReadInt32();

            gameObjectAsset.Name = reader.ReadStringLength(length);

            GameObjectsByAssetId.Add(identifier, gameObjectAsset);
        }
Ejemplo n.º 8
0
        private void InitObject(GameObject obj, GameObjectAsset asset)
        {
            GameObject go = GameObject.Instantiate(obj) as GameObject;

            go.transform.position   = asset.pos;
            go.transform.rotation   = asset.rotation;
            go.transform.localScale = asset.scale;
            if (go.renderer != null)
            {
                go.transform.parent = sceneParent.transform;
                go.AddComponent <MeshCollider>();
                go.renderer.lightmapIndex        = asset.lightmapIndex;
                go.renderer.lightmapTilingOffset = asset.lightmapTilingOffset;
            }
            if (go.animation != null)
            {
                go.transform.parent = sceneParent.transform;
            }
            if (go.name.IndexOf("PlayerLight_") >= 0)
            {
                SceneLight = go;
                go.transform.localPosition = new Vector3(0, asset.pos.y, 0);
                go.transform.localRotation = UnityEngine.Quaternion.identity;
                go.transform.localScale    = UnityEngine.Vector3.one;
                if (go.transform.localPosition.y < 2 || go.transform.localPosition.y > 10)
                {
                    go.transform.localPosition = new Vector3(0, 6, 0);
                }
                go.light.cullingMask = CameraLayerManager.GetInstance().GetSceneObjectLightCullingMask();
                SceneView.GetInstance().SetSceneLight();
            }
            if (go.name.IndexOf("SunLight_") >= 0)
            {
                go.light.cullingMask = CameraLayerManager.GetInstance().GetSceneObjectSunLightCullingMask();
                go.transform.parent  = sceneParent.transform;
            }
        }
Ejemplo n.º 9
0
    public void AddAssets(Dictionary <string, GameObject> assets)
    {
        if (assets == null)
        {
            return;
        }

        foreach (KeyValuePair <string, GameObject> asset in assets)
        {
            GameObjectAsset sameAsset = Assets.Find((_asset) => _asset.Name == asset.Key);

            if (sameAsset == null)
            {
                Assets.Add(new GameObjectAsset()
                {
                    Name = asset.Key, Asset = asset.Value
                });
            }
            else
            {
                Debug.LogError("assets contains key " + asset.Key);
            }
        }
    }
Ejemplo n.º 10
0
 private bool CheckSceneUnit(GameObjectAsset asset, Vector3 rolePos)
 {
     return(true);
 }