Exemple #1
0
        public void Rename(int id, string name)
        {
            IHasResource res = this[id];

            res.Resource.Name = name;
            ResourceChanged?.Invoke(this, res);
        }
Exemple #2
0
 public void AddResource(ResourceDictionary resource)
 {
     ResourceChanged?.Invoke(this, new ResourcesChangedEventArgs()
     {
         NewResource = resource
     });
 }
Exemple #3
0
        /// <summary>
        /// <para>Creates and returns a new set of random data bytes.</para>
        /// <para>After this method returns, requests for the random data file
        /// should return the same bytes returned by this method.</para>
        /// </summary>
        /// <param name="newLength">The length of the new random data.</param>
        /// <returns>An array of bytes containing the new random data.</returns>
        /// <seealso cref="RandomDataUrlPath"/>
        /// <seealso cref="RandomDataLength"/>
        /// <seealso cref="GetRandomData"/>
        public byte[] ChangeRandomData(int newLength)
        {
            var data = CreateRandomData(newLength);

            _randomDataFile.SetData(data);
            ResourceChanged?.Invoke(RandomDataPath);
            return(data);
        }
Exemple #4
0
 public void AddResource(string path)
 {
     ResourceChanged?.Invoke(this, new ResourcesChangedEventArgs()
     {
         NewResource = new ResourceDictionary()
         {
             Source = new Uri(path)
         }
     });
 }
 public void NotifyChange(Resource resource, string propertyName)
 {
     if (ResourceChanged != null)
     {
         ResourceChangedEventArgs m = new ResourceChangedEventArgs(resource, propertyName);
         foreach (System.EventHandler <ResourceChangedEventArgs> e in ResourceChanged?.GetInvocationList())
         {
             Task.Run(() => e.Invoke(this, m));
         }
     }
 }
Exemple #6
0
        public bool Remove(int id)
        {
            if (!Resources.ContainsKey(id))
            {
                return(false);
            }

            Resources.Remove(id);
            ResourceChanged?.Invoke(this, null);
            return(true);
        }
 public void NotifyChange(Resource resource, string propertyName)
 {
     if (ResourceChanged != null)
     {
         ResourceChangedEventArgs m = new ResourceChangedEventArgs(resource, propertyName);
         foreach (System.EventHandler <ResourceChangedEventArgs> e in ResourceChanged?.GetInvocationList())
         {
             e.BeginInvoke(this, m, e.EndInvoke, null);
         }
     }
 }
Exemple #8
0
        public ushort Add(IHasResource res)
        {
            int id = NextResourceId;

            if (NextResourceId == 0 || NextResourceId > ushort.MaxValue)
            {
                throw new IndexOutOfRangeException($"Too many resources.");
            }

            res.Resource.ID = (ushort)id;
            Resources[id]   = res;

            ResourceChanged?.Invoke(this, res);
            return((ushort)id);
        }
Exemple #9
0
        public void AddResource(string path)
        {
            if (!File.Exists(path))
            {
                ToolbarLogger.GetLogger("EverythingToolbar").Error("Could not find resource file " + path);
                return;
            }

            ResourceChanged?.Invoke(this, new ResourcesChangedEventArgs()
            {
                NewResource = new ResourceDictionary()
                {
                    Source = new Uri(path)
                }
            });
        }
