Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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();
            }
        }