public void Place(Vector3[] Positions, Quaternion[] Rotations, Vector3[] Scales, bool RegisterUndo) { if (Positions.Length > 0 && RegisterUndo && !IsPasteAction && !UndoRegistered) { Undo.RegisterUndo(new UndoHistory.HistoryPropsChange()); } for (int i = 0; i < Positions.Length; i++) { if (!MapLuaParser.IsInArea(Positions[i])) { continue; } Positions[i].y = ScmapEditor.Current.Teren.SampleHeight(Positions[i]); Prop NewProp = new Prop(); NewProp.GroupId = RandomPropGroup; NewProp.CreateObject(Positions[i], Rotations[i], Vector3.one); AllPropsTypes[RandomPropGroup].PropsInstances.Add(NewProp); if (IsPasteAction && i == 0) { PastedObjects.Add(NewProp.Obj.gameObject); } } }
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 (isPasteAction) { Vector3 NewPos; int CopyDataCount = CopyData.Count; for (int i = 0; i < Positions.Length; i++) { for (int m = 0; m < CopyDataCount; m++) { if (!AnyCreated) { Undo.RegisterUndo(new UndoHistory.HistoryMarkersRemove()); } AnyCreated = true; //Debug.Log(Mpreset.Markers[m].Tr.localPosition); NewPos = Positions[i] + Rotations[i] * CopyData[m].Position; 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(CopyData[m].MarkerType, MapLua.SaveLua.GetLowestName(CopyData[m].Name)); 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); if (i == 0) { PastedObjects.Add(NewMarker.MarkerObj.gameObject); } } } } else if (CreationId == CREATE_PRESET) { 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.RegisterUndo(new UndoHistory.HistoryMarkersRemove()); } 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.RegisterUndo(new UndoHistory.HistoryMarkersRemove()); } 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 == CREATE_CAM) { NewMarker.orientation = MarkerObject.MarkerRotToScmapRot(Rotations[i], MapLua.SaveLua.Marker.MarkerTypes.CameraInfo); } 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(); } }