IEnumerator PreloadEditor() { yield return(null); MapLuaParser.LoadStructurePaths(); yield return(null); BrushGenerator.Current.LoadBrushes(); yield return(null); //Preload heavy gamedata files GetGamedataFile.GetZipFileInstance(GetGamedataFile.UnitsScd); yield return(null); yield return(null); GetGamedataFile.GetFAFZipFileInstance(GetGamedataFile.UnitsScd); yield return(null); yield return(null); yield return(null); SceneManager.LoadSceneAsync(1, LoadSceneMode.Single); }
public void Bake() { //Group.Blueprint = GetGamedataFile.FixMapsPath(Group.Blueprint.Replace("\\", "/")); BlueprintPath = Group.Blueprint.Replace("\\", "/"); if (!BlueprintPath.StartsWith("/")) { BlueprintPath = "/" + BlueprintPath; } BlueprintPath = GetGamedataFile.FixMapsPath(BlueprintPath); Position = ScmapEditor.WorldPosToScmap(Obj.Tr.position); RotationX = Vector3.zero; RotationY = Vector3.zero; RotationZ = Vector3.zero; MassMath.QuaternionToRotationMatrix(Obj.Tr.localRotation, ref RotationX, ref RotationY, ref RotationZ); Scale = Obj.Tr.localScale; if (Group.PropObject.BP != null) { Scale.x /= Group.PropObject.BP.LocalScale.x; Scale.y /= Group.PropObject.BP.LocalScale.y; Scale.z /= Group.PropObject.BP.LocalScale.z; } }
public override void DoRedo() { Undo.Current.EditMenu.SetState(Editing.EditStates.TexturesStat); ScmapEditor.Current.Textures[i].Albedo = Textures.Albedo; ScmapEditor.Current.Textures[i].AlbedoPath = Textures.AlbedoPath; ScmapEditor.Current.Textures[i].AlbedoScale = Textures.AlbedoScale; ScmapEditor.Current.Textures[i].Normal = Textures.Normal; ScmapEditor.Current.Textures[i].NormalPath = Textures.NormalPath; ScmapEditor.Current.Textures[i].NormalScale = Textures.NormalScale; ScmapEditor.Current.map.Layers[i].PathTexture = Textures.AlbedoPath; ScmapEditor.Current.map.Layers[i].PathNormalmap = Textures.NormalPath; ScmapEditor.Current.Textures[i].Tilling = Textures.Tilling; if (ScmapEditor.Current.Textures[i].Albedo == null) { GetGamedataFile.LoadTextureFromGamedata(Textures.AlbedoPath, i, false); } if (ScmapEditor.Current.Textures[i].Normal == null) { GetGamedataFile.LoadTextureFromGamedata(Textures.NormalPath, i, true); } ScmapEditor.Current.SetTextures(i); Undo.Current.EditMenu.EditStratum.ReloadStratums(); Undo.Current.EditMenu.EditStratum.SelectStratum(i); }
public WaveRenderer(WaveGenerator wave) { waveTexture = GetGamedataFile.LoadTexture2D(wave.TextureName, false, true, true); rampTexture = GetGamedataFile.LoadTexture2D(wave.RampName, false, true, true); waveTexture.wrapMode = TextureWrapMode.Clamp; rampTexture.wrapMode = TextureWrapMode.Clamp; waveTexture.mipMapBias = -0.5f; mpb = new MaterialPropertyBlock(); waveMaterial = new Material(Instance.waveMaterial); waveMaterial.SetTexture(SHADER_ALBEDO, waveTexture); waveMaterial.SetTexture(SHADER_RAMP, rampTexture); //waveMaterial.SetVector(SHADER_VELOCITY, wave.Velocity); Instance.loadedMaterial = waveMaterial; instancesCount = 0; count = 0; AddInstance(wave); }
void CreatePrefabAction(GameObject InstancedPrefab) { UnitSource us = GetGamedataFile.LoadUnit(SelectedUnit.CodeName); SelectedUnitSource.Parent = FirstSelected.Source; SelectedUnitSource.Owner = FirstSelected.Owner; us.FillGameObjectValues(InstancedPrefab, SelectedUnitSource, FirstSelected.Source, Vector3.zero, Quaternion.identity); }
public void Load(Decal Source) { Type = Source.Type; Tex1Path = GetGamedataFile.FixMapsPath(Source.TexPathes[0]); Tex2Path = GetGamedataFile.FixMapsPath(Source.TexPathes[1]); UpdateMaterial(); }
public static Texture2D AssignTextureFromPath(ref Material mat, string property, string path) { Texture2D Tex = GetGamedataFile.LoadTexture2DFromGamedata(GetGamedataFile.EnvScd, path); Tex.wrapMode = TextureWrapMode.Clamp; mat.SetTexture(property, Tex); return(Tex); }
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); }
void Awake() { Current = this; LoadStructurePaths(); DecalsInfo.Current = DecalsMenu; PropsInfo.Current = PropsMenu; UnitsInfo.Current = UnitsMenu; GetGamedataFile.LoadGamedata(); }
int GenerateMapTextureButton(string loadPath, string absolutePath, GameObject Prefab) { Texture2D LoadedTex; string RelativePath = "/" + absolutePath.Replace(MapLuaParser.LoadedMapFolderPath, MapLuaParser.RelativeLoadedMapFolderPath); //Debug.Log(RelativePath); try { LoadedTex = GetGamedataFile.LoadTexture2D(RelativePath, false, false); } catch (System.Exception e) { LoadedTex = new Texture2D(128, 128); Debug.LogWarning("Can't load DDS texture: " + e); return(0); } string TexPath = ""; if (RelativePath.EndsWith(".dds")) { TexPath = RelativePath.Replace(".dds", ""); } else if (RelativePath.EndsWith(".DDS")) { TexPath = RelativePath.Replace(".DDS", ""); } GameObject NewButton = Instantiate(Prefab) as GameObject; NewButton.transform.SetParent(Pivot, false); NewButton.GetComponent <ResourceObject>().SetImages(LoadedTex); NewButton.GetComponent <ResourceObject>().InstanceId = LoadedTextures.Count; NewButton.GetComponent <ResourceObject>().NameField.text = TexPath; LoadedTextures.Add(LoadedTex); LoadedPaths.Add(RelativePath); if (RelativePath.ToLower() == SelectedObject.ToLower()) { LastSelection = NewButton.GetComponent <ResourceObject>().Selected; LastSelection.SetActive(true); Pivot.GetComponent <RectTransform>().anchoredPosition = Vector2.up * 250 * Mathf.FloorToInt(LoadedPaths.Count / 5f); } return(1); }
IEnumerator GenerateList() { Loading.SetActive(true); Layout.enabled = true; SizeFitter.enabled = true; int GenerateCount = 0; for (int i = 0; i < FoundUnits.Count; i++) { GetGamedataFile.UnitDB UnitDB = GetGamedataFile.LoadUnitBlueprintPreview(FoundUnits[i]); GameObject NewButton = Instantiate(Prefab) as GameObject; NewButton.transform.SetParent(Pivot, false); ResourceObject NewResObject = NewButton.GetComponent <ResourceObject>(); NewResObject.RawImages[0].texture = IconBackgrounds[UnitDB.Icon]; NewResObject.RawImages[1].texture = GetGamedataFile.LoadTexture2DFromGamedata(GetGamedataFile.TexturesScd, "/textures/ui/common/icons/units/" + UnitDB.CodeName + "_icon.dds", false, true, true); if (NewResObject.RawImages[1].texture == Texture2D.whiteTexture) { NewResObject.RawImages[1].enabled = false; } NewResObject.InstanceId = i; NewResObject.NameField.text = UnitDB.CodeName; NewResObject.CustomTexts[0].text = SortDescription(UnitDB); NewResObject.CustomTexts[1].text = UnitDB.Name; NewButton.SetActive(CheckSorting(UnitDB)); LoadedButtons.Add(NewResObject); LoadedUnits.Add(UnitDB); GenerateCount++; if (GenerateCount >= 7) { GenerateCount = 0; yield return(null); } } IsGenerated = true; yield return(null); Loading.SetActive(false); Layout.enabled = false; SizeFitter.enabled = false; GeneratingList = null; SortUnits(); }
public void Instantiate() { if (Instance && Instance.gameObject) { return; } UnitInstance ui = GetGamedataFile.LoadUnit(type).CreateUnitObject(this, Parent); ui.IsWreckage = Parent.IsWreckage ? 1 : 0; if (AllNames.Contains(Name)) { Name = GetFreeName("UNIT_"); } AllNames.Add(Name); }
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); }
bool GenerateTextureButton(string localpath, string LocalName, GameObject Prefab) { if (!LocalName.ToLower().EndsWith(".dds")) { return(true); } Texture2D LoadedTex; try { LoadedTex = GetGamedataFile.LoadTexture2DFromGamedata(GetGamedataFile.EnvScd, localpath, false, false); } catch (System.Exception e) { LoadedTex = new Texture2D(128, 128); Debug.LogWarning("Can't load DDS texture: " + e); } string TexPath = ""; if (localpath.EndsWith(".dds")) { TexPath = LocalName.Replace(".dds", ""); } else if (localpath.EndsWith(".DDS")) { TexPath = LocalName.Replace(".DDS", ""); } GameObject NewButton = Instantiate(Prefab) as GameObject; NewButton.transform.SetParent(Pivot, false); NewButton.GetComponent <ResourceObject>().SetImages(LoadedTex); NewButton.GetComponent <ResourceObject>().InstanceId = LoadedTextures.Count; NewButton.GetComponent <ResourceObject>().NameField.text = TexPath; LoadedTextures.Add(LoadedTex); LoadedPaths.Add(localpath); if (localpath.ToLower() == SelectedObject.ToLower()) { LastSelection = NewButton.GetComponent <ResourceObject>().Selected; LastSelection.SetActive(true); Pivot.GetComponent <RectTransform>().anchoredPosition = Vector2.up * 250 * Mathf.FloorToInt(LoadedPaths.Count / 5f); } return(false); }
public void Bake() { _Dec.Type = _Dec.Shared.Type; _Dec.Position = ScmapEditor.WorldPosToScmap(GetPivotPoint()); _Dec.Scale = tr.localScale * 10f; _Dec.Rotation = tr.localEulerAngles * Mathf.Deg2Rad; _Dec.CutOffLOD = CutOffLOD; _Dec.NearCutOffLOD = NearCutOffLOD; _Dec.TexPathes = new string[2]; _Dec.Shared.FixPaths(); _Dec.Shared.Tex1Path = GetGamedataFile.FixMapsPath(_Dec.Shared.Tex1Path); _Dec.Shared.Tex2Path = GetGamedataFile.FixMapsPath(_Dec.Shared.Tex2Path); _Dec.TexPathes[0] = _Dec.Shared.Tex1Path; _Dec.TexPathes[1] = _Dec.Shared.Tex2Path; _Dec.Obj = this; }
public UnitsGroup(string name, LuaTable Table) { Name = name; orders = LuaParser.Read.StringFromTable(Table, KEY_ORDERS); platoon = LuaParser.Read.StringFromTable(Table, KEY_PLATOON); UnitGroups = new HashSet <UnitsGroup>(); UnitInstances = new HashSet <UnitInstance>(); LuaTable[] UnitsTables = LuaParser.Read.GetTableTables((LuaTable)Table.RawGet(KEY_UNITS)); string[] UnitsNames = LuaParser.Read.GetTableKeys((LuaTable)Table.RawGet(KEY_UNITS)); if (UnitsNames.Length > 0) { for (int i = 0; i < UnitsNames.Length; i++) { if (LuaParser.Read.ValueExist(UnitsTables[i], KEY_TYPE)) { Unit NewUnit = new Unit(); NewUnit.Name = UnitsNames[i]; NewUnit.type = LuaParser.Read.StringFromTable(UnitsTables[i], KEY_TYPE); NewUnit.orders = LuaParser.Read.StringFromTable(UnitsTables[i], KEY_ORDERS); NewUnit.platoon = LuaParser.Read.StringFromTable(UnitsTables[i], KEY_PLATOON); //Debug.Log(UnitsTables[i].RawGet(KEY_POSITION)); NewUnit.Position = LuaParser.Read.Vector3FromTable(UnitsTables[i], KEY_POSITION); NewUnit.Orientation = LuaParser.Read.Vector3FromTable(UnitsTables[i], KEY_ORIENTATION); GetGamedataFile.LoadUnit(NewUnit.type).CreateUnitObject(NewUnit, this); } else { UnitsGroup NewUnitsGroup = new UnitsGroup(UnitsNames[i], UnitsTables[i]); UnitGroups.Add(NewUnitsGroup); } } } else { UnitGroups = new HashSet <UnitsGroup>(); UnitInstances = new HashSet <UnitInstance>(); } }
public void SetWaterTextures() { Texture2D WaterRamp = GetGamedataFile.LoadTexture2DFromGamedata(GetGamedataFile.TexturesScd, map.Water.TexPathWaterRamp, false, true, true); WaterRamp.wrapMode = TextureWrapMode.Clamp; Shader.SetGlobalTexture("_WaterRam", WaterRamp); try { Cubemap WaterReflection = GetGamedataFile.GetGamedataCubemap(GetGamedataFile.TexturesScd, map.Water.TexPathCubemap); WaterMaterial.SetTexture("SkySampler", WaterReflection); } catch { WaterMaterial.SetTexture("SkySampler", DefaultWaterSky); } const int WaterAnisoLevel = 4; Texture2D WaterNormal = GetGamedataFile.LoadTexture2DFromGamedata(GetGamedataFile.TexturesScd, map.Water.WaveTextures[0].TexPath, false, true, true); WaterNormal.anisoLevel = WaterAnisoLevel; WaterMaterial.SetTexture("NormalSampler0", WaterNormal); WaterNormal = GetGamedataFile.LoadTexture2DFromGamedata(GetGamedataFile.TexturesScd, map.Water.WaveTextures[1].TexPath, false, true, true); WaterNormal.anisoLevel = WaterAnisoLevel; WaterMaterial.SetTexture("NormalSampler1", WaterNormal); WaterNormal = GetGamedataFile.LoadTexture2DFromGamedata(GetGamedataFile.TexturesScd, map.Water.WaveTextures[2].TexPath, false, true, true); WaterNormal.anisoLevel = WaterAnisoLevel; WaterMaterial.SetTexture("NormalSampler2", WaterNormal); WaterNormal = GetGamedataFile.LoadTexture2DFromGamedata(GetGamedataFile.TexturesScd, map.Water.WaveTextures[3].TexPath, false, true, true); WaterNormal.anisoLevel = WaterAnisoLevel; WaterMaterial.SetTexture("NormalSampler3", WaterNormal); Shader.SetGlobalVector("normal1Movement", map.Water.WaveTextures[0].NormalMovement); Shader.SetGlobalVector("normal2Movement", map.Water.WaveTextures[1].NormalMovement); Shader.SetGlobalVector("normal3Movement", map.Water.WaveTextures[2].NormalMovement); Shader.SetGlobalVector("normal4Movement", map.Water.WaveTextures[3].NormalMovement); Shader.SetGlobalVector("normalRepeatRate", new Vector4(map.Water.WaveTextures[0].NormalRepeat, map.Water.WaveTextures[1].NormalRepeat, map.Water.WaveTextures[2].NormalRepeat, map.Water.WaveTextures[3].NormalRepeat)); }
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 LoadUnits() { var ListEnum = UnitsToLoad.GetEnumerator(); int count = UnitsToLoad.Count; int counter = 1; int BreakCounter = 0; MapLuaParser.Current.InfoPopup.Show(true, "Loading map...\n( Loading units " + counter + "/" + count + ")"); yield return(null); bool NeedReload = false; while (ListEnum.MoveNext()) { NeedReload = !GetGamedataFile.IsUnitSourceLoaded(ListEnum.Current.type); ListEnum.Current.Instantiate(); counter++; BreakCounter++; if (BreakCounter > 100) { BreakCounter = 0; NeedReload = true; } if (NeedReload) { MapLuaParser.Current.InfoPopup.Show(true, "Loading map...\n( Loading units " + counter + "/" + count + ")"); yield return(null); } } ListEnum.Dispose(); yield return(null); }
public static string FixMapsPath(string BlueprintPath) { if (GetGamedataFile.IsMapPath(BlueprintPath)) { //Debug.Log(MapLuaParser.Current.FolderName); if (!BlueprintPath.StartsWith("/maps/" + MapLuaParser.Current.FolderName) && !BlueprintPath.StartsWith("maps/" + MapLuaParser.Current.FolderName)) { //if (!System.IO.File.Exists(GetGamedataFile.MapAssetSystemPath(BlueprintPath))) //{ string NewBlueprintPath = GetGamedataFile.TryRecoverMapAsset(BlueprintPath); Debug.Log("Before: " + BlueprintPath + ", after: " + NewBlueprintPath); if (!string.IsNullOrEmpty(NewBlueprintPath)) { return(NewBlueprintPath); } else { Debug.LogError("Unable to recover wrong map path: " + BlueprintPath); } } } return(BlueprintPath); }
private void SaveTexture(BinaryWriter Stream, Texture2D texture, GetGamedataFile.HeaderClass header) { byte[] texArray = TextureLoader.SaveTextureDDS(texture, header); Debug.Log("L2: " + texArray.Length); Stream.Write(texArray.Length); Stream.Write(texArray,0,texArray.Length); }
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])); }
void ReadAllUnits() { FoundUnits.Clear(); IconBackgrounds.Clear(); ZipFile zf = GetGamedataFile.GetZipFileInstance(GetGamedataFile.UnitsScd); ZipFile FAF_zf = GetGamedataFile.GetFAFZipFileInstance(GetGamedataFile.UnitsScd); if (zf == null) { Preferences.Open(); GenericInfoPopup.ShowInfo("Gamedata path not exist!"); return; } IconBackgrounds.Add("land", GetGamedataFile.LoadTexture2DFromGamedata(GetGamedataFile.TexturesScd, "/textures/ui/common/icons/units/land_up.dds", false, true, true)); IconBackgrounds.Add("amph", GetGamedataFile.LoadTexture2DFromGamedata(GetGamedataFile.TexturesScd, "/textures/ui/common/icons/units/amph_up.dds", false, true, true)); IconBackgrounds.Add("sea", GetGamedataFile.LoadTexture2DFromGamedata(GetGamedataFile.TexturesScd, "/textures/ui/common/icons/units/sea_up.dds", false, true, true)); IconBackgrounds.Add("air", GetGamedataFile.LoadTexture2DFromGamedata(GetGamedataFile.TexturesScd, "/textures/ui/common/icons/units/air_up.dds", false, true, true)); foreach (ZipEntry zipEntry in zf) { if (zipEntry.IsDirectory) { continue; } string LocalName = zipEntry.Name; if (LocalName.ToLower().EndsWith("mesh.bp")) { continue; } if (LocalName.ToLower().EndsWith(".bp") && LocalName.Split('/').Length <= 3) { FoundUnits.Add(LocalName); } } int Count = FoundUnits.Count; if (FAF_zf != null) { string[] NewFiles = GetGamedataFile.GetNewFafFiles(GetGamedataFile.UnitsScd); for (int i = 0; i < NewFiles.Length; i++) { string LocalName = NewFiles[i]; if (LocalName.ToLower().EndsWith("mesh.bp")) { continue; } if (LocalName.ToLower().EndsWith(".bp") && LocalName.Split('/').Length <= 3) { FoundUnits.Add(LocalName); } } } Debug.Log("Found " + FoundUnits.Count + " units ( FAF: " + (FoundUnits.Count - Count) + ")"); FoundUnits.Sort(); Initialised = true; }
public IEnumerator LoadScmapFile() { map = new Map(); //string MapPath = EnvPaths.GetMapsPath(); string path = MapLuaParser.MapRelativePath(MapLuaParser.Current.ScenarioLuaFile.Data.map); if (map.Load(path)) { UpdateLighting(); } else { Debug.LogWarning("File not found!\n" + path); yield break; } if (map.VersionMinor >= 60) { map.AdditionalSkyboxData.Data.UpdateSize(); } else { LoadDefaultSkybox(); } EnvPaths.CurrentGamedataPath = EnvPaths.GamedataPath; //Shader MapLuaParser.Current.EditMenu.TexturesMenu.TTerrainXP.isOn = map.TerrainShader == "TTerrainXP"; ToogleShader(); // Set Variables int xRes = MapLuaParser.Current.ScenarioLuaFile.Data.Size[0]; int zRes = MapLuaParser.Current.ScenarioLuaFile.Data.Size[1]; float HalfxRes = xRes / 10f; float HalfzRes = zRes / 10f; TerrainMaterial.SetTexture("_TerrainNormal", map.UncompressedNormalmapTex); Shader.SetGlobalTexture("_UtilitySamplerC", map.UncompressedWatermapTex); Shader.SetGlobalFloat("_WaterScaleX", xRes); Shader.SetGlobalFloat("_WaterScaleZ", xRes); //***************************************** // ***** Set Terrain proportives //***************************************** LoadHeights(); // Load Stratum Textures Paths LoadStratumScdTextures(); MapLuaParser.Current.InfoPopup.Show(true, "Loading map...\n( Assing scmap data )"); WaterLevel.transform.localScale = new Vector3(HalfxRes, 1, HalfzRes); TerrainMaterial.SetFloat("_GridScale", HalfxRes); TerrainMaterial.SetTexture("_UtilitySamplerC", map.UncompressedWatermapTex); WaterMaterial.SetFloat("_GridScale", HalfxRes); for (int i = 0; i < map.EnvCubemapsFile.Length; i++) { if (map.EnvCubemapsName[i] == "<default>") { try { CurrentEnvironmentCubemap = GetGamedataFile.GetGamedataCubemap(GetGamedataFile.TexturesScd, map.EnvCubemapsFile[i]); Shader.SetGlobalTexture("environmentSampler", CurrentEnvironmentCubemap); } catch { WaterMaterial.SetTexture("environmentSampler", DefaultWaterSky); } } } SetWaterTextures(); SetWater(); Teren.gameObject.layer = 8; SetTextures(); if (Slope) { ToogleSlope(Slope); } yield return(null); }
public void LoadStratumScdTextures(bool Loading = true) { // Load Stratum Textures Paths for (int i = 0; i < Textures.Length; i++) { if (Loading) { MapLuaParser.Current.InfoPopup.Show(true, "Loading map...\n( Stratum textures " + (i + 1) + " )"); if (i >= map.Layers.Count) { map.Layers.Add(new Layer()); } Textures[i].AlbedoPath = GetGamedataFile.FixMapsPath(map.Layers[i].PathTexture); Textures[i].NormalPath = GetGamedataFile.FixMapsPath(map.Layers[i].PathNormalmap); if (Textures[i].AlbedoPath.StartsWith("/")) { Textures[i].AlbedoPath = Textures[i].AlbedoPath.Remove(0, 1); } if (Textures[i].NormalPath.StartsWith("/")) { Textures[i].NormalPath = Textures[i].NormalPath.Remove(0, 1); } Textures[i].AlbedoScale = map.Layers[i].ScaleTexture; Textures[i].NormalScale = map.Layers[i].ScaleNormalmap; } string Env = GetGamedataFile.EnvScd; if (Textures[i].AlbedoPath.ToLower().StartsWith("maps")) { Env = GetGamedataFile.MapScd; } try { Textures[i].AlbedoPath = GetGamedataFile.FindFile(Env, Textures[i].AlbedoPath); //Debug.Log("Found: " + Textures[i].AlbedoPath); GetGamedataFile.LoadTextureFromGamedata(GetGamedataFile.EnvScd, Textures[i].AlbedoPath, i, false); } catch (System.Exception e) { Debug.LogError(i + ", Albedo tex: " + Textures[i].AlbedoPath); Debug.LogError(e); } Env = GetGamedataFile.EnvScd; if (Textures[i].NormalPath.ToLower().StartsWith("maps")) { Env = GetGamedataFile.MapScd; } try { Textures[i].NormalPath = GetGamedataFile.FindFile(Env, Textures[i].NormalPath); //Debug.Log("Found: " + Textures[i].NormalPath); GetGamedataFile.LoadTextureFromGamedata(GetGamedataFile.EnvScd, Textures[i].NormalPath, i, true); } catch (System.Exception e) { Debug.LogError(i + ", Normal tex: " + Textures[i].NormalPath); Debug.LogError(e); } } }
void CleanAssetsMemory() { if (LastLoadedType == 0) { //Textures UsedTerrainTexturesMemory.Clear(); for (int i = 0; i < ScmapEditor.Current.Textures.Length; i++) { if (ScmapEditor.Current.Textures[i].Albedo != null) { UsedTerrainTexturesMemory.Add(ScmapEditor.Current.Textures[i].Albedo); } if (ScmapEditor.Current.Textures[i].Normal != null) { UsedTerrainTexturesMemory.Add(ScmapEditor.Current.Textures[i].Normal); } } int count = LoadedTextures.Count; for (int i = 0; i < count; i++) { if (LoadedTextures[i] != null && !UsedTerrainTexturesMemory.Contains(LoadedTextures[i])) { Destroy(LoadedTextures[i]); } } UsedTerrainTexturesMemory.Clear(); } else if (LastLoadedType == 1 || LastLoadedType == 2) { // Decals UsedTerrainTexturesMemory.Clear(); HashSet <Decal.DecalSharedSettings> .Enumerator ListEnum = Decal.AllDecalsShared.GetEnumerator(); while (ListEnum.MoveNext()) { Decal.DecalSharedSettings Current = ListEnum.Current; if (Current != null) { if (Current.Texture1) { UsedTerrainTexturesMemory.Add(Current.Texture1); } if (Current.Texture2) { UsedTerrainTexturesMemory.Add(Current.Texture2); } } } int count = LoadedTextures.Count; for (int i = 0; i < count; i++) { if (LoadedTextures[i] != null && !UsedTerrainTexturesMemory.Contains(LoadedTextures[i])) { Destroy(LoadedTextures[i]); } } UsedTerrainTexturesMemory.Clear(); } else if (LastLoadedType == 3) { int count = LoadedProps.Count; for (int i = 0; i < count; i++) { for (int l = 0; l < LoadedProps[i].BP.LODs.Length; l++) { if (!GetGamedataFile.IsStoredInMemory(LoadedProps[i].BP.LODs[l].Albedo) && LoadedProps[i].BP.LODs[l].Albedo != Texture2D.whiteTexture) { Destroy(LoadedProps[i].BP.LODs[l].Albedo); } if (!GetGamedataFile.IsStoredInMemory(LoadedProps[i].BP.LODs[l].Normal) && LoadedProps[i].BP.LODs[l].Normal != GetGamedataFile.emptyNormalTexture) { Destroy(LoadedProps[i].BP.LODs[l].Normal); } } } } LoadedTextures.Clear(); LoadedPaths.Clear(); LoadedProps.Clear(); }
IEnumerator GenerateList() { SelectedCategory = Category.value; if (!DontReload) { Clean(); } else if (LastSelection) { LastSelection.SetActive(false); } Loading.SetActive(true); GeneratedId = 0; int Counter = 0; Layout.enabled = true; SizeFitter.enabled = true; LastLoadedType = Category.value; if (LoadedEnvPaths[EnvType.value] == CurrentMapFolderPath) { if (MapLuaParser.IsMapLoaded) { string LoadPath = MapLuaParser.LoadedMapFolderPath + "env/" + CategoryPaths[LastLoadedType]; Debug.Log("Try load assets from: " + LoadPath); if (Directory.Exists(LoadPath)) { string[] AllFiles = Directory.GetFiles(LoadPath, "*", SearchOption.AllDirectories); Debug.Log("Found " + AllFiles.Length + " files in map folder"); for (int i = 0; i < AllFiles.Length; i++) { string path = AllFiles[i]; // Load Texture switch (LastLoadedType) { case 0: if (path.ToLower().EndsWith(".dds")) { Counter += GenerateMapTextureButton(LoadPath, path, Prefab_Texture); } break; case 1: if (path.ToLower().EndsWith(".dds")) { Counter += GenerateMapTextureButton(LoadPath, path, Prefab_Decal); } break; case 2: if (path.ToLower().EndsWith(".dds")) { Counter += GenerateMapTextureButton(LoadPath, path, Prefab_Decal); } break; case 3: if (path.ToLower().EndsWith(".bp")) { Counter += GenerateMapPropButton(LoadPath, path, Prefab_Prop); } break; } if (Counter >= PauseEveryLoadedAsset) { Counter = 0; yield return(null); } } yield return(null); yield return(null); } } } else if (LoadedEnvPaths[EnvType.value] == CurrentMapPath) { if (LastLoadedType == 3) { int Count = EditMap.PropsInfo.AllPropsTypes.Count; Debug.Log("Found props: " + Count); for (int i = 0; i < Count; i++) { LoadAtPath(GetGamedataFile.LocalBlueprintPath(EditMap.PropsInfo.AllPropsTypes[i].Blueprint), EditMap.PropsInfo.AllPropsTypes[i].PropObject.BP.Name); Counter++; if (Counter >= PauseEveryLoadedAsset) { Counter = 0; yield return(null); } } } else { yield return(null); yield return(null); } } else { ZipFile zf = null; ZipFile zf_faf = null; SelectedDirectory = ("env/" + EnvType.options[EnvType.value].text + "/" + CategoryPaths[LastLoadedType]).ToLower(); try { zf = GetGamedataFile.GetZipFileInstance(GetGamedataFile.EnvScd); zf_faf = GetGamedataFile.GetFAFZipFileInstance(GetGamedataFile.EnvScd); bool HasFafFile = zf_faf != null; yield return(null); bool Breaked = false; //bool ReplacedByFaf = false; ZipEntry Current; foreach (ZipEntry zipEntry in zf) { Current = zipEntry; if (!Current.IsFile) { continue; } if (!IsProperFile(Current.Name)) { continue; } //ReplacedByFaf = false; if (HasFafFile) { ZipEntry FafEntry = zf_faf.GetEntry(Current.Name); if (FafEntry != null && FafEntry.IsFile) { //Debug.Log("Replace " + Current.Name + "\nwith FAF file: " + FafEntry.Name); Current = FafEntry; //ReplacedByFaf = true; } } if (LoadZipEntry(ref Current, out Breaked)) { continue; } //if (ReplacedByFaf) // Debug.Log("Replace with FAF file: " + Current.Name); if (Breaked) { break; } GeneratedId++; Counter++; if (Counter >= PauseEveryLoadedAsset) { Counter = 0; yield return(null); } } if (!Breaked && HasFafFile) { string[] NewFiles = GetGamedataFile.GetNewFafFiles(GetGamedataFile.EnvScd); for (int i = 0; i < NewFiles.Length; i++) { if (!IsProperFile(NewFiles[i])) { continue; } Current = zf_faf.GetEntry(NewFiles[i]); if (LoadZipEntry(ref Current, out Breaked)) { continue; } //Debug.Log("New faf file: " + Current.Name); if (Breaked) { break; } GeneratedId++; Counter++; if (Counter >= PauseEveryLoadedAsset) { Counter = 0; yield return(null); } } } } finally { /* * if (zf != null) * { * zf.IsStreamOwner = true; // Makes close also shut the underlying stream * zf.Close(); // Ensure we release resources * } */ } } yield return(null); Layout.enabled = false; SizeFitter.enabled = false; Loading.SetActive(false); GeneratingList = null; }
void ReadAllFolders() { if (Initialised) { return; } EnvType.ClearOptions(); LoadedEnvPaths = new List <string>(); List <Dropdown.OptionData> NewOptions = new List <Dropdown.OptionData>(); if (!Directory.Exists(EnvPaths.GamedataPath)) { Debug.LogWarning("Gamedata path not exist!"); return; } HashSet <string> LoadedDirectorys = new HashSet <string>(); ZipFile zf = GetGamedataFile.GetZipFileInstance(GetGamedataFile.EnvScd); if (zf == null) { Debug.LogError("Unable to load ZipFile!"); return; } foreach (ZipEntry zipEntry in zf) { if (zipEntry == null || !zipEntry.IsDirectory) { continue; } string LocalName = zipEntry.Name.Replace("env/", ""); if (string.IsNullOrEmpty(LocalName)) { continue; } LoadedDirectorys.Add(LocalName); int ContSeparators = 0; char Separator = ("/")[0]; for (int i = 0; i < LocalName.Length; i++) { if (LocalName[i] == Separator) { ContSeparators++; if (ContSeparators > 1) { break; } } } if (ContSeparators > 1) { continue; } LocalName = LocalName.Replace("/", ""); LoadedEnvPaths.Add(LocalName); Dropdown.OptionData NewOptionInstance = new Dropdown.OptionData(LocalName); NewOptions.Add(NewOptionInstance); } // FAF zf = GetGamedataFile.GetFAFZipFileInstance(GetGamedataFile.EnvScd); if (zf != null) { foreach (ZipEntry zipEntry in zf) { if (!zipEntry.IsDirectory) { continue; } string LocalName = zipEntry.Name.Replace("env/", ""); if (string.IsNullOrEmpty(LocalName)) { continue; } if (LoadedDirectorys.Contains(LocalName)) { continue; } LoadedDirectorys.Add(LocalName); int ContSeparators = 0; char Separator = ("/")[0]; for (int i = 0; i < LocalName.Length; i++) { if (LocalName[i] == Separator) { ContSeparators++; if (ContSeparators > 1) { break; } } } if (ContSeparators > 1) { continue; } LocalName = LocalName.Replace("/", ""); LoadedEnvPaths.Add(LocalName); Dropdown.OptionData NewOptionInstance = new Dropdown.OptionData(LocalName); NewOptions.Add(NewOptionInstance); } } LoadedEnvPaths.Add(CurrentMapFolderPath); Dropdown.OptionData NewOptionInstance2 = new Dropdown.OptionData("Map folder"); NewOptions.Add(NewOptionInstance2); LoadedEnvPaths.Add(CurrentMapPath); Dropdown.OptionData NewOptionInstance3 = new Dropdown.OptionData("On map"); NewOptions.Add(NewOptionInstance3); EnvType.AddOptions(NewOptions); Initialised = true; }
public void SaveScmapFile() { float LowestElevation = ScmapEditor.MaxElevation; float HighestElevation = 0; if (Teren) { heights = Teren.terrainData.GetHeights(0, 0, Teren.terrainData.heightmapWidth, Teren.terrainData.heightmapHeight); heightsLength = heights.GetLength(0); int y = 0; int x = 0; for (y = 0; y < map.Width + 1; y++) { for (x = 0; x < map.Height + 1; x++) { float Height = heights[x, y]; LowestElevation = Mathf.Min(LowestElevation, Height); HighestElevation = Mathf.Max(HighestElevation, Height); //double HeightValue = ((double)Height) * HeightResize; //map.SetHeight(y, map.Height - x, (short)(HeightValue + RoundingError)); map.SetHeight(y, map.Height - x, (ushort)(Height * HeightResize)); } } } LowestElevation = (LowestElevation * TerrainHeight) / 0.1f; HighestElevation = (HighestElevation * TerrainHeight) / 0.1f; if (HighestElevation - LowestElevation > 49.9) { Debug.Log("Lowest point: " + LowestElevation); Debug.Log("Highest point: " + HighestElevation); Debug.LogWarning("Height difference is too high! it might couse rendering issues! Height difference is: " + (HighestElevation - LowestElevation)); GenericInfoPopup.ShowInfo("Height difference " + (HighestElevation - LowestElevation) + " is too high!\nIt might couse rendering issues!"); } if (MapLuaParser.Current.EditMenu.MapInfoMenu.SaveAsFa.isOn) { if (map.AdditionalSkyboxData == null || map.AdditionalSkyboxData.Data == null || map.AdditionalSkyboxData.Data.Position.x == 0) { // Convert to v60 LoadDefaultSkybox(); } map.VersionMinor = 60; map.AdditionalSkyboxData.Data.UpdateSize(); } else if (map.VersionMinor >= 60) // Convert to v56 { LoadDefaultSkybox(); map.AdditionalSkyboxData.Data.UpdateSize(); map.VersionMinor = 56; } //Debug.Log("Set Heightmap to map " + map.Width + ", " + map.Height); //string MapPath = EnvPaths.GetMapsPath(); string path = MapLuaParser.MapRelativePath(MapLuaParser.Current.ScenarioLuaFile.Data.map); //TODO force values if needed //map.TerrainShader = Shader; map.TerrainShader = MapLuaParser.Current.EditMenu.TexturesMenu.TTerrainXP.isOn ? ("TTerrainXP") : ("TTerrain"); map.MinimapContourColor = new Color32(0, 0, 0, 255); map.MinimapDeepWaterColor = new Color32(71, 140, 181, 255); map.MinimapShoreColor = new Color32(141, 200, 225, 255); map.MinimapLandStartColor = new Color32(119, 101, 108, 255); map.MinimapLandEndColor = new Color32(206, 206, 176, 255); //map.MinimapLandEndColor = new Color32 (255, 255, 215, 255); map.MinimapContourInterval = 10; map.WatermapTex = new Texture2D(map.UncompressedWatermapTex.width, map.UncompressedWatermapTex.height, map.UncompressedWatermapTex.format, false); map.WatermapTex.SetPixels(map.UncompressedWatermapTex.GetPixels()); map.WatermapTex.Apply(); map.WatermapTex.Compress(true); map.WatermapTex.Apply(); map.NormalmapTex = new Texture2D(map.UncompressedNormalmapTex.width, map.UncompressedNormalmapTex.height, map.UncompressedNormalmapTex.format, false); map.NormalmapTex.SetPixels(map.UncompressedNormalmapTex.GetPixels()); map.NormalmapTex.Apply(); map.NormalmapTex.Compress(true); map.NormalmapTex.Apply(); map.PreviewTex = PreviewRenderer.RenderPreview(((LowestElevation + HighestElevation) / 2) * 0.1f); for (int i = 0; i < map.Layers.Count; i++) { Textures[i].AlbedoPath = GetGamedataFile.FixMapsPath(Textures[i].AlbedoPath); Textures[i].NormalPath = GetGamedataFile.FixMapsPath(Textures[i].NormalPath); map.Layers[i].PathTexture = Textures[i].AlbedoPath; map.Layers[i].PathNormalmap = Textures[i].NormalPath; map.Layers[i].ScaleTexture = Textures[i].AlbedoScale; map.Layers[i].ScaleNormalmap = Textures[i].NormalScale; } List <Prop> AllProps = new List <Prop>(); if (EditMap.PropsInfo.AllPropsTypes != null) { int Count = EditMap.PropsInfo.AllPropsTypes.Count; for (int i = 0; i < EditMap.PropsInfo.AllPropsTypes.Count; i++) { AllProps.AddRange(EditMap.PropsInfo.AllPropsTypes[i].GenerateSupComProps()); } } map.Props = AllProps; if (map.VersionMinor < 56) { map.ConvertToV56(); } map.Save(path, map.VersionMinor); }
public bool Load(string Filename) { if (string.IsNullOrEmpty(Filename)) { return(false); } if (!System.IO.File.Exists(Filename)) { return(false); } this.Filename = Filename; Clear(); System.IO.FileStream fs = new System.IO.FileStream(Filename, System.IO.FileMode.Open, System.IO.FileAccess.Read); BinaryReader Stream = new BinaryReader(fs); PreviewTex = new Texture2D(0, 0); TexturemapTex = new Texture2D(0, 0); TexturemapTex2 = new Texture2D(0, 0); NormalmapTex = new Texture2D(0, 0); WatermapTex = new Texture2D(0, 0); WaterDataTexture = new Texture2D(0, 0); byte[] TexturemapData = new byte[0]; byte[] TexturemapData2 = new byte[0]; byte[] NormalmapData = new byte[0]; byte[] WatermapData = new byte[0]; int Count = 0; BinaryReader _with1 = Stream; //# Header Section # if (_with1.ReadInt32() == MAP_MAGIC) { VersionMajor = _with1.ReadInt32(); //? always 2 Unknown10 = _with1.ReadInt32(); //? always EDFE EFBE Unknown11 = _with1.ReadInt32(); //? always 2 Unknown16 = _with1.ReadSingle(); //Map Width (in float) Unknown17 = _with1.ReadSingle(); //Map Height (in float) Unknown12 = _with1.ReadSingle(); //? always 0 Unknown13 = _with1.ReadInt16(); //? always 0 PreviewImageLength = _with1.ReadInt32(); PreviewData = _with1.ReadBytes(PreviewImageLength); VersionMinor = _with1.ReadInt32(); if (VersionMinor <= 0) { VersionMinor = 56; } //# Heightmap Section # Width = _with1.ReadInt32(); Height = _with1.ReadInt32(); HeightScale = _with1.ReadSingle(); //Height Scale, usually 1/128 HeightmapData = new ushort[(Height + 1) * (Width + 1)]; for (int i = 0; i < HeightmapData.Length; i++) { HeightmapData[i] = _with1.ReadUInt16(); } //HeightmapData = _with1.ReadInt16Array((Height + 1) * (Width + 1));//TODO: Current saving method gets a memory overload on trying to reload the map here. //heightmap dimension is always 1 more than texture dimension! if (VersionMinor >= 56) { Unknown15 = _with1.ReadByte(); } else { Unknown15 = 0; } //Always 0? //# Texture Definition Section # TerrainShader = _with1.ReadStringNull(); //Terrain Shader, usually "TTerrain" TexPathBackground = _with1.ReadStringNull(); TexPathSkyCubemap = _with1.ReadStringNull(); if (VersionMinor >= 56) { Count = _with1.ReadInt32(); //always 1? EnvCubemapsName = new string[Count]; EnvCubemapsFile = new string[Count]; for (int i = 0; i <= Count - 1; i++) { EnvCubemapsName[i] = _with1.ReadStringNull(); EnvCubemapsFile[i] = _with1.ReadStringNull(); } } else { EnvCubemapsName = new string[3]; EnvCubemapsFile = new string[3]; EnvCubemapsName[0] = "<aeon>"; EnvCubemapsName[1] = "<default>"; EnvCubemapsName[2] = "<seraphim>"; EnvCubemapsFile[0] = "/textures/environment/envcube_aeon_evergreen.dds"; EnvCubemapsFile[1] = _with1.ReadStringNull(); EnvCubemapsFile[2] = "/textures/environment/envcube_seraphim_evergreen.dds"; } LightingMultiplier = _with1.ReadSingle(); SunDirection = _with1.ReadVector3(); SunAmbience = _with1.ReadVector3(); SunColor = _with1.ReadVector3(); ShadowFillColor = _with1.ReadVector3(); SpecularColor = _with1.ReadVector4(); Bloom = _with1.ReadSingle(); FogColor = _with1.ReadVector3(); FogStart = _with1.ReadSingle(); FogEnd = _with1.ReadSingle(); Water.Load(Stream); Count = _with1.ReadInt32(); WaveGenerators.Clear(); for (int i = 0; i <= Count - 1; i++) { WaveGenerator WaveGen = new WaveGenerator(); WaveGen.Load(Stream); WaveGenerators.Add(WaveGen); } if (VersionMinor < 56) { _with1.ReadStringNull(); // always "No Tileset" Count = _with1.ReadInt32(); //always 6 for (int i = 0; i <= 4; i++) { Layer Layer = new Layer(); Layer.Load(Stream); Layers.Add(Layer); } for (int i = 5; i <= 8; i++) { Layers.Add(new Layer()); } for (int i = 9; i <= 9; i++) { Layer Layer = new Layer(); Layer.Load(Stream); Layers.Add(Layer); } } else { MinimapContourInterval = _with1.ReadInt32(); int argb = _with1.ReadInt32(); MinimapDeepWaterColor = Int32ToColor(argb); /*int r = (argb)&0xFF; * int g = (argb>>8)&0xFF; * int b = (argb>>16)&0xFF; * int a = (argb>>24)&0xFF; * MinimapDeepWaterColor = new Color(r,g,b,a);*/ int argb2 = _with1.ReadInt32(); /*int r2 = (argb2)&0xFF; * int g2 = (argb2>>8)&0xFF; * int b2 = (argb2>>16)&0xFF; * int a2 = (argb2>>24)&0xFF; * MinimapContourColor = new Color(r2,g2,b2,a2);*/ MinimapContourColor = Int32ToColor(argb2); int argb3 = _with1.ReadInt32(); /*int r3 = (argb3)&0xFF; * int g3 = (argb3>>8)&0xFF; * int b3 = (argb3>>16)&0xFF; * int a3 = (argb3>>24)&0xFF; * MinimapShoreColor = new Color(r3,g3,b3,a3);*/ MinimapShoreColor = Int32ToColor(argb3); int argb4 = _with1.ReadInt32(); /*int r4 = (argb4)&0xFF; * int g4 = (argb4>>8)&0xFF; * int b4 = (argb4>>16)&0xFF; * int a4 = (argb4>>24)&0xFF; * MinimapLandStartColor = new Color(r4,g4,b4,a4);*/ MinimapLandStartColor = Int32ToColor(argb4); int argb5 = _with1.ReadInt32(); /*int r5 = (argb5)&0xFF; * int g5 = (argb5>>8)&0xFF; * int b5 = (argb5>>16)&0xFF; * int a5 = (argb5>>24)&0xFF; * MinimapLandEndColor = new Color(r5,g5,b5,a5);*/ MinimapLandEndColor = Int32ToColor(argb5); if (VersionMinor > 56) { Unknown14 = _with1.ReadSingle(); //Not sure what this is. } Count = 10; for (int i = 0; i <= Count - 1; i++) { Layer Layer = new Layer(); Layer.LoadAlbedo(Stream); Layers.Add(Layer); } for (int i = 0; i <= Count - 2; i++) { Layers[i].LoadNormal(Stream); } } Unknown7 = _with1.ReadInt32(); //? Unknown8 = _with1.ReadInt32(); //? int DecalCount = _with1.ReadInt32(); //Debug.Log(DecalCount); for (int i = 0; i < DecalCount; i++) { Decal Feature = new Decal(); Feature.Load(Stream); Decals.Add(Feature); } int GroupCount = _with1.ReadInt32(); for (int i = 0; i <= GroupCount - 1; i++) { IntegerGroup Group = new IntegerGroup(); Group.Load(Stream); DecalGroups.Add(Group); } _with1.ReadInt32(); //Width again _with1.ReadInt32(); //Height again int Length = 0; int NormalmapCount = _with1.ReadInt32(); //always 1 for (int i = 0; i < NormalmapCount; i++) { Length = _with1.ReadInt32(); if (i == 0) { NormalmapData = _with1.ReadBytes(Length); } else { _with1.BaseStream.Position += Length; // just to make sure that it doesn't crash if it is not just 1 normalmap for some reason } } if (VersionMinor < 56) { _with1.ReadInt32(); } //always 1 Length = _with1.ReadInt32(); TexturemapData = _with1.ReadBytes(Length); if (VersionMinor >= 56) { Length = _with1.ReadInt32(); TexturemapData2 = _with1.ReadBytes(Length); } //Watermap _with1.ReadInt32(); //always 1 Length = _with1.ReadInt32(); WatermapData = _with1.ReadBytes(Length); int HalfSize = (Width / 2) * (Height / 2); WaterFoamMask = _with1.ReadBytes(HalfSize); WaterFlatnessMask = _with1.ReadBytes(HalfSize); WaterDepthBiasMask = _with1.ReadBytes(HalfSize); WaterDataTexture = new Texture2D(Width / 2, Height / 2, TextureFormat.RGB24, false); Color32[] NewColors = new Color32[HalfSize]; for (int i = 0; i < HalfSize; i++) { NewColors[i] = new Color32(WaterFoamMask[i], WaterFlatnessMask[i], WaterDepthBiasMask[i], 0); } WaterDataTexture.SetPixels32(NewColors); WaterDataTexture.Apply(); TerrainTypeData = _with1.ReadBytes(Width * Height); // TerrainTypeData = _with1.ReadBytes(Width * Height).ToList(); if (VersionMinor <= 52) { _with1.ReadInt16(); } //Debug.Log("Scmap file version: " + VersionMinor); if (VersionMinor >= 60) { AdditionalSkyboxData.Load(_with1); } else { ScmapEditor.Current.LoadDefaultSkybox(); } try { int PropCount = _with1.ReadInt32(); //Debug.Log ("PropCount: " + PropCount + ", v" + VersionMinor ); for (int i = 0; i < PropCount; i++) { Prop Prop = new Prop(); Prop.Load(Stream); Props.Add(Prop); //Debug.Log(Prop.BlueprintPath); } } catch { Debug.LogError("Loading props crashed"); } } _with1.Close(); fs.Close(); fs.Dispose(); PreviewTextHeader = GetGamedataFile.GetDdsFormat(PreviewData); PreviewTextHeader.Format = TextureFormat.BGRA32; PreviewTex = TextureLoader.ConvertToRGBA(TextureLoader.LoadTextureDXT(PreviewData, PreviewTextHeader)); try { TextureMapHeader = GetGamedataFile.GetDdsFormat(TexturemapData); TextureMapHeader.Format = TextureFormat.BGRA32; //TexturemapTex = TextureLoader.LoadTextureDXT(TexturemapData, TextureMapHeader); TexturemapTex = TextureLoader.ConvertToRGBA(TextureLoader.LoadTextureDXT(TexturemapData, TextureMapHeader)); TexturemapData = new byte[0]; } catch (Exception e) { TexturemapTex = new Texture2D(Width / 2, Height / 2); Debug.LogException(e); } if (TexturemapData2.Length > 0) { TextureMap2Header = GetGamedataFile.GetDdsFormat(TexturemapData2); TextureMap2Header.Format = TextureFormat.BGRA32; TexturemapTex2 = TextureLoader.ConvertToRGBA(TextureLoader.LoadTextureDXT(TexturemapData2, TextureMap2Header)); TexturemapData2 = new byte[0]; } else { TextureMap2Header = TextureMapHeader; TexturemapTex2 = new Texture2D(Width / 2, Height / 2); Color[] Pixels = TexturemapTex2.GetPixels(); for (int p = 0; p < Pixels.Length; p++) { Pixels[p] = new Color(0, 0, 0, 0); } TexturemapTex2.SetPixels(Pixels); TexturemapTex2.Apply(); } TexturemapTex.wrapMode = TextureWrapMode.Clamp; TexturemapTex2.wrapMode = TextureWrapMode.Clamp; NormalmapHeader = GetGamedataFile.GetDdsFormat(NormalmapData); NormalmapHeader.Format = TextureFormat.DXT5; NormalmapTex = TextureLoader.LoadTextureDXT(NormalmapData, NormalmapHeader); NormalmapData = new byte[0]; UncompressedNormalmapTex = new Texture2D(NormalmapTex.width, NormalmapTex.height, TextureFormat.RGBA32, false); UncompressedNormalmapTex.SetPixels(NormalmapTex.GetPixels()); UncompressedNormalmapTex.wrapMode = TextureWrapMode.Clamp; UncompressedNormalmapTex.Apply(); try { WatermapHeader = GetGamedataFile.GetDdsFormat(WatermapData); WatermapHeader.Format = TextureFormat.DXT5; WatermapTex = TextureLoader.LoadTextureDXT(WatermapData, WatermapHeader); WatermapData = new byte[0]; } catch (Exception e) { WatermapTex = new Texture2D(Width / 2, Height / 2); Debug.LogException(e); } UncompressedWatermapTex = new Texture2D(WatermapTex.width, WatermapTex.height, TextureFormat.RGBA32, false); UncompressedWatermapTex.SetPixels(WatermapTex.GetPixels()); UncompressedWatermapTex.wrapMode = TextureWrapMode.Clamp; UncompressedWatermapTex.Apply(); if (VersionMinor < 56) { ConvertToV56(); } return(true); }