Esempio n. 1
0
 public float GetSceneScale(PrefabInfo prefab)
 {
     float value;
     if (sceneScale.TryGetValue (prefab, out value)) {
         return value;
     } else {
         Debug.LogErrorFormat ("{0} not in database!", prefab.fileName);
         return 0f;
     }
 }
 protected int ItemsGenericCategorySort(PrefabInfo a, PrefabInfo b)
 {
     if (a.editorCategory == b.editorCategory)
     {
         return a.m_UIPriority.CompareTo(b.m_UIPriority);
     }
     else
     {
         var aID = Array.FindIndex(this.m_editorCategories, c => c == a.editorCategory);
         var bID = Array.FindIndex(this.m_editorCategories, c => c == b.editorCategory);
         return aID - bID;
     }
 }
Esempio n. 3
0
    public void SavePrefabInformation(GeneratablePrefab prefab, string assetPath, bool shouldRecomputePrefabInformation, bool replaceOld = true)
    {
        /*
         * Saves the prefab information in "prefabs" property of PrefabDatabase prefab.
         */
        string newFileName = "";
        if (assetPath == null) {
            const string resPrefix = "Resources/";
            assetPath = AssetDatabase.GetAssetPath (prefab);
            if (string.IsNullOrEmpty (assetPath))
                return;
            newFileName = assetPath.Substring (assetPath.LastIndexOf (resPrefix) + resPrefix.Length);
            newFileName = newFileName.Substring (0, newFileName.LastIndexOf ("."));
        } else {
            if (!(assetPath.ToLowerInvariant ().Contains ("http://"))) {
                const string resPrefix = BUNDLES_SUBPATH;
                string currentPath = Directory.GetCurrentDirectory ();
                newFileName = Path.Combine (currentPath, assetPath);
            } else {
                newFileName = assetPath;
            }
        }
        int replaceIndex = -1;
        if (replaceOld) {
            replaceIndex = prefabs.FindIndex ((PrefabInfo testInfo) => {
                return testInfo.fileName == newFileName;
            });
            if (replaceIndex >= 0)
                prefabs.RemoveAt (replaceIndex);
        }

        if (prefab.shouldUse) {

            if (shouldRecomputePrefabInformation)
                prefab.ProcessPrefab ();
            PrefabInfo newInfo = new PrefabInfo ();
            newInfo.fileName = newFileName;
            newInfo.complexity = prefab.myComplexity;
            newInfo.bounds = prefab.myBounds;
            newInfo.isLight = prefab.isLight;
            newInfo.anchorType = prefab.attachMethod;
            foreach (GeneratablePrefab.StackableInfo stackRegion in prefab.stackableAreas)
                newInfo.stackableAreas.Add (stackRegion);
            if (replaceIndex < 0)
                prefabs.Add (newInfo);
            else
                prefabs.Insert (replaceIndex, newInfo);
        }
        EditorUtility.SetDirty (this);
    }
