// For sub-buildings, name may be package.assetname.
        static T Get <T>(Package package, string fullName, string name, bool tryName) where T : PrefabInfo
        {
            T info = PrefabCollection <T> .FindLoaded(fullName);

            if (info == null && tryName)
            {
                info = PrefabCollection <T> .FindLoaded(name);
            }

            if (info == null)
            {
                Package.Asset data = package.Find(name);

                if (data == null && tryName)
                {
                    data = FindAsset(name); // yes, name
                }
                if (data != null)
                {
                    fullName = data.fullName;
                }
                else if (name.Contains("."))
                {
                    fullName = name;
                }

                if (Load(ref fullName, data))
                {
                    info = PrefabCollection <T> .FindLoaded(fullName);
                }
            }

            return(info);
        }
Esempio n. 2
0
        public static void SetupTrackProps(NetInfo prefab, NetInfoVersion version)
        {
            if (version != NetInfoVersion.Tunnel)
            {
                return;
            }
            var lanes    = prefab.m_lanes.ToList();
            var propLane = new NetInfo.Lane();

            propLane.m_laneProps = ScriptableObject.CreateInstance <NetLaneProps>();
            var propsList   = new List <NetLaneProps.Prop>();
            var thePropInfo = PrefabCollection <PropInfo> .FindLoaded("Tunnel Light Small Road") ??
                              PrefabCollection <PropInfo> .FindLoaded("Wall Light White");

            if (prefab.name.Contains("Steel"))
            {
                propsList.AddBasicProp(thePropInfo, new Vector3(-5.5f, 6, 0), 270);
            }
            else
            {
                propsList.AddBasicProp(thePropInfo, new Vector3(-3.5f, 6, 0), 270);
            }

            propLane.m_laneProps.m_props = propsList.ToArray();
            lanes.Add(propLane);
            prefab.m_lanes = lanes.ToArray();
        }
Esempio n. 3
0
        public static void ReplaceTrackIcon(NetInfo prefab, NetInfoVersion version)
        {
            if (version != NetInfoVersion.Ground)
            {
                return;
            }
            var metroTrack = PrefabCollection <NetInfo> .FindLoaded("Metro Track");

            prefab.m_Atlas                = metroTrack.m_Atlas;
            prefab.m_Thumbnail            = metroTrack.m_Thumbnail;
            prefab.m_InfoTooltipAtlas     = metroTrack.m_InfoTooltipAtlas;
            prefab.m_InfoTooltipThumbnail = metroTrack.m_InfoTooltipThumbnail;
            prefab.m_isCustomContent      = false;
            prefab.m_availableIn          = ItemClass.Availability.All;
            var locale = LocaleManager.instance.GetLocale();
            var key    = new Locale.Key {
                m_Identifier = "NET_TITLE", m_Key = prefab.name
            };

            if (!locale.Exists(key))
            {
                locale.AddLocalizedString(key, locale.Get(new Locale.Key {
                    m_Identifier = "NET_TITLE", m_Key = "Metro Track"
                }));
            }
            key = new Locale.Key {
                m_Identifier = "NET_DESC", m_Key = prefab.name
            };
            if (!locale.Exists(key))
            {
                locale.AddLocalizedString(key, locale.Get(new Locale.Key {
                    m_Identifier = "NET_DESC", m_Key = "Metro Track"
                }));
            }
        }
        //this method is supposed to be called before level loading
        public static void UpdateVanillaMetroTracks()
        {
            NetInfo metroTrack        = null;
            NetInfo metroStationTrack = null;

            if (OptionsWrapper <Options> .Options.ghostMode)
            {
                metroTrack = PrefabCollection <NetInfo> .FindLoaded("Metro Track Ground");

                metroStationTrack = PrefabCollection <NetInfo> .FindLoaded("Metro Station Track Ground");
            }
            else
            {
                metroTrack = PrefabCollection <NetInfo> .FindLoaded("Metro Track");

                metroStationTrack = PrefabCollection <NetInfo> .FindLoaded("Metro Station Track");
            }
            if (metroTrack != null)
            {
                metroTrack.m_availableIn = ItemClass.Availability.Editors;
            }
            if (metroStationTrack != null)
            {
                metroStationTrack.m_availableIn = ItemClass.Availability.Editors;
            }
        }
