Ejemplo n.º 1
0
        public static void Fullness(string command, string[] args)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }
            if (Context.IsMultiplayer)
            {
                if (Context.IsMainPlayer)
                {
                    if (args.Length > 0)
                    {
                        bool _player_check = false;
                        foreach (Farmer _farmer in Game1.getAllFarmers())
                        {
                            if (_farmer.displayName == args[0])
                            {
                                Data _data = ModEntry.instance.Helper.Data.ReadSaveData <Data>($"{_farmer.UniqueMultiplayerID}");
                                _data.actual_hunger = _data.max_hunger;
                                _data.actual_thirst = _data.max_thirst;
                                ModEntry.instance.Helper.Data.WriteSaveData($"{_farmer.UniqueMultiplayerID}", _data);

                                if (Context.IsMainPlayer)
                                {
                                    ModEntry.data.actual_hunger = _data.max_hunger;
                                    ModEntry.data.actual_thirst = _data.actual_thirst;
                                    BarsUpdate.CalculatePercentage();
                                }
                                else
                                {
                                    NetController.SyncSpecificPlayer(_farmer.UniqueMultiplayerID);
                                }

                                Debugger.Log($"Setting full status to the player {_farmer.displayName}.", "Info");
                                _player_check = true;
                                break;
                            }
                        }
                        if (!_player_check)
                        {
                            Debugger.Log(_error_player_not_found, "Error");
                        }
                    }
                    else
                    {
                        Debugger.Log($"{_error_command_wrong} 'help {command}'", "Error");
                    }
                }
                else
                {
                    Debugger.Log(_error_permission, "Error");
                }
            }
            else
            {
                ModEntry.data.actual_hunger = ModEntry.data.max_hunger;
                ModEntry.data.actual_thirst = ModEntry.data.max_thirst;
                Debugger.Log("Setting full status to the player.", "info");
            }
        }
Ejemplo n.º 2
0
        public static void Sync()
        {
            if (Context.IsMainPlayer)
            {
                if (Game1.IsMultiplayer)
                {
                    Debugger.Log($"Saving host data.", "Trace");
                }

                Data _data = Helper.Data.ReadSaveData <Data>($"{Game1.player.UniqueMultiplayerID}") ?? new Data();
                if (!firstLoad)
                {
                    ModEntry.data = _data;
                    firstLoad     = true;
                }
                Helper.Data.WriteSaveData($"{Game1.player.UniqueMultiplayerID}", ModEntry.data);

                BarsUpdate.CalculatePercentage();
            }
            else
            {
                Debugger.Log($"Sending important data to host.", "Trace");

                Helper.Multiplayer.SendMessage(
                    message: ModEntry.data,
                    messageType: "SaveDataToHost",
                    modIDs: new[] { Manifest.UniqueID },
                    playerIDs: new[] { Game1.MasterPlayer.UniqueMultiplayerID }
                    );
            }
        }
Ejemplo n.º 3
0
 private void OnTimeChanged(object sender, TimeChangedEventArgs e)
 {
     BarsUpdate.UpdateBarsInformation();
     BarsUpdate.CalculatePercentage();
     BarsWarnings.VerifyStatus();
     Penalty.VerifyPenalty();
     NetController.Sync();
 }
Ejemplo n.º 4
0
 private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
 {
     if (!NetController.firstLoad)
     {
         NetController.Sync();
     }
     Interaction.Awake();
     NetController.Sync();
     BarsPosition.SetBarsPosition();
     Interaction.ReceiveAwakeInfos();
     BarsUpdate.CalculatePercentage();
     BarsWarnings.VerifyStatus();
 }
Ejemplo n.º 5
0
        public static void OnMessageReceived(ModMessageReceivedEventArgs e)
        {
            if (!Context.IsMainPlayer && e.FromModID == Manifest.UniqueID && e.Type == "SaveDataFromHost")
            {
                ModEntry.data = e.ReadAs <Data>();
                BarsUpdate.CalculatePercentage();
                Debugger.Log("Received important data from host.", "Trace");
                BarsUpdate.CalculatePercentage();
            }

            if (Context.IsMainPlayer && e.FromModID == Manifest.UniqueID && e.Type == "SaveDataToHost")
            {
                Data _data = e.ReadAs <Data>();
                Debugger.Log($"Received important data from player {e.FromPlayerID}.", "Trace");
                Helper.Data.WriteSaveData($"{e.FromPlayerID}", _data);
            }
        }