Exemple #1
0
 private void ResourcePackageStartedMoving(ResourcePackage providedResourcePackage)
 {
     ProvidedResourceList.Remove(providedResourcePackage);
     if (ProvidedResourceList.Count == 0)
     {
         AllProvisionsLeft?.Invoke(this);
     }
 }
Exemple #2
0
        public void UpdateProvisionPriority(ResourcePackage resourcePackage, RequestPriority priority)
        {
            var provisions = Provisions.ToArray();

            foreach (var provision in provisions)
            {
                if (provision == resourcePackage)
                {
                    Provisions.UpdatePriority(provision, priority);
                }
            }
        }
Exemple #3
0
        public void UpdateRequestPriority(ResourcePackage resourcePackage, RequestPriority priority)
        {
            var requests = Requests.ToArray();

            foreach (var request in requests)
            {
                if (request == resourcePackage)
                {
                    Requests.UpdatePriority(request, priority);
                }
            }
        }
Exemple #4
0
        public ResourcePackage RequestResource(Structure requestingStructure, ResourceType resourceType, RequestPriority priority)
        {
            var providedPackage = Provisions.Dequeue(resourceType, rp => HasPathFilter(rp.StartStructure, requestingStructure));

            if (providedPackage != null)
            {
                providedPackage.DestinationStructure = requestingStructure;
                providedPackage.SpecifyResourceType(resourceType);
                providedPackage.Move();
                return(providedPackage);
            }
            var resourcePackage = new ResourcePackage(resourceType, World.PathFinder, World.GameSettings.GameplaySettings)
            {
                DestinationStructure = requestingStructure
            };

            AddPackage(resourcePackage);
            Requests.Enqueue(resourcePackage, priority);
            return(resourcePackage);
        }
Exemple #5
0
 private void ResourcePackage_StartedMoving(ResourcePackage resourcePackage)
 {
     PackageStarted?.Invoke(this, resourcePackage);
 }
Exemple #6
0
 private void ResourcePackage_ArrivedAtDestination(ResourcePackage resourcePackage)
 {
     PackageArrived?.Invoke(this, resourcePackage);
     AllPackageList.Remove(resourcePackage);
 }
Exemple #7
0
 private void AddPackage(ResourcePackage resourcePackage)
 {
     AllPackageList.Add(resourcePackage);
     resourcePackage.StartedMoving        += ResourcePackage_StartedMoving;
     resourcePackage.ArrivedAtDestination += ResourcePackage_ArrivedAtDestination;
 }
Exemple #8
0
 public void ResourcePassesThrough(ResourcePackage resourcePackage)
 {
 }
Exemple #9
0
 public void ResourceArrived(ResourcePackage resourcePackage)
 {
     RequestedNetworkResourceList.Remove(resourcePackage);
     ArrivedResourceList.Add(resourcePackage.ResourceType);
     NewResourceAvailable();
 }
Exemple #10
0
 /// <summary>
 /// Get's called everytime a Resource passes the Node the Building is located at.
 /// </summary>
 /// <param name="resource">The Resource that passes through.</param>
 public virtual void OnResourcePassesThrough(ResourcePackage resource)
 {
     ResourceDirector.ResourcePassesThrough(resource);
 }
Exemple #11
0
 /// <summary>
 /// Get's called everytime a Resource arrives which destination was this Building.
 /// </summary>
 /// <param name="resource">The Resource that arrived.</param>
 public void OnResourceArrived(ResourcePackage resource)
 {
     ResourceDirector.ResourceArrived(resource);
 }