示例#1
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="codex">Provides subject entries for target values.</param>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="farmer">The lookup target.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 /// <param name="isLoadMenu">Whether this is being displayed on the load menu, before the save data is fully initialized.</param>
 public FarmerSubject(SubjectFactory codex, GameHelper gameHelper, SFarmer farmer, ITranslationHelper translations, bool isLoadMenu = false)
     : base(codex, gameHelper, farmer.Name, null, L10n.Types.Player(), translations)
 {
     this.Target      = farmer;
     this.IsLoadMenu  = isLoadMenu;
     this.RawSaveData = isLoadMenu
         ? new Lazy <XElement>(() => this.ReadSaveFile(farmer.slotName))
         : null;
 }
示例#2
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="codex">Provides subject entries for target values.</param>
        /// <param name="showLookup">Show a lookup menu.</param>
        public SearchMenu(SubjectFactory codex, Action <ISubject> showLookup)
        {
            // save data
            this.ShowLookup   = showLookup;
            this.SearchLookup = codex.GetSearchSubjects().ToLookup(p => p.Name, StringComparer.InvariantCultureIgnoreCase);

            // initialise
            this.CalculateDimensions();
            this.SearchTextbox = new SearchTextBox(Game1.smallFont, Color.Black);
            this.SearchTextbox.Select();
            this.SearchTextbox.OnChanged += (sender, text) => this.ReceiveSearchTextboxChanged(text);
        }
示例#3
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="codex">Provides subject entries for target values.</param>
        /// <param name="showLookup">Show a lookup menu.</param>
        /// <param name="monitor">Encapsulates logging and monitoring.</param>
        public SearchMenu(SubjectFactory codex, Action <ISubject> showLookup, IMonitor monitor)
        {
            // save data
            this.ShowLookup   = showLookup;
            this.Monitor      = monitor;
            this.SearchLookup = codex.GetSearchSubjects().ToLookup(p => p.Name, StringComparer.OrdinalIgnoreCase);

            // initialise
            this.UpdateLayout();
            this.SearchTextbox = new SearchTextBox(Game1.smallFont, Color.Black);
            this.SearchTextbox.Select();
            this.SearchTextbox.OnChanged += (sender, text) => this.ReceiveSearchTextboxChanged(text);
        }
示例#4
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="codex">Provides subject entries for target values.</param>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</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="item">The underlying target.</param>
 /// <param name="context">The context of the object being looked up.</param>
 /// <param name="knownQuality">Whether the item quality is known. This is <c>true</c> for an inventory item, <c>false</c> for a map object.</param>
 /// <param name="fromCrop">The crop associated with the item (if applicable).</param>
 public ItemSubject(SubjectFactory codex, GameHelper gameHelper, ITranslationHelper translations, bool progressionMode, bool highlightUnrevealedGiftTastes, Item item, ObjectContext context, bool knownQuality, Crop fromCrop = null)
     : base(codex, gameHelper, translations)
 {
     this.ProgressionMode = progressionMode;
     this.HighlightUnrevealedGiftTastes = highlightUnrevealedGiftTastes;
     this.Target      = item;
     this.DisplayItem = this.GetMenuItem(item);
     this.FromCrop    = fromCrop;
     if ((item as SObject)?.Type == "Seeds" && fromCrop == null) // fromCrop == null to exclude planted coffee beans
     {
         this.SeedForCrop = new Crop(item.ParentSheetIndex, 0, 0);
     }
     this.Context      = context;
     this.KnownQuality = knownQuality;
     this.Initialize(this.DisplayItem.DisplayName, this.GetDescription(this.DisplayItem), this.GetTypeValue(this.DisplayItem));
 }
