Example #1
0
    public void SetRegionMapValues(RegionMap regionMap)
    {
        textureSize = regionMap.textureSize;
        hdCount     = 0;
        foreach (HumidityData hd in regionMap.humidityLevels)
        {
            if (hd.isActive)
            {
                hdCount++;
            }
        }
        hdLenghts  = regionMap.GetHumidityLevelsLenght(hdLenghts);
        hdIncRegs  = regionMap.GetAllIncludedRegions(hdIncRegs);
        biomsBlend = regionMap.biomsBlend;

        if (useTextures)
        {
            mainTextures  = regionMap.regions.Select(x => x.mainTexture).ToArray();
            slopeTextures = regionMap.regions.Select(x => x.slopeTexture).ToArray();
        }
        scales             = GetSizedArray(regionMap.regions.Select(x => x.scale).ToArray(), scales);
        colorStrenghts     = GetSizedArray(regionMap.regions.Select(x => x.colorStrenght).ToArray(), colorStrenghts);
        mainColors         = GetSizedArray(regionMap.regions.Select(x => x.mainColor).ToArray(), mainColors);
        slopeColors        = GetSizedArray(regionMap.regions.Select(x => x.slopeColor).ToArray(), slopeColors);
        heights            = GetSizedArray(regionMap.regions.Select(x => x.height).ToArray(), heights);
        slopeThresholds    = GetSizedArray(regionMap.regions.Select(x => x.slopeThreshold).ToArray(), slopeThresholds);
        slopeBlendAmounts  = GetSizedArray(regionMap.regions.Select(x => x.slopeBlendAmount).ToArray(), slopeBlendAmounts);
        regionBlendAmounts = GetSizedArray(regionMap.regions.Select(x => x.regionBlendAmount).ToArray(), regionBlendAmounts);
    }
Example #2
0
        /// <summary>
        /// Attempts to retrieve an item with the specified ID, returning success or
        /// failure.
        /// </summary>
        /// <typeparam name="T">
        /// The type of the item to retrieve.
        /// </typeparam>
        /// <param name="id">
        /// The ID of the item to retrieve.
        /// </param>
        /// <param name="value">
        /// Output parameter.  With contain the retrieved value if a match is found,
        /// or the default value otherwise.
        /// </param>
        /// <returns>
        /// <see langword="true" /> if a matching item was successfully retrieved;
        /// otherwise <see langword="false" />.
        /// </returns>
        public bool TryGetValue <T>(IConvertible id, out T value)
        {
            Contract.Requires(id != null, Resources.Messages.EveCache_IdCannotBeNull);
            Contract.Ensures(!Contract.Result <bool>() || Contract.ValueAtReturn <T>(out value) != null);

            string region = RegionMap.GetRegion(typeof(T));
            string key    = EveCache.CreateCacheKey(region, id);

            this.EnterReadLock(region);

            try
            {
                object result;

                if (this.InnerTryGetValue(key, out result))
                {
                    value = (T)result;
                    return(true);
                }
            }
            finally
            {
                this.ExitReadLock(region);
            }

            this.Statistics.Misses++;
            value = default(T);
            return(false);
        }
 uint IEstateRegionMapServiceInterface.this[UUID regionID]
 {
     get
     {
         uint estateID;
         if (!RegionMap.TryGetValue(regionID, out estateID))
         {
             throw new KeyNotFoundException();
         }
         return(estateID);
     }
     set
     {
         var vals = new Dictionary <string, object>
         {
             ["EstateID"] = value,
             ["RegionID"] = regionID
         };
         using (var conn = new MySqlConnection(m_ConnectionString))
         {
             conn.Open();
             conn.ReplaceInto("estate_regionmap", vals);
         }
     }
 }
