public TestCaseMultiScreen() { Multiplayer multi = new Multiplayer(); AddStep(@"show", () => Add(multi)); AddWaitStep(5); AddStep(@"exit", multi.Exit); }
public static void PlayerDisconnected(this Multiplayer multiplayer, Farmer farmer) { PlayerDisconnectedEventArgs args = new PlayerDisconnectedEventArgs { Player = farmer }; OnPlayerDisconnected(null, args); }
public static Task <string> CreateRoomAsync(this Multiplayer multiplayer, string roomId, string roomType, bool visible, Dictionary <string, string> roomData) { var tcs = new TaskCompletionSource <string>(); multiplayer.CreateRoom(roomId, roomType, visible, roomData, tcs.SetResult, tcs.SetException); return(tcs.Task); }
public static Task <RoomInfo[]> ListRoomsAsync(this Multiplayer multiplayer, string roomType, Dictionary <string, string> searchCriteria, int resultLimit, int resultOffset) { var tcs = new TaskCompletionSource <RoomInfo[]>(); multiplayer.ListRooms(roomType, searchCriteria, resultLimit, resultOffset, tcs.SetResult, tcs.SetException); return(tcs.Task); }
public static Task <Connection> JoinRoomAsync(this Multiplayer multiplayer, string roomId, Dictionary <string, string> joinData) { var tcs = new TaskCompletionSource <Connection>(); multiplayer.JoinRoom(roomId, joinData, tcs.SetResult, tcs.SetException); return(tcs.Task); }
public static void DoLoadSelectedGame_Postfix() { if (Multiplayer.IsInMultiplayerMenu) { Log.Info($"Listening server on port {Config.Options.HostPort}"); Multiplayer.HostGame(new Server(Config.Options.HostPort, true)); } }
public override void Entry(IModHelper helper) { ModEntry.mod = this; ModEntry.multiplayer = helper.Reflection.GetField <Multiplayer>(typeof(Game1), "multiplayer").GetValue(); DeepWoodsSettings.Init(helper.Translation); Textures.LoadAll(); RegisterEvents(helper.Events); }
public override void process(Server server, Server.Client client) { location = Multiplayer.processLocationNameForPlayerUnique(client.farmer, location); process(); server.broadcast(this, client.id); }
public TerrainFeaturePacket(GameLocation loc, Vector2 pos) : this() { create = false; location = Multiplayer.getUniqueLocationName(loc); posX = pos.X; posY = pos.Y; }
public void leaveGame() { Multiplayer m = FindObjectOfType <Multiplayer>(); m.Disconnect(); Destroy(m.gameObject); SceneManager.LoadScene("Menu"); }
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e) { QuickGrassStarterObjectId = jsonAssetsApi.GetObjectId("Quick Grass Starter"); // Cache these private objects and methods we'll need for later patching. Game1Multiplayer = typeof(Game1).GetField("multiplayer", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance | BindingFlags.FlattenHierarchy).GetValue(null) as Multiplayer; GrassShakeMethodInfo = typeof(Grass).GetMethod("shake", BindingFlags.NonPublic | BindingFlags.Instance); }
public MuseumUpdatedPacket(GameLocation loc) : this() { clientId = Multiplayer.getMyId(); name = loc.name; artifacts = Util.serialize((loc as LibraryMuseum).museumPieces); message(); }
public override void _Process(float delta) { if (Queue.Count > 1) { CreateRoom(); } Multiplayer.Poll(); }
private void SetupGame(Scene arg0, Scene arg1) { multiplayer = GameObject.FindObjectOfType <Multiplayer>(); lobby = null; pingAtTime = 0; multiplayer?.SetupGame(gameParams); SceneManager.activeSceneChanged -= SetupGame; }
public override void process(Server server, Server.Client client) { //redirect the packet to all connected clients to avoid item/data loss server.broadcast(this, client.id); location = Multiplayer.processLocationNameForPlayerUnique(client.farmer, location); process(); }
//TODO: Not in use, remove if not needed public static void PlayerConnected(this Multiplayer multiplayer, IncomingMessage msg) { PlayerConnectedEventArgs args = new PlayerConnectedEventArgs { Player = multiplayer.readFarmer(msg.Reader).Value }; ModEntry.ModMonitor.Log("PlayerConnected(this Multiplayer multiplayer, IncomingMessage msg)"); OnPlayerConnected(null, args); }
public static void HandleApplicationQuit_Prefix() { if (Multiplayer.IsActive) { Log.Warn("Multiplayer is still running, closing now..."); Multiplayer.LeaveGame(); } DiscordManager.Cleanup(); }
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event data.</param> private void OnButtonPressed(object sender, ButtonPressedEventArgs e) { if (Game1.activeClickableMenu is GameMenu gameMenu && gameMenu.currentTab == GameMenu.mapTab) { if (modHelper.Input.IsDown(SButton.LeftAlt) && modHelper.Input.IsDown(SButton.MouseLeft)) { MapPage mapPage = (MapPage)Reflection.GetField <List <IClickableMenu> >(gameMenu, "pages").GetValue()[GameMenu.mapTab]; Vector2 mapCoord = new Vector2(Reflection.GetField <int>(mapPage, "mapX").GetValue(), Reflection.GetField <int>(mapPage, "mapY").GetValue()); //Vector2 mapPos = Utility.getTopLeftPositionForCenteringOnScreen(Sprites.Map.SourceRectangle.Width * Game1.pixelZoom, Sprites.Map.SourceRectangle.Height * Game1.pixelZoom); Vector2 pingedCoord = new Vector2(e.Cursor.ScreenPixels.X - mapCoord.X, e.Cursor.ScreenPixels.Y - mapCoord.Y); int mapWidth = Sprites.Map.SourceRectangle.Width * Game1.pixelZoom; int mapHeight = Sprites.Map.SourceRectangle.Height * Game1.pixelZoom; if (IsPingWithinMapBounds(mapWidth, mapHeight, pingedCoord)) { //TODO: Send ping to players if (config.ShowPingsInChat) { string hoverText = Reflection.GetField <string>(mapPage, "hoverText").GetValue(); if (!String.IsNullOrWhiteSpace(hoverText)) { hoverText = $"\"{GetHoverTextLocationName(hoverText)}\""; } if (!MapPings.ContainsKey(Game1.player)) { MapPings.Add(Game1.player, new PlayerMapPing(Color.Red)); } MapPings[Game1.player].AddPing(Game1.player, pingedCoord, hoverText); string messageKey = "UserNotificationMessageFormat"; string messageText = $"{Game1.player.Name} pinged {hoverText} [X:{pingedCoord.X}, Y:{pingedCoord.Y}]"; if (Game1.IsMultiplayer) { Multiplayer multiplayer = Reflection.GetField <Multiplayer>(typeof(Game1), "multiplayer").GetValue(); multiplayer.globalChatInfoMessage(messageKey, messageText); } else { Game1.chatBox.addInfoMessage(Game1.content.LoadString("Strings\\UI:Chat_" + messageKey, messageText)); } } #if DEBUG ModEntry.ModLogger.Log($"MapCoords => (x: {pingedCoord.X}, y: {pingedCoord.Y})"); ModEntry.ModLogger.Log($"Map (X: {mapCoord.X}, Y: {mapCoord.Y})"); #endif } modHelper.Input.Suppress(SButton.MouseLeft); } } }
public CommunityCenterUpdatedPacket(GameLocation loc, SerializableDictionary <int, bool> rewards) : this() { clientId = Multiplayer.getMyId(); name = loc.name; reason = (byte)Reason.BundlesRewards; xml = Util.serialize(rewards); message(); }
private void NotifyAllNodesSynched() { // Called from client the first time they complete their node synch MDLog.Trace(LOG_CAT, $"Peer [{Multiplayer.GetRpcSenderId()}] has completed node synchronization"); if (!PeerSynchInfo.ContainsKey(Multiplayer.GetRpcSenderId())) { PeerSynchInfo[Multiplayer.GetRpcSenderId()].CompletedNodeSynch = true; } }
//TODO: Not in use, remove if not needed public static void PlayerDisconnected(this Multiplayer multiplayer, IncomingMessage msg) { PlayerDisconnectedEventArgs args = new PlayerDisconnectedEventArgs { Player = msg.SourceFarmer }; ModEntry.ModMonitor.Log("PlayerDisconnected(this Multiplayer multiplayer, IncomingMessage msg)"); OnPlayerDisconnected(null, args); }
static void Main(string[] args) { Multiplayer calc = (x, y) => x * y; //same as Func<int,int,int> PrintSomething action = () => Console.WriteLine("Hello!"); //same as action() Action <string> print = message => Console.WriteLine(message); }
protected override void Dispose(bool disposing) { if (client != null && disposing && Game1.client != client) { Multiplayer.LogDisconnect(Multiplayer.IsTimeout(client.pendingDisconnect) ? Multiplayer.DisconnectType.Timeout_FarmhandSelection : Multiplayer.DisconnectType.ExitedToMainMenu_FromFarmhandSelect); client.disconnect(); } base.Dispose(disposing); }
public CommunityCenterUpdatedPacket(GameLocation loc, bool[] theCompleted) : this() { clientId = Multiplayer.getMyId(); name = loc.name; reason = (byte)Reason.BundlesCompleted; completed = theCompleted; message(); }
/// <summary>Implement this function to make a custom inspector.</summary> public override void OnInspectorGUI() { if (GUILayout.Button("Update Prefabs")) { Multiplayer multiplayer = target as Multiplayer; UpdateList(ref multiplayer); } base.OnInspectorGUI(); }
public static void ReceiveEmoteBroadcast(this Multiplayer multiplayer, IncomingMessage msg) { if (msg.Data.Length >= 0) { int emoteIndex = msg.Reader.ReadInt32(); msg.SourceFarmer.IsEmoting = false; msg.SourceFarmer.doEmote(emoteIndex); } }
public void BroadcastEmote(int whichEmote) { TemporaryAnimatedSprite emoteStart = new TemporaryAnimatedSprite("TileSheets\\emotes", new Rectangle(0, 0, 16, 16), new Vector2(Game1.player.Position.X, Game1.player.Position.Y - 160), false, 0f, Color.White) { interval = 80f, animationLength = 4, scale = 4f, layerDepth = 0.9f, local = false, timeBasedMotion = true, attachedCharacter = Game1.player, extraInfoForEndBehavior = 0, endFunction = FinishedAnimation }; TemporaryAnimatedSprite emote = new TemporaryAnimatedSprite("TileSheets\\emotes", new Rectangle(0, whichEmote * 16, 16, 16), new Vector2(Game1.player.Position.X, Game1.player.Position.Y - 160), false, 0f, Color.White) { delayBeforeAnimationStart = 100, interval = 250f, animationLength = 4, scale = 4f, layerDepth = 1f, local = false, timeBasedMotion = true, attachedCharacter = Game1.player, extraInfoForEndBehavior = 1, endFunction = FinishedAnimation }; TemporaryAnimatedSprite emoteEnding = new TemporaryAnimatedSprite("TileSheets\\emotes", new Rectangle(0, 0, 16, 16), new Vector2(Game1.player.Position.X, Game1.player.Position.Y - 160), false, 0f, Color.White) { delayBeforeAnimationStart = 800, interval = 80f, animationLength = 4, scale = 4f, layerDepth = 0.9f, local = false, timeBasedMotion = true, pingPong = true, // This makes the animation play, forwards, and when finished backwards sourceRect = new Rectangle(48, 0, 16, 16), // Set the current sprite position to the last animation image currentParentTileIndex = 3, // To play the animation backwards, we tell it that its in the last frame attachedCharacter = Game1.player, extraInfoForEndBehavior = 2, endFunction = FinishedAnimation }; temporaryAnimationList = new List <TemporaryAnimatedSprite>() { emoteStart, emote, emoteEnding }; Multiplayer multiplayer = Reflection.GetField <Multiplayer>(typeof(Game1), "multiplayer").GetValue(); multiplayer.broadcastSprites(Game1.player.currentLocation, temporaryAnimationList); }
public void retreivePlayerList() { Debug.Log("Retreiving Player Data"); Tournament thisTournament = selectedTournament; Multiplayer.clearList(); players.Clear(); StartCoroutine(HttpUtil.Get(HttpUtil.getPlayersInAMatch + "/" + thisTournament.id, GetPlayersInAMatchCallback)); }
// Send a PM public static void publishPrivateMessage(Farmer player, string msg) { // send to everyone else Multiplayer multiplayer = Helper.Reflection.GetField <Multiplayer>(typeof(Game1), "multiplayer").GetValue(); multiplayer.sendChatMessage(LocalizedContentManager.CurrentLanguageCode, msg, player.UniqueMultiplayerID); // also show the message in our own message box Game1.chatBox.receiveChatMessage(Game1.player.UniqueMultiplayerID, (int)ChatMessage.ChatKinds.PrivateMessage, LocalizedContentManager.CurrentLanguageCode, msg); }
public static void Check() { if (UserID == "") { Startup.Clean(); Network.Disconnect(); Multiplayer.Reset(); Application.LoadLevel(0); } }