Exemplo n.º 1
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="codex">Provides subject entries.</param>
        /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
        /// <param name="npc">The lookup target.</param>
        /// <param name="type">The NPC type.</param>
        /// <param name="metadata">Provides metadata that's not available from the game data directly.</param>
        /// <param name="reflectionHelper">Simplifies access to private game code.</param>
        /// <param name="progressionMode">Whether to only show content once the player discovers it.</param>
        /// <param name="highlightUnrevealedGiftTastes">Whether to highlight item gift tastes which haven't been revealed in the NPC profile.</param>
        /// <param name="enableTargetRedirection">Whether to look up the original entity when the game spawns a temporary copy.</param>
        /// <remarks>Reverse engineered from <see cref="NPC"/>.</remarks>
        public CharacterSubject(ISubjectRegistry codex, GameHelper gameHelper, NPC npc, SubjectType type, Metadata metadata, IReflectionHelper reflectionHelper, bool progressionMode, bool highlightUnrevealedGiftTastes, bool enableTargetRedirection)
            : base(gameHelper)
        {
            this.Codex           = codex;
            this.Reflection      = reflectionHelper;
            this.ProgressionMode = progressionMode;
            this.HighlightUnrevealedGiftTastes = highlightUnrevealedGiftTastes;
            this.EnableTargetRedirection       = enableTargetRedirection;

            // initialize
            this.Target     = npc;
            this.TargetType = type;
            CharacterData overrides = metadata.GetCharacter(npc, type);

            this.Initialize(
                name: npc.getName(),
                description: overrides?.DescriptionKey != null ? I18n.GetByKey(overrides.DescriptionKey) : null,
                type: CharacterSubject.GetTypeName(npc, type)
                );

            // detect special cases
            if (npc is Bat bat)
            {
                this.IsHauntedSkull = bat.hauntedSkull.Value;
                this.IsMagmaSprite  = bat.magmaSprite.Value;
            }
            else
            {
                this.IsGourmand = type == SubjectType.Villager && npc.Name == "Gourmand" && npc.currentLocation.Name == nameof(IslandFarmCave);
            }
        }
Exemplo n.º 2
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
        /// <param name="npc">The lookup target.</param>
        /// <param name="type">The NPC type.</param>
        /// <param name="metadata">Provides metadata that's not available from the game data directly.</param>
        /// <param name="reflectionHelper">Simplifies access to private game code.</param>
        /// <param name="progressionMode">Whether to only show content once the player discovers it.</param>
        /// <param name="highlightUnrevealedGiftTastes">Whether to highlight item gift tastes which haven't been revealed in the NPC profile.</param>
        /// <remarks>Reverse engineered from <see cref="NPC"/>.</remarks>
        public CharacterSubject(GameHelper gameHelper, NPC npc, SubjectType type, Metadata metadata, IReflectionHelper reflectionHelper, bool progressionMode, bool highlightUnrevealedGiftTastes)
            : base(gameHelper)
        {
            this.Reflection      = reflectionHelper;
            this.ProgressionMode = progressionMode;
            this.HighlightUnrevealedGiftTastes = highlightUnrevealedGiftTastes;

            // initialize
            this.Target     = npc;
            this.TargetType = type;
            CharacterData overrides = metadata.GetCharacter(npc, type);

            this.Initialize(
                name: npc.getName(),
                description: overrides?.DescriptionKey != null ? I18n.GetByKey(overrides.DescriptionKey) : null,
                type: CharacterSubject.GetTypeName(npc, type)
                );
            this.IsHauntedSkull = npc is Bat && this.Reflection.GetField <NetBool>(npc, "hauntedSkull").GetValue().Value;
        }