Esempio n. 4
0
        private static void DrawTextFrame(BoardTextDescriptorGeneralXml textDescriptor, MaterialPropertyBlock materialPropertyBlock, ref Vector3 targetPos, ref Vector3 targetRotation, ref Vector3 baseScale, ref Color parentColor, PrefabInfo srcInfo, Camera targetCamera, ref Matrix4x4 containerMatrix, ref int defaultCallsCounter)
        {
            var frameConfig = textDescriptor.BackgroundMeshSettings.FrameMeshSettings;

            if (m_genMesh is null)
            {
                WTSDisplayContainerMeshUtils.GenerateDisplayContainer(new Vector2(1, 1), new Vector2(1, 1), new Vector2(), 0.05f, 0.3f, 0.1f, out Vector3[] points, out Vector4[] tangents);
Esempio n. 5
0
        public static string GetLocalizedTitle(PrefabInfo prefab)
        {
            string name = prefab.name;

            if (prefab is BuildingInfo)
            {
                if (!Locale.GetUnchecked("BUILDING_TITLE", prefab.name, out name))
                {
                    name = prefab.name;
                }
                else
                {
                    name = name.Replace(".", "");
                }
            }
            else if (prefab is PropInfo)
            {
                if (!Locale.GetUnchecked("PROPS_TITLE", prefab.name, out name))
                {
                    name = prefab.name;
                }
                else
                {
                    name = name.Replace(".", "");
                }
            }
            else if (prefab is TreeInfo)
            {
                if (!Locale.GetUnchecked("TREE_TITLE", prefab.name, out name))
                {
                    name = prefab.name;
                }
                else
                {
                    name = name.Replace(".", "");
                }
            }
            else if (prefab is NetInfo)
            {
                if (!Locale.GetUnchecked("NET_TITLE", prefab.name, out name))
                {
                    name = prefab.name;
                }
                else
                {
                    name = name.Replace(".", "");
                }
            }

            int index = name.IndexOf('.');

            if (index >= 0)
            {
                name = name.Substring(index + 1);
            }

            if (name.IsNullOrWhiteSpace())
            {
                name = prefab.name;
            }

            index = name.LastIndexOf("_Data");
            if (index >= 0)
            {
                name = name.Substring(0, index);
            }

            name = Regex.Replace(name, @"[_-]+", " ");
            name = Regex.Replace(name, @"([A-Z][a-z]+)", " $1");
            name = Regex.Replace(name, @"([^\d])(\d+)", "$1 $2");
            name = Regex.Replace(name, @"\b(.) (\d+)", " $1$2 ");
            name = Regex.Replace(name, @"(\d+) ?x (\d+)", " $1x$2 ");
            name = Regex.Replace(name, @"\s+", " ");

            name = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(name).Trim();

            return(name);
        }
Esempio n. 6
0
 /// <summary>
 /// Gets the mesh.
 /// </summary>
 /// <param name="prefab">The prefab.</param>
 /// <returns>
 /// The mesh.
 /// </returns>
 protected override Mesh GetMainMesh(PrefabInfo prefab)
 {
     return(GetMeshWithFallback(prefab, ((PropInfo)prefab).m_mesh));
 }
Esempio n. 7
0
        /// <summary>
        /// Sets the target prefab.
        /// </summary>
        /// <param name="targetPrefabInfo">Target prefab to set</param>
        internal override void SetTarget(PrefabInfo targetPrefabInfo)
        {
            // Don't do anything if invalid target, or target hasn't changed.
            if (!(targetPrefabInfo is BuildingInfo) || selectedPrefab == targetPrefabInfo)
            {
                return;
            }

            // Base setup.
            base.SetTarget(targetPrefabInfo);

            // Set target reference.
            currentBuilding = SelectedBuilding;

            // Does this building have sub-buildings?
            if (currentBuilding.m_subBuildings != null && currentBuilding.m_subBuildings.Length > 0)
            {
                // Yes - create lists of sub-buildings (names and infos).
                int numSubs    = currentBuilding.m_subBuildings.Length;
                int numChoices = numSubs + 1;
                SubBuildingNames    = new string[numChoices];
                subBuildings        = new BuildingInfo[numChoices];
                SubBuildingNames[0] = PrefabLists.GetDisplayName(currentBuilding);
                subBuildings[0]     = currentBuilding;

                object[] subBuildingIndexes = new object[numChoices];
                subBuildingIndexes[0] = 0;

                for (int i = 0; i < numSubs; ++i)
                {
                    SubBuildingNames[i + 1]   = PrefabLists.GetDisplayName(currentBuilding.m_subBuildings[i].m_buildingInfo);
                    subBuildings[i + 1]       = currentBuilding.m_subBuildings[i].m_buildingInfo;
                    subBuildingIndexes[i + 1] = i + 1;
                }

                // Add sub-building menu, if it doesn't already exist.
                if (subBuildingPanel == null)
                {
                    subBuildingPanel = this.AddUIComponent <UIPanel>();

                    // Basic behaviour.
                    subBuildingPanel.autoLayout    = false;
                    subBuildingPanel.canFocus      = true;
                    subBuildingPanel.isInteractive = true;

                    // Appearance.
                    subBuildingPanel.backgroundSprite = "MenuPanel2";
                    subBuildingPanel.opacity          = PanelOpacity;

                    // Size and position.
                    subBuildingPanel.size             = new Vector2(200f, PanelHeight - TitleHeight);
                    subBuildingPanel.relativePosition = new Vector2(-205f, TitleHeight);

                    // Heading.
                    UILabel subTitleLabel = UIControls.AddLabel(subBuildingPanel, 5f, 5f, Translations.Translate("BOB_PNL_SUB"), 190f);
                    subTitleLabel.textAlignment    = UIHorizontalAlignment.Center;
                    subTitleLabel.relativePosition = new Vector2(5f, (TitleHeight - subTitleLabel.height) / 2f);

                    // List panel.
                    UIPanel subBuildingListPanel = subBuildingPanel.AddUIComponent <UIPanel>();
                    subBuildingListPanel.relativePosition = new Vector2(Margin, TitleHeight);
                    subBuildingListPanel.width            = subBuildingPanel.width - (Margin * 2f);
                    subBuildingListPanel.height           = subBuildingPanel.height - TitleHeight - (Margin * 2f);


                    subBuildingList = UIFastList.Create <UISubBuildingRow>(subBuildingListPanel);
                    ListSetup(subBuildingList);

                    // Create return fastlist from our filtered list.
                    subBuildingList.rowsData = new FastList <object>
                    {
                        m_buffer = subBuildingIndexes,
                        m_size   = subBuildingIndexes.Length
                    };
                }
                else
                {
                    // If the sub-building panel has already been created. just make sure it's visible.
                    subBuildingPanel.Show();
                }
            }
            else
            {
                // Otherwise, hide the sub-building panel (if it exists).
                subBuildingPanel?.Hide();
            }

            // Populate target list and select target item.
            TargetList();

            // Apply Harmony rendering patches.
            RenderOverlays.CurrentBuilding = selectedPrefab as BuildingInfo;
            Patcher.PatchBuildingOverlays(true);
        }
Esempio n. 8
0
 public void CreateAssetItem(PrefabInfo info)
 {
     m_createAssetItem.Invoke(this, new object[] { info });
 }
Esempio n. 9
0
    private void InstantiatePrefabInternal(GameObject resource, ref PrefabInfo info)
    {
        if (resource != null) {
            GameObject inst = null;
            if (Application.isPlaying) {
                inst = Instantiate (resource) as GameObject;
                inst.name = inst.name.Replace ("(Clone)", "");
            } else {
                #if UNITY_EDITOR
                inst = PrefabUtility.InstantiatePrefab(resource) as GameObject;
                inst.name += "(Preview)";
                inst.hideFlags = HideFlags.DontSave;
                #endif
            }

            Transform trans = inst.transform;
            trans.SetParent (this.transform);
            if (!info.transformData.isInit) {
                info.transformData.Init ();
                info.transformData.isInit = true;
            }
            trans.localPosition = info.transformData.localPosition;
            trans.localRotation = info.transformData.localRotation;
            trans.localScale = info.transformData.localScale;

            info.instance = inst;

            #if UNITY_EDITOR
            EditorUtility.SetDirty(this);
            #endif
        }
    }
Esempio n. 10
0
        bool RegisterPrefab(String fullName, Package.Asset asset, CustomAssetMetaData metaData, PrefabInfo info, GameObject go)
        {
            PropInfo pi = go.GetComponent <PropInfo>();

            if (pi != null)
            {
                if (pi.m_lodObject != null)
                {
                    pi.m_lodObject.SetActive(false);
                }

                if (StorePropName(fullName))
                {
                    PrefabCollection <PropInfo> .InitializePrefabs("Custom Assets", pi, null);

                    return(true);
                }
            }

            TreeInfo ti = go.GetComponent <TreeInfo>();

            if (ti != null && StoreTreeName(fullName))
            {
                PrefabCollection <TreeInfo> .InitializePrefabs("Custom Assets", ti, null);

                return(true);
            }

            BuildingInfo bi = go.GetComponent <BuildingInfo>();

            if (bi != null)
            {
                if (bi.m_lodObject != null)
                {
                    bi.m_lodObject.SetActive(false);
                }

                if (StoreBuildingName(fullName))
                {
                    PrefabCollection <BuildingInfo> .InitializePrefabs("Custom Assets", bi, null);

                    bi.m_dontSpawnNormally = !IsCommonBuilding(fullName, asset, metaData);

                    if (bi.GetAI() is IntersectionAI)
                    {
                        loadedIntersections.Add(fullName);
                    }

                    return(true);
                }
            }

            VehicleInfo vi = go.GetComponent <VehicleInfo>();

            if (vi != null)
            {
                if (vi.m_lodObject != null)
                {
                    vi.m_lodObject.SetActive(false);
                }

                if (StoreVehicleName(fullName))
                {
                    PrefabCollection <VehicleInfo> .InitializePrefabs("Custom Assets", vi, null);

                    return(true);
                }
            }

            return(false);
        }
Esempio n. 11
0
        public bool LoadAsset(string fullName, Package.Asset asset, bool mainAsset = false)
        {
            if (asset == null)
            {
                return(StoreNotFoundName(fullName));
            }

            Profiler.Info("Loading asset {0}", asset.fullName);

            try
            {
                Profiler.Trace("Clearing stack");
                stack.Clear();

                if (mainAsset)
                {
                    Profiler.Info("Pushing {0} on stack", fullName);
                    stack.Push(fullName);
                }

                Profiler.Info("Stack count {0}, current {1}", stack.Count, Current);

                CustomAssetMetaData assetMetaData = InstantiateAssetMetaData(asset);

                // Always remember: assetRef may point to another package because the deserialization method accepts any asset with a matching checksum.
                // There is a bug in the 1.6.0 game update in this.
                fullName = asset.package.packageName + "." + assetMetaData.assetRef.name;

                //impl
                GameObject assetGameObject = InstantiateAssetGameObject(assetMetaData);
                assetGameObject.name = fullName;

                PrefabInfo assetPrefabInfo = InstantiateAssetPrefab(assetGameObject);

                if (mainAsset && Settings.instance.installDependencies && notFoundIndirect.Count > 0)
                {
                    return(HotloadManager.DeferLoad(fullName, notFoundIndirect.Keys.ToList()));
                }


                RegisterPrefab(fullName, asset, assetMetaData, assetPrefabInfo, assetGameObject);
                //impl
                if (mainAsset)
                {
                    Profiler.Trace("Popping {0} from stack", stack.Peek());
                    stack.Pop();
                }
                Profiler.Info("Stack count {0}", stack.Count);

                return(StorePrefabInfo(assetPrefabInfo));
            }
            catch (Exception e)
            {
                if (mainAsset)
                {
                    Profiler.Trace("Popping {0} from stack due to error {1}", stack.Peek(), e.Message);
                    stack.Pop();
                }
                Profiler.Error("Cannot load " + fullName, e);
                StoreFailedAssetName(fullName ?? asset.fullName, e);
                return(false);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Applies a new (or updated) pack replacement; basically an all-network replacement.
        /// </summary>
        /// <param name="target">Targeted (original) prop prefab</param>
        /// <param name="replacement">Replacment prop prefab</param>
        /// <param name="angle">Replacment prop angle adjustment</param>
        /// <param name="offsetX">Replacment X position offset</param>
        /// <param name="offsetY">Replacment Y position offset</param>
        /// <param name="offsetZ">Replacment Z position offset</param>
        /// <param name="probability">Replacement probability</param>
        private void Apply(PrefabInfo target, PrefabInfo replacement, float angle, float offsetX, float offsetY, float offsetZ, int probability)
        {
            // Make sure that target and replacement are the same type before doing anything.
            if (target == null || replacement == null || (target is TreeInfo && !(replacement is TreeInfo)) || (target is PropInfo) && !(replacement is PropInfo))
            {
                return;
            }

            Logging.Message("applying pack replacement for ", target.name);

            // Check to see if we already have a replacement entry for this prop - if so, revert the replacement first.
            if (replacements.ContainsKey(target))
            {
                Revert(target);
            }

            // Create new dictionary entry if none already exists.
            if (!replacements.ContainsKey(target))
            {
                replacements.Add(target, new BOBNetReplacement());
            }

            // Add/replace dictionary replacement data.
            replacements[target].references  = new List <NetPropReference>();
            replacements[target].tree        = target is TreeInfo;
            replacements[target].targetInfo  = target;
            replacements[target].target      = target.name;
            replacements[target].angle       = angle;
            replacements[target].offsetX     = offsetX;
            replacements[target].offsetY     = offsetY;
            replacements[target].offsetZ     = offsetZ;
            replacements[target].probability = probability;

            // Record replacement prop.
            replacements[target].replacementInfo = replacement;
            replacements[target].Replacement     = replacement.name;

            // Iterate through each loaded network and record props to be replaced.
            for (int i = 0; i < PrefabCollection <NetInfo> .LoadedCount(); ++i)
            {
                // Get local reference.
                NetInfo network = PrefabCollection <NetInfo> .GetLoaded((uint)i);

                // Skip any netorks without lanes.
                if (network.m_lanes == null)
                {
                    continue;
                }

                // Iterate through each lane.
                for (int laneIndex = 0; laneIndex < network.m_lanes.Length; ++laneIndex)
                {
                    // If no props in this lane, skip it and go to the next one.
                    if (network.m_lanes[laneIndex].m_laneProps?.m_props == null)
                    {
                        continue;
                    }

                    // Iterate through each prop in lane.
                    for (int propIndex = 0; propIndex < network.m_lanes[laneIndex].m_laneProps.m_props.Length; ++propIndex)
                    {
                        // Check for any currently active conflicting replacements.
                        if (NetworkReplacement.instance.GetOriginal(network, laneIndex, propIndex) != null)
                        {
                            // Active network replacement; skip this one.
                            continue;
                        }
                        else if (AllNetworkReplacement.instance.GetOriginal(network, laneIndex, propIndex) != null)
                        {
                            // Active all-network replacement; skip this one.
                            continue;
                        }
                        else
                        {
                            // Active pack replacement; skip this one.
                            PrefabInfo original = GetOriginal(network, laneIndex, propIndex);

                            if (original != null)
                            {
                                continue;
                            }
                        }

                        // Get this prop from network.
                        PrefabInfo thisProp = target is PropInfo ? (PrefabInfo)network.m_lanes[laneIndex].m_laneProps.m_props[propIndex].m_finalProp : (PrefabInfo)network.m_lanes[laneIndex].m_laneProps.m_props[propIndex].m_finalTree;

                        // See if this prop matches our replacement.
                        if (thisProp != null && thisProp == target)
                        {
                            // Match!  Add reference data to the list.
                            replacements[target].references.Add(new NetPropReference
                            {
                                network     = network,
                                laneIndex   = laneIndex,
                                propIndex   = propIndex,
                                angle       = network.m_lanes[laneIndex].m_laneProps.m_props[propIndex].m_angle,
                                postion     = network.m_lanes[laneIndex].m_laneProps.m_props[propIndex].m_position,
                                probability = network.m_lanes[laneIndex].m_laneProps.m_props[propIndex].m_probability
                            });
                        }
                    }
                }
            }

            // Now, iterate through each entry found and apply the replacement to each one.
            foreach (NetPropReference propReference in replacements[target].references)
            {
                NetworkReplacement.instance.ReplaceProp(replacements[target], propReference);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Performs setup, loads pack files, and initialises the dictionaries.  Must be called prior to use.
        /// </summary>
        internal void Setup()
        {
            // Initialise dictionaries.
            packRecords      = new Dictionary <string, Dictionary <PrefabInfo, PropReplacement> >();
            replacements     = new Dictionary <PrefabInfo, BOBNetReplacement>();
            packEnabled      = new Dictionary <string, bool>();
            packNotAllLoaded = new Dictionary <string, bool>();

            // Read config files.
            List <BOBPackFile> packFiles = PackUtils.LoadPackFiles();

            foreach (BOBPackFile packFile in packFiles)
            {
                // Iterate through each prop pack loaded from the settings file.
                foreach (PropPack propPack in packFile.propPacks)
                {
                    // Check to see if we already have a record for this pack.
                    if (packRecords.ContainsKey(propPack.name))
                    {
                        // Yes - log the message and carry on.
                        Logging.Message("duplicate record for replacement pack with name", propPack.name);
                    }
                    else
                    {
                        // No - add pack to our records.
                        packRecords.Add(propPack.name, new Dictionary <PrefabInfo, PropReplacement>());
                        packEnabled.Add(propPack.name, false);
                    }

                    // Iterate through each replacement in the pack.
                    for (int i = 0; i < propPack.propReplacements.Count; ++i)
                    {
                        // Get reference.
                        PropReplacement propReplacement = propPack.propReplacements[i];

                        // Can we find both target and replacment?
                        PrefabInfo targetInfo = propReplacement.isTree ? (PrefabInfo)PrefabCollection <TreeInfo> .FindLoaded(propReplacement.targetName) : PrefabCollection <PropInfo> .FindLoaded(propReplacement.targetName);

                        propReplacement.replacementInfo = propReplacement.isTree ? (PrefabInfo)PrefabCollection <TreeInfo> .FindLoaded(propReplacement.replacementName) : PrefabCollection <PropInfo> .FindLoaded(propReplacement.replacementName);

                        if (targetInfo == null)
                        {
                            // Target prop not found - log and continue.
                            Logging.Message("couldn't find pack target prop");
                        }
                        else if (propReplacement.replacementInfo == null)
                        {
                            // Replacement prop not found - flag that pack wasn't all loaded.
                            if (!packNotAllLoaded.ContainsKey(propPack.name))
                            {
                                packNotAllLoaded.Add(propPack.name, true);
                            }
                        }
                        else
                        {
                            // Target and replacment both found - add this replacmeent to our pack dictionary entry.
                            if (packRecords[propPack.name].ContainsKey(targetInfo))
                            {
                                // Skip any duplicates.
                                Logging.Error("duplicate replacement ", targetInfo.name, " in replacement pack ", propPack.name);
                            }
                            else
                            {
                                packRecords[propPack.name].Add(targetInfo, propReplacement);
                            }
                        }
                    }

                    // Check to make sure we have at least one replacement; if not, remove the pack from our records.
                    if (packRecords[propPack.name].Count == 0)
                    {
                        Logging.Message("replacement pack ", propPack.name, " has no valid replacements; removing from list");
                        packRecords.Remove(propPack.name);
                        packEnabled.Remove(propPack.name);
                    }
                }
            }
        }
Esempio n. 14
0
        public static Vector3 GetPOInstancePosition(PrefabInfo prefab)
        {
            try
            {
                GameObject gameLogicObject = GameObject.Find("Logic_ProceduralObjects");
                if (gameLogicObject == null)
                {
                    return(Vector3.zero);
                }

                Type      ProceduralObjectsLogicType = Type.GetType("ProceduralObjects.ProceduralObjectsLogic");
                Type      ProceduralObjectType       = Type.GetType("ProceduralObjects.Classes.ProceduralObject");
                Component logic  = gameLogicObject.GetComponent("ProceduralObjectsLogic");
                object    poList = ProceduralObjectsLogicType.GetField("proceduralObjects").GetValue(logic);

                storedPositions.Clear();
                foreach (var i in poList as IList)
                {
                    string basePrefabName = ProceduralObjectType.GetField("basePrefabName").GetValue(i).ToString();
                    string infoType       = ProceduralObjectType.GetField("baseInfoType").GetValue(i).ToString();
                    if (basePrefabName != null && infoType != null && basePrefabName == prefab.name)
                    {
                        object  positionObject = ProceduralObjectType.GetField("m_position").GetValue(i);
                        Vector3 position       = (Vector3)positionObject;
                        storedPositions.Add(position);
                    }
                }
                if (storedPositions.Count == 0)
                {
                    return(Vector3.zero);
                }

                if (storedPrefabName != prefab.name)
                {
                    storedPrefabName    = prefab.name;
                    storedPOCounter     = 0;
                    storedPositionsSize = storedPositions.Count;
                }
                else
                {
                    if (storedPositionsSize != storedPositions.Count)
                    {
                        storedPOCounter     = 0;
                        storedPositionsSize = storedPositions.Count;
                    }
                }
                Vector3 result = storedPositions[storedPOCounter];
                if (storedPOCounter == storedPositions.Count - 1)
                {
                    storedPOCounter = 0;
                }
                else
                {
                    storedPOCounter += 1;
                }
                return(result);
            }
            catch (Exception e)
            {
                Debugging.LogException(e);
            }

            return(Vector3.zero);
        }
Esempio n. 15
0
        private static void SetupButtonsForPrefab(PrefabInfo prefabInfo)
        {
            switch (prefabInfo)
            {
            case VehicleInfoBase vehicleInfoBase:
                SetupMeshPreviewButtons(
                    vehicleInfoBase.name,
                    vehicleInfoBase.m_mesh,
                    vehicleInfoBase.m_material,
                    vehicleInfoBase.m_lodMesh,
                    vehicleInfoBase.m_lodMaterial);
                SetupVehicleFullDumpButton(
                    vehicleInfoBase.name,
                    vehicleInfoBase.m_mesh,
                    vehicleInfoBase.m_material,
                    vehicleInfoBase.m_lodMesh,
                    vehicleInfoBase.m_lodMaterial,
                    vehicleInfoBase is VehicleInfo vehicleInfo ? vehicleInfo.m_subMeshes : null);
                break;

            case NetInfo netInfo:
                SetupPlopButton(prefabInfo);
                if (netInfo.m_segments?.Length > 0)
                {
                    var previewSegment = Array.Find(netInfo.m_segments, s => s != null);
                    if (previewSegment != null)
                    {
                        SetupMeshPreviewButtons(
                            netInfo.name,
                            previewSegment.m_mesh,
                            previewSegment.m_material,
                            previewSegment.m_lodMesh,
                            previewSegment.m_lodMaterial);
                    }
                }

                SetupNetworkFullDumpButton(netInfo.name, netInfo.m_segments, netInfo.m_nodes);
                break;

            case BuildingInfoBase buildingInfoBase:
                if (buildingInfoBase is BuildingInfo)
                {
                    SetupPlopButton(prefabInfo);
                }

                SetupMeshPreviewButtons(
                    buildingInfoBase.name,
                    buildingInfoBase.m_mesh,
                    buildingInfoBase.m_material,
                    buildingInfoBase.m_lodMesh,
                    buildingInfoBase.m_lodMaterial);
                SetupBuildingFullDumpButton(
                    buildingInfoBase.name,
                    buildingInfoBase.m_mesh,
                    buildingInfoBase.m_material,
                    buildingInfoBase.m_lodMesh,
                    buildingInfoBase.m_lodMaterial,
                    buildingInfoBase is BuildingInfo buildingInfo ? buildingInfo.m_subMeshes : buildingInfoBase is BuildingInfoSub buildingInfoSub ? buildingInfoSub.m_subMeshes : null);
                break;

            case PropInfo propInfo:
                SetupPlopButton(prefabInfo);
                SetupMeshPreviewButtons(propInfo.name, propInfo.m_mesh, propInfo.m_material, propInfo.m_lodMesh, propInfo.m_lodMaterial);
                SetupGenericAssetFullDumpButton(propInfo.name, propInfo.m_mesh, propInfo.m_material, propInfo.m_lodMesh, propInfo.m_lodMaterial);
                break;

            case TreeInfo treeInfo:
                SetupPlopButton(prefabInfo);
                SetupMeshPreviewButtons(treeInfo.name, treeInfo.m_mesh, treeInfo.m_material, null, null);
                SetupGenericAssetFullDumpButton(treeInfo.name, treeInfo.m_mesh, treeInfo.m_material, null, null);
                break;

            case CitizenInfo citizenInfo:
                SetupMeshPreviewButtons(
                    citizenInfo.name,
                    citizenInfo.m_skinRenderer?.sharedMesh,
                    citizenInfo.m_skinRenderer?.material,
                    citizenInfo.m_lodMesh,
                    citizenInfo.m_lodMaterial);
                SetupGenericAssetFullDumpButton(
                    citizenInfo.name,
                    citizenInfo.m_skinRenderer?.sharedMesh,
                    citizenInfo.m_skinRenderer?.material,
                    citizenInfo.m_lodMesh,
                    citizenInfo.m_lodMaterial);
                break;
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Populates the target fastlist with a list of target-specific trees or props.
        /// </summary>
        protected override void TargetList()
        {
            // Clear current selection.
            targetList.selectedIndex = -1;

            // List of prefabs that have passed filtering.
            List <TargetListItem> itemList = new List <TargetListItem>();

            // Check to see if this building contains any props.
            if (currentBuilding.m_props == null || currentBuilding.m_props.Length == 0)
            {
                // No props - show 'no props' label and return an empty list.
                noPropsLabel.Show();
                targetList.rowsData = new FastList <object>();
                return;
            }

            // Iterate through each prop in building.
            for (int propIndex = 0; propIndex < currentBuilding.m_props.Length; ++propIndex)
            {
                // Create new list item.
                TargetListItem targetListItem = new TargetListItem();

                // Try to get relevant prefab (prop/tree), using finalProp.
                PrefabInfo finalInfo = IsTree ? (PrefabInfo)currentBuilding.m_props[propIndex]?.m_finalTree : (PrefabInfo)currentBuilding.m_props[propIndex]?.m_finalProp;

                // Check to see if we were succesful - if not (e.g. we only want trees and this is a prop), continue on to next building prop.
                if (finalInfo?.name == null)
                {
                    continue;
                }

                // Grouped or individual?
                if (CurrentMode == ReplacementModes.Individual)
                {
                    // Individual - set index to the current building prop indexes.
                    targetListItem.index = propIndex;
                }
                else
                {
                    // Grouped - set index to -1 and add to our list of indexes.
                    targetListItem.index = -1;
                    targetListItem.indexes.Add(propIndex);
                }

                // Get original (pre-replacement) tree/prop prefab and current probability (as default original probability).
                targetListItem.originalPrefab = finalInfo;
                targetListItem.originalProb   = currentBuilding.m_props[propIndex].m_probability;
                targetListItem.originalAngle  = (currentBuilding.m_props[propIndex].m_radAngle * 180f) / Mathf.PI;

                // All-building replacement and original probability (if any).
                BOBBuildingReplacement allBuildingReplacement = AllBuildingReplacement.Instance.ActiveReplacement(currentBuilding, propIndex);
                if (allBuildingReplacement != null)
                {
                    targetListItem.allPrefab = allBuildingReplacement.replacementInfo;
                    targetListItem.allProb   = allBuildingReplacement.probability;

                    // Update original prop reference.
                    targetListItem.originalPrefab = allBuildingReplacement.targetInfo;
                }

                // Building replacement and original probability (if any).
                BOBBuildingReplacement buildingReplacement = BuildingReplacement.Instance.ActiveReplacement(currentBuilding, propIndex);
                if (buildingReplacement != null)
                {
                    targetListItem.replacementPrefab = buildingReplacement.replacementInfo;
                    targetListItem.replacementProb   = buildingReplacement.probability;

                    // Update original prop reference.
                    targetListItem.originalPrefab = buildingReplacement.targetInfo;
                }

                // Individual replacement and original probability (if any).
                BOBBuildingReplacement individualReplacement = IndividualBuildingReplacement.Instance.ActiveReplacement(currentBuilding, propIndex);
                if (individualReplacement != null)
                {
                    targetListItem.individualPrefab = individualReplacement.replacementInfo;
                    targetListItem.individualProb   = individualReplacement.probability;

                    // Update original prop reference.
                    targetListItem.originalPrefab = individualReplacement.targetInfo;
                }

                // Are we grouping?
                if (targetListItem.index == -1)
                {
                    // Yes, grouping - initialise a flag to show if we've matched.
                    bool matched = false;

                    // Iterate through each item in our existing list of props.
                    foreach (TargetListItem item in itemList)
                    {
                        // Check to see if we already have this in the list - matching original prefab, individual replacement prefab, building replacement prefab, all-building replacement prefab, and probability.
                        if (item.originalPrefab == targetListItem.originalPrefab && item.individualPrefab == targetListItem.individualPrefab && item.replacementPrefab == targetListItem.replacementPrefab && targetListItem.allPrefab == item.allPrefab)
                        {
                            // We've already got an identical grouped instance of this item - add this index and lane to the lists of indexes and lanes under that item and set the flag to indicate that we've done so.
                            item.indexes.Add(propIndex);
                            matched = true;

                            // No point going any further through the list, since we've already found our match.
                            break;
                        }
                    }

                    // Did we get a match?
                    if (matched)
                    {
                        // Yes - continue on to next building prop (without adding this item separately to the list).
                        continue;
                    }
                }

                // Add this item to our list.
                itemList.Add(targetListItem);
            }

            // Create return fastlist from our filtered list, ordering by name.
            targetList.rowsData = new FastList <object>
            {
                m_buffer = targetSearchStatus == (int)OrderBy.NameDescending ? itemList.OrderByDescending(item => item.DisplayName).ToArray() : itemList.OrderBy(item => item.DisplayName).ToArray(),
                m_size   = itemList.Count
            };

            // If the list is empty, show the 'no props' label; otherwise, hide it.
            if (targetList.rowsData.m_size == 0)
            {
                noPropsLabel.Show();
            }
            else
            {
                noPropsLabel.Hide();
            }
        }
 private void OnEditPrefabChanged(PrefabInfo info)
 {
     var ai = info.GetAI();
     if (ai != null)
         m_selectAIPanel.value = ai.GetType().FullName;
 }
Esempio n. 18
0
 /// <summary>
 /// Initializes the current instance with values from specified prefab.
 /// </summary>
 /// <param name="prefab">The prefab.</param>
 public void Initialize(PrefabInfo prefab)
 {
     this.Initialized = this.InitializePrefab(prefab);
 }
Esempio n. 19
0
 private bool NetTool(PrefabInfo info)
 {
     NetInfo netInfo = info as NetInfo;
     if (netInfo == null) {
         NetTool netTool = ToolsModifierControl.SetTool<NetTool>();
         if (netTool == null) {
             netTool.m_prefab = netInfo;
             return true;
         }
     }
     return false;
 }
Esempio n. 20
0
 /// <summary>
 /// Initializes the types.
 /// </summary>
 /// <param name="prefab">The prefab.</param>
 /// <returns>True on success.</returns>
 protected virtual bool InitializeTypes(PrefabInfo prefab)
 {
     return(true);
 }
 public void CreateAssetItem(PrefabInfo info)
 {
     ReflectionUtils.InvokeInstanceMethod(m_CreateAssetItem, this, info);
 }
Esempio n. 22
0
        /// <summary>
        /// Initializes the current instance with values from specified prefab.
        /// </summary>
        /// <param name="prefab">The prefab.</param>
        private bool InitializePrefab(PrefabInfo prefab)
        {
            try
            {
                this.Clear();

                if ((UnityEngine.Object)prefab == (UnityEngine.Object)null)
                {
                    this.InitializeNames((string)null);
                    this.InitializeFailed(prefab);

                    return(false);
                }

                bool success = this.InitializeTypes(prefab);

                try
                {
                    if (!string.IsNullOrEmpty(prefab.name))
                    {
                        success = this.InitializeNames(prefab.name) & success;
                    }
                    else if (!String.IsNullOrEmpty(prefab.gameObject.name))
                    {
                        success = this.InitializeNames(prefab.gameObject.name) && success;
                    }
                    else
                    {
                        this.InitializeNames((string)null);
                        success = false;
                    }
                }
                catch
                {
                    this.InitializeNames((string)null);
                    success = false;
                }

                try
                {
                    this.Title = prefab.GetLocalizedTitle();
                    if (this.Title != null)
                    {
                        this.Title = titleCleaningPattern.Replace(this.Title, "$1");
                    }
                }
                catch
                {
                    this.Title = null;
                }

                success = this.InitializeCategory(prefab) && success;

                if (!success)
                {
                    this.InitializeFailed(prefab);

                    return(false);
                }

                return(this.InitializeData(prefab) && success);
            }
            catch (Exception ex)
            {
                if (Log.LogALot)
                {
                    Log.Error(this, "Initialize", ex);
                }

                return(false);
            }
        }
Esempio n. 23
0
 /// <summary>
 /// Gets the lod texture.
 /// </summary>
 /// <param name="prefab">The prefab.</param>
 /// <returns>
 /// The lod texture.
 /// </returns>
 protected override Texture GetLodTexture(PrefabInfo prefab)
 {
     return(GetTextureWithFallback(((PropInfo)prefab).m_lodObject, ((PropInfo)prefab).m_lodMaterial));
 }
Esempio n. 24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ObjectInfo"/> class.
 /// </summary>
 /// <param name="prefab">The prefab.</param>
 public ObjectInfo(PrefabInfo prefab)
 {
     this.Initialized = this.InitializePrefab(prefab);
 }
Esempio n. 25
0
 /// <summary>
 /// Gets the texture.
 /// </summary>
 /// <param name="prefab">The prefab.</param>
 /// <returns>
 /// The texture.
 /// </returns>
 protected override Texture GetMainTexture(PrefabInfo prefab)
 {
     return(GetTextureWithFallback(prefab, ((PropInfo)prefab).m_material));
 }
        internal void LoadImpl(Package.Asset assetRef)
        {
            try
            {
                stack.Push(assetRef);
                LoadingManager.instance.m_loadingProfilerCustomAsset.BeginLoading(AssetName(assetRef.name));
                GameObject go = AssetDeserializer.Instantiate(assetRef) as GameObject;
                CustomAssetMetaData.Type type = GetMetaType(assetRef);
                string packageName            = assetRef.package.packageName;
                string fullName = type < CustomAssetMetaData.Type.RoadElevation ? packageName + "." + go.name : PillarOrElevationName(packageName, go.name);
                go.name = fullName;
                go.SetActive(false);
                PrefabInfo info = go.GetComponent <PrefabInfo>();
                info.m_isCustomContent = true;

                if (info.m_Atlas != null && !string.IsNullOrEmpty(info.m_InfoTooltipThumbnail) && info.m_Atlas[info.m_InfoTooltipThumbnail] != null)
                {
                    info.m_InfoTooltipAtlas = info.m_Atlas;
                }

                PropInfo pi = go.GetComponent <PropInfo>();

                if (pi != null)
                {
                    if (pi.m_lodObject != null)
                    {
                        pi.m_lodObject.SetActive(false);
                    }

                    Initialize(pi);
                    loadedProps.Add(fullName);
                    propCount++;
                }

                TreeInfo ti = go.GetComponent <TreeInfo>();

                if (ti != null)
                {
                    Initialize(ti);
                    loadedTrees.Add(fullName);
                    treeCount++;
                }

                BuildingInfo bi = go.GetComponent <BuildingInfo>();

                if (bi != null)
                {
                    if (bi.m_lodObject != null)
                    {
                        bi.m_lodObject.SetActive(false);
                    }

                    bi.m_dontSpawnNormally = dontSpawnNormally.Remove(fullName);
                    Initialize(bi);
                    loadedBuildings.Add(fullName);
                    buildingCount++;

                    if (bi.GetAI() is IntersectionAI)
                    {
                        loadedIntersections.Add(fullName);
                    }
                }

                VehicleInfo vi = go.GetComponent <VehicleInfo>();

                if (vi != null)
                {
                    if (vi.m_lodObject != null)
                    {
                        vi.m_lodObject.SetActive(false);
                    }

                    Initialize(vi);
                    loadedVehicles.Add(fullName);
                    vehicleCount++;
                }

                CitizenInfo ci = go.GetComponent <CitizenInfo>();

                if (ci != null)
                {
                    if (ci.m_lodObject != null)
                    {
                        ci.m_lodObject.SetActive(false);
                    }

                    if (ci.InitializeCustomPrefab(citizenMetaDatas[assetRef.fullName]))
                    {
                        citizenMetaDatas.Remove(assetRef.fullName);
                        ci.gameObject.SetActive(true);
                        Initialize(ci);
                        loadedCitizens.Add(fullName);
                    }
                    else
                    {
                        CODebugBase <LogChannel> .Warn(LogChannel.Modding, "Custom citizen [" + assetRef.fullName + "] template not available in selected theme. Asset not added in game.");
                    }
                }

                NetInfo ni = go.GetComponent <NetInfo>();

                if (ni != null)
                {
                    loadedNets.Add(fullName);
                    Initialize(ni);
                }
            }
            finally
            {
                stack.Pop();
                assetCount++;
                LoadingManager.instance.m_loadingProfilerCustomAsset.EndLoading();
            }
        }
Esempio n. 27
0
        public static void RenderTextMesh(ushort refID, int boardIdx, int secIdx, BoardInstanceXml descriptor, Matrix4x4 propMatrix,
                                          BoardDescriptorGeneralXml propLayout, ref BoardTextDescriptorGeneralXml textDescriptor, MaterialPropertyBlock materialPropertyBlock,
                                          int instanceFlags, Color parentColor, PrefabInfo srcInfo, ref int defaultCallsCounter, Camera targetCamera = null)
        {
            BasicRenderInformation renderInfo = WTSTextMeshProcess.GetTextMesh(textDescriptor, refID, boardIdx, secIdx, descriptor, propLayout, out IEnumerable <BasicRenderInformation> multipleOutput, propLayout?.CachedProp);

            if (renderInfo == null)
            {
                if (multipleOutput != null && multipleOutput.Count() > 0)
                {
                    BasicRenderInformation[] resultArray = multipleOutput.ToArray();
                    if (resultArray.Length == 1)
                    {
                        renderInfo = multipleOutput.First();
                    }
                    else
                    {
                        BoardTextDescriptorGeneralXml.SubItemSettings settings = textDescriptor.MultiItemSettings;
                        int targetCount = Math.Min(settings.SubItemsPerRow * settings.SubItemsPerColumn, resultArray.Length);
                        int maxItemsInARow, maxItemsInAColumn, lastRowOrColumnItemCount;

                        if (textDescriptor.MultiItemSettings.VerticalFirst)
                        {
                            maxItemsInAColumn        = Math.Min(targetCount, settings.SubItemsPerColumn);
                            maxItemsInARow           = Mathf.CeilToInt((float)targetCount / settings.SubItemsPerColumn);
                            lastRowOrColumnItemCount = targetCount % settings.SubItemsPerColumn;
                        }
                        else
                        {
                            maxItemsInARow           = Math.Min(targetCount, settings.SubItemsPerRow);
                            maxItemsInAColumn        = Mathf.CeilToInt((float)targetCount / settings.SubItemsPerRow);
                            lastRowOrColumnItemCount = targetCount % settings.SubItemsPerRow;
                        }
                        float unscaledColumnWidth = resultArray.Max(x => x?.m_sizeMetersUnscaled.x ?? 0) * SCALING_FACTOR;
                        float rowHeight           = resultArray.Max(x => x?.m_sizeMetersUnscaled.y ?? 0) * SCALING_FACTOR * textDescriptor.m_textScale + textDescriptor.MultiItemSettings.SubItemSpacing.Y;
                        float columnWidth         = (unscaledColumnWidth * textDescriptor.m_textScale) + textDescriptor.MultiItemSettings.SubItemSpacing.X;
                        var   maxWidth            = textDescriptor.m_maxWidthMeters;


                        float regularOffsetX = CalculateOffsetXMultiItem(textDescriptor.m_textAlign, maxItemsInARow, columnWidth, maxWidth);
                        float cloneOffsetX   = textDescriptor.PlacingConfig.m_invertYCloneHorizontalAlign ? CalculateOffsetXMultiItem(2 - textDescriptor.m_textAlign, maxItemsInARow, columnWidth, maxWidth) : regularOffsetX;
                        float regularOffsetY = CalculateOffsetYMultiItem(textDescriptor.MultiItemSettings.VerticalAlign, maxItemsInAColumn, rowHeight);

                        var startPoint      = new Vector3(textDescriptor.PlacingConfig.Position.X + regularOffsetX, textDescriptor.PlacingConfig.Position.Y - regularOffsetY, textDescriptor.PlacingConfig.Position.Z);
                        var startPointClone = new Vector3(textDescriptor.PlacingConfig.Position.X + cloneOffsetX, textDescriptor.PlacingConfig.Position.Y - regularOffsetY, textDescriptor.PlacingConfig.Position.Z);

                        Vector3 lastRowOrColumnStartPoint = textDescriptor.MultiItemSettings.VerticalFirst
                            ? new Vector3(startPoint.x, textDescriptor.PlacingConfig.Position.Y - CalculateOffsetYMultiItem(textDescriptor.MultiItemSettings.VerticalAlign, lastRowOrColumnItemCount, rowHeight), startPoint.z)
                            : new Vector3(textDescriptor.PlacingConfig.Position.X + CalculateOffsetXMultiItem(textDescriptor.m_textAlign, lastRowOrColumnItemCount, columnWidth, maxWidth), startPoint.y, startPoint.z);
                        Color colorToSet = GetTextColor(refID, boardIdx, secIdx, descriptor, propLayout, textDescriptor);
                        //LogUtils.DoWarnLog($"sz = {resultArray.Length};targetCount = {targetCount}; origPos = {textDescriptor.PlacingConfig.Position}; maxItemsInAColumn = {maxItemsInAColumn}; maxItemsInARow = {maxItemsInARow};columnWidth={columnWidth};rowHeight={rowHeight}");



                        int firstItemIdxLastRowOrColumn = targetCount - lastRowOrColumnItemCount;
                        for (int i = 0; i < targetCount; i++)
                        {
                            int x, y;
                            if (textDescriptor.MultiItemSettings.VerticalFirst)
                            {
                                y = i % settings.SubItemsPerColumn;
                                x = i / settings.SubItemsPerColumn;
                            }
                            else
                            {
                                x = i % settings.SubItemsPerRow;
                                y = i / settings.SubItemsPerRow;
                            }

                            BasicRenderInformation currentItem = resultArray[i];
                            Vector3 targetPosA = (i >= firstItemIdxLastRowOrColumn ? lastRowOrColumnStartPoint : startPoint) - new Vector3(columnWidth * x, rowHeight * y);
                            DrawTextBri(refID, boardIdx, secIdx, propMatrix, textDescriptor, materialPropertyBlock, currentItem, colorToSet, targetPosA, textDescriptor.PlacingConfig.Rotation, descriptor.PropScale, false, textDescriptor.m_textAlign, 0, instanceFlags, parentColor, srcInfo, ref defaultCallsCounter, targetCamera);
                            if (textDescriptor.PlacingConfig.m_create180degYClone)
                            {
                                targetPosA    = startPointClone - new Vector3(columnWidth * (maxItemsInARow - x - 1), rowHeight * y);
                                targetPosA.z *= -1;
                                DrawTextBri(refID, boardIdx, secIdx, propMatrix, textDescriptor, materialPropertyBlock, currentItem, colorToSet, targetPosA, textDescriptor.PlacingConfig.Rotation + new Vector3(0, 180), descriptor.PropScale, false, textDescriptor.m_textAlign, 0, instanceFlags, parentColor, srcInfo, ref defaultCallsCounter, targetCamera);
                            }
                        }
                    }
                }
                else
                {
                    return;
                }
            }
            if (renderInfo?.m_mesh is null || renderInfo?.m_generatedMaterial is null)
            {
                return;
            }

            Vector3 targetPos = textDescriptor.PlacingConfig.Position;


            DrawTextBri(refID, boardIdx, secIdx, propMatrix, textDescriptor, materialPropertyBlock, renderInfo, GetTextColor(refID, boardIdx, secIdx, descriptor, propLayout, textDescriptor), targetPos, textDescriptor.PlacingConfig.Rotation, descriptor.PropScale, textDescriptor.PlacingConfig.m_create180degYClone, textDescriptor.m_textAlign, textDescriptor.m_maxWidthMeters, instanceFlags, parentColor, srcInfo, ref defaultCallsCounter, targetCamera);
        }
Esempio n. 28
0
    private void PreOpenWindow(int type)
    {
        if (!WindowPrefabsInfo.ContainsKey(type) || m_self == null)
        {
                        #if UNITY_EDITOR
            Debug.LogError("PreOpenWindow,No such type window. TypeID = " + type);
                        #endif
            return;
        }

        bool found = false;

        for (int i = 0; i < m_windowGoBack.Count; ++i)
        {
            if (m_windowGoBack[i].WinType == type)
            {
                found = true;
                break;
            }
        }

        GameObject go = null;
        if (!found)
        {
            //find the resource(prefab) path
            PrefabInfo info = WindowPrefabsInfo[type];

            //intialize gameobject

            Assert.IsTrue(!info.IsInternal, "Not Impl With Bundle");

            if (!info.IsInternal)
            {
                AssetManager.LoadAssetFromResources(info.Path, typeof(GameObject), (AssetManager.Asset asset) =>
                {
                    if (asset.State == AssetManager.State.Loaded)
                    {
                        go = GameObject.Instantiate(asset.AssetObject) as GameObject;
                    }
                });
            }
        }

        if (go != null)
        {
            go.transform.parent = CommonCanvas;
            WindowBase win = go.GetComponent <WindowBase>();
            win.WinType   = type;
            win.IsPreLoad = true;
            go.SetActive(false);
            m_windowGoBack.Add(win);
            int[] subWinIDs = win.PreLoadSubWindowID();
            if (subWinIDs != null)
            {
                for (int i = 0; i < subWinIDs.Length; ++i)
                {
                    PreOpenWindow(subWinIDs[i]);
                }
            }
        }
    }
Esempio n. 29
0
        internal void LoadImpl(Package.Asset assetRef)
        {
            try
            {
                stack.Push(assetRef);
                LoadingManager.instance.m_loadingProfilerCustomAsset.BeginLoading(AssetName(assetRef.name));
                GameObject go = AssetDeserializer.Instantiate(assetRef) as GameObject;
                CustomAssetMetaData.Type type = GetMetaType(assetRef);
                string packageName            = assetRef.package.packageName;
                string fullName = type < CustomAssetMetaData.Type.RoadElevation ? packageName + "." + go.name : PillarOrElevationName(packageName, go.name);
                go.name = fullName;
                go.SetActive(false);
                PrefabInfo info = go.GetComponent <PrefabInfo>();
                info.m_isCustomContent = true;

                if (info.m_Atlas != null && !string.IsNullOrEmpty(info.m_InfoTooltipThumbnail) && info.m_Atlas[info.m_InfoTooltipThumbnail] != null)
                {
                    info.m_InfoTooltipAtlas = info.m_Atlas;
                }

                PropInfo     pi;
                TreeInfo     ti;
                BuildingInfo bi;
                VehicleInfo  vi;
                CitizenInfo  ci;
                NetInfo      ni;

                if ((pi = go.GetComponent <PropInfo>()) != null)
                {
                    if (pi.m_lodObject != null)
                    {
                        pi.m_lodObject.SetActive(false);
                    }

                    Initialize(pi);
                    loadedProps.Add(fullName);
                }
                else if ((ti = go.GetComponent <TreeInfo>()) != null)
                {
                    Initialize(ti);
                    loadedTrees.Add(fullName);
                }
                else if ((bi = go.GetComponent <BuildingInfo>()) != null)
                {
                    if (bi.m_lodObject != null)
                    {
                        bi.m_lodObject.SetActive(false);
                    }

                    bi.m_dontSpawnNormally = dontSpawnNormally.Remove(fullName);
                    Initialize(bi);
                    loadedBuildings.Add(fullName);

                    if (bi.GetAI() is IntersectionAI)
                    {
                        loadedIntersections.Add(fullName);
                    }
                }
                else if ((vi = go.GetComponent <VehicleInfo>()) != null)
                {
                    if (vi.m_lodObject != null)
                    {
                        vi.m_lodObject.SetActive(false);
                    }

                    Initialize(vi);
                    loadedVehicles.Add(fullName);
                }
                else if ((ci = go.GetComponent <CitizenInfo>()) != null)
                {
                    if (ci.m_lodObject != null)
                    {
                        ci.m_lodObject.SetActive(false);
                    }

                    if (ci.InitializeCustomPrefab(citizenMetaDatas[assetRef.fullName]))
                    {
                        citizenMetaDatas.Remove(assetRef.fullName);
                        ci.gameObject.SetActive(true);
                        Initialize(ci);
                        loadedCitizens.Add(fullName);
                    }
                    else
                    {
                        info = null;
                        CODebugBase <LogChannel> .Warn(LogChannel.Modding, "Custom citizen [" + assetRef.fullName + "] template not available in selected theme. Asset not added in game.");
                    }
                }
                else if ((ni = go.GetComponent <NetInfo>()) != null)
                {
                    loadedNets.Add(fullName);
                    Initialize(ni);
                }
                else
                {
                    info = null;
                }

                if (info != null)
                {
                    string path = Path.GetDirectoryName(assetRef.package.packagePath);

                    if (!string.IsNullOrEmpty(path) && plugins.TryGetValue(path, out PluginInfo plugin))
                    {
                        IAssetDataExtension[] extensions = plugin.GetInstances <IAssetDataExtension>();

                        if (extensions.Length > 0)
                        {
                            UserAssetData uad = GetUserAssetData(assetRef, out string name);

                            if (uad != null)
                            {
                                for (int i = 0; i < extensions.Length; i++)
                                {
                                    try
                                    {
                                        extensions[i].OnAssetLoaded(name, info, uad.Data);
                                    }
                                    catch (Exception e)
                                    {
                                        ModException ex = new ModException("The Mod " + plugin.ToString() + " has caused an error when loading " + fullName, e);
                                        UIView.ForwardException(ex);
                                        Debug.LogException(ex);
                                    }
                                }
                            }
                            else
                            {
                                Util.DebugPrint("UserAssetData is null for", fullName);
                            }
                        }
                    }
                }
            }
            finally
            {
                stack.Pop();
                assetCount++;
                LoadingManager.instance.m_loadingProfilerCustomAsset.EndLoading();
            }
        }
Esempio n. 30
0
    public static WindowBase OpenSubWindow(int type, WindowBase parentWin, params System.Object[] args)
    {
        if (!WindowPrefabsInfo.ContainsKey(type) || m_self == null)
        {
                        #if UNITY_EDITOR
            Debug.LogError("OpenSubWindow,No such type window. TypeID = " + type);
                        #endif
            return(null);
        }

        if (parentWin == null)
        {
                        #if UNITY_EDITOR
            Debug.LogError("OpenSubWindow, must have a parent window");
                        #endif
            return(null);
        }

        //check if exist
        GameObject go    = null;
        WindowBase win   = null;
        int        exist = 0;
        for (int i = 0; i < m_self.m_subWindowGoList.Count; ++i)
        {
            WindowBase window = m_self.m_subWindowGoList[i];
            if (window.WinType == type && window.IsSingleton)
            {
                win   = window;
                go    = win.MainObject;
                exist = 1;
                if (win.ParentWindow == parentWin)
                {
                    go.SetActive(true);
                    return(win);
                }
                break;
            }
        }
        if (0 == exist)
        {
            for (int i = 0; i < m_self.m_windowGoList.Count; ++i)
            {
                WindowBase window = m_self.m_windowGoList[i];
                if (window.WinType == type && window.IsSingleton)
                {
                    win   = window;
                    go    = win.MainObject;
                    exist = 2;
                    break;
                }
            }
        }

        if (0 == exist)
        {
            for (int i = 0; i < m_self.m_windowGoBack.Count; ++i)
            {
                if (m_self.m_windowGoBack[i].WinType == type)
                {
                    win   = m_self.m_windowGoBack[i];
                    go    = win.MainObject;
                    exist = 3;
                    break;
                }
            }
        }

        if (0 == exist)
        {
            //find the resource(prefab) path
            PrefabInfo info = WindowPrefabsInfo[type];

            //intialize gameobject
            Assert.IsTrue(!info.IsInternal, "Not Impl With Bundle");

            if (!info.IsInternal)
            {
                AssetManager.LoadAssetFromResources(info.Path, typeof(GameObject), (AssetManager.Asset asset) =>
                {
                    if (asset.State == AssetManager.State.Loaded)
                    {
                        go = GameObject.Instantiate(asset.AssetObject) as GameObject;
                    }
                });
            }
        }

        go.SetActive(true);
        int depth = parentWin.GetSunWindowCount() + 1;
        go.transform.parent     = parentWin.CatchedTransform;
        go.transform.localScale = Vector3.one;
        //go.transform.localPosition = new Vector3(0,0,-depth);

        if (1 == exist)
        {
            //m_self.m_subWindowGoList.Remove(win);
            //m_self.m_subWindowGoList.Add(win);
        }
        else if (2 == exist)
        {
            m_self.m_windowGoList.Remove(win);
            m_self.m_subWindowGoList.Add(win);
        }
        else if (3 == exist)
        {
            m_self.m_windowGoBack.Remove(win);
            m_self.m_subWindowGoList.Add(win);
        }
        else
        {
            win = go.GetComponent <WindowBase>();
            if (win != null)
            {
                win.WinType = type;
                m_self.m_subWindowGoList.Add(win);
            }
            else
            {
                                #if UNITY_EDITOR
                Debug.LogError("OpenSubWindow: Can't find WindowBase at window root. WinObj = " + go.name);
                                #endif
                Destroy(go);
                return(null);
            }
        }

        if (win != null)
        {
            if (win.ParentWindow != null)
            {
                win.ParentWindow.RemoveSubWindow(win);
            }
            win.IsPreLoad = parentWin.IsPreLoad;
            if (!win.Started)
            {
                win.Init(args);
            }
            win.IsSubWindow = true;

            win.MainCanvas.sortingLayerID = LayerMask.GetMask("UI");
            win.MainCanvas.sortingOrder   = depth;
            parentWin.AddSubWindow(win);
            if (win.Started)
            {
                if (3 == exist && win.Closed)
                {
                    win.OnOpen(args);
                }

                if (!win.Actived)
                {
                    win.OnActive();
                }
            }
        }

        return(win);
    }
Esempio n. 31
0
    public void SavePrefabInformation_lazily(string assetPath)
    {
        /*
         * Saves the prefab information in "prefabs" property of PrefabDatabase prefab.
                 * lazily means only load the remote thing when needed
         */
                PrefabInfo newInfo = new PrefabInfo ();
                newInfo.fileName = assetPath;
                newInfo.loaded = 0;
                prefabs.Add (newInfo);

        EditorUtility.SetDirty (this);
    }
Esempio n. 32
0
    public static WindowBase OpenWindowWithPriorty(int type, int priority, params System.Object[] args)
    {
        if (!WindowPrefabsInfo.ContainsKey(type) || m_self == null)
        {
                        #if UNITY_EDITOR
            Debug.LogError("No such type window. TypeID = " + type);
                        #endif
            return(null);
        }

        //Debug.LogWarning("Open window : " + type);
        //check if exist
        GameObject go    = null;
        WindowBase win   = null;
        int        exist = 0;

        for (int i = 0; i < m_self.m_windowGoList.Count; ++i)
        {
            WindowBase window = m_self.m_windowGoList[i];
            if (window.WinType == type && window.IsSingleton)
            {
                win   = window;
                go    = win.MainObject;
                exist = 1;
                if (m_self.CurrentWindow == win || win.SortType == WindowBase.WindowSortType.AlwaysTop)
                {
                    go.SetActive(true);
                    return(win);
                }
                break;
            }
        }

        if (0 == exist)
        {
            for (int i = 0; i < m_self.m_subWindowGoList.Count; ++i)
            {
                WindowBase window = m_self.m_subWindowGoList[i];
                if (window.WinType == type && window.IsSingleton)
                {
                    win   = window;
                    go    = win.MainObject;
                    exist = 2;
                    break;
                }
            }
        }

        if (0 == exist)
        {
            for (int i = 0; i < m_self.m_windowGoBack.Count; ++i)
            {
                if (m_self.m_windowGoBack[i].WinType == type)
                {
                    win   = m_self.m_windowGoBack[i];
                    go    = win.MainObject;
                    exist = 3;
                    break;
                }
            }
        }

        if (0 == exist)
        {
            //find the resource(prefab) path
            PrefabInfo info = WindowPrefabsInfo[type];
            //intialize gameobject
            Assert.IsTrue(!info.IsInternal, "Not Impl With Bundle");

            if (!info.IsInternal)
            {
                AssetManager.LoadAssetFromResources(info.Path, typeof(GameObject), (AssetManager.Asset asset) =>
                {
                    if (asset.State == AssetManager.State.Loaded)
                    {
                        go = GameObject.Instantiate(asset.AssetObject) as GameObject;
                    }
                });
            }
        }

        //add to UI-Root and set to top
        if (go == null)
        {
                        #if UNITY_EDITOR
            Debug.LogError("OpenWindow: Found a NULL window. TypeID = " + type);
                        #endif
            return(null);
        }

        go.SetActive(true);

        if (1 == exist)
        {
            m_self.m_windowGoList.Remove(win);
            m_self.m_windowGoList.Add(win);
        }
        else if (2 == exist)
        {
            m_self.m_subWindowGoList.Remove(win);
            m_self.m_windowGoList.Add(win);
        }
        else if (3 == exist)
        {
            m_self.m_windowGoBack.Remove(win);
            m_self.m_windowGoList.Add(win);
        }
        else
        {
            go.transform.parent = m_self.CommonCanvas;

            win = go.GetComponent <WindowBase>();
            if (win != null)
            {
                win.WinType = type;
                m_self.m_windowGoList.Add(win);
            }
            else
            {
                                #if UNITY_EDITOR
                Debug.LogError("OpenWindow: Can't find WindowBase at window root. WinObj = " + go.name);
                                #endif
                Destroy(go);
                return(null);
            }
        }

        win.IsPreLoad = false;
        if (!win.Started)
        {
            win.Init(args);
        }

        go.transform.localScale       = Vector3.one;
        go.transform.localEulerAngles = Vector3.zero;
        go.transform.localPosition    = new Vector3(0, 0, -1000);
        if (priority > 0)
        {
            win.SortType = WindowBase.WindowSortType.AlwaysTop;
            win.Priority = priority;
        }
        if (win.SortType == WindowBase.WindowSortType.AlwaysTop)
        {
            //Debug.LogWarning("window manager test " + win.Priority + priority);
            //go.transform.localPosition = new Vector3(0, 0, -600);
            if (exist != 1)
            {
                ++m_self.m_topWinNum;
            }
            for (int i = m_self.m_windowGoList.Count - m_self.m_topWinNum, max = m_self.m_windowGoList.Count; i < max; ++i)
            {
                if (m_self.m_windowGoList[i].Priority < win.Priority)
                {
                    m_self.m_windowGoList.Remove(win);
                    m_self.m_windowGoList.Insert(i, win);
                    break;
                }
            }
        }
        else
        {
            if (m_self.m_topWinNum > 0)
            {
                m_self.m_windowGoList.Remove(win);
                m_self.m_windowGoList.Insert(m_self.m_windowGoList.Count - m_self.m_topWinNum, win);
            }
        }

        int containModelWinCount     = 0;
        int lastContainModelWinIndex = -1;
        int currentIndex             = -1;
        for (int i = 0, max = m_self.m_windowGoList.Count; i < max; ++i)
        {
            WindowBase window = m_self.m_windowGoList[i];
            if (window != null)
            {
                //Debug.Log("sort window : " + window.name + i);
                Vector3 pos = window.CatchedTransform.localPosition;
                if (window.SortType == WindowBase.WindowSortType.AlwaysTop)
                {
                    window.CatchedTransform.localPosition = new Vector3(pos.x, pos.y, (max - i) * 10 - 1000);
                }
                else if (window != win)
                {
                    window.CatchedTransform.localPosition = new Vector3(pos.x, pos.y, (max - i - m_self.m_topWinNum) * 500 - 200);
                }

                if (currentIndex > -1 && window.IsFullWindow && i > currentIndex)
                {
                    win.MainObject.SetActive(false);
                }

                if (window == win)
                {
                    currentIndex = i;
                }

                if (window.MainCanvas != null)
                {
                    window.MainCanvas.sortingLayerID = LayerMask.GetMask("UI");
                    window.MainCanvas.sortingOrder   = (i - containModelWinCount) * 20;
                }

                if (window.ContainModel && window != win && !win.IsFullWindow)
                {
                    lastContainModelWinIndex = i;
                    if (win.ContainModel)
                    {
                        window.MainObject.SetActive(false);
                    }
                }
            }
        }

        /*
         * if(win.MainPanel != null)
         * {
         *      if(win.SortType == WindowBase.WindowSortType.AlwaysTop)
         *      {
         *              win.MainPanel.depth = 200;
         *      }
         *      else
         *      {
         *              win.MainPanel.depth = 160;
         *      }
         * }
         */
        if (m_self.m_currentWindow != null)
        {
            if (m_self.m_currentWindow.Started && m_self.m_currentWindow.Actived)
            {
                m_self.m_currentWindow.OnDeactive();
            }
            else
            {
                m_self.m_currentWindow.Canceled = true;
            }

            //open a new window, how about current window? do we need to hide it?
            if (win.IsFullWindow)
            {
                int current = m_self.m_windowGoList.IndexOf(m_self.m_currentWindow);
                int thiswin = m_self.m_windowGoList.IndexOf(win) - 1;
                if (thiswin < current)
                {
                    current = thiswin;
                }

                for (int i = current; i >= 0; --i)
                {
                    WindowBase winTmp = m_self.m_windowGoList[i];
                    if (winTmp.MainObject.activeSelf)
                    {
                        //Debug.Log("deactive current window : " + winTmp.name + i);
                        winTmp.MainObject.SetActive(false);
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }
        m_self.m_currentWindow = win;

        if (win != null)
        {
            win.IsSubWindow = false;
            if (win.ParentWindow != null)
            {
                win.ParentWindow.RemoveSubWindow(win);
            }
            //win.ParentWindow = null;
            if (win.Started)
            {
                if (3 == exist && win.Closed)
                {
                    win.OnOpen(args);
                }

                if (!win.Actived)
                {
                    win.OnActive();
                }
            }
            //if(win.IsFullWindow)
            //UICamera.ReleaseCurrentTouch();
        }

        return(win);
    }
 private void AddGroup(PoolList<GroupInfo> groupItems, PrefabInfo info)
 {
     throw new NotImplementedException("AddGroup is target of redirection and is not implemented.");
 }
Esempio n. 34
0
        /// <summary>
        /// Applies an all-building prop replacement.
        /// </summary>
        /// <param name="replacement">Replacement record to apply</param>
        protected override void ApplyReplacement(BOBNetReplacement replacement)
        {
            // Don't do anything if prefabs can't be found.
            if (replacement?.targetInfo == null || replacement.replacementInfo == null)
            {
                return;
            }

            // Create new reference list.
            List <NetPropReference> referenceList = new List <NetPropReference>();

            // Iterate through each loaded network and record props to be replaced.
            for (int i = 0; i < PrefabCollection <NetInfo> .LoadedCount(); ++i)
            {
                // Get local reference.
                NetInfo netInfo = PrefabCollection <NetInfo> .GetLoaded((uint)i);

                // Skip any null networks, or netorks without lanes.
                if (netInfo?.m_lanes == null)
                {
                    continue;
                }

                // Iterate through each lane.
                for (int laneIndex = 0; laneIndex < netInfo.m_lanes.Length; ++laneIndex)
                {
                    // Local reference.
                    NetLaneProps.Prop[] theseLaneProps = netInfo.m_lanes[laneIndex]?.m_laneProps?.m_props;

                    // If no props in this lane, skip it and go to the next one.
                    if (theseLaneProps == null)
                    {
                        continue;
                    }

                    // Iterate through each prop in lane.
                    for (int propIndex = 0; propIndex < theseLaneProps.Length; ++propIndex)
                    {
                        // Local reference.
                        NetLaneProps.Prop thisLaneProp = theseLaneProps[propIndex];

                        // If invalid entry, skip this one.
                        if (thisLaneProp == null)
                        {
                            continue;
                        }

                        // Check for any currently active network or individual replacement.
                        if (NetworkReplacement.Instance.ActiveReplacement(netInfo, laneIndex, propIndex) != null || IndividualNetworkReplacement.Instance.ActiveReplacement(netInfo, laneIndex, propIndex) != null)
                        {
                            // Active network or individual replacement; skip this one.
                            continue;
                        }

                        // Check for any existing pack replacement.
                        PrefabInfo thisProp = NetworkPackReplacement.Instance.ActiveReplacement(netInfo, laneIndex, propIndex)?.targetInfo;
                        if (thisProp == null)
                        {
                            // No active replacement; use current PropInfo.
                            if (replacement.isTree)
                            {
                                thisProp = thisLaneProp.m_finalTree;
                            }
                            else
                            {
                                thisProp = thisLaneProp.m_finalProp;
                            }
                        }

                        // See if this prop matches our replacement.
                        if (thisProp != null && thisProp == replacement.targetInfo)
                        {
                            // Match!  Add reference data to the list.
                            referenceList.Add(CreateReference(netInfo, thisProp, laneIndex, propIndex, replacement.isTree));
                        }
                    }
                }
            }

            // Now, iterate through each entry found and apply the replacement to each one.
            foreach (NetPropReference propReference in referenceList)
            {
                // Remove any pack replacements first.
                NetworkPackReplacement.Instance.RemoveEntry(propReference.netInfo, replacement.targetInfo, propReference.laneIndex, propReference.propIndex);

                // Add entry to dictionary.
                AddReference(replacement, propReference);

                // Apply the replacement.
                ReplaceProp(replacement, propReference);
            }
        }
Esempio n. 35
0
        public static string GenerateBeautifiedPrefabName(PrefabInfo prefab)
        {
            string itemName;

            if (prefab == null)
            {
                itemName = "None";
            }
            else
            {
                itemName = prefab.GetUncheckedLocalizedTitle();

                /*
                var index1 = itemName.IndexOf('.');
                if (index1 > -1) itemName = itemName.Substring(index1 + 1);

                var index2 = itemName.IndexOf("_Data", StringComparison.Ordinal);
                if (index2 > -1) itemName = itemName.Substring(0, index2);
                */

                // replace spaces at start and end
                itemName = itemName.Trim();

                // replace multiple spaces with one
                itemName = Regex.Replace(itemName, " {2,}", " ");

                //itemName = AddSpacesToSentence(itemName);
            }

            return itemName;
        }
Esempio n. 36
0
 /// <summary>
 /// Restores any replacements from lower-priority replacements after a reversion.
 /// </summary>
 /// <param name="netInfo">Network prefab</param>
 /// <param name="targetInfo">Target prop info</param>
 /// <param name="laneIndex">Lane index</param>
 /// <param name="propIndex">Prop index</param>
 protected override void RestoreLower(NetInfo netInfo, PrefabInfo targetInfo, int laneIndex, int propIndex) => NetworkPackReplacement.Instance.Restore(netInfo, targetInfo, laneIndex, propIndex);
Esempio n. 37
0
 private bool BuildingTool(PrefabInfo info)
 {
     BuildingInfo buildingInfo = info as BuildingInfo;
     if (buildingInfo == null)
         return false;
     BuildingTool buildingTool = ToolsModifierControl.SetTool<BuildingTool>();
     if (buildingTool == null)
         return false;
     buildingTool.m_prefab = buildingInfo;
     buildingTool.m_relocate = 0;
     return true;
 }
Esempio n. 38
0
 /// <summary>
 /// Retrieves a currently-applied replacement entry for the given network, lane and prop index.
 /// </summary>
 /// <param name="networkInfo">Network prefab</param>
 /// <param name="targetInfo">Target prop/tree prefab</param>
 /// <param name="laneIndex">Lane number</param>
 /// <param name="propIndex">Prop index number</param>
 /// <returns>Currently-applied individual network replacement (null if none)</returns>
 internal override BOBNetReplacement EligibileReplacement(NetInfo netInfo, PrefabInfo targetInfo, int laneIndex, int propIndex) => ReplacementList(netInfo)?.Find(x => x.targetInfo == targetInfo);
Esempio n. 39
0
 private bool PropTool(PrefabInfo info)
 {
     PropInfo propInfo = info as PropInfo;
     if (propInfo != null) {
         PropTool propTool = ToolsModifierControl.SetTool<PropTool>();
         if (propTool != null) {
             propTool.m_prefab = propInfo;
             return true;
         }
     }
     return false;
 }
Esempio n. 40
0
        private void ShowInPanelResolveGrowables(PrefabInfo pInfo)
        {
            if (!(pInfo is BuildingInfo))
            {
                ShowInPanel(pInfo);
                return;
            }


            BuildingInfo info = pInfo as BuildingInfo;

            //BuildingInfo info = PrefabCollection<BuildingInfo>.FindLoaded("4x3_Beach Hotel3");
            if (info != null &&
                ((info.m_class.m_service == ItemClass.Service.Residential) ||
                 (info.m_class.m_service == ItemClass.Service.Industrial) ||
                 (info.m_class.m_service == ItemClass.Service.Commercial) ||
                 (info.m_class.m_service == ItemClass.Service.Office) ||
                 (info.m_class.m_service == ItemClass.Service.Tourism)))
            {
                Debug.LogWarning("Info " + info.name + " is a growable (or RICO).");

                bool Pass1 = false;

                // Try to locate in Find It!
                UIComponent SearchBoxPanel = UIView.Find("UISearchBox");
                if (SearchBoxPanel != null && SearchBoxPanel.isVisible == false)
                {
                    UIButton FIButton = UIView.Find <UIButton>("FindItMainButton");
                    if (FIButton == null)
                    {
                        return;
                    }
                    FIButton.SimulateClick();
                }
                if (SearchBoxPanel == null)
                {
                    return;
                }

                UIDropDown FilterDropdown = SearchBoxPanel.Find <UIDropDown>("UIDropDown");
                FilterDropdown.selectedValue = "Growable";

                UITextField TextField = SearchBoxPanel.Find <UITextField>("UITextField");
                TextField.text = "";

                UIComponent UIFilterGrowable = SearchBoxPanel.Find("UIFilterGrowable");
                UIFilterGrowable.GetComponentInChildren <UIButton>().SimulateClick();

                // Reflect into the scroll panel, starting with the growable panel:
                if (!ReflectIntoFindIt(info))
                {
                    // And then if that fails, RICO:
                    FilterDropdown.selectedValue = "Rico";
                    if (!ReflectIntoFindIt(info))
                    {
                        // And then if that fails, give up and get a drink
                        Debug.Log("Could not be found in Growable or Rico menus.");
                    }
                }
            }
            else
            {
                Debug.LogWarning("Info " + info.name + " is not a growable.");
                ShowInPanel(pInfo);
            }
        }
Esempio n. 41
0
 protected override bool IsServiceValid(PrefabInfo info)
 {
     return true;
 }
Esempio n. 42
0
 /// <summary>
 /// Check if the prefab should be included.
 /// </summary>
 /// <param name="prefab">The prefab.</param>
 /// <returns>True to include.</returns>
 private static bool IncludePrefab(PrefabInfo prefab)
 {
     return(((PropInfo)prefab).m_hasRenderer && !((PropInfo)prefab).m_isMarker);
 }
Esempio n. 43
0
 /// <summary>
 /// Gets the lod mesh.
 /// </summary>
 /// <param name="prefab">The prefab.</param>
 /// <returns>
 /// The lod mesh.
 /// </returns>
 protected override Mesh GetLodMesh(PrefabInfo prefab)
 {
     return(GetMeshWithFallback(((PropInfo)prefab).m_lodObject, ((PropInfo)prefab).m_lodMesh));
 }
Esempio n. 44
0
        public static void FixThumbnails(PrefabInfo prefab, UIButton button)
        {
            // Fixing thumbnails
            if (prefab.m_Atlas == null || prefab.m_Thumbnail.IsNullOrWhiteSpace() ||
                // used for more than one prefab
                prefab.m_Thumbnail == "Thumboldasphalt" ||
                prefab.m_Thumbnail == "Thumbbirdbathresidential" ||
                prefab.m_Thumbnail == "Thumbcrate" ||
                prefab.m_Thumbnail == "Thumbhedge" ||
                prefab.m_Thumbnail == "Thumbhedge2" ||
                // empty thumbnails
                prefab.m_Thumbnail == "thumb_Ferry Info Sign" ||
                prefab.m_Thumbnail == "thumb_Paddle Car 01" ||
                prefab.m_Thumbnail == "thumb_Paddle Car 02" ||
                prefab.m_Thumbnail == "thumb_Pier Rope Pole" ||
                prefab.m_Thumbnail == "thumb_RailwayPowerline Singular" ||
                prefab.m_Thumbnail == "thumb_Rubber Tire Row" ||
                prefab.m_Thumbnail == "thumb_Dam" ||
                prefab.m_Thumbnail == "thumb_Power Line" ||
                // terrible thumbnails
                prefab.m_Thumbnail == "thumb_Railway Crossing Long" ||
                prefab.m_Thumbnail == "thumb_Railway Crossing Medium" ||
                prefab.m_Thumbnail == "thumb_Railway Crossing Short" ||
                prefab.m_Thumbnail == "thumb_Railway Crossing Very Long"
                )
            {
                if (!FindIt.thumbnailsToGenerate.ContainsKey(prefab))
                {
                    FindIt.thumbnailsToGenerate.Add(prefab, button);
                }
                else if (button != null)
                {
                    FindIt.thumbnailsToGenerate[prefab] = button;
                }

                return;
            }

            if (prefab.m_Atlas != null && (
                    // Missing variations
                    prefab.m_Atlas.name == "AssetThumbs" ||
                    prefab.m_Atlas.name == "Monorailthumbs" ||
                    prefab.m_Atlas.name == "Netpropthumbs" ||
                    prefab.m_Atlas.name == "Animalthumbs" ||
                    prefab.m_Atlas.name == "PublictransportProps" ||
                    prefab.m_Thumbnail == "thumb_Path Rock 01" ||
                    prefab.m_Thumbnail == "thumb_Path Rock 02" ||
                    prefab.m_Thumbnail == "thumb_Path Rock 03" ||
                    prefab.m_Thumbnail == "thumb_Path Rock 04" ||
                    prefab.m_Thumbnail == "thumb_Path Rock Small 01" ||
                    prefab.m_Thumbnail == "thumb_Path Rock Small 02" ||
                    prefab.m_Thumbnail == "thumb_Path Rock Small 03" ||
                    prefab.m_Thumbnail == "thumb_Path Rock Small 04"
                    ))
            {
                AddThumbnailVariantsInAtlas(prefab);

                if (button != null)
                {
                    button.atlas = prefab.m_Atlas;

                    button.normalFgSprite   = prefab.m_Thumbnail;
                    button.hoveredFgSprite  = prefab.m_Thumbnail + "Hovered";
                    button.pressedFgSprite  = prefab.m_Thumbnail + "Pressed";
                    button.disabledFgSprite = prefab.m_Thumbnail + "Disabled";
                    button.focusedFgSprite  = null;
                }
            }
        }