Esempio n. 1
0
            public void Update(Cache <string, List <Actor> > buildings)
            {
                var nowHasPrerequisites = true;

                foreach (var p in prerequisites)
                {
                    if (!buildings.Keys.Contains(p))
                    {
                        nowHasPrerequisites = false;
                        break;
                    }
                }

                if (nowHasPrerequisites && !hasPrerequisites)
                {
                    watcher.PrerequisitesAvailable(key);
                }

                if (!nowHasPrerequisites && hasPrerequisites)
                {
                    watcher.PrerequisitesUnavailable(key);
                }

                hasPrerequisites = nowHasPrerequisites;
            }
Esempio n. 2
0
            public void Update(Cache<string, List<Actor>> ownedPrerequisites)
            {
                var hasReachedLimit = limit > 0 && ownedPrerequisites.ContainsKey(Key) && ownedPrerequisites[Key].Count >= limit;

                // The '!' annotation inverts prerequisites: "I'm buildable if this prerequisite *isn't* met"
                var nowHasPrerequisites = HasPrerequisites(ownedPrerequisites) && !hasReachedLimit;
                var nowHidden = IsHidden(ownedPrerequisites);

                if (initialized == false)
                {
                    initialized = true;
                    hasPrerequisites = !nowHasPrerequisites;
                    hidden = !nowHidden;
                }

                // Hide the item from the UI if a prereq annotated with '~' is not met.
                if (nowHidden && !hidden)
                    watcher.PrerequisitesItemHidden(Key);

                if (!nowHidden && hidden)
                    watcher.PrerequisitesItemVisible(Key);

                if (nowHasPrerequisites && !hasPrerequisites)
                    watcher.PrerequisitesAvailable(Key);

                if (!nowHasPrerequisites && hasPrerequisites)
                    watcher.PrerequisitesUnavailable(Key);

                hidden = nowHidden;
                hasPrerequisites = nowHasPrerequisites;
            }
Esempio n. 3
0
            public void Update(Cache <string, List <Actor> > buildings)
            {
                var nowHasPrerequisites = HasPrerequisites(buildings);

                if (nowHasPrerequisites && !hasPrerequisites)
                {
                    watcher.PrerequisitesAvailable(key);
                }

                if (!nowHasPrerequisites && hasPrerequisites)
                {
                    watcher.PrerequisitesUnavailable(key);
                }

                hasPrerequisites = nowHasPrerequisites;
            }
Esempio n. 4
0
            public void Update(Cache <string, List <Actor> > buildables)
            {
                var hasReachedBuildLimit = buildLimit > 0 && buildables[Key].Count >= buildLimit;
                var nowHasPrerequisites  = HasPrerequisites(buildables) && !hasReachedBuildLimit;

                if (nowHasPrerequisites && !hasPrerequisites)
                {
                    watcher.PrerequisitesAvailable(Key);
                }

                if (!nowHasPrerequisites && hasPrerequisites)
                {
                    watcher.PrerequisitesUnavailable(Key);
                }

                hasPrerequisites = nowHasPrerequisites;
            }
Esempio n. 5
0
            public void Update(Cache <string, List <Actor> > ownedPrerequisites)
            {
                var hasReachedLimit = limit > 0 && ownedPrerequisites.ContainsKey(Key) && ownedPrerequisites[Key].Count >= limit;

                var nowHasPrerequisites = HasPrerequisites(ownedPrerequisites) && !hasReachedLimit;
                var nowHidden           = IsHidden(ownedPrerequisites);

                if (!initialized)
                {
                    initialized      = true;
                    hasPrerequisites = !nowHasPrerequisites;
                    hidden           = !nowHidden;
                }

                // Hide the item from the UI if a prereq annotated with '~' is not met.
                if (nowHidden && !hidden)
                {
                    watcher.PrerequisitesItemHidden(Key);
                }

                if (!nowHidden && hidden)
                {
                    watcher.PrerequisitesItemVisible(Key);
                }

                if (nowHasPrerequisites && !hasPrerequisites)
                {
                    watcher.PrerequisitesAvailable(Key);
                }

                if (!nowHasPrerequisites && hasPrerequisites)
                {
                    watcher.PrerequisitesUnavailable(Key);
                }

                hidden           = nowHidden;
                hasPrerequisites = nowHasPrerequisites;
            }