Beispiel #1
0
 /// <summary>
 /// Sends out the volcano data manager whenever a new player connects.
 /// </summary>
 /// <param name="sender">SMAPI.</param>
 /// <param name="e">Event args.</param>
 private void OnPlayerConnected(object?sender, PeerConnectedEventArgs e)
 {
     if (e.Peer.ScreenID == 0 && Context.IsWorldReady && Context.IsMainPlayer)
     {
         VolcanoChestAdjuster.BroadcastData(this.Helper.Multiplayer, new[] { e.Peer.PlayerID });
     }
 }
Beispiel #2
0
 private void BeforeSaving(object?sender, SavingEventArgs e)
 {
     if (Context.IsMainPlayer)
     {
         VolcanoChestAdjuster.SaveData(this.Helper.Data, this.Helper.Multiplayer);
     }
 }
Beispiel #3
0
    /**************
     * REGION MULTIPLAYER
     * ***********/

    private void OnModMessageRecieved(object?sender, ModMessageReceivedEventArgs e)
    {
        if (e.FromModID != ModEntry.UNIQUEID)
        {
            return;
        }
        VolcanoChestAdjuster.RecieveData(e);
    }
Beispiel #4
0
    /// <summary>
    /// Raised when save is loaded.
    /// </summary>
    /// <param name="sender">Unknown, used by SMAPI.</param>
    /// <param name="e">Parameters.</param>
    private void SaveLoaded(object?sender, SaveLoadedEventArgs e)
    {
        // This allows NPCs to say hi to the player. Yes, I'm that petty.
        Game1.player.displayName = Game1.player.Name;

        if (Context.IsSplitScreen && Context.ScreenId != 0)
        {
            return;
        }

        // Have to wait until here to populate locations
        Config.PrePopulateLocations();
        this.Helper.WriteConfig(Config);

        this.migrator = new(this.ModManifest, this.Helper, this.Monitor);
        this.migrator.ReadVersionInfo();

        this.Helper.Events.GameLoop.Saved += this.WriteMigrationData;

        if (GMCM?.HasGottenAPI == true)
        {
            GMCM.AddPageHere("Bombs", I18n.BombLocationDetailed)
            .AddParagraph(I18n.BombLocationDetailed_Description);

            foreach (GameLocation loc in Game1.locations)
            {
                GMCM.AddEnumOption(
                    name: () => loc.NameOrUniqueName,
                    getValue: () => Config.SafeLocationMap.TryGetValue(loc.NameOrUniqueName, out IsSafeLocationEnum val) ? val : IsSafeLocationEnum.Dynamic,
                    setValue: (value) => Config.SafeLocationMap[loc.NameOrUniqueName] = value);
            }
        }
        if (Context.IsMainPlayer)
        {
            VolcanoChestAdjuster.LoadData(this.Helper.Data, this.Helper.Multiplayer);

            // Make an attempt to clear all nulls from chests.
            Utility.ForAllLocations(action: (GameLocation loc) =>
            {
                foreach (SObject obj in loc.Objects.Values)
                {
                    if (obj is Chest chest)
                    {
                        chest.clearNulls();
                    }
                }
            });
        }
    }