From 11025947fb2d97d8180e519679c4099e2e85d4a0 Mon Sep 17 00:00:00 2001 From: Date: Tue, 8 May 2018 21:34:32 -0700 Subject: [PATCH] added function to get all farmers except the current player. --- .../Framework/CustomMultiplayer.cs | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/GeneralMods/ModdedUtilitiesNetworking/Framework/CustomMultiplayer.cs b/GeneralMods/ModdedUtilitiesNetworking/Framework/CustomMultiplayer.cs index 2823e735..9f3fd085 100644 --- a/GeneralMods/ModdedUtilitiesNetworking/Framework/CustomMultiplayer.cs +++ b/GeneralMods/ModdedUtilitiesNetworking/Framework/CustomMultiplayer.cs @@ -229,31 +229,86 @@ namespace ModdedUtilitiesNetworking.Framework } + /// + /// Get's the server host farmer. + /// + /// public static Farmer getServerHost() { return Game1.serverHost.Value; } + /// + /// Get's the farmer in the player one slot also known as player 1. + /// + /// public static Farmer getPlayerOne() { return getServerHost(); } + /// + /// Get's the farmer in the player two slot for the server. + /// + /// public static Farmer getPlayerTwo() { return Game1.otherFarmers.ElementAt(0).Value; } + /// + /// Get's the farmer in the player three slot for the server. + /// + /// public static Farmer getPlayerThree() { return Game1.otherFarmers.ElementAt(1).Value; } + /// + /// Get's the farmer in the player four slot for the server. + /// + /// public static Farmer getPlayerFour() { return Game1.otherFarmers.ElementAt(2).Value; } + /// + /// Gets all farmers that are not the current player. + /// + /// + public static List getAllFarmersExceptThisOne() + { + Farmer player = Game1.player; + + Farmer player1 = getPlayerOne(); + Farmer player2 = getPlayerTwo(); + Farmer player3 = getPlayerThree(); + Farmer player4 = getPlayerFour(); + + List otherFarmers=new List(); + + if (player1 != null) + { + if (player != player1) otherFarmers.Add(player1); + } + if (player2 != null) + { + if (player != player2) otherFarmers.Add(player2); + } + if (player3 != null) + { + if (player != player3) otherFarmers.Add(player3); + } + if (player4 != null) + { + if (player != player4) otherFarmers.Add(player4); + } + return otherFarmers; + } + + } }