Esempio n. 5
0
        public static void ReplaceMedianSigns(NetInfo asset)
        {
            // only works on ground mode
            if (!OptionUI.levelLoaded && imedianSign == 1)
            {
                return;
            }
            foreach (NetInfo.Lane lane in asset.m_lanes)
            {
                // traffic lights are always on a non-vehicle lane
                if (lane.m_vehicleType == VehicleInfo.VehicleType.None)
                {
                    foreach (NetLaneProps.Prop prop in lane.m_laneProps.m_props)
                    {
                        if (prop.m_prop && prop.m_prop.name.Contains("CSUR MidSign"))
                        {
                            if (imedianSign == 0)
                            {
                                prop.m_prop      = null;
                                prop.m_finalProp = null;
                            }
                            else if (imedianSign == 2)
                            {
                                prop.m_prop = PrefabCollection <PropInfo> .FindLoaded("R2 R4-7 Keep Right Sign_Data");

                                prop.m_finalProp = prop.m_prop;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 6
0
        private void clickVehicleToNone(UIComponent component, UIMouseEventParameter eventParam)
        {
            foreach (KeyValuePair <string, List <byte> > e in customEmergencyLanes)
            {
                NetInfo info = PrefabCollection <NetInfo> .FindLoaded(e.Key);

                if (info == null)
                {
                    Log.Warning($"Could not find NetInfo by name {e.Key}");
                    continue;
                }

                foreach (byte index in e.Value)
                {
                    if (index < 0 || index >= info.m_lanes.Length)
                    {
                        Log.Warning($"Illegal lane index {index} for NetInfo {e.Key}");
                        continue;
                    }

                    Log._Debug($"Resetting vehicle type of lane {index} @ {info.name}");

                    info.m_lanes[index].m_vehicleType = VehicleInfo.VehicleType.None;
                    info.m_lanes[index].m_laneType    = NetInfo.LaneType.None;
                }
            }
            customEmergencyLanes.Clear();
        }
Esempio n. 7
0
        private void InitCapacitiesInAssets()
        {
            var keys = AssetConfigurations.Keys.ToList();

            foreach (string entry in keys)
            {
                try
                {
                    VehicleInfo info = PrefabCollection <VehicleInfo> .FindLoaded(entry);

                    if (info != null)
                    {
                        VehicleAI ai = info.m_vehicleAI;
                        UpdateDefaultCapacity(ai);
                        SetVehicleCapacity(ai, SafeGetAsset(entry).Capacity);
                    }
                    else
                    {
                        AssetConfigurations.Remove(entry);
                    }
                }
                catch (Exception e)
                {
                    LogUtils.DoErrorLog($"ERROR LOADING ASSET CONFIG: {e}=> {e.Message}\n{e.StackTrace}");
                }
            }
            SimulationManager.instance.StartCoroutine(TLMLineUtils.UpdateCapacityUnits());
        }
Esempio n. 8
0
        public static PropInfo GetSpecialPointProp(SpecialPointType pointType)
        {
            switch (pointType)
            {
            case SpecialPointType.Unknown:
                return(null);

            default:
                return(null);

            case SpecialPointType.SpawnPointTarget:
                return(PrefabCollection <PropInfo> .FindLoaded(SpecialPoints.SpawnPointTarget));

            case SpecialPointType.SpawnPointPosition:
                return(PrefabCollection <PropInfo> .FindLoaded(SpecialPoints.SpawnPointPosition));

            case SpecialPointType.DespawnPointTarget:
                return(PrefabCollection <PropInfo> .FindLoaded(SpecialPoints.DespawnPointTarget));

            case SpecialPointType.DespawnPointPosition:
                return(PrefabCollection <PropInfo> .FindLoaded(SpecialPoints.DespawnPointPosition));

            case SpecialPointType.SpawnPoint2Target:
                return(PrefabCollection <PropInfo> .FindLoaded(SpecialPoints.SpawnPoint2Target));

            case SpecialPointType.SpawnPoint2Position:
                return(PrefabCollection <PropInfo> .FindLoaded(SpecialPoints.SpawnPoint2Position));

            case SpecialPointType.TruckDespawnPosition:
                return(PrefabCollection <PropInfo> .FindLoaded(SpecialPoints.TruckDespawnPosition));

            case SpecialPointType.TruckSpawnPosition:
                return(PrefabCollection <PropInfo> .FindLoaded(SpecialPoints.TruckSpawnPosition));
            }
        }
Esempio n. 9
0
        public void SetVehicleCapacity(string assetName, int newCapacity)
        {
            VehicleInfo vehicle = PrefabCollection <VehicleInfo> .FindLoaded(assetName);

            if (vehicle != null && !VehicleUtils.IsTrailer(vehicle))
            {
                Dictionary <string, MutableTuple <float, int> > assetsCapacitiesPercentagePerTrailer = GetCapacityRelative(vehicle);
                int capacityUsed = 0;
                foreach (KeyValuePair <string, MutableTuple <float, int> > entry in assetsCapacitiesPercentagePerTrailer)
                {
                    SafeGetAsset(entry.Key).Capacity = Mathf.RoundToInt(newCapacity <= 0 ? -1f : entry.Value.First *newCapacity);
                    capacityUsed += SafeGetAsset(entry.Key).Capacity *entry.Value.Second;
                }
                if (newCapacity > 0 && capacityUsed != newCapacity)
                {
                    SafeGetAsset(assetsCapacitiesPercentagePerTrailer.Keys.ElementAt(0)).Capacity += (newCapacity - capacityUsed) / assetsCapacitiesPercentagePerTrailer[assetsCapacitiesPercentagePerTrailer.Keys.ElementAt(0)].Second;
                }
                foreach (string entry in assetsCapacitiesPercentagePerTrailer.Keys)
                {
                    VehicleAI vai = PrefabCollection <VehicleInfo> .FindLoaded(entry).m_vehicleAI;

                    SetVehicleCapacity(vai, SafeGetAsset(entry).Capacity);
                }
                SimulationManager.instance.StartCoroutine(TLMLineUtils.UpdateCapacityUnits());
            }
        }
Esempio n. 10
0
        public void LateBuildUp(NetInfo info, NetInfoVersion version)
        {
            var bollardName  = "StoneBollard";
            var stoneBollard = PrefabCollection <PropInfo> .FindLoaded($"{Framework.Tools.PackageName(bollardName)}.{bollardName}_Data");

            var RoadPlanter1Name = "RoadPlanter1";
            var RoadPlanter1     = PrefabCollection <PropInfo> .FindLoaded($"{Framework.Tools.PackageName(RoadPlanter1Name)}.{RoadPlanter1Name}_Data");

            var pedLanes = info.m_lanes.Where(pl => pl.m_laneType == NetInfo.LaneType.Pedestrian).ToArray();

            for (var i = 0; i < pedLanes.Length; i++)
            {
                var additionalProps = new List <NetLaneProps.Prop>();
                var bollardProp     = new NetLaneProps.Prop()
                {
                    m_prop             = stoneBollard,
                    m_finalProp        = stoneBollard,
                    m_probability      = 100,
                    m_segmentOffset    = 1,
                    m_minLength        = 10,
                    m_endFlagsRequired = NetNode.Flags.Transition
                };
                bollardProp.m_position.x = ((i * 2) - 1) * -3f;
                bollardProp.m_position.y = -0.3f;

                var bollardProp2 = bollardProp.ShallowClone();
                bollardProp2.m_segmentOffset      = -1;
                bollardProp2.m_endFlagsRequired   = NetNode.Flags.None;
                bollardProp2.m_startFlagsRequired = NetNode.Flags.Transition;

                var bollardProp3 = bollardProp.ShallowClone();
                bollardProp3.m_position.x = ((i * 2) - 1);

                var bollardProp4 = bollardProp2.ShallowClone();
                bollardProp4.m_position.x         = ((i * 2) - 1);
                bollardProp2.m_endFlagsRequired   = NetNode.Flags.None;
                bollardProp2.m_startFlagsRequired = NetNode.Flags.Transition;

                additionalProps.Add(bollardProp);
                additionalProps.Add(bollardProp2);
                additionalProps.Add(bollardProp3);
                additionalProps.Add(bollardProp4);

                //if (version == NetInfoVersion.Ground)
                //{
                //    var planterProp = new NetLaneProps.Prop();
                //    planterProp.m_prop = RoadPlanter1;
                //    planterProp.m_finalProp = RoadPlanter1;
                //    planterProp.m_repeatDistance = 30;
                //    planterProp.m_probability = 100;
                //    planterProp.m_position.x = ((i * 2) - 1) * 1.4f;
                //    additionalProps.Add(planterProp);
                //}

                var tempProps = pedLanes[i].m_laneProps.m_props.ToList();
                tempProps.AddRange(additionalProps);
                pedLanes[i].m_laneProps.m_props = tempProps.ToArray();
            }
        }
Esempio n. 11
0
        private static void NotInUseChangeTrainTrackExp(NetInfo info)
        {
            info.m_intersectClass = null;

            ItemClass road = PrefabCollection <NetInfo> .FindLoaded("Basic Road").m_class;

            info.m_connectionClass = road;
        }
Esempio n. 12
0
        private static void NotInUseChangeMetroTrackExp(NetInfo info)
        {
            ItemClass train = PrefabCollection <NetInfo> .FindLoaded("Train Track").m_class;

            info.m_connectionClass = train;

            info.m_class.m_layer = ItemClass.Layer.Default;
        }
Esempio n. 13
0
 public Dictionary <string, string> GetSelectedBasicAssets(uint prefix)
 {
     if (basicAssetsList == null)
     {
         LoadBasicAssets();
     }
     return(GetAssetList(prefix).Where(x => PrefabCollection <VehicleInfo> .FindLoaded(x) != null).ToDictionary(x => x, x => string.Format("[Cap={0}] {1}", TLMUtils.getCapacity(PrefabCollection <VehicleInfo> .FindLoaded(x)), Locale.Get("VEHICLE_TITLE", x))));
 }
Esempio n. 14
0
        public static NetInfo NetInfoFromUI(int fromSelected, int toSelected, byte symmetry,
                                            bool hasSidewalk, bool hasBike)
        {
            Debug.Log("fromSelected = " + fromSelected.ToString() + " toSelected = " + toSelected.ToString() + " symmetry = " + symmetry.ToString() + " hasSidewalk: " + hasSidewalk.ToString());
            string moduleName = ModuleNameFromUI(fromSelected, toSelected, symmetry, hasSidewalk, hasBike);

            return(PrefabCollection <NetInfo> .FindLoaded(moduleName + "_Data"));
        }
Esempio n. 15
0
        public static object CreateProp(object msg)
        {
            var      data = (CreatePropMessage)msg;
            PropInfo info = PrefabCollection <PropInfo> .FindLoaded(data.Type);

            Util.Assert(info, "Prefab '" + data.Type + "' not found");
            return(ManagersLogic.PrepareProp(ManagersUtil.CreateProp(data.Position.ToUnityTerrain(), (float)data.Angle, info, true)));
        }
Esempio n. 16
0
        public static void ReplaceLaneProp(string original, string replacement)
        {
            for (uint i = 0; i < PrefabCollection <NetInfo> .LoadedCount(); i++)
            {
                var netInfo = PrefabCollection <NetInfo> .GetLoaded(i);

                if (netInfo == null)
                {
                    Log.Info("SSE: The name '" + netInfo + "'does not belong to a loaded net!");
                    return;
                }
                if (!netInfo.m_hasPedestrianLanes)
                {
                    continue;
                }

                var replacementProp = PrefabCollection <PropInfo> .FindLoaded(replacement);

                if (replacementProp == null)
                {
                    Log.Info("SSE:The name '" + replacement + "'does not belong to a loaded prop!");
                    return;
                }

                if (netInfo.m_lanes != null)
                {
                    foreach (var lane in netInfo.m_lanes)
                    {
                        if (lane != null && lane.m_laneProps != null && lane.m_laneProps.m_props != null)
                        {
                            foreach (var laneProp in lane.m_laneProps.m_props)
                            {
                                if (laneProp != null && laneProp.m_prop != null && laneProp.m_prop.name == original)
                                {
                                    laneProp.m_prop      = replacementProp;
                                    laneProp.m_finalProp = replacementProp;

                                    switch (lane.m_laneProps.name)
                                    {
                                    case "Props - Gravel Left":
                                        laneProp.m_angle = -90;
                                        break;

                                    case "Props - Gravel Right":
                                        laneProp.m_angle = 90;
                                        break;

                                    case "Props - Basic Right":
                                        laneProp.m_angle = 180;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        private void CreateModelCheckBox(UICheckBox checkbox)
        {
            checkbox.eventMouseEnter += (x, y) =>
            {
                m_lastInfo = PrefabCollection <VehicleInfo> .FindLoaded(x.objectUserData.ToString());

                RedrawModel();
            };
        }
Esempio n. 18
0
        public override void OnLevelLoaded(LoadMode mode)
        {
            base.OnLevelLoaded(mode);
            var prefab = PrefabCollection <TreeInfo> .FindLoaded("CherryTree01");

            if (prefab == null)
            {
                UnityEngine.Debug.LogWarning("CherryTree01 wasn't found");
                return;
            }
            prefab.m_availableIn = ItemClass.Availability.All;
            var field = typeof(PrefabInfo).GetField("m_UICategory", BindingFlags.Instance | BindingFlags.NonPublic);

            field.SetValue(prefab, "BeautificationProps");
            var thumb   = Util.LoadTextureFromAssembly($"{typeof (ZenGardenTreeUnlocker).Name}.thumb.png", false);
            var tooltip = Util.LoadTextureFromAssembly($"{typeof(ZenGardenTreeUnlocker).Name}.tooltip.png", false);
            var atlas   = Util.CreateAtlas(new[] { thumb, tooltip });

            prefab.m_Atlas                = atlas;
            prefab.m_Thumbnail            = thumb.name;
            prefab.m_InfoTooltipAtlas     = atlas;
            prefab.m_InfoTooltipThumbnail = tooltip.name;


            var localeField = typeof(LocaleManager).GetField("m_Locale", BindingFlags.NonPublic | BindingFlags.Instance);
            var locale      = (Locale)localeField.GetValue(SingletonLite <LocaleManager> .instance);
            var key         = new Locale.Key()
            {
                m_Identifier = "TREE_TITLE", m_Key = prefab.name
            };

            if (!locale.Exists(key))
            {
                locale.AddLocalizedString(key, "Zen Garden Cherry Blossom");
            }
            key = new Locale.Key()
            {
                m_Identifier = "TREE_DESC", m_Key = prefab.name
            };
            if (!locale.Exists(key))
            {
                locale.AddLocalizedString(key, "A Cherry Blossom tree that is bundled with Zen Garden");
            }

            switch (mode)
            {
            case LoadMode.NewGame:
            case LoadMode.LoadGame:
                GameObject.Find("BeautificationPropsPanel").GetComponent <BeautificationPanel>().RefreshPanel();
                break;

            case LoadMode.NewMap:
            case LoadMode.LoadMap:
                GameObject.Find("ForestPanel").GetComponent <ForestGroupPanel>().RefreshPanel();
                break;
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Render a roads
        /// </summary>
        /// <param name="roads"></param>
        public static void RenderSegments(RenderManager.CameraInfo cameraInfo, Color segmentColor, List <Bezier3> roads)
        {
            var netPrefab = PrefabCollection <NetInfo> .FindLoaded("Basic Road");

            foreach (var road in roads)
            {
                RenderManager.instance.OverlayEffect.DrawBezier(cameraInfo, segmentColor, road, netPrefab.m_halfWidth * 4f / 3f, 100000f, -100000f, -1f, 1280f, false, true);
            }
        }
        public void LateBuildUp(NetInfo info, NetInfoVersion version)
        {
            var plPropInfo = PrefabCollection <PropInfo> .FindLoaded("RailwayPowerline Singular");

            var oldPlPropInfo = Prefabs.Find <PropInfo>("RailwayPowerline");

            NetInfoExtensions.ReplaceProps(info, plPropInfo, oldPlPropInfo);
            for (int i = 0; i < info.m_lanes.Count(); i++)
            {
                var powerLineProp = info.m_lanes[i].m_laneProps.m_props.Where(p => p.m_prop == plPropInfo).ToList();
                for (int j = 0; j < powerLineProp.Count(); j++)
                {
                    powerLineProp[j].m_position = new Vector3(2.4f, -0.15f, 0);
                    powerLineProp[j].m_angle    = 0;
                }
            }

            if (version == NetInfoVersion.Elevated)
            {
                var epPropInfo = PrefabCollection <BuildingInfo> .FindLoaded($"{Util.PackageName("Rail1LElevatedPillar")}.Rail1LElevatedPillar_Data");

                if (epPropInfo == null)
                {
                    throw new Exception($"{info.name}: Rail1LElevatedPillar prop not found!");
                }

                if (epPropInfo != null)
                {
                    var bridgeAI = info.GetComponent <TrainTrackBridgeAI>();
                    if (bridgeAI != null)
                    {
                        bridgeAI.m_doubleLength       = false;
                        bridgeAI.m_bridgePillarInfo   = epPropInfo;
                        bridgeAI.m_bridgePillarOffset = 1;
                        bridgeAI.m_middlePillarInfo   = null;
                    }
                }
            }
            else if (version == NetInfoVersion.Bridge)
            {
                var bpPropInfo = PrefabCollection <BuildingInfo> .FindLoaded($"{Util.PackageName("Rail1LBridgePillar")}.Rail1LBridgePillar_Data");

                if (bpPropInfo == null)
                {
                    throw new Exception($"{info.name}: Rail1LBridgePillar prop not found!");
                }

                if (bpPropInfo != null)
                {
                    var bridgeAI = info.GetComponent <TrainTrackBridgeAI>();
                    if (bridgeAI != null)
                    {
                        bridgeAI.m_bridgePillarInfo = bpPropInfo;
                    }
                }
            }
        }
        private void CreateModelCheckBox(string i, UICheckBox checkbox)
        {
            checkbox.eventMouseEnter += (x, y) =>
            {
                m_lastInfo = PrefabCollection <VehicleInfo> .FindLoaded(i);

                redrawModel();
            };
        }
Esempio n. 22
0
        private void ShowNetwork(string name, string desc, GeneratedScrollPanel panel, int constructionCost, int maintenanceCost, string prefixIcon)
        {
            UIButton button = panel.Find <UIButton>(name);

            if (button != null && button.name == name)
            {
                GameObject.DestroyImmediate(button);
            }

            NetInfo netInfo = PrefabCollection <NetInfo> .FindLoaded(name);

            if (netInfo == null)
            {
                DebugUtils.Warning("Couldn't find NetInfo named '" + name + "'");
                return;
            }

            //DebugUtils.Log("NetInfo named '" + name + "' found.");

            PlayerNetAI netAI = netInfo.m_netAI as PlayerNetAI;

            // Adding cost
            netAI.m_constructionCost = constructionCost;
            netAI.m_maintenanceCost  = maintenanceCost;

            // Making the prefab valid
            netInfo.m_availableIn    = ItemClass.Availability.All;
            netInfo.m_placementStyle = ItemClass.Placement.Manual;
            typeof(NetInfo).GetField("m_UICategory", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(netInfo, "PublicTransportPlane");

            // Adding icons
            netInfo.m_Atlas     = m_atlas;
            netInfo.m_Thumbnail = prefixIcon;

            // Adding missing locale
            Locale locale = (Locale)typeof(LocaleManager).GetField("m_Locale", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(SingletonLite <LocaleManager> .instance);

            Locale.Key key = new Locale.Key()
            {
                m_Identifier = "NET_TITLE", m_Key = name
            };
            if (!locale.Exists(key))
            {
                locale.AddLocalizedString(key, name);
            }
            key = new Locale.Key()
            {
                m_Identifier = "NET_DESC", m_Key = name
            };
            if (!locale.Exists(key))
            {
                locale.AddLocalizedString(key, desc);
            }

            typeof(GeneratedScrollPanel).GetMethod("CreateAssetItem", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(panel, new object[] { netInfo });
        }
Esempio n. 23
0
        private static NetInfo FindMetroTrack(string trackName)
        {
            var result = PrefabCollection <NetInfo> .FindLoaded(trackName);

            if (result == null)
            {
                throw new Exception($"Metro Station Converter didn't find asset {trackName}.");
            }
            return(result);
        }
Esempio n. 24
0
        //this method is supposed to be called before level loading
        public static void PreventVanillaMetroTrainSpawning()
        {
            var metro = PrefabCollection <VehicleInfo> .FindLoaded("Metro");

            if (metro == null)
            {
                return;
            }
            metro.m_class = ScriptableObject.CreateInstance <ItemClass>();
        }
Esempio n. 25
0
        public Dictionary <string, string> GetSelectedBasicAssets(uint lineId)
        {
            TransportSystemDefinition tsd = TransportSystemDefinition.from(lineId);

            if (!basicAssetsList.ContainsKey(tsd))
            {
                basicAssetsList[tsd] = TLMUtils.LoadBasicAssets(ref tsd);
            }
            return(GetAssetList(lineId).Where(x => PrefabCollection <VehicleInfo> .FindLoaded(x) != null).ToDictionary(x => x, x => string.Format("[Cap={0}] {1}", TLMUtils.getCapacity(PrefabCollection <VehicleInfo> .FindLoaded(x)), Locale.Get("VEHICLE_TITLE", x))));
        }
        public static AudioInfo GetAudioInfoFromBuildingInfo(string id)
        {
            BuildingInfo building = PrefabCollection <BuildingInfo> .FindLoaded(id);

            if (building != null)
            {
                return(building.m_customLoopSound);
            }
            return(null);
        }
Esempio n. 27
0
        /// <summary>
        /// Adds the referenced asset.
        /// </summary>
        /// <typeparam name="T">The prefab type.</typeparam>
        /// <param name="referenceType">Type of the reference.</param>
        /// <param name="prefab">The prefab.</param>
        protected void AddReferencedAsset <T>(Reference.ReferenceTypes referenceType, PrefabInfo prefab) where T : PrefabInfo
        {
            if (!this.ReferencedAssets.ContainsKey(prefab.gameObject.name))
            {
                bool exists = prefab.m_prefabInitialized ||
                              PrefabCollection <T> .FindLoaded(prefab.gameObject.name) != null;

                this.ReferencedAssets[prefab.gameObject.name] = new Reference(referenceType, prefab, exists);
            }
        }
Esempio n. 28
0
        private static void ChangeMetroTrack(NetInfo info)
        {
            // Add layer Default, which is the same layer as Train Track.
            info.m_class.m_layer |= ItemClass.Layer.Default;

            // Let Metro Track be able to connect to Train Track.
            ItemClass train = PrefabCollection <NetInfo> .FindLoaded("Train Track").m_class;

            info.m_connectionClass = train;
        }
Esempio n. 29
0
        public static NetInfo GetInfo(string name)
        {
            var ret = PrefabCollection <NetInfo> .FindLoaded(name);

            if (ret is null)
            {
                Log.Warning($"NetInfo '{name}' not found!");
            }
            return(ret);
        }
Esempio n. 30
0
        private static PropInfo FindProp(string prefabName, string packageName)
        {
            var prefab = PrefabCollection <PropInfo> .FindLoaded(prefabName) ??
                         PrefabCollection <PropInfo> .FindLoaded(prefabName + "_Data") ??
                         PrefabCollection <PropInfo> .FindLoaded(PathEscaper.Escape(prefabName) + "_Data") ??
                         PrefabCollection <PropInfo> .FindLoaded(packageName + "." + prefabName + "_Data") ??
                         PrefabCollection <PropInfo> .FindLoaded(packageName + "." + PathEscaper.Escape(prefabName) + "_Data");

            return(prefab);
        }