Example #4
0
        static void ParseRegionData(MutagenFrame frame, IRegionInternal item)
        {
            var rdatFrame = frame.GetSubrecordFrame();

            RegionData.RegionDataType dataType = (RegionData.RegionDataType)BinaryPrimitives.ReadUInt32LittleEndian(rdatFrame.Content);
            var subMeta = frame.GetSubrecord(offset: rdatFrame.TotalLength);
            int len     = rdatFrame.TotalLength;

            if (IsExpected(dataType, subMeta.RecordType))
            {
                len += subMeta.TotalLength;
            }
            switch (dataType)
            {
            case RegionData.RegionDataType.Object:
                item.Objects = RegionObjects.CreateFromBinary(frame.SpawnWithLength(len, checkFraming: false));
                break;

            case RegionData.RegionDataType.Map:
                item.MapName = RegionMap.CreateFromBinary(frame.SpawnWithLength(len, checkFraming: false));
                break;

            case RegionData.RegionDataType.Grass:
                item.Grasses = RegionGrasses.CreateFromBinary(frame.SpawnWithLength(len, checkFraming: false));
                break;

            case RegionData.RegionDataType.Sound:
                if (frame.Reader.TryGetSubrecord(out var nextRec, offset: len) &&
                    (nextRec.RecordType.Equals(RDSD) || nextRec.RecordType.Equals(RDMD)))
                {
                    len += nextRec.TotalLength;
                }
                item.Sounds = RegionSounds.CreateFromBinary(frame.SpawnWithLength(len, checkFraming: false));
                break;

            case RegionData.RegionDataType.Weather:
                item.Weather = RegionWeather.CreateFromBinary(frame.SpawnWithLength(len, checkFraming: false));
                break;

            case RegionData.RegionDataType.Icon:
                frame.Position += frame.MetaData.Constants.SubConstants.HeaderLength + rdatFrame.TotalLength;
                len             = len - frame.MetaData.Constants.SubConstants.HeaderLength - rdatFrame.TotalLength;
                if (StringBinaryTranslation.Instance.Parse(
                        frame.SpawnWithLength(len, checkFraming: false),
                        out var iconVal))
                {
                    item.Icon = iconVal;
                }
                else
                {
                    item.Icon = null;
                }
                break;

            default:
                throw new NotImplementedException();
            }
        }
