public static void CreateMarker(SaveLua.Marker Owner, int mc) { GameObject NewMarker = Instantiate(Current.MarkerPrefab, Current.MasterChains[mc]); NewMarker.name = Owner.Name; MarkerObject NewObj = NewMarker.GetComponent <MarkerObject>(); NewObj.Owner = Owner; Owner.MarkerObj = NewObj; MarkerPropGraphic PropGraphic; if (Owner.MarkerType == SaveLua.Marker.MarkerTypes.BlankMarker && ArmyInfo.ArmyExist(Owner.Name)) { PropGraphic = Current.SpawnGraphic; } else { PropGraphic = GetPropByType(Owner.MarkerType); } NewObj.Mf.sharedMesh = PropGraphic.SharedMesh; NewObj.Mr.sharedMaterial = PropGraphic.SharedMaterial; NewObj.Bc.size = PropGraphic.SharedMesh.bounds.size; NewObj.Bc.center = PropGraphic.SharedMesh.bounds.center; NewObj.Tr.localPosition = ScmapEditor.ScmapPosToWorld(Owner.position); NewObj.Tr.localRotation = MarkerObject.ScmapRotToMarkerRot(Owner.orientation, Owner.MarkerType); NewMarker.SetActive(Current.MarkerLayersSettings.ActiveByType(Owner.MarkerType)); }
void ChangeConnection(SelectionManager.SelectedObjects Sel, bool Connect) { SaveLua.Marker[] SelectedMarkers = new SaveLua.Marker[Sel.Ids.Count]; for (int i = 0; i < SelectedMarkers.Length; i++) { SelectedMarkers[i] = SelectionManager.Current.AffectedGameObjects[Sel.Ids[i]].GetComponent <MarkerObject>().Owner; } for (int i = 0; i < Sel.Ids.Count; i++) { SaveLua.Marker Mobj = SelectionManager.Current.AffectedGameObjects[Sel.Ids[i]].GetComponent <MarkerObject>().Owner; for (int c = 0; c < SelectedMarkers.Length; c++) { if (SelectedMarkers[c] != null && SelectedMarkers[c] != Mobj) { if (Connect && SelectedMarkers[c].MarkerType != Mobj.MarkerType) { continue; } if (Connect && !Mobj.AdjacentToMarker.Contains(SelectedMarkers[c])) { Mobj.AdjacentToMarker.Add(SelectedMarkers[c]); } else if (!Connect && Mobj.AdjacentToMarker.Contains(SelectedMarkers[c])) { Mobj.AdjacentToMarker.Remove(SelectedMarkers[c]); } } } } }
public static int RecreateMarker(int mc, SaveLua.Marker Marker, int Insert = -1) { CreateMarker(Marker, mc); int ToReturn = 0; if (Insert >= 0 && Insert <= MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Count) { MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Insert(Insert, Marker); ToReturn = Insert; } else { MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Add(Marker); ToReturn = MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Count - 1; } int ChainsCount = Marker.ConnectedToChains.Count; for (int c = 0; c < ChainsCount; c++) { if (Marker.ConnectedToChains[c] != null && !Marker.ConnectedToChains[c].ConnectedMarkers.Contains(Marker)) { Marker.ConnectedToChains[c].ConnectedMarkers.Add(Marker); } } return(ToReturn); }
bool SetTableGroupToggle(SaveLua.Marker markerInstance, bool SetTo, string TableKey) { if (markerInstance.MarkerType != SaveLua.Marker.MarkerTypes.Mass && markerInstance.MarkerType != SaveLua.Marker.MarkerTypes.Hydrocarbon) { return(false); } if (SetTo) { if (!markerInstance.AdaptiveKeys.Contains(TableKey)) { markerInstance.AdaptiveKeys.Add(TableKey); return(true); } } else { if (markerInstance.AdaptiveKeys.Contains(TableKey)) { markerInstance.AdaptiveKeys.Remove(TableKey); return(true); } } return(false); }
bool SetMarkerArmyToggle(SaveLua.Marker markerInstance, bool SetTo, int ToggleId) { if (markerInstance.MarkerType != SaveLua.Marker.MarkerTypes.Mass && markerInstance.MarkerType != SaveLua.Marker.MarkerTypes.Hydrocarbon) { return(false); } if (SetTo) { if (!markerInstance.SpawnWithArmy.Contains(ToggleId)) { markerInstance.SpawnWithArmy.Add(ToggleId); return(true); } } else { if (markerInstance.SpawnWithArmy.Contains(ToggleId)) { markerInstance.SpawnWithArmy.Remove(ToggleId); return(true); } } return(false); }
public static void UpdateAdaptiveLines() { Clear(); var allArmies = MapLuaParser.Current.ScenarioLuaFile.GetAllArmies(false); int mc = 0; int Mcount = MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Count; MapLua.SaveLua.Marker Current; for (int m = 0; m < Mcount; m++) { Current = MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers[m]; if (Current.MarkerObj == null) { continue; } if (Current.MarkerType != MapLua.SaveLua.Marker.MarkerTypes.Mass && Current.MarkerType != MapLua.SaveLua.Marker.MarkerTypes.Hydrocarbon) { continue; } int ArmyCount = Current.SpawnWithArmy.Count; for (int ai = 0; ai < ArmyCount; ai++) { string ArmyMarkerName = allArmies[Current.SpawnWithArmy[ai]].Name; //string ArmyMarkerName = "ARMY_" + (Current.SpawnWithArmy[ai] + 1); SaveLua.Marker ArmyMarker = SaveLua.GetMarker(ArmyMarkerName); if (ArmyMarker != null && ArmyMarker.MarkerObj != null) { AdaptiveConnections.Add(new AdaptiveConnection(Current.MarkerObj.Tr, ArmyMarker.MarkerObj.Tr, GetColor(Current.SpawnWithArmy[ai]))); } else { Debug.LogWarning("Cant find marker with name: " + ArmyMarkerName); } } int AdaptiveCount = Current.AdaptiveKeys.Count; if (AdaptiveCount > 0) { string Text = ""; for (int ai = 0; ai < AdaptiveCount; ai++) { if (ai > 0) { Text += "\n"; } Text += Current.AdaptiveKeys[ai]; } AdaptiveCustoms.Add(new AdaptiveCustom(Current.MarkerObj.Tr, Text)); } } RenderEnabled = true; }
public void OnTableToggleChanged(int GroupId, int ToggleId) { TablesLua.TablesInfo TablesData = MapLuaParser.Current.TablesLuaFile.Data; bool SetTo = false; if (CustomToggles[GroupId][ToggleId].HasOffValue) { SetTo = true; } string TableKey; if (TablesData.AllTables[GroupId].OneDimension) { TableKey = TablesData.AllTables[GroupId].Key; } else { TableKey = TablesData.AllTables[GroupId].Key + "#" + ToggleId; } int Count = SelectionManager.Current.Selection.Ids.Count; bool AnyChanged = false; for (int i = 0; i < Count; i++) { GameObject CurrentObj = SelectionManager.Current.AffectedGameObjects[SelectionManager.Current.Selection.Ids[i]]; SaveLua.Marker Current = CurrentObj.GetComponent <MarkerObject>().Owner; AnyChanged |= SetTableGroupToggle(Current, SetTo, TableKey); } for (int s = 0; s < SelectionManager.Current.SymetrySelection.Length; s++) { for (int i = 0; i < SelectionManager.Current.SymetrySelection[s].Ids.Count; i++) { GameObject CurrentObj = SelectionManager.Current.AffectedGameObjects[SelectionManager.Current.SymetrySelection[s].Ids[i]]; SaveLua.Marker Current = CurrentObj.GetComponent <MarkerObject>().Owner; AnyChanged |= SetTableGroupToggle(Current, SetTo, TableKey); } } CustomToggles[GroupId][ToggleId].HasOnValue = SetTo; CustomToggles[GroupId][ToggleId].HasOffValue = !SetTo; CustomToggles[GroupId][ToggleId].ApplyTesting(); if (AnyChanged) { RenderAdaptiveMarkers.UpdateAdaptiveLines(); } }
public void OnArmyToggleChanged(int GroupId, int ToggleId) { bool SetTo = false; if (ArmyToogles[ToggleId].HasOffValue) { SetTo = true; } int Count = SelectionManager.Current.Selection.Ids.Count; bool AnyChanged = false; for (int i = 0; i < Count; i++) { GameObject CurrentObj = SelectionManager.Current.AffectedGameObjects[SelectionManager.Current.Selection.Ids[i]]; SaveLua.Marker Current = CurrentObj.GetComponent <MarkerObject>().Owner; if (Current.MarkerType != SaveLua.Marker.MarkerTypes.Mass && Current.MarkerType != SaveLua.Marker.MarkerTypes.Hydrocarbon) { continue; } if (SetTo) { if (!Current.SpawnWithArmy.Contains(ToggleId)) { Current.SpawnWithArmy.Add(ToggleId); AnyChanged = true; } } else { if (Current.SpawnWithArmy.Contains(ToggleId)) { Current.SpawnWithArmy.Remove(ToggleId); AnyChanged = true; } } } ArmyToogles[ToggleId].HasOnValue = SetTo; ArmyToogles[ToggleId].HasOffValue = !SetTo; ArmyToogles[ToggleId].ApplyTesting(); if (AnyChanged) { RenderAdaptiveMarkers.UpdateAdaptiveLines(); } }
public void WeatherChanged() { Loading = true; Vector3 valueWeatherDriftDirection = WeatherDriftDirection.GetVector3Value(); string valueMapStyle = MapStyle.text; string valueWeatherType01 = WeatherType01.text; string valueWeatherType02 = WeatherType02.text; string valueWeatherType03 = WeatherType03.text; string valueWeatherType04 = WeatherType04.text; float valueWeatherType01Chance = WeatherType01Chance.value; float valueWeatherType02Chance = WeatherType02Chance.value; float valueWeatherType03Chance = WeatherType03Chance.value; float valueWeatherType04Chance = WeatherType04Chance.value; Undo.RegisterUndo(new UndoHistory.HistoryMarkersChange(), new UndoHistory.HistoryMarkersChange.MarkersChangeHistoryParameter(AllMarkers)); for (int i = 0; i < Count; i++) { SaveLua.Marker current = SelectedGameObjects[i].GetComponent <MarkerObject>().Owner; current.WeatherDriftDirection = valueWeatherDriftDirection; current.MapStyle = valueMapStyle; current.WeatherType01 = valueWeatherType01; current.WeatherType02 = valueWeatherType02; current.WeatherType03 = valueWeatherType03; current.WeatherType04 = valueWeatherType04; current.WeatherType01Chance = valueWeatherType01Chance; current.WeatherType02Chance = valueWeatherType02Chance; current.WeatherType03Chance = valueWeatherType03Chance; current.WeatherType04Chance = valueWeatherType04Chance; } WeatherDriftDirection.SetVectorField(valueWeatherDriftDirection); MapStyle.SetValue(valueMapStyle); WeatherType01.SetValue(valueWeatherType01); WeatherType02.SetValue(valueWeatherType02); WeatherType03.SetValue(valueWeatherType03); WeatherType04.SetValue(valueWeatherType04); WeatherType01Chance.SetValue(valueWeatherType01Chance); WeatherType02Chance.SetValue(valueWeatherType02Chance); WeatherType03Chance.SetValue(valueWeatherType03Chance); WeatherType04Chance.SetValue(valueWeatherType04Chance); Loading = false; }
public void NameChanged() { if (Loading) { return; } Loading = true; string NameToChange = NameField.text; if (AllowConnect) { NameToChange.Replace(" ", ""); } for (int i = 0; i < SelectionManager.Current.AffectedGameObjects.Length; i++) { if (SelectionManager.Current.AffectedGameObjects[i].name == NameToChange) { Loading = true; NameField.text = SelectedGameObjects[0].name; Loading = false; return; } } SaveLua.Marker Current = SelectedGameObjects[0].GetComponent <MarkerObject>().Owner; Undo.RegisterUndo(new UndoHistory.HistoryMarkersChange(), new UndoHistory.HistoryMarkersChange.MarkersChangeHistoryParameter(new SaveLua.Marker[] { Current })); //MapLua.SaveLua.RemoveMarkerName(SelectedGameObjects[0].name); //MapLua.SaveLua.RegisterMarkerName(NameToChange); MapLua.SaveLua.RemoveMarker(SelectedGameObjects[0].name); Current.Name = NameToChange; SelectedGameObjects[0].name = NameToChange; NameField.text = NameToChange; MapLua.SaveLua.AddNewMarker(Current); MarkerListControler.UpdateList(true); MarkersControler.UpdateBlankMarkersGraphics(); Loading = false; }
public void CloudsChanged() { Loading = true; float valueCloudCount = CloudCount.value; float valueCloudCountRange = CloudCountRange.value; float valueCloudEmitterScale = CloudEmitterScale.value; float valueCloudEmitterScaleRange = CloudEmitterScaleRange.value; float valueCloudHeight = CloudHeight.value; float valueCloudHeightRange = CloudHeightRange.value; float valueCloudSpread = CloudSpread.value; float valueCloudSpawnChance = CloudSpawnChance.value; string valueCloudForceType = CloudForceType.text; Undo.RegisterUndo(new UndoHistory.HistoryMarkersChange(), new UndoHistory.HistoryMarkersChange.MarkersChangeHistoryParameter(AllMarkers)); for (int i = 0; i < Count; i++) { SaveLua.Marker current = SelectedGameObjects[i].GetComponent <MarkerObject>().Owner; current.cloudCount = valueCloudCount; current.cloudCountRange = valueCloudCountRange; current.cloudEmitterScale = valueCloudEmitterScale; current.cloudEmitterScaleRange = valueCloudEmitterScaleRange; current.cloudHeight = valueCloudHeight; current.cloudHeightRange = valueCloudHeightRange; current.cloudSpread = valueCloudSpread; current.spawnChance = valueCloudSpawnChance; current.ForceType = valueCloudForceType; } CloudCount.SetValue(valueCloudCount); CloudCountRange.SetValue(valueCloudCountRange); CloudEmitterScale.SetValue(valueCloudEmitterScale); CloudEmitterScaleRange.SetValue(valueCloudEmitterScaleRange); CloudHeight.SetValue(valueCloudHeight); CloudHeightRange.SetValue(valueCloudHeightRange); CloudSpread.SetValue(valueCloudSpread); CloudSpawnChance.SetValue(valueCloudSpawnChance); CloudForceType.SetValue(valueCloudForceType); Loading = false; }
void UpdateArmyToggles() { for (int t = 0; t < ArmyToogles.Length; t++) { ArmyToogles[t].ResetTesting(); } int Count = SelectionManager.Current.Selection.Ids.Count; for (int i = 0; i < Count; i++) { GameObject CurrentObj = SelectionManager.Current.AffectedGameObjects[SelectionManager.Current.Selection.Ids[i]]; MarkerObject Mo = CurrentObj.GetComponent <MarkerObject>(); if (Mo == null) { continue; } SaveLua.Marker Current = CurrentObj.GetComponent <MarkerObject>().Owner; if (Current.MarkerType == SaveLua.Marker.MarkerTypes.Mass || Current.MarkerType == SaveLua.Marker.MarkerTypes.Hydrocarbon) { for (int t = 0; t < ArmyToogles.Length; t++) { if (Current.SpawnWithArmy.Contains(t)) { ArmyToogles[t].HasOnValue = true; } else { ArmyToogles[t].HasOffValue = true; } } } } for (int t = 0; t < ArmyToogles.Length; t++) { ArmyToogles[t].ApplyTesting(); } }
public static void UpdateGraphics(SaveLua.Marker Owner, int mc) { bool Active = true; MarkerPropGraphic PropGraphic; if (Owner.MarkerType == SaveLua.Marker.MarkerTypes.BlankMarker && ArmyInfo.ArmyExist(Owner.Name)) { PropGraphic = Current.SpawnGraphic; Active = Current.MarkerLayersSettings.Spawn; } else { PropGraphic = GetPropByType(Owner.MarkerType); Active = Current.MarkerLayersSettings.ActiveByType(Owner.MarkerType); } Owner.MarkerObj.Mf.sharedMesh = PropGraphic.SharedMesh; Owner.MarkerObj.Mr.sharedMaterial = PropGraphic.SharedMaterial; Owner.MarkerObj.Bc.size = PropGraphic.SharedMesh.bounds.size; Owner.MarkerObj.Bc.center = PropGraphic.SharedMesh.bounds.center; Owner.MarkerObj.gameObject.SetActive(Active); }
public void OnTableToggleChanged(int GroupId, int ToggleId) { TablesLua.TablesInfo TablesData = MapLuaParser.Current.TablesLuaFile.Data; bool SetTo = false; if (CustomToggles[GroupId][ToggleId].HasOffValue) { SetTo = true; } string TableKey; if (TablesData.AllTables[GroupId].OneDimension) { TableKey = TablesData.AllTables[GroupId].Key; } else { TableKey = TablesData.AllTables[GroupId].Key + "#" + ToggleId; } int Count = SelectionManager.Current.Selection.Ids.Count; bool AnyChanged = false; for (int i = 0; i < Count; i++) { GameObject CurrentObj = SelectionManager.Current.AffectedGameObjects[SelectionManager.Current.Selection.Ids[i]]; SaveLua.Marker Current = CurrentObj.GetComponent <MarkerObject>().Owner; if (Current.MarkerType != SaveLua.Marker.MarkerTypes.Mass && Current.MarkerType != SaveLua.Marker.MarkerTypes.Hydrocarbon) { continue; } if (SetTo) { if (!Current.AdaptiveKeys.Contains(TableKey)) { Current.AdaptiveKeys.Add(TableKey); AnyChanged = true; } } else { if (Current.AdaptiveKeys.Contains(TableKey)) { Current.AdaptiveKeys.Remove(TableKey); AnyChanged = true; } } } CustomToggles[GroupId][ToggleId].HasOnValue = SetTo; CustomToggles[GroupId][ToggleId].HasOffValue = !SetTo; CustomToggles[GroupId][ToggleId].ApplyTesting(); if (AnyChanged) { RenderAdaptiveMarkers.UpdateAdaptiveLines(); } }
void UpdateCustomToggles() { for (int t = 0; t < CustomToggles.Length; t++) { for (int j = 0; j < CustomToggles[t].Length; j++) { CustomToggles[t][j].ResetTesting(); } } TablesLua.TablesInfo TablesData = MapLuaParser.Current.TablesLuaFile.Data; int Count = SelectionManager.Current.Selection.Ids.Count; for (int i = 0; i < Count; i++) { GameObject CurrentObj = SelectionManager.Current.AffectedGameObjects[SelectionManager.Current.Selection.Ids[i]]; SaveLua.Marker Current = CurrentObj.GetComponent <MarkerObject>().Owner; if (Current.MarkerType != SaveLua.Marker.MarkerTypes.Mass && Current.MarkerType != SaveLua.Marker.MarkerTypes.Hydrocarbon) { continue; } for (int t = 0; t < CustomToggles.Length; t++) { if (TablesData.AllTables[t].OneDimension) { if (Current.AdaptiveKeys.Contains(TablesData.AllTables[t].Key)) { CustomToggles[t][0].HasOnValue = true; } else { CustomToggles[t][0].HasOffValue = true; } } else { for (int j = 0; j < CustomToggles[t].Length; j++) { // Check if contain if (Current.AdaptiveKeys.Contains(TablesData.AllTables[t].Key + "#" + j)) { CustomToggles[t][j].HasOnValue = true; } else { CustomToggles[t][j].HasOffValue = true; } } } } } for (int t = 0; t < CustomToggles.Length; t++) { for (int j = 0; j < CustomToggles[t].Length; j++) { CustomToggles[t][j].ApplyTesting(); } } }