示例#5
0
 protected override void ToolUpdate()
 {
     //テキストフィールドの設定
     subjectName_ = GUILayout.TextField(subjectName_);
     if (GUILayout.Button("作成"))
     {
         List <string> local_string = SubjectFactory.Script(subjectName_);
         StreamWriter  textfile     = new StreamWriter("Assets/Chiga/Scripts/School/" + subjectName_ + ".cs", false);// TextData.txtというファイルを新規で用意
         foreach (var for_name in local_string)
         {
             textfile.WriteLine(for_name); // ファイルに書き出したあと改行
         }
         textfile.Flush();                 // StreamWriterのバッファに書き出し残しがないか確認
         textfile.Close();                 // ファイルを閉じる
     }
 }
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="codex">Provides subject entries for target values.</param>
        /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
        /// <param name="building">The lookup target.</param>
        /// <param name="sourceRectangle">The building's source rectangle in its spritesheet.</param>
        /// <param name="translations">Provides translations stored in the mod folder.</param>
        public BuildingSubject(SubjectFactory codex, GameHelper gameHelper, Building building, Rectangle sourceRectangle, ITranslationHelper translations)
            : base(codex, gameHelper, building.buildingType.Value, null, L10n.Types.Building(), translations)
        {
            // init
            this.Target          = building;
            this.SourceRectangle = sourceRectangle;

            // get name/description from blueprint if available
            try
            {
                BluePrint blueprint = new BluePrint(building.buildingType.Value);
                this.Name        = blueprint.displayName;
                this.Description = blueprint.description;
            }
            catch (ContentLoadException)
            {
                // use default values
            }
        }
示例#7
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="codex">Provides subject entries for target values.</param>
        /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
        /// <param name="bush">The lookup target.</param>
        /// <param name="translations">Provides translations stored in the mod folder.</param>
        /// <param name="reflection">Simplifies access to private game code.</param>
        public BushSubject(SubjectFactory codex, GameHelper gameHelper, Bush bush, ITranslationHelper translations, IReflectionHelper reflection)
            : base(codex, gameHelper, translations)
        {
            this.Target     = bush;
            this.Reflection = reflection;

            if (this.IsBerryBush(bush))
            {
                this.Initialize(L10n.Bush.BerryName(), L10n.Bush.BerryDescription(), L10n.Types.Bush());
            }
            else if (this.IsTeaBush(bush))
            {
                this.Initialize(L10n.Bush.TeaName(), L10n.Bush.TeaDescription(), L10n.Types.Bush());
            }
            else
            {
                this.Initialize(L10n.Bush.PlainName(), L10n.Bush.PlainDescription(), L10n.Types.Bush());
            }
        }
示例#8
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="codex">Provides subject entries for target values.</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="translations">Provides translations stored in the mod folder.</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(SubjectFactory codex, GameHelper gameHelper, NPC npc, SubjectType type, Metadata metadata, ITranslationHelper translations, IReflectionHelper reflectionHelper, bool progressionMode, bool highlightUnrevealedGiftTastes)
            : base(codex, gameHelper, translations)
        {
            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 ? translations.Get(overrides.DescriptionKey) : null,
                type: CharacterSubject.GetTypeName(npc, type)
                );
            this.IsHauntedSkull = npc is Bat && this.Reflection.GetField <NetBool>(npc, "hauntedSkull").GetValue().Value;
        }
示例#9
0
        /*********
        ** Private methods
        *********/
        /****
        ** Event handlers
        ****/
        /// <summary>The method invoked on the first update tick, once all mods are initialized.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            if (!this.IsDataValid)
            {
                return;
            }

            // get mod APIs
            JsonAssetsIntegration jsonAssets = new JsonAssetsIntegration(this.Helper.ModRegistry, this.Monitor);

            // initialize functionality
            var customFarming     = new CustomFarmingReduxIntegration(this.Helper.ModRegistry, this.Monitor);
            var producerFramework = new ProducerFrameworkModIntegration(this.Helper.ModRegistry, this.Monitor);

            this.GameHelper     = new GameHelper(customFarming, producerFramework, this.Metadata);
            this.SubjectFactory = new SubjectFactory(this.Metadata, this.Helper.Translation, this.Helper.Reflection, this.GameHelper, this.Config);
            this.TargetFactory  = new TargetFactory(this.Helper.Reflection, this.GameHelper, jsonAssets, this.SubjectFactory);
            this.DebugInterface = new DebugInterface(this.GameHelper, this.TargetFactory, this.Config, this.Monitor);
        }
