Пример #1
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;
            }
Пример #2
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;
            }