async Task InitPersos() { if (loader != null) { for (int i = 0; i < loader.persos.Count; i++) { detailedState = "Initializing persos: " + i + "/" + loader.persos.Count; await WaitIfNecessary(); Perso p = loader.persos[i]; PersoBehaviour unityBehaviour = p.Gao.AddComponent <PersoBehaviour>(); unityBehaviour.controller = this; if (loader.globals != null && loader.globals.spawnablePersos != null) { if (loader.globals.spawnablePersos.IndexOf(p) > -1) { unityBehaviour.IsAlways = true; unityBehaviour.transform.position = new Vector3(i * 10, -1000, 0); } } if (!unityBehaviour.IsAlways) { if (p.sectInfo != null && p.sectInfo.off_sector != null) { unityBehaviour.sector = sectorManager.sectors.FirstOrDefault(s => s.sector != null && s.sector.SuperObject.offset == p.sectInfo.off_sector); } else { SectorComponent sc = sectorManager.GetActiveSectorWrapper(p.Gao.transform.position); unityBehaviour.sector = sc; } } else { unityBehaviour.sector = null; } unityBehaviour.perso = p; unityBehaviour.Init(); // Scripts if (p.Gao) { if (p.brain != null && p.brain.mind != null && p.brain.mind.AI_model != null) { if (p.brain.mind.AI_model.behaviors_normal != null) { GameObject intelParent = new GameObject("Rule behaviours"); intelParent.transform.parent = p.Gao.transform; Behavior[] normalBehaviors = p.brain.mind.AI_model.behaviors_normal; int iter = 0; foreach (Behavior behavior in normalBehaviors) { string shortName = behavior.GetShortName(p.brain.mind.AI_model, Behavior.BehaviorType.Intelligence, iter); GameObject behaviorGao = new GameObject(shortName); behaviorGao.transform.parent = intelParent.transform; foreach (Script script in behavior.scripts) { GameObject scriptGao = new GameObject("Script"); scriptGao.transform.parent = behaviorGao.transform; ScriptComponent scriptComponent = scriptGao.AddComponent <ScriptComponent>(); scriptComponent.SetScript(script, p); } if (behavior.firstScript != null) { ScriptComponent scriptComponent = behaviorGao.AddComponent <ScriptComponent>(); scriptComponent.SetScript(behavior.firstScript, p); } if (iter == 0) { behaviorGao.name += " (Init)"; } if ((behavior.scripts == null || behavior.scripts.Length == 0) && behavior.firstScript == null) { behaviorGao.name += " (Empty)"; } iter++; } } if (p.brain.mind.AI_model.behaviors_reflex != null) { GameObject reflexParent = new GameObject("Reflex behaviours"); reflexParent.transform.parent = p.Gao.transform; Behavior[] reflexBehaviors = p.brain.mind.AI_model.behaviors_reflex; int iter = 0; foreach (Behavior behavior in reflexBehaviors) { string shortName = behavior.GetShortName(p.brain.mind.AI_model, Behavior.BehaviorType.Reflex, iter); GameObject behaviorGao = new GameObject(shortName); behaviorGao.transform.parent = reflexParent.transform; foreach (Script script in behavior.scripts) { GameObject scriptGao = new GameObject("Script"); scriptGao.transform.parent = behaviorGao.transform; ScriptComponent scriptComponent = scriptGao.AddComponent <ScriptComponent>(); scriptComponent.SetScript(script, p); } if (behavior.firstScript != null) { ScriptComponent scriptComponent = behaviorGao.AddComponent <ScriptComponent>(); scriptComponent.SetScript(behavior.firstScript, p); } if ((behavior.scripts == null || behavior.scripts.Length == 0) && behavior.firstScript == null) { behaviorGao.name += " (Empty)"; } iter++; } } if (p.brain.mind.AI_model.macros != null) { GameObject macroParent = new GameObject("Macros"); macroParent.transform.parent = p.Gao.transform; Macro[] macros = p.brain.mind.AI_model.macros; int iter = 0; foreach (Macro macro in macros) { GameObject behaviorGao = new GameObject(macro.GetShortName(p.brain.mind.AI_model, iter)); behaviorGao.transform.parent = macroParent.transform; ScriptComponent scriptComponent = behaviorGao.AddComponent <ScriptComponent>(); scriptComponent.SetScript(macro.script, p); iter++; } } } } } // Initialize DSGVars after all persos have their perso behaviours for (int i = 0; i < loader.persos.Count; i++) { Perso p = loader.persos[i]; Moddable mod = null; if (p.SuperObject != null && p.SuperObject.Gao != null) { mod = p.SuperObject.Gao.GetComponent <Moddable>(); if (mod != null) { mod.persoBehaviour = p.Gao.GetComponent <PersoBehaviour>(); } } if (p.Gao && p.brain != null && p.brain.mind != null && p.brain.mind.AI_model != null) { // DsgVars if (p.brain.mind.dsgMem != null || p.brain.mind.AI_model.dsgVar != null) { DsgVarComponent dsgVarComponent = p.Gao.AddComponent <DsgVarComponent>(); dsgVarComponent.SetPerso(p); if (mod != null) { mod.dsgVarComponent = dsgVarComponent; } } // Dynam if (p.dynam != null && p.dynam.dynamics != null) { DynamicsMechanicsComponent dynamicsBehaviour = p.Gao.AddComponent <DynamicsMechanicsComponent>(); dynamicsBehaviour.SetDynamics(p.dynam.dynamics); } // Mind if (p.brain != null && p.brain.mind != null) { MindComponent mindComponent = p.Gao.AddComponent <MindComponent>(); mindComponent.Init(p, p.brain.mind); if (mod != null) { mod.mindComponent = mindComponent; } } // Custom Bits if (p.stdGame != null) { CustomBitsComponent c = p.Gao.AddComponent <CustomBitsComponent>(); c.stdGame = p.stdGame; if (Settings.s.engineVersion == Settings.EngineVersion.R3) { c.hasAiCustomBits = true; } c.Init(); } } } } if (loader is OpenSpace.Loader.R2ROMLoader) { OpenSpace.Loader.R2ROMLoader romLoader = loader as OpenSpace.Loader.R2ROMLoader; if (romPersos.Count > 0) { for (int i = 0; i < romPersos.Count; i++) { detailedState = "Initializing persos: " + i + "/" + romPersos.Count; await WaitIfNecessary(); ROMPersoBehaviour unityBehaviour = romPersos[i]; unityBehaviour.controller = this; /*if (loader.globals != null && loader.globals.spawnablePersos != null) { * if (loader.globals.spawnablePersos.IndexOf(p) > -1) { * unityBehaviour.IsAlways = true; * unityBehaviour.transform.position = new Vector3(i * 10, -1000, 0); * } * }*/ if (!unityBehaviour.IsAlways) { SectorComponent sc = sectorManager.GetActiveSectorWrapper(unityBehaviour.transform.position); unityBehaviour.sector = sc; } else { unityBehaviour.sector = null; } /*Moddable mod = null; * if (p.SuperObject != null && p.SuperObject.Gao != null) { * mod = p.SuperObject.Gao.GetComponent<Moddable>(); * if (mod != null) { * mod.persoBehaviour = unityBehaviour; * } * }*/ unityBehaviour.Init(); var iteratorPerso = unityBehaviour.perso; // Of sound brain and AI model? if (iteratorPerso.brain?.Value?.aiModel?.Value != null) { var aiModel = iteratorPerso.brain.Value.aiModel.Value; // DsgVars if (iteratorPerso.brain?.Value?.dsgMem?.Value != null || aiModel.dsgVar?.Value != null) { DsgVarComponent dsgVarComponent = unityBehaviour.gameObject.AddComponent <DsgVarComponent>(); dsgVarComponent.SetPerso(iteratorPerso); } // Comports if (aiModel.comportsIntelligence.Value != null) { aiModel.comportsIntelligence.Value.CreateGameObjects("Rule", unityBehaviour.gameObject, iteratorPerso); } if (aiModel.comportsReflex.Value != null) { aiModel.comportsReflex.Value.CreateGameObjects("Reflex", unityBehaviour.gameObject, iteratorPerso); } } } } if (romLoader.level != null && romLoader.level.spawnablePersos.Value != null && romLoader.level.num_spawnablepersos > 0) { GameObject spawnableParent = new GameObject("Spawnable persos"); for (int i = 0; i < romLoader.level.num_spawnablepersos; i++) { detailedState = "Initializing spawnable persos: " + i + "/" + romLoader.level.num_spawnablepersos; await WaitIfNecessary(); OpenSpace.ROM.SuperObjectDynamic sod = romLoader.level.spawnablePersos.Value.superObjects[i]; GameObject sodGao = sod.GetGameObject(); if (sodGao != null) { ROMPersoBehaviour unityBehaviour = sodGao.GetComponent <ROMPersoBehaviour>(); unityBehaviour.controller = this; unityBehaviour.IsAlways = true; unityBehaviour.transform.SetParent(spawnableParent.transform); unityBehaviour.transform.position = new Vector3(i * 10, -1000, 0); unityBehaviour.transform.rotation = Quaternion.identity; unityBehaviour.transform.localScale = Vector3.one; if (!unityBehaviour.IsAlways) { SectorComponent sc = sectorManager.GetActiveSectorWrapper(unityBehaviour.transform.position); unityBehaviour.sector = sc; } else { unityBehaviour.sector = null; } unityBehaviour.Init(); var iteratorPerso = unityBehaviour.perso; // Of sound brain and AI model? if (iteratorPerso.brain?.Value?.aiModel?.Value != null) { var aiModel = iteratorPerso.brain.Value.aiModel.Value; // DsgVars if (iteratorPerso.brain?.Value?.dsgMem?.Value != null || aiModel.dsgVar?.Value != null) { DsgVarComponent dsgVarComponent = unityBehaviour.gameObject.AddComponent <DsgVarComponent>(); dsgVarComponent.SetPerso(iteratorPerso); } // Comports if (aiModel.comportsIntelligence.Value != null) { aiModel.comportsIntelligence.Value.CreateGameObjects("Rule", unityBehaviour.gameObject, iteratorPerso); } if (aiModel.comportsReflex.Value != null) { aiModel.comportsReflex.Value.CreateGameObjects("Reflex", unityBehaviour.gameObject, iteratorPerso); } } } } } } }
public void Init() { if (MapLoader.Loader is OpenSpace.Loader.R2ROMLoader) { OpenSpace.Loader.R2ROMLoader l = MapLoader.Loader as OpenSpace.Loader.R2ROMLoader; foreach (OpenSpace.ROM.WayPoint wp in l.waypointsROM) { AddWaypoint(wp.GetGameObject()); } if (graphRoot == null && l.graphsROM.Count > 0) { graphRoot = new GameObject("Graphs"); graphRoot.transform.SetParent(transform); graphRoot.SetActive(false); } foreach (OpenSpace.ROM.Graph graph in l.graphsROM) { GameObject go_graph = new GameObject("Graph " + graph.Offset); go_graph.transform.SetParent(graphRoot.transform); for (int i = 0; i < graph.num_nodes; i++) { OpenSpace.ROM.GraphNode node = graph.nodes.Value.nodes[i].Value; if (node.waypoint.Value != null) { WaypointBehaviour wp = waypoints.FirstOrDefault(w => w.wpROM == node.waypoint.Value); if (wp != null) { wp.nodesROM.Add(node); wp.name = "GraphNode[" + i + "].WayPoint (" + wp.wpROM.Offset + ")"; if (i == 0) { go_graph.transform.position = wp.transform.position; } wp.transform.SetParent(go_graph.transform); } } } } } else { MapLoader l = MapLoader.Loader; foreach (WayPoint wp in l.waypoints) { AddWaypoint(wp.Gao.GetComponent <WaypointBehaviour>()); } if (graphRoot == null && l.graphs.Count > 0) { graphRoot = new GameObject("Graphs"); graphRoot.transform.SetParent(transform); graphRoot.SetActive(false); } foreach (Graph graph in l.graphs) { GameObject go_graph = new GameObject(graph.name ?? "Graph " + graph.offset.ToString()); go_graph.transform.SetParent(graphRoot.transform); for (int i = 0; i < graph.nodes.Count; i++) { GraphNode node = graph.nodes[i]; if (node == null) { continue; } if (node.wayPoint != null) { WaypointBehaviour wp = waypoints.FirstOrDefault(w => w.wp == node.wayPoint); if (wp != null) { wp.nodes.Add(node); wp.name = "GraphNode[" + i + "].WayPoint (" + wp.wp.offset + ")"; if (i == 0) { go_graph.transform.position = wp.transform.position; } wp.transform.SetParent(go_graph.transform); } } } } } List <WaypointBehaviour> isolateWaypoints = waypoints.Where(w => w.nodes.Count == 0 && w.nodesROM.Count == 0).ToList(); if (isolateWaypointRoot == null && isolateWaypoints.Count > 0) { isolateWaypointRoot = new GameObject("Isolate WayPoints"); isolateWaypointRoot.transform.SetParent(transform); isolateWaypointRoot.SetActive(false); } foreach (WaypointBehaviour wp in isolateWaypoints) { wp.name = "Isolate WayPoint @" + (wp.wpROM != null ? wp.wpROM.Offset : wp.wp.offset); wp.transform.SetParent(isolateWaypointRoot.transform); } foreach (WaypointBehaviour wp in waypoints) { wp.Init(); } UpdateViewGraphs(); //loaded = true; }
public WebJSON.Localization GetLocalizationJSON() { MapLoader l = MapLoader.Loader; if (l is OpenSpace.Loader.R2ROMLoader) { OpenSpace.Loader.R2ROMLoader rl = l as OpenSpace.Loader.R2ROMLoader; OpenSpace.ROM.Localization rloc = rl.localizationROM; if (rloc != null) { int commonStart = rloc.languageTables[1].num_txtTable + rloc.languageTables[1].num_binaryTable; WebJSON.Localization.Language GetLanguage(int langIndex) { OpenSpace.ROM.LanguageTable lang = rloc.languageTables[langIndex]; string[] entries = new string[lang.num_txtTable + lang.num_binaryTable]; if (langIndex == 0) { for (int i = 0; i < entries.Length; i++) { entries[i] = rloc.Lookup(commonStart + i); } } else { for (int i = 0; i < entries.Length; i++) { entries[i] = rloc.Lookup(i, languageIndex: langIndex); } } return(new WebJSON.Localization.Language() { Name = lang.name.Split(':')[0], NameLocalized = lang.name.Split(':')[1], Entries = entries }); } return(new WebJSON.Localization() { LanguageStart = 0, CommonStart = commonStart, Common = GetLanguage(0), Languages = Enumerable.Range(1, rloc.languageTables.Length - 1).Select(ind => GetLanguage(ind)).ToArray() }); } } else if (l is OpenSpace.Loader.R2PS1Loader) { } else { OpenSpace.Text.LocalizationStructure loc = l.localization; if (loc != null) { return(new WebJSON.Localization() { LanguageStart = 0, CommonStart = 20000, Common = new WebJSON.Localization.Language() { Name = "Common", NameLocalized = "Common", Entries = loc.misc.entries }, Languages = Enumerable.Range(0, loc.num_languages).Select(ind => new WebJSON.Localization.Language() { Name = l.languages?[ind] ?? ("Language " + ind), NameLocalized = l.languages_loc?[ind] ?? ("Language " + ind), Entries = loc.languages[ind].entries }).ToArray() }); } } return(null); }
private void UpdateBackgroundROM() { // Update background color or material Color?backgroundColor = null; OpenSpace.ROM.VisualMaterial skyMaterial = null; OpenSpace.ROM.VisualMaterial[] skyMaterialsDD = null; SectorComponent activeBackgroundSector = null; OpenSpace.Loader.R2ROMLoader l = MapLoader.Loader as OpenSpace.Loader.R2ROMLoader; OpenSpace.ROM.LevelHeader lh = l.level; if (lh != null && lh.backgroundUpLeft != null && lh.backgroundUpLeft.Value != null && lh.backgroundUpRight != null && lh.backgroundUpRight.Value != null && lh.backgroundDownLeft != null && lh.backgroundDownLeft.Value != null && lh.backgroundDownRight != null && lh.backgroundDownRight.Value != null) { skyMaterial = null; skyMaterialsDD = new OpenSpace.ROM.VisualMaterial[4]; skyMaterialsDD[0] = lh.backgroundUpLeft.Value; skyMaterialsDD[1] = lh.backgroundUpRight.Value; skyMaterialsDD[2] = lh.backgroundDownLeft.Value; skyMaterialsDD[3] = lh.backgroundDownRight.Value; } else { if (sectorManager != null && sectorManager.sectors != null && sectorManager.sectors.Count > 0) { foreach (SectorComponent s in sectorManager.sectors) { if (!s.Loaded) { continue; } if (s.sectorROM == null) { continue; } if (s.sectorROM.background != null && s.sectorROM.background.Value != null && s.sectorROM.background.Value.num_textures > 0 && s.sectorROM.background.Value.textures.Value != null && s.sectorROM.background.Value.textures.Value.vmTex[0].texRef.Value != null && s.sectorROM.background.Value.textures.Value.vmTex[0].texRef.Value.texInfo.Value != null) { skyMaterial = s.sectorROM.background; //print(skyMaterial.Offset); activeBackgroundSector = s; break; } else { /*foreach (LightInfo li in s.sector.staticLights) { * if (li.type == 6) { * backgroundColor = li.background_color; * break; * } * }*/ } } } } if (!controller.viewCollision) { if (skyMaterial != null) { backgroundPanel.gameObject.SetActive(true); if (backgroundMaterialROM != skyMaterial) { backgroundMaterialROM = skyMaterial; Material skyboxMat = skyMaterial.GetMaterial(OpenSpace.ROM.VisualMaterial.Hint.None); /*Texture tex = skyboxMat.GetTexture("_Tex0"); * tex.filterMode = FilterMode.Point; * tex.wrapMode = TextureWrapMode.Clamp; * skyboxMat.SetTexture("_Tex0", tex);*/ backgroundPanel.sharedMaterial = skyboxMat; } //skyboxMat.SetFloat("_DisableLighting", 1f); backgroundPanel.sharedMaterial.SetFloat("_DisableLightingLocal", 1f); if (activeBackgroundSector != null) { if (activeBackgroundSector != previousActiveBackgroundSector) { //backgroundPanel.material.SetFloat("_DisableLightingLocal", 0f); sectorManager.ApplySectorLighting(activeBackgroundSector, backgroundPanel.gameObject, LightInfo.ObjectLightedFlag.Environment); previousActiveBackgroundSector = activeBackgroundSector; } } else { //backgroundPanel.material.SetFloat("_DisableLighting", 1f); } //RenderSettings.skybox = skyboxMat; //Camera.main.clearFlags = CameraClearFlags.Skybox; } else { backgroundPanel.gameObject.SetActive(false); } if (skyMaterialsDD != null) { for (int i = 0; i < 4; i++) { backgroundPanelsROM[i].gameObject.SetActive(true); } if (backgroundMaterialsDDROM == null) { backgroundMaterialsDDROM = skyMaterialsDD; for (int i = 0; i < 4; i++) { Material skyboxMat = skyMaterialsDD[i].GetMaterial(OpenSpace.ROM.VisualMaterial.Hint.None); backgroundPanelsROM[i].sharedMaterial = skyboxMat; backgroundPanelsROM[i].sharedMaterial.SetFloat("_DisableLightingLocal", 1f); } } if (activeBackgroundSector != null) { if (activeBackgroundSector != previousActiveBackgroundSector) { //backgroundPanel.material.SetFloat("_DisableLightingLocal", 0f); //sectorManager.ApplySectorLighting(activeBackgroundSector, backgroundPanel.gameObject, LightInfo.ObjectLightedFlag.Environment); previousActiveBackgroundSector = activeBackgroundSector; } } else { //backgroundPanel.material.SetFloat("_DisableLighting", 1f); } //RenderSettings.skybox = skyboxMat; //Camera.main.clearFlags = CameraClearFlags.Skybox; } else { for (int i = 0; i < 4; i++) { backgroundPanelsROM[i].gameObject.SetActive(false); } } } else { backgroundPanel.gameObject.SetActive(false); for (int i = 0; i < 4; i++) { backgroundPanelsROM[i].gameObject.SetActive(false); } //RenderSettings.skybox = null; //Camera.main.clearFlags = CameraClearFlags.SolidColor; } if (backgroundColor.HasValue && !controller.viewCollision) { Camera.main.backgroundColor = backgroundColor.Value; //Camera.main.backgroundColor = Color.Lerp(Camera.main.backgroundColor, backgroundColor.Value, 0.5f * Time.deltaTime); } else { Camera.main.backgroundColor = Color.black; //Camera.main.backgroundColor = Color.Lerp(Camera.main.backgroundColor, Color.black, 0.5f * Time.deltaTime); } }
public void Init() { if (MapLoader.Loader is OpenSpace.Loader.R2ROMLoader) { OpenSpace.Loader.R2ROMLoader l = MapLoader.Loader as OpenSpace.Loader.R2ROMLoader; foreach (OpenSpace.ROM.WayPoint wp in l.waypointsROM) { AddWaypoint(wp.GetGameObject()); } if (graphRoot == null && l.graphsROM.Count > 0) { graphRoot = new GameObject("Graphs"); graphRoot.transform.SetParent(transform); graphRoot.SetActive(false); } foreach (OpenSpace.ROM.Graph graph in l.graphsROM) { GameObject go_graph = new GameObject("Graph " + graph.Offset); go_graph.transform.SetParent(graphRoot.transform); GraphBehaviour gb = go_graph.AddComponent <GraphBehaviour>(); graphs.Add(gb); gb.graphROM = graph; graphROMDict[graph] = gb; for (int i = 0; i < graph.num_nodes; i++) { OpenSpace.ROM.GraphNode node = graph.nodes.Value.nodes[i].Value; if (node.waypoint.Value != null) { WayPointBehaviour wp = waypoints.FirstOrDefault(w => w.wpROM == node.waypoint.Value); if (wp != null) { gb.nodes.Add(wp); wp.nodesROM.Add(node); if (!wp.graphs.Contains(gb)) { wp.graphs.Add(gb); } wp.name = "GraphNode[" + i + "].WayPoint (" + wp.wpROM.Offset + ")"; if (i == 0) { go_graph.transform.position = wp.transform.position; } wp.transform.SetParent(go_graph.transform); } } } } } else if (MapLoader.Loader is OpenSpace.Loader.R2PS1Loader) { OpenSpace.Loader.R2PS1Loader l = MapLoader.Loader as OpenSpace.Loader.R2PS1Loader; if (l.levelHeader?.wayPoints != null) { foreach (OpenSpace.PS1.WayPoint wp in l.levelHeader.wayPoints) { AddWaypoint(wp.GetGameObject()); } } if (l.levelHeader?.graphs != null) { if (graphRoot == null && l.levelHeader?.graphs.Length > 0) { graphRoot = new GameObject("Graphs"); graphRoot.transform.SetParent(transform); graphRoot.SetActive(false); } foreach (OpenSpace.PS1.Graph graph in l.levelHeader?.graphs) { GameObject go_graph = new GameObject("Graph " + graph.Offset); go_graph.transform.SetParent(graphRoot.transform); GraphBehaviour gb = go_graph.AddComponent <GraphBehaviour>(); graphs.Add(gb); gb.graphPS1 = graph; graphPS1Dict[graph] = gb; for (int i = 0; i < graph.arcs.Length; i++) { OpenSpace.PS1.Arc arc = graph.arcs[i]; if (arc.node1 != null) { WayPointBehaviour wp = waypoints.FirstOrDefault(w => w.wpPS1 == arc.node1); if (wp != null) { if (!gb.nodes.Contains(wp)) { gb.nodes.Add(wp); } wp.arcsPS1.Add(arc); if (!wp.graphs.Contains(gb)) { wp.graphs.Add(gb); } wp.name = "GraphNode[" + i + "].WayPoint (" + wp.wpPS1.Offset + ")"; /*if (i == 0) { * go_graph.transform.position = wp.transform.position; * }*/ wp.transform.SetParent(go_graph.transform); } } if (arc.node2 != null) { WayPointBehaviour wp = waypoints.FirstOrDefault(w => w.wpPS1 == arc.node2); if (wp != null) { if (!gb.nodes.Contains(wp)) { gb.nodes.Add(wp); } wp.arcsPS1.Add(arc); if (!wp.graphs.Contains(gb)) { wp.graphs.Add(gb); } wp.name = "GraphNode[" + i + "].WayPoint (" + wp.wpPS1.Offset + ")"; /*if (i == 0) { * go_graph.transform.position = wp.transform.position; * }*/ wp.transform.SetParent(go_graph.transform); } } } } } } else { MapLoader l = MapLoader.Loader; foreach (WayPoint wp in l.waypoints) { AddWaypoint(wp.Gao.GetComponent <WayPointBehaviour>()); } if (graphRoot == null && l.graphs.Count > 0) { graphRoot = new GameObject("Graphs"); graphRoot.transform.SetParent(transform); graphRoot.SetActive(false); } foreach (Graph graph in l.graphs) { GameObject go_graph = new GameObject(graph.name ?? "Graph " + graph.offset.ToString()); go_graph.transform.SetParent(graphRoot.transform); GraphBehaviour gb = go_graph.AddComponent <GraphBehaviour>(); graphs.Add(gb); gb.graph = graph; graphDict[graph] = gb; for (int i = 0; i < graph.nodes.Count; i++) { GraphNode node = graph.nodes[i]; if (node == null) { continue; } if (node.wayPoint != null) { WayPointBehaviour wp = waypoints.FirstOrDefault(w => w.wp == node.wayPoint); if (wp != null) { gb.nodes.Add(wp); wp.nodes.Add(node); if (!wp.graphs.Contains(gb)) { wp.graphs.Add(gb); } wp.name = "GraphNode[" + i + "].WayPoint (" + wp.wp.offset + ")"; if (i == 0) { go_graph.transform.position = wp.transform.position; } wp.transform.SetParent(go_graph.transform); } } } } } List <WayPointBehaviour> isolateWaypoints = waypoints.Where(w => w.nodes.Count == 0 && w.nodesROM.Count == 0 && w.arcsPS1.Count == 0).ToList(); if (isolateWaypointRoot == null && isolateWaypoints.Count > 0) { isolateWaypointRoot = new GameObject("Isolate WayPoints"); isolateWaypointRoot.transform.SetParent(transform); isolateWaypointRoot.SetActive(false); } foreach (WayPointBehaviour wp in isolateWaypoints) { Pointer offset = (wp.wpROM != null ? wp.wpROM.Offset : (wp.wpPS1 != null ? wp.wpPS1.Offset : wp.wp.offset)); wp.name = "Isolate WayPoint @" + offset; wp.transform.SetParent(isolateWaypointRoot.transform); } foreach (WayPointBehaviour wp in waypoints) { wp.Init(); } UpdateViewGraphs(); //loaded = true; }
protected override AdvancedDropdownItem BuildRoot() { var root = new AdvancedDropdownItem(name); LocalizationStructure loc = MapLoader.Loader.localization; root.AddChild(new AdvancedDropdownItem("-1 - None")); if (loc != null) { if (loc.languages != null && loc.languages.Length > 0 && loc.languages[0].entries.Length > 0) { AdvancedDropdownItem lang = new AdvancedDropdownItem("Localized Text"); root.AddChild(lang); for (int i = 0; i < loc.languages[0].entries.Length; i++) { lang.AddChild(new AdvancedDropdownItem( i.ToString() // ID + " - " + (loc.languages[0].entries[i] == null ? "null" : loc.languages[0].entries[i].Replace("\n", "\\n")) // Text )); } } if (loc.misc.entries != null && loc.misc.entries.Length > 0) { AdvancedDropdownItem misc = new AdvancedDropdownItem("Misc Text"); root.AddChild(misc); for (int i = 0; i < loc.misc.entries.Length; i++) { misc.AddChild(new AdvancedDropdownItem( (20000 + i).ToString() // ID + " - " + loc.misc.entries[i].Replace("\n", "\\n") // Text )); } } } else if (MapLoader.Loader is OpenSpace.Loader.R2ROMLoader) { OpenSpace.Loader.R2ROMLoader l = MapLoader.Loader as OpenSpace.Loader.R2ROMLoader; OpenSpace.ROM.LanguageTable[] langs = l.localizationROM?.languageTables; if (langs != null && langs.Length > 0) { int i = 0; AdvancedDropdownItem misc = new AdvancedDropdownItem(langs[0].name); root.AddChild(misc); for (int j = 0; j < langs[0].num_txtTable; j++) { misc.AddChild(new AdvancedDropdownItem( i.ToString() // ID + " - " + langs[0].textTable.Value.strings[j].Value?.ToString().Replace("\n", "\\n") // Text )); i++; } for (int j = 0; j < langs[0].num_binaryTable; j++) { misc.AddChild(new AdvancedDropdownItem( i.ToString() // ID + " - " + langs[0].binaryTable.Value.strings[j].Value?.ToString().Replace("\n", "\\n") // Text )); i++; } if (langs.Length > 1) { AdvancedDropdownItem lang = new AdvancedDropdownItem(langs[1].name); root.AddChild(lang); for (int j = 0; j < langs[1].num_txtTable; j++) { lang.AddChild(new AdvancedDropdownItem( i.ToString() // ID + " - " + langs[1].textTable.Value.strings[j].Value?.ToString().Replace("\n", "\\n") // Text )); i++; } for (int j = 0; j < langs[1].num_binaryTable; j++) { lang.AddChild(new AdvancedDropdownItem( i.ToString() // ID + " - " + langs[1].binaryTable.Value.strings[j].Value?.ToString().Replace("\n", "\\n") // Text )); i++; } } } } return(root); }