Exemple #10
0
        public void AddTrait(Trait item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            if (!traits.Contains(item))
            {
                traits.Add(item);
            }
            item.AttributeChanged += (sender, args) =>
            {
                AttributeChanged?.Invoke(this, args);
            };
            item.ResourceChanged += (sender, args) =>
            {
                ResourceChanged?.Invoke(this, args);
            };
            item.ValueChanged += (sender, args) =>
            {
                ValueChanged?.Invoke(this, args);
            };
            item.TaWChanged += (sender, args) =>
            {
                TaWChanged?.Invoke(this, args);
            };
            item.ATChanged += (sender, args) =>
            {
                ATChanged?.Invoke(this, args);
            };
            item.PAChanged += (sender, args) =>
            {
                PAChanged?.Invoke(this, args);
            };
            item.APInvestChanged += (sender, args) =>
            {
                APInvestChanged?.Invoke(this, GetAPInvested());
            };
            item.APEarnedChanged += (sender, args) =>
            {
                APEarnedChanged?.Invoke(this, GetAPEarned());
            };

            CallChangedAll(item);
        }
        public bool AddResource(string type, string name)
        {
            string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string path           = Path.Combine(assemblyFolder, type, name + ".xaml");

            if (!File.Exists(path))
            {
                ToolbarLogger.GetLogger("EverythingToolbar").Error("Could not find resource file " + path);
                return(false);
            }

            ResourceChanged?.Invoke(this, new ResourcesChangedEventArgs()
            {
                NewResource = new ResourceDictionary()
                {
                    Source = new Uri(path)
                }
            });
            return(true);
        }
        void OnResourceAmountChanged(ResourceChanged <ResourceType> type)
        {
            var currentInventory = inventoryForInspector.backingInventory.CloneSimulated();

            foreach (var pile in GetPiles())
            {
                var piledAmounts = new Dictionary <ResourceType, int>();

                float amountPiledSoFar = 0;
                foreach (var resource in pile.pileTypes)
                {
                    var consumeAttempt = currentInventory.Consume(resource, pile.capacity - amountPiledSoFar);
                    consumeAttempt.Execute();
                    amountPiledSoFar += consumeAttempt.info;

                    piledAmounts[resource] = (int)consumeAttempt.info;
                }
                pile.SetResourceNumbers(piledAmounts);
            }
        }
 private void OnResourceCapacityChanged(object sender, ResourceChanged<ResourceType> change)
 {
     resourceCapacityChanged.OnNext(change);
 }
 private void OnResourceAmountsChanged(object sender, ResourceChanged<ResourceType> change)
 {
     resourceAmountsChanged.OnNext(change);
 }
 protected virtual void OnResourceChanged(ResourceChangedEventArgs e)
 {
     ResourceChanged?.Invoke(this, e);
 }
Exemple #16
0
 public void ReduceResource(ResourceType type, float amount)
 {
     dictionary[type].Value -= amount;
     ResourceChanged?.Invoke(type, GetResource(type));
 }
 private void OnResourceChanged(ResourceChangedEventArgs args)
 {
     ResourceChanged?.Invoke(this, args);
 }
Exemple #18
0
 public void UpdateIron(float amount)
 {
     IronOre.Value += amount;
     ResourceChanged?.Invoke(ResourceType.IRON, IronOre.Value);
     ConsoleManger.Instance.DisplayNotification($"Aquired x{amount} Iron!");
 }
Exemple #19
0
 public void UpdateStone(float amount)
 {
     Stone.Value += amount;
     ResourceChanged?.Invoke(ResourceType.STONE, Stone.Value);
     ConsoleManger.Instance.DisplayNotification($"Aquired x{amount} Stone!");
 }
Exemple #20
0
 public void UpdateWood(float amount)
 {
     Wood.Value += amount;
     ResourceChanged?.Invoke(ResourceType.WOOD, Wood.Value);
     ConsoleManger.Instance.DisplayNotification($"Aquired x{amount} Wood!");
 }
Exemple #21
0
 private void Start()
 {
     ResourceChanged?.Invoke(ResourceType.WOOD, Wood.Value);
     ResourceChanged?.Invoke(ResourceType.STONE, Stone.Value);
     ResourceChanged?.Invoke(ResourceType.IRON, IronOre.Value);
 }
Exemple #22
0
 /// <summary>
 /// AResource classes must use this to indicate the resource has changed.
 /// </summary>
 /// <param name="sender">The resource (or sub-class) that has changed.</param>
 /// <param name="e">(Empty) event data object.</param>
 protected virtual void OnResourceChanged(object sender, EventArgs e)
 {
     dirty = true;
     //Console.WriteLine(this.GetType().Name + " dirtied.");
     ResourceChanged?.Invoke(sender, e);
 }
Exemple #23
0
 /// <summary>
 /// Appelé lorsque la valeur de le propriété <see cref="Resource"/> a changé.
 /// </summary>
 /// <param name="oldValue">L'ancienne valeur.</param>
 /// <param name="newValue">La nouvelle valeur.</param>
 protected virtual void OnResourceChanged(bool oldValue, bool newValue) =>
 ResourceChanged?.Invoke(this, new PropertyChangedEventArgs <bool>(oldValue, newValue));
Exemple #24
0
 public void NotifyChange(Resource resource, string propertyName)
 {
     ResourceChanged?.Invoke(this, new ResourceChangedEventArgs(resource, propertyName));
 }