示例#10
0
        public void Create_ValidName_NewSubject()
        {
            // Arrange
            var factory       = new SubjectFactory();
            var personOneName = this.Faker.Name.FullName();
            var personTwoName = this.Faker.Name.FullName();

            // Act
            var personOne = factory.Create(personOneName);
            var personTwo = factory.Create(personTwoName);

            // Assert
            personOne.Should().NotBeNull();
            personOne.Id.Should().BeGreaterThan(0);
            personOne.Name.Should().NotBeNullOrWhiteSpace().And.Be(personOneName);

            personTwo.Should().NotBeNull();
            personTwo.Id.Should().BeGreaterThan(1);
            personTwo.Name.Should().NotBeNullOrWhiteSpace().And.Be(personTwoName);
        }
        protected virtual async ValueTask <ClaimsIdentity> CreateOutgoingSubjectAsync(WsTrustRequest request, Scope scope, CancellationToken cancellationToken)
        {
            var subject = await SubjectFactory.CreateOutgoingSubjectAsync(scope.Subject, scope.RelyingParty, request.TokenType);

            return(subject);
        }
示例#12
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="codex">Provides subject entries for target values.</param>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 /// <param name="item">The underlying target.</param>
 public MovieSnackSubject(SubjectFactory codex, GameHelper gameHelper, ITranslationHelper translations, MovieConcession item)
     : base(codex, gameHelper, translations)
 {
     this.Target = item;
     this.Initialize(item.DisplayName, item.getDescription(), L10n.Types.Other());
 }
示例#13
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="codex">Provides subject entries for target values.</param>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="tree">The lookup target.</param>
 /// <param name="tile">The tree's tile position.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 public FruitTreeSubject(SubjectFactory codex, GameHelper gameHelper, FruitTree tree, Vector2 tile, ITranslationHelper translations)
     : base(codex, gameHelper, L10n.FruitTree.Name(fruitName: gameHelper.GetObjectBySpriteIndex(tree.indexOfFruit.Value).DisplayName), null, L10n.Types.FruitTree(), translations)
 {
     this.Target = tree;
     this.Tile   = tile;
 }
示例#14
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="codex">Provides subject entries for target values.</param>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="location">The game location.</param>
 /// <param name="position">The tile position.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 public TileSubject(SubjectFactory codex, GameHelper gameHelper, GameLocation location, Vector2 position, ITranslationHelper translations)
     : base(codex, gameHelper, $"({position.X}, {position.Y})", L10n.Tile.Description(), L10n.Types.Tile(), translations)
 {
     this.Location = location;
     this.Position = position;
 }
示例#15
0
 /// <summary>Construct an instance.</summary>
 /// <param name="codex">Provides subject entries for target values.</param>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="name">The display name.</param>
 /// <param name="description">The object description (if applicable).</param>
 /// <param name="type">The object type.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 protected BaseSubject(SubjectFactory codex, GameHelper gameHelper, string name, string description, string type, ITranslationHelper translations)
     : this(codex, gameHelper, translations)
 {
     this.Initialize(name, description, type);
 }
示例#16
0
 /*********
 ** Protected methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="codex">Provides subject entries for target values.</param>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 protected BaseSubject(SubjectFactory codex, GameHelper gameHelper, ITranslationHelper translations)
 {
     this.Codex      = codex;
     this.GameHelper = gameHelper;
     this.Text       = translations;
 }
示例#17
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="codex">Provides subject entries for target values.</param>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="tree">The lookup target.</param>
 /// <param name="tile">The tree's tile position.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 public TreeSubject(SubjectFactory codex, GameHelper gameHelper, Tree tree, Vector2 tile, ITranslationHelper translations)
     : base(codex, gameHelper, TreeSubject.GetName(tree), null, L10n.Types.Tree(), translations)
 {
     this.Target = tree;
     this.Tile   = tile;
 }
示例#18
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="codex">Provides subject entries for target values.</param>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="animal">The lookup target.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 /// <remarks>Reverse engineered from <see cref="FarmAnimal"/>.</remarks>
 public FarmAnimalSubject(SubjectFactory codex, GameHelper gameHelper, FarmAnimal animal, ITranslationHelper translations)
     : base(codex, gameHelper, animal.displayName, null, animal.type.Value, translations)
 {
     this.Target = animal;
 }