public static MTexture GetHairTexture(On.Celeste.PlayerHair.orig_GetHairTexture orig, PlayerHair self, int index) { MTexture texOrig = orig(self, index); Ghost ghost = self.Entity as Ghost; GhostNetClient client = GhostNetModule.Instance.Client; uint playerID; GhostNetFrame frame; ChunkUUpdate update; if (ghost == null || client == null || !client.GhostPlayerIDs.TryGetValue(ghost, out playerID) || !client.UpdateMap.TryGetValue(playerID, out frame) || (update = frame) == null) { return(texOrig); } if (index < 0 || update.HairColors.Length <= index) { return(texOrig); } string texName = update.HairTextures[index]; if (!GFX.Game.Has(texName)) { return(texOrig); } return(GFX.Game[texName]); }
public void Stop() { if (Client != null) { Client.Stop(); Client = null; } if (Server != null) { Server.Stop(); Server = null; } }
public void Stop() { if (Client != null) { Client.Stop(); Client = null; } if (Server != null) { Server.Stop(); Server = null; GhostNetWatchdog.StopWatchdog(); } }
public void Start(bool server = false, bool client = false) { Stop(); if (Settings.IsHost || server) { Server = new GhostNetServer(Celeste.Instance); if (!_StartHeadless) { Celeste.Instance.Components.Add(Server); } Server.OPs.Add(0); Server.Start(); GhostNetWatchdog.InitializeWatchdog(); } if (!Settings.IsHost && server && !client) { return; } try { Client = new GhostNetClient(Celeste.Instance); if (!_StartHeadless) { Celeste.Instance.Components.Add(Client); } Client.Start(); } catch (Exception e) { Logger.Log(LogLevel.Warn, "ghostnet", "Failed starting client"); Logger.LogDetailed(e); if (Settings.EnabledEntry != null) { Settings.EnabledEntry.LeftPressed(); } Stop(); } }
public static Color GetHairColor(On.Celeste.PlayerHair.orig_GetHairColor orig, PlayerHair self, int index) { Color colorOrig = orig(self, index); Ghost ghost = self.Entity as Ghost; GhostNetClient client = GhostNetModule.Instance.Client; uint playerID; GhostNetFrame frame; ChunkUUpdate update; if (ghost == null || client == null || !client.GhostPlayerIDs.TryGetValue(ghost, out playerID) || !client.UpdateMap.TryGetValue(playerID, out frame) || (update = frame) == null) { return(colorOrig); } if (index < 0 || update.HairColors.Length <= index) { return(Color.Transparent); } return(update.HairColors[index]); }
public void TurnOn(uint idIn = 9999) { //if (!Switch.Activated) //{ // touchSfx.Play("event:/game/general/touchswitch_any", null, 0f); // if (Switch.Activate()) // { // SoundEmitter.Play("event:/game/general/touchswitch_last_oneshot"); // base.Add(new SoundSource("event:/game/general/touchswitch_last_cutoff")); // } //} Controller controllerIn = Controller.Neutral; GhostNetClient client = GhostNetModule.Instance.Client; if (client != null && client.Connection != null) { if (idIn == 9999) { idIn = client.PlayerID; } if (idIn == client.P1_id) { controllerIn = Controller.P1; } else if (idIn == client.P2_id) { controllerIn = Controller.P2; } else { return; } } else { return; } if (controllerIn != currentController) { currentController = controllerIn; ControlSwitch.controller = controllerIn; int startingNum = 8 - client.ControlSwitches.Count; int chimeNum = 0; int p1Chimes = 0; int p2Chimes = 0; foreach (MultiplayerControlSwitch mSwitch in client.ControlSwitches) { if (mSwitch.currentController == Controller.P1) { p1Chimes++; } } foreach (MultiplayerControlSwitch mSwitch in client.ControlSwitches) { if (mSwitch.currentController == Controller.P2) { p2Chimes++; } } int realChimeNum = 0; uint loserID = uint.MaxValue; if (p1Chimes > p2Chimes) { chimeNum = p1Chimes + startingNum; realChimeNum = p1Chimes; loserID = client.P2_id; } else { chimeNum = p2Chimes + startingNum; realChimeNum = p2Chimes; loserID = client.P1_id; } string str = ""; if (realChimeNum >= client.ControlSwitches.Count) { if (client.PlayerID == loserID) { str = "event:/kevinball_8_lose"; } else { str = "event:/kevinball_8_win"; } } else { if (chimeNum >= 7) { chimeNum = 7; } str = "event:/kevinball_" + chimeNum.ToString(); } Logger.Log("Kevinball", "PLAYING CHIME -- " + str); touchSfx.Play(str, null, 0f); if (currentController == Controller.P1) { icon.Color = P1Color; } else { icon.Color = P2Color; } } }