bool GeneratePropButton(string localpath, string LocalName, GameObject Prefab) { if (!localpath.ToLower().EndsWith(".bp")) { return(false); } string PropPath = ""; if (localpath.EndsWith(".bp")) { PropPath = LocalName.Replace(".bp", ""); } else if (localpath.EndsWith(".BP")) { PropPath = LocalName.Replace(".BP", ""); } GetGamedataFile.PropObject LoadedProp = null; if (localpath.ToLower().StartsWith("maps")) { localpath = "/" + localpath; LoadedProp = GetGamedataFile.LoadProp(GetGamedataFile.MapScd, localpath); } else { LoadedProp = GetGamedataFile.LoadProp(GetGamedataFile.EnvScd, localpath); } GameObject NewButton = Instantiate(Prefab) as GameObject; NewButton.transform.SetParent(Pivot, false); if (LoadedProp.BP.LODs.Length > 0 && LoadedProp.BP.LODs[0].Albedo) { NewButton.GetComponent <RawImage>().texture = LoadedProp.BP.LODs[0].Albedo; } ResourceObject Ro = NewButton.GetComponent <ResourceObject>(); Ro.InstanceId = LoadedPaths.Count; Ro.NameField.text = LoadedProp.BP.Name; PropPath = PropPath.Replace(LoadedProp.BP.Name, ""); Ro.CustomTexts[2].text = PropPath; Ro.CustomTexts[0].text = LoadedProp.BP.ReclaimMassMax.ToString(); Ro.CustomTexts[1].text = LoadedProp.BP.ReclaimEnergyMax.ToString(); LoadedPaths.Add(localpath); LoadedProps.Add(LoadedProp); if (localpath.ToLower() == SelectedObject.ToLower()) { Ro.Selected.SetActive(true); Pivot.GetComponent <RectTransform>().anchoredPosition = Vector2.up * 250 * Mathf.FloorToInt(LoadedPaths.Count / 5f); } return(true); }
int GenerateMapPropButton(string loadPath, string absolutePath, GameObject Prefab) { string RelativePath = "/" + absolutePath.Replace(MapLuaParser.LoadedMapFolderPath, MapLuaParser.RelativeLoadedMapFolderPath); Debug.Log(RelativePath); string PropPath = ""; if (RelativePath.EndsWith(".bp")) { PropPath = RelativePath.Replace(".bp", ""); } else if (RelativePath.EndsWith(".BP")) { PropPath = RelativePath.Replace(".BP", ""); } GetGamedataFile.PropObject LoadedProp = GetGamedataFile.LoadProp(GetGamedataFile.MapScd, RelativePath); GameObject NewButton = Instantiate(Prefab) as GameObject; NewButton.transform.SetParent(Pivot, false); if (LoadedProp.BP.LODs.Length > 0 && LoadedProp.BP.LODs[0].Albedo) { NewButton.GetComponent <RawImage>().texture = LoadedProp.BP.LODs[0].Albedo; } ResourceObject Ro = NewButton.GetComponent <ResourceObject>(); Ro.InstanceId = LoadedPaths.Count; Ro.NameField.text = LoadedProp.BP.Name; PropPath = PropPath.Replace(LoadedProp.BP.Name, ""); Ro.CustomTexts[2].text = PropPath; Ro.CustomTexts[0].text = LoadedProp.BP.ReclaimMassMax.ToString(); Ro.CustomTexts[1].text = LoadedProp.BP.ReclaimEnergyMax.ToString(); LoadedPaths.Add(RelativePath); LoadedProps.Add(LoadedProp); if (RelativePath.ToLower() == SelectedObject.ToLower()) { Ro.Selected.SetActive(true); Pivot.GetComponent <RectTransform>().anchoredPosition = Vector2.up * 250 * Mathf.FloorToInt(LoadedPaths.Count / 5f); } return(1); }
int GetPropType(string blueprint) { int AllPropsTypesCount = AllPropsTypes.Count; if (AllPropsTypesCount == 0) { } else { for (int g = 0; g < AllPropsTypesCount; g++) { if (blueprint == AllPropsTypes[g].Blueprint) { return(g); } } } AllPropsTypes.Add(new PropTypeGroup()); AllPropsTypes[AllPropsTypesCount].Blueprint = blueprint; AllPropsTypes[AllPropsTypesCount].PropObject = GetGamedataFile.LoadProp(blueprint); return(AllPropsTypesCount); }
public IEnumerator LoadProps() { LoadingProps = true; UnloadProps(); List <Prop> Props = ScmapEditor.Current.map.Props; //Debug.Log("Found props: " + Props.Count); const int YieldStep = 1000; int LoadCounter = YieldStep; int Count = Props.Count; LoadedCount = 0; bool AllowFarLod = Count < 10000; for (int i = 0; i < Count; i++) { bool NewProp = false; int GroupId = 0; if (AllPropsTypes.Count == 0) { NewProp = true; } else { NewProp = true; for (int g = 0; g < AllPropsTypes.Count; g++) { if (Props[i].BlueprintPath == AllPropsTypes[g].Blueprint) { NewProp = false; GroupId = g; break; } } } if (NewProp) { GroupId = AllPropsTypes.Count; AllPropsTypes.Add(new PropTypeGroup()); AllPropsTypes[GroupId].Blueprint = Props[i].BlueprintPath; AllPropsTypes[GroupId].PropObject = GetGamedataFile.LoadProp(AllPropsTypes[GroupId].Blueprint); LoadCounter = YieldStep; yield return(null); } Props[i].GroupId = GroupId; Props[i].CreateObject(AllowFarLod); AllPropsTypes[GroupId].PropsInstances.Add(Props[i]); LoadedCount++; LoadCounter--; if (LoadCounter <= 0) { LoadCounter = YieldStep; yield return(null); } TotalMassCount += AllPropsTypes[GroupId].PropObject.BP.ReclaimMassMax; TotalEnergyCount += AllPropsTypes[GroupId].PropObject.BP.ReclaimEnergyMax; TotalReclaimTime += AllPropsTypes[GroupId].PropObject.BP.ReclaimTime; } UpdatePropStats(); yield return(null); LoadingProps = false; }
public void ImportPropsSet() { var extensions = new[] { new ExtensionFilter("Props paint set", "proppaintset") }; var paths = StandaloneFileBrowser.OpenFilePanel("Import props paint set", DefaultPath, extensions, false); if (paths.Length <= 0 || string.IsNullOrEmpty(paths[0])) { return; } string data = File.ReadAllText(paths[0]); PaintButtonsSet PaintSet = JsonUtility.FromJson <PaintButtonsSet>(data); while (PaintButtons.Count > 0) { RemoveProp(0); } //bool[] Exist = new bool[PaintPropObjects.Count]; for (int i = 0; i < PaintSet.PaintProps.Length; i++) { //bool Found = false; int o = 0; /* * for(o = 0; i < PaintPropObjects.Count; o++) * { * if(PaintPropObjects[i].BP.Path == PaintSet.PaintProps[i].Blueprint) * { * if (o < Exist.Length) * Exist[o] = true; * Found = true; * break; * } * }*/ //if (!Found) { // Load if (!LoadProp(GetGamedataFile.LoadProp(PaintSet.PaintProps[i].Blueprint))) { Debug.LogWarning("Can't load prop at path: " + PaintSet.PaintProps[i].Blueprint); continue; } o = PaintButtons.Count - 1; } PaintButtons[o].ScaleMin.SetValue(PaintSet.PaintProps[i].ScaleMin); PaintButtons[o].ScaleMax.SetValue(PaintSet.PaintProps[i].ScaleMax); PaintButtons[o].RotationMin.SetValue(PaintSet.PaintProps[i].RotationMin); PaintButtons[o].RotationMax.SetValue(PaintSet.PaintProps[i].RotationMax); PaintButtons[o].Chance.SetValue(PaintSet.PaintProps[i].Chance); } /* * for(int i = Exist.Length - 1; i >= 0; i--) * { * if (!Exist[i]) * { * RemoveProp(i); * } * } */ EnvPaths.SetLastPath(ExportPathKey, System.IO.Path.GetDirectoryName(paths[0])); }
public void ImportPropsSet() { var extensions = new[] { new ExtensionFilter("Props paint set", "proppaintset") }; var paths = StandaloneFileBrowser.OpenFilePanel("Import props paint set", EnvPaths.GetMapsPath(), extensions, false); if (paths.Length <= 0 || string.IsNullOrEmpty(paths[0])) { return; } string data = File.ReadAllText(paths[0]); PaintButtonsSet PaintSet = JsonUtility.FromJson <PaintButtonsSet>(data); bool[] Exist = new bool[PaintPropObjects.Count]; for (int i = 0; i < PaintSet.PaintProps.Length; i++) { bool Found = false; int o = 0; for (o = 0; i < PaintPropObjects.Count; o++) { if (PaintPropObjects[i].BP.Path == PaintSet.PaintProps[i].Blueprint) { if (o < Exist.Length) { Exist[o] = true; } Found = true; break; } } if (!Found) { // Load if (!LoadProp(GetGamedataFile.LoadProp(PaintSet.PaintProps[i].Blueprint))) { Debug.LogWarning("Can't load prop at path: " + PaintSet.PaintProps[i].Blueprint); continue; } o = PaintButtons.Count - 1; } PaintButtons[o].ScaleMin.SetValue(PaintSet.PaintProps[i].ScaleMin); PaintButtons[o].ScaleMax.SetValue(PaintSet.PaintProps[i].ScaleMax); PaintButtons[o].RotationMin.SetValue(PaintSet.PaintProps[i].RotationMin); PaintButtons[o].RotationMax.SetValue(PaintSet.PaintProps[i].RotationMax); PaintButtons[o].Chance.SetValue(PaintSet.PaintProps[i].Chance); } for (int i = Exist.Length - 1; i >= 0; i--) { if (!Exist[i]) { RemoveProp(i); } } }