House.House.UpdateCoordsForPlayer C# (CSharp) Méthode

UpdateCoordsForPlayer() public méthode

public UpdateCoordsForPlayer ( string PlayerName, int x, int y, int houseIndex ) : void
PlayerName string
x int
y int
houseIndex int
Résultat void
        public void UpdateCoordsForPlayer(string PlayerName, int x, int y, int houseIndex = 0)
        {
            Player player = Server.GetPlayerByName(PlayerName);
            bool starthouse = player.PluginData.ContainsKey("starthouse") ? (bool)player.PluginData["starthouse"] : false;
            bool endhouse = player.PluginData.ContainsKey("endhouse") ? (bool)player.PluginData["endhouse"] : false;

            CreatePlayerHouse(PlayerName);

            int playerIndex = GetPlayerHouseIndex(PlayerName);

            PlayerHouseCoords tempCoords;

            if (playerHouses[playerIndex].Houses.Count == houseIndex)
            {
                if (!tempHouses.ContainsKey(player.Name))
                {
                    tempHouses[player.Name] = new PlayerHouseCoords((string)player.PluginData["houseName"]);
                }

                tempCoords = (PlayerHouseCoords)tempHouses[player.Name];

                if (tempCoords.HouseName != (string)player.PluginData["houseName"])
                {
                    tempHouses[player.Name] = new PlayerHouseCoords((string)player.PluginData["houseName"]);
                    tempCoords = (PlayerHouseCoords)tempHouses[player.Name];
                }

                if (starthouse)
                {
                    tempCoords.TopLeft.X = x;
                    tempCoords.TopLeft.Y = y;
                }
                else if (endhouse)
                {
                    tempCoords.BottomRight.X = x;
                    tempCoords.BottomRight.Y = y;
                }

                if (tempCoords.TopLeft.X != 0 && tempCoords.TopLeft.Y != 0 &&
                    tempCoords.BottomRight.X != 0 && tempCoords.BottomRight.Y != 0)
                {
                    playerHouses[playerIndex].Houses.Add(tempCoords);
                    tempHouses.Remove(player.Name);
                    validateHouse(PlayerName, houseIndex);
                }

                else
                {
                    tempHouses[player.Name] = tempCoords;
                }
            }
            else
            {
                tempCoords = playerHouses[playerIndex].Houses[houseIndex];
                if (starthouse)
                {
                    tempCoords.TopLeft.X = x;
                    tempCoords.TopLeft.Y = y;
                    playerHouses[playerIndex].Houses[houseIndex] = tempCoords;
                }
                else if (endhouse)
                {
                    tempCoords.BottomRight.X = x;
                    tempCoords.BottomRight.Y = y;
                    playerHouses[playerIndex].Houses[houseIndex] = tempCoords;
                }

                validateHouse(PlayerName, houseIndex);
            }
        }