Beispiel #1
0
        /// <summary>
        /// Get a managed resource handle, from a handle which was saved off independently. The handle may or may not have the same origin index,
        ///     but will have sufficient size
        /// </summary>
        /// <param name="savedHandle"></param>
        /// <returns>a different global handle instance, properly linked</returns>
        public LSystemGlobalResourceHandle GetManagedResourceHandleFromSavedData(LSystemGlobalResourceHandle savedHandle, LSystemBehavior assocatedBehavior)
        {
            var matchingHandle = allResourceReservations
                                 .Where(x => x.uniqueIdOriginPoint == savedHandle.uniqueIdOriginPoint && x.uniqueIdReservationSize == savedHandle.uniqueIdReservationSize)
                                 .FirstOrDefault();

            if (matchingHandle != null)
            {
                matchingHandle.InitializePostDeserialize(assocatedBehavior, this);
                return(matchingHandle);
            }
            return(this.AllocateResourceHandle(assocatedBehavior, savedHandle.requestedNextReservationSize));
        }
Beispiel #2
0
        public LSystemGlobalResourceHandle AllocateResourceHandle(LSystemBehavior associatedBehavior, uint initialReservationSize)
        {
            var  lastReservation = allResourceReservations.LastOrDefault();
            uint originPoint     = 1;
            uint globalPlantId   = 1;

            if (lastReservation != null)
            {
                originPoint   = lastReservation.uniqueIdOriginPoint + lastReservation.requestedNextReservationSize;
                globalPlantId = lastReservation.globalPlantId + 1;
            }
            var newHandle = new LSystemGlobalResourceHandle(
                originPoint,
                initialReservationSize,
                globalPlantId,
                this,
                associatedBehavior);

            allResourceReservations.Add(newHandle);

            return(newHandle);
        }