Exemple #1
0
        public void SaveRace(Client player, bool mapEditorFile = false)
        {
            if (CurrentMap == null)
            {
                return;
            }
            Objects.ToList().ForEach(obj =>
            {
                CurrentMap.MapObjects.Add(new MapObject
                {
                    Model    = obj.Value.model,
                    Position = obj.Value.position,
                    Rotation = obj.Value.rotation
                });
            });
            if (mapEditorFile)
            {
                MapEditorService.SaveMap(CurrentMap, CurrentMap.Name);
                API.sendChatMessageToPlayer(player, "Map Saved at ~b~MapEditorMaps/" + CurrentMap.Name + ".xml");
            }
            else
            {
                MapService.SaveMap(CurrentMap, CurrentMap.Name);
                API.sendChatMessageToPlayer(player, "Map Saved at ~b~Maps/" + CurrentMap.Name + ".xml");
            }

            Objects.ToList().ForEach(obj =>
            {
                API.deleteEntity(obj.Value);
            });
            Objects.Clear();
            ObjectBuilder.Labels.ToList().ForEach(lbl =>
            {
                API.deleteEntity(lbl.Value);
            });
            ObjectBuilder.Labels.Clear();
            ObjectBuilder.NextObjId = 1;
            CurrentMap = null;
        }
Exemple #2
0
        public void LoadEditorMapCmd(Client player, string filename)
        {
            Map map = MapEditorService.LoadMapFromFile(filename);

            if (map == null)
            {
                player.sendChatMessage("~r~Error~w~: Map not found..");
                return;
            }
            CurrentMap = map;

            map.MapObjects.ForEach(obj =>
            {
                var cobj  = API.createObject(obj.Model, obj.Position, obj.Rotation);
                var label = API.createTextLabel("Object ID: ~b~" + ObjectBuilder.NextObjId, player.position + new Vector3(0, 0, 1), 20f, 0.5f, true);
                API.attachEntityToEntity(label, cobj, "", new Vector3(0, 0, 1), new Vector3());
                ObjectBuilder.Labels.Add(ObjectBuilder.NextObjId, label);
                Objects.Add(ObjectBuilder.NextObjId, cobj);
                ObjectBuilder.NextObjId++;
            });
            CurrentMap.MapObjects.Clear();
            API.sendNotificationToAll($"Map ~b~{CurrentMap.Name} ~w~loaded by ~y~{player.name}");
        }