Example #5
0
            static void ParseRegionData(MutagenFrame frame, IRegionInternal item)
            {
                var rdatFrame = frame.Reader.GetSubrecordFrame();
                int len       = rdatFrame.TotalLength;

                RegionData.RegionDataType dataType = (RegionData.RegionDataType)BinaryPrimitives.ReadUInt32LittleEndian(rdatFrame.Content);

                if (frame.Reader.TryGetSubrecord(out var subMeta, offset: len))
                {
                    var recType = subMeta.RecordType;
                    if (recType == RecordTypes.ICON)
                    {
                        len += subMeta.TotalLength;
                        // Skip icon subrecord for now
                        subMeta = frame.Reader.GetSubrecord(offset: rdatFrame.TotalLength + subMeta.TotalLength);
                    }
                    if (IsExpected(dataType, recType))
                    {
                        len += subMeta.TotalLength;
                    }
                }

                switch (dataType)
                {
                case RegionData.RegionDataType.Object:
                    item.Objects = RegionObjects.CreateFromBinary(frame.SpawnWithLength(len, checkFraming: false));
                    break;

                case RegionData.RegionDataType.Map:
                    item.Map = RegionMap.CreateFromBinary(frame.SpawnWithLength(len, checkFraming: false));
                    break;

                case RegionData.RegionDataType.Grass:
                    item.Grasses = RegionGrasses.CreateFromBinary(frame.SpawnWithLength(len, checkFraming: false));
                    break;

                case RegionData.RegionDataType.Sound:
                    if (frame.Reader.TryGetSubrecord(out var nextRec, offset: len) &&
                        (nextRec.RecordType.Equals(RDSA) || nextRec.RecordType.Equals(RDMO)))
                    {
                        len += nextRec.TotalLength;
                    }
                    item.Sounds = RegionSounds.CreateFromBinary(frame.SpawnWithLength(len, checkFraming: false));
                    break;

                case RegionData.RegionDataType.Weather:
                    item.Weather = RegionWeather.CreateFromBinary(frame.SpawnWithLength(len, checkFraming: false));
                    break;

                case RegionData.RegionDataType.Land:
                    item.Land = RegionLand.CreateFromBinary(frame.SpawnWithLength(len, checkFraming: false));
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
Example #6
0
 uint IEstateRegionMapServiceInterface.this[UUID regionID]
 {
     get
     {
         uint estateID;
         if (!RegionMap.TryGetValue(regionID, out estateID))
         {
             throw new KeyNotFoundException();
         }
         return(estateID);
     }
     set
     {
         m_RegionMapData[regionID] = value;
     }
 }
Example #7
0
    void Start()
    {
        gamaBuilder = GameObject.Find("GamaBuilder");

        regionMap = (RegionMap)FindObjectOfType(typeof(RegionMap));

        regionMap.ApiKey        = "NO9atv-JQf289NztiKv45g";
        regionMap.UnitsPerMeter = 1.0f;
        //regionMap.RegionName = "GamaMap";
        regionMap.Area = new TileArea(
            new LngLat(-74.009463, 40.711446),
            new LngLat(-73.999306, 40.706939),
            16);

        //regionMap.DownloadTilesAsync();
        //regionMap.GenerateSceneGraph();
    }
Example #8
0
        /// <summary>
        /// Retrieves the item with the specified ID from the cache, or, if no
        /// matching item is present, adds the specified value to the cache and
        /// returns it.
        /// </summary>
        /// <typeparam name="T">
        /// The type of item to add to or retrieve from the cache.
        /// </typeparam>
        /// <param name="value">
        /// The value which will be added and returned if a matching item cannot
        /// be found in the cache.
        /// </param>
        /// <returns>
        /// The cached item with the same key as <paramref name="value" />, if
        /// such an item exists.  Otherwise, <paramref name="value" /> will be
        /// added to the cache and then returned.
        /// </returns>
        public T GetOrAdd <T>(T value) where T : IEveCacheable
        {
            Contract.Requires(value != null, Resources.Messages.EveCache_ValueCannotBeNull);
            Contract.Ensures(Contract.Result <T>() != null);

            string region = RegionMap.GetRegion(value.GetType());
            string key    = EveCache.CreateCacheKey(region, value.CacheKey);

            this.EnterReadLock(region);

            try
            {
                object result;

                if (this.InnerTryGetValue(key, out result))
                {
                    return((T)result);
                }
            }
            finally
            {
                this.ExitReadLock(region);
            }

            // Otherwise, write to the cache
            this.EnterWriteLock(region);

            try
            {
                object result;

                if (this.InnerTryGetValue(key, out result))
                {
                    return((T)result);
                }

                this.Statistics.Misses++;
                this.InnerSet(key, value, false);
                return(value);
            }
            finally
            {
                this.ExitWriteLock(region);
            }
        }
Example #9
0
        /// <summary>
        /// Returns a value indicating whether an item with the specified ID is
        /// contained in the cache.
        /// </summary>
        /// <typeparam name="T">
        /// The type of the item to locate.
        /// </typeparam>
        /// <param name="id">
        /// The ID to locate in the cache.
        /// </param>
        /// <returns>
        /// <see langword="true" /> if an item with the specified ID is contained
        /// in the cache; otherwise <see langword="false" />.
        /// </returns>
        public bool Contains <T>(IConvertible id)
        {
            Contract.Requires(id != null, Resources.Messages.EveCache_IdCannotBeNull);

            string region = RegionMap.GetRegion(typeof(T));
            string key    = EveCache.CreateCacheKey(region, id);

            this.EnterReadLock(region);

            try
            {
                return(this.InnerContains(key));
            }
            finally
            {
                this.ExitReadLock(region);
            }
        }
Example #10
0
        /// <summary>
        /// Add the item to the cache, replacing any existing item with the same ID.
        /// </summary>
        /// <typeparam name="T">
        /// The type of item to add to the cache.
        /// </typeparam>
        /// <param name="value">
        /// The item to add to the cache.
        /// </param>
        /// <param name="permanent">
        /// Specifies whether to add the value permanently or whether it can be
        /// automatically evicted.
        /// </param>
        /// <remarks>
        /// <para>
        /// Items added with <paramref name="permanent" /> equal to
        /// <see langword="true" /> are immune to automatic eviction, but can
        /// still be removed or overwritten manually.
        /// </para>
        /// </remarks>
        public void AddOrReplace <T>(T value, bool permanent) where T : IEveCacheable
        {
            Contract.Requires(value != null, Resources.Messages.EveCache_ValueCannotBeNull);

            string region = RegionMap.GetRegion(typeof(T));
            string key    = EveCache.CreateCacheKey(region, value.CacheKey);

            this.EnterWriteLock(region);

            try
            {
                this.InnerSet(key, value, permanent);
            }
            finally
            {
                this.ExitWriteLock(region);
            }
        }
Example #11
0
        /// <summary>
        /// Removes the item with the specified key.
        /// </summary>
        /// <typeparam name="T">
        /// The type of the item to remove.
        /// </typeparam>
        /// <param name="id">
        /// The ID of the item to remove.
        /// </param>
        /// <returns>
        /// The removed item, or the default value if no matching item was found.
        /// </returns>
        public T Remove <T>(IConvertible id)
        {
            Contract.Requires(id != null, Resources.Messages.EveCache_IdCannotBeNull);

            string region = RegionMap.GetRegion(typeof(T));
            string key    = EveCache.CreateCacheKey(region, id);

            this.EnterWriteLock(region);

            try
            {
                var result = this.InnerRemove(key);
                return((result == null) ? default(T) : (T)result);
            }
            finally
            {
                this.ExitWriteLock(region);
            }
        }
Example #12
0
        private void ParseSectionMap(Stream s)
        {
            //NOTE: We loose the ordering sections were specified in the file
            //here. That's OK for now, because we have a read-only structure.
            //If we ever need to use this code for round-tripping PE files,
            //then this needs to be modified to also track section order.

            s.AssumeNotNull();
            m_header.AssumeNotNull();

            m_sections =
                new RegionMap<SectionHeader>(
                    x => x.SectionRVA,
                    x => x.VirtualSize
                );

            for (int i = 0; i < m_header.NumberOfSections; ++i)
            {
                var section = new SectionHeader();
                section.Load(s);
                m_sections.Add(section);
            }
        }
Example #13
0
 public async Task ProcessEventAsync(JournalMessage message)
 {
     message.Region = RegionMap.FindRegion(message.StarPos[0], message.StarPos[1], message.StarPos[2]);
     await _systemsContainer.UpsertItemAsync(message, message.Region == null?PartitionKey.None : new PartitionKey(message.Region.Name));
 }
Example #14
0
    public override void OnInspectorGUI()
    {
        serializableObject = (RegionMap)target;
        regionCount        = serializableObject.regions.Count;
        List <string> regionNames = InitializeRegionNamesList();

        DisplaySettings();

        // humidity levels /////////////////////////////////////

        if (serializableObject.humidityLevels.Count > 0)
        {
            for (int j = 0; j < serializableObject.humidityLevels.Count; j++)
            {
                DisplayHumidityLevel(serializableObject.humidityLevels[j], regionNames);
            }
        }
        else
        {
            EditorGUILayout.LabelField("There is no humidity levels in list!");
        }

        if (serializableObject.humidityLevels.Count < maxHDCount)
        {
            GUILayout.Space(15);
            if (GUILayout.Button("Add humidity level", GUILayout.Height(30)))
            {
                serializableObject.humidityLevels.Add(new HumidityData(serializableObject.humidityLevels.Count));
            }
        }

        GUILayout.Space(50);
        // Regions /////////////////////////////////////////////

        if (regionCount > 0)
        {
            for (int i = 0; i < regionCount; i++)
            {
                DisplayRegion(serializableObject.regions[i], i);
            }
        }
        else
        {
            EditorGUILayout.LabelField("There is no regions in list!");
        }

        if (regionCount < maxRegionCount)
        {
            GUILayout.Space(15);
            if (GUILayout.Button("Add region", GUILayout.Height(30)))
            {
                serializableObject.regions.Add(new RegionData());
            }
        }

        GUILayout.Space(50);

        if (GUI.changed)
        {
            if (autoUpdateShader)
            {
                serializableObject.UpdateAndApplyShaderData();
            }
            EditorUtility.SetDirty(serializableObject);
            EditorSceneManager.MarkSceneDirty(serializableObject.gameObject.scene);
        }
    }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            MapStyle mapStyle = serializedObject.targetObject as MapStyle;

            if (mapStyle == null)
            {
                // ????
                return;
            }

            GUILayout.Label("Editing options", labelBoldStyle);

            var liveUpdateProperty = serializedObject.FindProperty("liveUpdateEnabled");

            EditorGUILayout.PropertyField(liveUpdateProperty, new GUIContent {
                text = "Update RegionMap while editing"
            });

            GUILayout.Space(EditorGUIUtility.singleLineHeight);

            GUILayout.Label("Layers", labelBoldStyle);

            layerTreeView.Layers = mapStyle.Layers;
            layerTreeView.Reload();
            layerTreeView.OnGUI(GUILayoutUtility.GetRect(0, 500, 0, 150));

            var selectedLayers = layerTreeView.GetSelection();

            var layerArrayProperty = serializedObject.FindProperty("Layers");

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add Layer"))
            {
                mapStyle.Layers.Add(new FeatureLayer("untitled"));
            }
            if (GUILayout.Button("Remove Selected"))
            {
                foreach (var index in selectedLayers.OrderByDescending(i => i))
                {
                    layerArrayProperty.DeleteArrayElementAtIndex(index);
                }
                selectedLayers = new int[0];
                layerTreeView.SetSelection(selectedLayers);
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(EditorGUIUtility.singleLineHeight);

            if (selectedLayers.Count == 1)
            {
                var index = selectedLayers[0];

                var layerProperty = layerArrayProperty.GetArrayElementAtIndex(index);

                layerProperty.isExpanded = true;

                GUILayout.Label("Layer Properties", labelBoldStyle);

                var layer = mapStyle.Layers[index];

                layer.FeatureCollection = (FeatureLayer.MapzenFeatureCollection)EditorGUILayout.EnumFlagsField("Feature Collections", layer.FeatureCollection);

                DrawSelectedLayer(layerProperty);
            }
            else
            {
                GUILayout.Label("Select a layer to see properties", labelItalicCenteredStyle);
            }

            serializedObject.ApplyModifiedProperties();

            if (liveUpdateProperty.boolValue)
            {
                // Find the regionMap containing the style mapStyle
                var       regionMaps = GameObject.FindObjectsOfType <RegionMap>();
                RegionMap map        = null;
                foreach (var regionMap in regionMaps)
                {
                    if (regionMap.Style == mapStyle)
                    {
                        map = regionMap;
                        break;
                    }
                }

                if (map != null)
                {
                    if (GUI.changed)
                    {
                        map.LogWarnings();
                        if (map.IsValid())
                        {
                            map.DownloadTilesAsync();
                        }
                        else
                        {
                            map.LogErrors();
                        }
                    }

                    if (map.HasPendingTasks())
                    {
                        Repaint();
                        if (map.FinishedRunningTasks())
                        {
                            map.GenerateSceneGraph();
                        }
                    }
                }
            }
        }
Example #16
0
    public ShaderData(Material material, int mapWidth, int mapHeight, int chunkWidth, int chunkHeight, Texture2D humidityMap, RegionMap regionMap)
    {
        this.mapWidth    = mapWidth;
        this.mapHeight   = mapHeight;
        this.chunkWidth  = chunkWidth;
        this.chunkHeight = chunkHeight;
        this.material    = material;
        this.humidityMap = humidityMap;
        useTextures      = regionMap.useTextures;

        SetRegionMapValues(regionMap);
    }
 private void OnEnable()
 {
     this.map = (RegionMap)target;
 }
Example #18
0
    public void CopyFromRemote(RegionMap remoteMap, WorldMap mainMap)
    {
        if (remoteMap == null)
        {
            Debug.Log("Didn't get world map!");
            return;
        }
        width = 17;
        height = 17;
        worldNameEnglish = remoteMap.name_english;
        regionOrigin = new DFCoord(remoteMap.map_x * 16, remoteMap.map_y * 16, 0);
        InitArrays();
        for (int x = 0; x < width; x++)
            for (int y = 0; y < height; y++)
            {
                int index = y * width + x;
                tiles[x, y] = new RegionTile(remoteMap.tiles[index]);
            }

        if (ContentLoader.Instance != null)
            GenerateMesh();
    }
Example #19
0
 private void OnEnable()
 {
     Debug.Log("This is from MapBuilder");
     this.map = (RegionMap)target;
 }
Example #20
0
        /// <summary>
        /// Retrieves the item with the specified ID from the cache, or, if no
        /// matching item is present, adds the specified value to the cache and
        /// returns it.
        /// </summary>
        /// <typeparam name="T">
        /// The type of item to add to or retrieve from the cache.
        /// </typeparam>
        /// <param name="id">
        /// The ID of the item to add or retrieve.
        /// </param>
        /// <param name="valueFactory">
        /// The <see cref="Func{TOutput}" /> which will generate the value to be
        /// added if a matching item cannot be found in the cache.
        /// </param>
        /// <returns>
        /// The item of the desired type and with the specified key, if a matching
        /// item is contained in the cache.  Otherwise, the result of executing
        /// <paramref name="valueFactory" />.
        /// </returns>
        public T GetOrAdd <T>(IConvertible id, Func <T> valueFactory) where T : IEveCacheable
        {
            Contract.Requires(id != null, Resources.Messages.EveCache_IdCannotBeNull);
            Contract.Requires(valueFactory != null, Resources.Messages.EveCache_ValueFactoryCannotBeNull);
            Contract.Ensures(Contract.Result <T>() != null);

            string region = RegionMap.GetRegion(typeof(T));
            string key    = EveCache.CreateCacheKey(region, id);

            this.EnterReadLock(region);

            try
            {
                object result;

                if (this.InnerTryGetValue(key, out result))
                {
                    return((T)result);
                }
            }
            finally
            {
                this.ExitReadLock(region);
            }

            // Otherwise, get our value to be added.  Do this outside of a lock in
            // case valueFactory() itself wants to read from or add something to the
            // cache.
            T value = valueFactory();

            Contract.Assume(value != null);

            // Check to make sure the value being added actually has the same key as
            // the value we were passed -- otherwise the cache could be put into an
            // inconsistent state.
            string verifyKey = EveCache.CreateCacheKey(region, value.CacheKey);

            if (!object.Equals(key, verifyKey))
            {
                throw new InvalidOperationException("The key of the item being added to the cache must be the same as the key being requested.");
            }

            // Write to the cache
            this.EnterWriteLock(region);

            try
            {
                object result;

                if (this.InnerTryGetValue(key, out result))
                {
                    return((T)result);
                }

                this.Statistics.Misses++;
                this.InnerSet(key, value, false);
                return(value);
            }
            finally
            {
                this.ExitWriteLock(region);
            }
        }
Example #21
0
 private void Reset()
 {
     m_header = null;
     m_sections = null;
     m_clrHeader = null;
 }