/// <summary> /// Search for all markers of defined types that name prefix is not correct /// </summary> void FixAiMarkersNamesExecute() { HashSet <MapLua.SaveLua.Marker> ToChange = new HashSet <MapLua.SaveLua.Marker>(); for (int mc = 0; mc < MapLuaParser.Current.SaveLuaFile.Data.MasterChains.Length; mc++) { int Mcount = MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Count; for (int m = 0; m < Mcount; m++) { switch (MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[m].MarkerType) { case MapLua.SaveLua.Marker.MarkerTypes.NavalArea: case MapLua.SaveLua.Marker.MarkerTypes.ExpansionArea: case MapLua.SaveLua.Marker.MarkerTypes.LargeExpansionArea: string RequiredPrefix = MapLua.SaveLua.GetPrefixByType(MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[m].MarkerType); if (!MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[m].Name.StartsWith(RequiredPrefix)) { ToChange.Add(MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[m]); } break; } } } if (ToChange.Count <= 0) { GenericPopup.ShowPopup(GenericPopup.PopupTypes.OneButton, "Fix AI Marker names", "There are no AI markers that need name fix.", "OK", null); return; } MapLua.SaveLua.Marker[] UndoMarkersArray = new MapLua.SaveLua.Marker[ToChange.Count]; ToChange.CopyTo(UndoMarkersArray); Undo.RegisterUndo(new UndoHistory.HistoryMarkersChange(), new UndoHistory.HistoryMarkersChange.MarkersChangeHistoryParameter(UndoMarkersArray)); int ChangedMarkersCount = 0; for (int i = 0; i < UndoMarkersArray.Length; i++) { //string RequiredPrefix = MapLua.SaveLua.GetPrefixByType(UndoMarkersArray[i].MarkerType); //if (!RequiredPrefix.StartsWith(RequiredPrefix)) //{ MapLua.SaveLua.RemoveMarker(UndoMarkersArray[i].Name); UndoMarkersArray[i].Name = MapLua.SaveLua.GetLowestName(UndoMarkersArray[i].MarkerType); if (UndoMarkersArray[i].MarkerObj) { UndoMarkersArray[i].MarkerObj.gameObject.name = UndoMarkersArray[i].Name; } MapLua.SaveLua.AddNewMarker(UndoMarkersArray[i]); ChangedMarkersCount++; //} } GenericPopup.ShowPopup(GenericPopup.PopupTypes.OneButton, "Fix AI Marker names", "Changed names of " + ChangedMarkersCount + " markers.", "OK", null); MarkerSelectionOptions.UpdateOptions(); }
void GoToCreation() { Selection.SelectionManager.Current.ClearAffectedGameObjects(false); PlacementManager.InstantiateAction = null; PlacementManager.MinRotAngle = 90; PlacementManager.BeginPlacement(GetCreationObject(), Place); if (ChangeControlerType.Current) { ChangeControlerType.Current.UpdateButtons(); } MarkerSelectionOptions.UpdateOptions(); }
public void GoToSelection() { if (!MarkersInfo.MarkerPageChange) { SelectionManager.Current.CleanSelection(); } int[] Types; SelectionManager.Current.SetAffectedGameObjects(MarkersControler.GetMarkerObjects(out Types), SelectionManager.SelectionControlTypes.Marker); SelectionManager.Current.SetAffectedTypes(Types); //Selection.SelectionManager.Current.SetCustomSettings(true, false, false); PlacementManager.Clear(); if (ChangeControlerType.Current) { ChangeControlerType.Current.UpdateButtons(); } MarkerSelectionOptions.UpdateOptions(); }
public void DestroyMarkers(List <GameObject> MarkerObjects, bool RegisterUndo = true) { int mc = 0; // MasterChainID bool AnyRemoved = false; int Mcount = MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Count; if (RegisterUndo) { LastDestroyedMarkers = new int[MarkerObjects.Count]; int Step = 0; for (int i = 0; i < Mcount; i++) { //bool Removed = false; for (int m = 0; m < MarkerObjects.Count; m++) { if (MarkerObjects[m] == null) { break; } if (MarkerObjects[m] == MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[i].MarkerObj.gameObject) { LastDestroyedMarkers[Step] = i; Step++; break; } } } Undo.Current.RegisterMarkersRemove(); } //List<MapLua.SaveLua.Marker> NewMarkers = new List<MapLua.SaveLua.Marker>(); //Mcount = MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Count; for (int i = 0; i < Mcount; i++) { if (MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[i].MarkerObj == null) { continue; } //bool Removed = false; for (int m = 0; m < MarkerObjects.Count; m++) { if (MarkerObjects[m] == MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[i].MarkerObj.gameObject) { MapLua.SaveLua.RemoveMarker(MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[i].Name); Destroy(MarkerObjects[m]); MarkerObjects.RemoveAt(m); MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[i] = null; MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.RemoveAt(i); Mcount--; i--; AnyRemoved = true; break; } } //if (!Removed) // NewMarkers.Add(MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[i]); } //MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers = NewMarkers.ToArray(); if (AnyRemoved) { SelectionManager.Current.CleanSelection(); int[] Types; SelectionManager.Current.SetAffectedGameObjects(MarkersControler.GetMarkerObjects(out Types), SelectionManager.SelectionControlTypes.Marker); SelectionManager.Current.SetAffectedTypes(Types); MarkerSelectionOptions.UpdateOptions(); RenderMarkersConnections.Current.UpdateConnections(); } }
public void Place(Vector3[] Positions, Quaternion[] Rotations, Vector3[] Scales) { //List<MapLua.SaveLua.Marker> NewMarkers = new List<MapLua.SaveLua.Marker>(); int mc = 0; // MasterChainID LastAddedMarkers = new List <int>(); int TotalMarkersCount = MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Count; bool AnyCreated = false; if (CreationId == 5) { Vector3 NewPos; MarkerPreset Mpreset = MarkerPresets[SpawnPressetDropdown.value].GetComponent <MarkerPreset>(); for (int i = 0; i < Positions.Length; i++) { for (int m = 0; m < Mpreset.Markers.Length; m++) { if (!AnyCreated) { Undo.Current.RegisterMarkersAdd(); } AnyCreated = true; //Debug.Log(Mpreset.Markers[m].Tr.localPosition); NewPos = Positions[i] + Rotations[i] * Mpreset.Markers[m].Tr.localPosition; if (SelectionManager.Current.SnapToGrid) { NewPos = ScmapEditor.SnapToGridCenter(NewPos, true, SelectionManager.Current.SnapToWater); } //NewPos.y = ScmapEditor.Current.Teren.SampleHeight(NewPos); MapLua.SaveLua.Marker NewMarker = new MapLua.SaveLua.Marker(Mpreset.Markers[m].MarkerType); NewMarker.position = ScmapEditor.WorldPosToScmap(NewPos); //NewMarker.orientation = MarkersControler.CreateMarker(NewMarker, mc); ChainsList.AddToCurrentChain(NewMarker); LastAddedMarkers.Add(TotalMarkersCount); TotalMarkersCount++; MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Add(NewMarker); } } } else { for (int i = 0; i < Positions.Length; i++) { if (!AnyCreated) { Undo.Current.RegisterMarkersAdd(); } AnyCreated = true; MapLua.SaveLua.Marker NewMarker = new MapLua.SaveLua.Marker(LastCreationType); bool snapToWater = SelectionManager.Current.SnapToWater; if (LastCreationType == MapLua.SaveLua.Marker.MarkerTypes.Mass || LastCreationType == MapLua.SaveLua.Marker.MarkerTypes.Hydrocarbon) { snapToWater = false; } if (SelectionManager.Current.SnapToGrid) { Positions[i] = ScmapEditor.SnapToGridCenter(Positions[i], true, snapToWater); } //Positions[i].y = ScmapEditor.Current.Teren.SampleHeight(Positions[i]); ChainsList.AddToCurrentChain(NewMarker); NewMarker.position = ScmapEditor.WorldPosToScmap(Positions[i]); if (CreationId == 3) { NewMarker.orientation = Rotations[i].eulerAngles; } else { NewMarker.orientation = Vector3.zero; } MarkersControler.CreateMarker(NewMarker, mc); LastAddedMarkers.Add(TotalMarkersCount); TotalMarkersCount++; MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Add(NewMarker); } } if (AnyCreated) { //MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers = MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Concat<MapLua.SaveLua.Marker>(NewMarkers.ToArray()); MarkerSelectionOptions.UpdateOptions(); MarkersControler.UpdateBlankMarkersGraphics(); RenderMarkersWarnings.Generate(); } }
void Awake() { Current = this; }