Example #1
0
        /// <summary>
        /// Create a subscriptionId that is unique per grainId, grainType, namespace combination.
        /// </summary>
        private Guid MakeSubscriptionGuid(GrainType grainType, InternalChannelId channelId)
        {
            // next 2 shorts inc guid are from namespace hash
            var namespaceHash     = JenkinsHash.ComputeHash(channelId.GetNamespace());
            var namespaceHashByes = BitConverter.GetBytes(namespaceHash);
            var s1 = BitConverter.ToInt16(namespaceHashByes, 0);
            var s2 = BitConverter.ToInt16(namespaceHashByes, 2);

            // Tailing 8 bytes of the guid are from the hash of the channelId Guid and a hash of the provider name.
            // get channelId guid hash code
            var channelIdGuidHash = JenkinsHash.ComputeHash(channelId.ChannelId.Key.Span);
            // get provider name hash code
            var providerHash = JenkinsHash.ComputeHash(channelId.ProviderName);

            // build guid tailing 8 bytes from grainIdHash and the hash of the provider name.
            var tail = new List <byte>();

            tail.AddRange(BitConverter.GetBytes(channelIdGuidHash));
            tail.AddRange(BitConverter.GetBytes(providerHash));

            // make guid.
            // - First int is grain type
            // - Two shorts from namespace hash
            // - 8 byte tail from channelId Guid and provider name hash.
            var id     = new Guid((int)JenkinsHash.ComputeHash(grainType.ToString()), s1, s2, tail.ToArray());
            var result = MarkSubscriptionGuid(id, isImplicitSubscription: true);

            return(result);
        }
Example #2
0
    //===================================================================
    public void BuildGrain(string projectFolderPath, string pdfFolderName, bool useVolumeProportion)
    {
        string pdfFileName   = projectFolderPath + "/" + pdfFolderName + "/" + PDF + ".txt";
        string grainFileName = "Grains/" + Type.ToString();

        distribution = new Distribution(pdfFileName, useVolumeProportion, PDFMultiplier, PDFOffset);
        grain        = Resources.Load <GameObject>(grainFileName);
        grain.transform.localScale = new Vector3(1, 1, 1);
        if (Type == GrainType.Sphere)
        {
            if (scale == new Vector3(1, 1, 1))
            {
                grain.GetComponent <SphereCollider>().enabled = true;
                grain.GetComponent <MeshCollider>().enabled   = false;
            }
            else
            {
                grain.GetComponent <SphereCollider>().enabled = false;
                grain.GetComponent <MeshCollider>().enabled   = true;
            }
        }
        volume           = GetVolume();
        grainObject      = new GameObject();
        grainObject.name = "Grain " + (grainGroupNumber + 1) + " - " + grainName;
    }
Example #3
0
        /// <summary>
        /// Create a subscriptionId that is unique per grainId, grainType, namespace combination.
        /// </summary>
        private Guid MakeSubscriptionGuid(GrainType grainType, InternalStreamId streamId)
        {
            // next 2 shorts inc guid are from namespace hash
            uint namespaceHash = JenkinsHash.ComputeHash(streamId.GetNamespace());

            byte[] namespaceHashByes = BitConverter.GetBytes(namespaceHash);
            short  s1 = BitConverter.ToInt16(namespaceHashByes, 0);
            short  s2 = BitConverter.ToInt16(namespaceHashByes, 2);

            // Tailing 8 bytes of the guid are from the hash of the streamId Guid and a hash of the provider name.
            // get streamId guid hash code
            uint streamIdGuidHash = JenkinsHash.ComputeHash(streamId.StreamId.Key.Span);
            // get provider name hash code
            uint providerHash = JenkinsHash.ComputeHash(streamId.ProviderName);

            // build guid tailing 8 bytes from grainIdHash and the hash of the provider name.
            var tail = new List <byte>();

            tail.AddRange(BitConverter.GetBytes(streamIdGuidHash));
            tail.AddRange(BitConverter.GetBytes(providerHash));

            // make guid.
            // - First int is grain type
            // - Two shorts from namespace hash
            // - 8 byte tail from streamId Guid and provider name hash.
            var id     = new Guid((int)JenkinsHash.ComputeHash(grainType.ToString()), s1, s2, tail.ToArray());
            var result = SubscriptionMarker.MarkAsImplictSubscriptionId(id);

            return(result);
        }