public void Awake() { Log.InGame("Multiplayer Client Loaded..."); multiplayerSession = NitroxServiceLocator.LocateService <IMultiplayerSession>(); packetReceiver = NitroxServiceLocator.LocateService <PacketReceiver>(); Log.InGameLogger = new SubnauticaInGameLogger(); NitroxModel.Helper.Map.Main = new SubnauticaMap(); Main = this; DontDestroyOnLoad(gameObject); }
public void Awake() { multiplayerSession = NitroxServiceLocator.LocateService <IMultiplayerSession>(); preferencesManager = NitroxServiceLocator.LocateService <PlayerPreferenceManager>(); InitializeJoinMenu(); SubscribeColorChanged(); DontDestroyOnLoad(gameObject); }
public LocalPlayer(IMultiplayerSession multiplayerSession, IPacketSender packetSender) { this.multiplayerSession = multiplayerSession; this.packetSender = packetSender; Body = Player.main.transform.Find("body").gameObject; PlayerModel = Body.transform.Find("player_view").gameObject; BodyPrototype = CreateBodyPrototype(); }
public LocalPlayer(IMultiplayerSession multiplayerSession, IPacketSender packetSender) { this.multiplayerSession = multiplayerSession; this.packetSender = packetSender; Body = Player.main.RequireGameObject("body"); PlayerModel = Body.RequireGameObject("player_view"); BodyPrototype = CreateBodyPrototype(); }
public void Awake() { Log.InGame(Language.main.Get("Nitrox_MultiplayerLoaded")); multiplayerSession = NitroxServiceLocator.LocateService <IMultiplayerSession>(); packetReceiver = NitroxServiceLocator.LocateService <PacketReceiver>(); Main = this; DontDestroyOnLoad(gameObject); }
public void Awake() { multiplayerSession = NitroxServiceLocator.LocateService <IMultiplayerSession>(); DevConsole.RegisterConsoleCommand(this, "mplayer", false); DevConsole.RegisterConsoleCommand(this, "warpto", false); DevConsole.RegisterConsoleCommand(this, "disconnect", false); DontDestroyOnLoad(gameObject); }
public static void OnDoUpgragePost() { if (NebulaModAPI.IsMultiplayerActive) { IMultiplayerSession session = NebulaModAPI.MultiplayerSession; if (session.LocalPlayer.IsClient) { session.Network.SendPacket(new ClearUndoRequestPacket(session.LocalPlayer.Id)); UIRealtimeTip.Popup("UndoClearedMessage".Translate(), false); VFAudio.Create("cancel-0", null, Vector3.zero, true, 4); return; } } PlayerUndo data = UndoManager.GetPlayerData(UndoManager.GetLocalUserId()); data.ResetUndo(); }
public void Show(string ip, int port) { NitroxServiceLocator.BeginNewLifetimeScope(); multiplayerSession = NitroxServiceLocator.LocateService <IMultiplayerSession>(); preferencesManager = NitroxServiceLocator.LocateService <PlayerPreferenceManager>(); gameObject.SetActive(true); serverIp = ip; serverPort = port; //Set Server IP in info label lowerDetailTextGameObject.GetComponent <Text>().text = $"{Language.main.Get("Nitrox_JoinServerIpAddress")}\n{serverIp}"; //Initialize elements from preferences activePlayerPreference = preferencesManager.GetPreference(serverIp); Color.RGBToHSV(activePlayerPreference.PreferredColor(), out float hue, out float _, out float vibrancy); colorPicker.SetHSB(new Vector3(hue, 1f, vibrancy)); SubscribeColorChanged(); playerNameInputField.text = activePlayerPreference.PlayerName; StartMultiplayerClient(); }
public Vehicles(IPacketSender packetSender, PlayerManager playerManager, IMultiplayerSession multiplayerSession) { this.packetSender = packetSender; this.playerManager = playerManager; this.multiplayerSession = multiplayerSession; }
public BroadcastEscapePodsProcessor(IPacketSender packetSender, IMultiplayerSession multiplayerSession) { this.packetSender = packetSender; this.multiplayerSession = multiplayerSession; }
public void Awake() { session = NitroxServiceLocator.LocateService <IMultiplayerSession>(); inputGroup = gameObject.AddComponent <uGUI_InputGroup>(); }
public SimulationOwnershipChangeProcessor(IMultiplayerSession multiplayerSession, SimulationOwnership simulationOwnershipManager) { this.multiplayerSession = multiplayerSession; this.simulationOwnershipManager = simulationOwnershipManager; }
public AddEscapePodProcessor(IMultiplayerSession multiplayerSession, EscapePodManager escapePodManager) { this.multiplayerSession = multiplayerSession; this.escapePodManager = escapePodManager; }
public ExosuitModuleEvent(IPacketSender packetSender, IMultiplayerSession multiplayerSession, Vehicles vehicles) { this.packetSender = packetSender; this.multiplayerSession = multiplayerSession; this.vehicles = vehicles; }
public LiveMixinManager(IMultiplayerSession multiplayerSession, SimulationOwnership simulationOwnership) { this.multiplayerSession = multiplayerSession; this.simulationOwnership = simulationOwnership; }
public static bool CalculatePositions(BuildTool_BlueprintPaste tool, List <ReformData> reforms, Color[] colors) { ReformBPUtils.currentGrid = tool.factory.planet.aux.mainGrid; PlanetData planet = tool.factory.planet; PlatformSystem platformSystem = tool.factory.platformSystem; Vector3 center = Vector3.zero; tmpPoints.Clear(); foreach (ReformData preview in reforms) { ReformBPUtils.GetSegmentCount(preview.latitude, preview.longitude, out float latCount, out float longCount, out int segmentCount); longCount = Mathf.Repeat(longCount, segmentCount); int reformIndex = platformSystem.GetReformIndexForSegment(latCount, longCount); if (reformIndex < 0) { continue; } int type = platformSystem.GetReformType(reformIndex); if (platformSystem.IsTerrainReformed(type)) { continue; } Vector3 pos = BlueprintUtils.GetDir(preview.longitude, preview.latitude); pos *= planet.realRadius + 0.2f; tmpPoints.Add(pos); center += pos; } int cost = ReformBPUtils.ComputeFlattenTerrainReform(tool.factory, tmpPoints, center); if (NebulaModAPI.IsMultiplayerActive) { IMultiplayerSession session = NebulaModAPI.MultiplayerSession; if (!session.Factories.IsIncomingRequest.Value && !CheckItems(tool, cost, tmpPoints.Count)) { return(false); } if (session.LocalPlayer.IsHost) { int planetId = session.Factories.EventFactory?.planetId ?? GameMain.localPlanet?.id ?? -1; session.Network.SendPacketToStar(new ReformPasteEventPacket(planetId, reforms, colors, session.Factories.PacketAuthor == NebulaModAPI.AUTHOR_NONE ? session.LocalPlayer.Id : session.Factories.PacketAuthor), GameMain.galaxy.PlanetById(planetId).star.id); } //If client builds, he need to first send request to the host and wait for reply if (!session.LocalPlayer.IsHost && !session.Factories.IsIncomingRequest.Value) { session.Network.SendPacket(new ReformPasteEventPacket(GameMain.localPlanet?.id ?? -1, reforms, colors, session.Factories.PacketAuthor == NebulaModAPI.AUTHOR_NONE ? session.LocalPlayer.Id : session.Factories.PacketAuthor)); return(true); } } else { if (!CheckItems(tool, cost, tmpPoints.Count)) { return(false); } } if (colors != null && colors.Length > 0) { ApplyColors(tool, colors); } ReformBPUtils.FlattenTerrainReform(tool.factory, tmpPoints, center); VFAudio.Create("reform-terrain", null, center, true, 4); foreach (ReformData preview in reforms) { ReformBPUtils.GetSegmentCount(preview.latitude, preview.longitude, out float latCount, out float longCount, out int segmentCount); longCount = Mathf.Repeat(longCount, segmentCount); int reformIndex = platformSystem.GetReformIndexForSegment(latCount, longCount); if (reformIndex < 0) { continue; } int reformType = platformSystem.GetReformType(reformIndex); int reformColor = platformSystem.GetReformColor(reformIndex); if (reformType == preview.type && reformColor == preview.color) { continue; } platformSystem.SetReformType(reformIndex, preview.type); platformSystem.SetReformColor(reformIndex, preview.color); } return(true); }
public Chat(IMultiplayerSession multiplayerSession) { this.multiplayerSession = multiplayerSession; }
public static void SwitchDelete(PlanetFactory factory, List <int> objectIds) { if (objectIds.Count <= 0) { return; } if (NebulaModAPI.IsMultiplayerActive) { IMultiplayerSession session = NebulaModAPI.MultiplayerSession; int planetId = session.Factories.TargetPlanet != NebulaModAPI.PLANET_NONE ? session.Factories.TargetPlanet : factory.planet?.id ?? -1; if (session.LocalPlayer.IsHost || !session.Factories.IsIncomingRequest.Value) { session.Network.SendPacket(new FastRemoveRequestPacket(planetId, objectIds.ToArray(), Array.Empty <int>(), session.Factories.PacketAuthor == NebulaModAPI.AUTHOR_NONE ? session.LocalPlayer.Id : session.Factories.PacketAuthor, false)); } if (!session.LocalPlayer.IsHost && !session.Factories.IsIncomingRequest.Value) { return; } } if (objectIds.Count < 25) { RegularDeleteEntities(factory, objectIds); return; } if (BlueprintTweaksPlugin.useFastDismantle.Value) { var player = GameMain.mainPlayer; PlayerAction_Build actionBuild = player.controller.actionBuild; float divLine = GetDivideLine(factory, actionBuild, objectIds); BPGratBox boundingBox = BlueprintUtils.GetBoundingRange(factory.planet, factory.planet.aux, objectIds.ToArray(), objectIds.Count, divLine); HashSet <int> edgeObjIds = new HashSet <int>(); int segmentCnt = 200; if (GameMain.localPlanet?.aux?.activeGrid != null) { segmentCnt = GameMain.localPlanet.aux.activeGrid.segment; } foreach (int objectId in objectIds) { if (objectId <= 0 || factory.entityPool[objectId].id != objectId) { continue; } if (boundingBox.IsOnEdgeOfGratBox(factory.entityPool[objectId].pos, segmentCnt)) { edgeObjIds.Add(objectId); } } if (edgeObjIds.Count == 0) { foreach (int objectId in objectIds) { if (objectId <= 0 || factory.entityPool[objectId].beltId <= 0) { continue; } RegularDeleteEntities(factory, objectIds); return; } } FastDeleteEntities(factory, objectIds, edgeObjIds.ToList()); } else { RegularDeleteEntities(factory, objectIds); } }
public MultiplayerSessionPolicyProcessor(IMultiplayerSession multiplayerSession) { this.multiplayerSession = multiplayerSession; }
public PlayerChatManager(IMultiplayerSession multiplayerSession) { this.multiplayerSession = multiplayerSession; Player.main.StartCoroutine(LoadChatLogAsset()); }
public Terrain(IMultiplayerSession multiplayerSession, IPacketSender packetSender, VisibleCells visibleCells) { this.multiplayerSession = multiplayerSession; this.packetSender = packetSender; this.visibleCells = visibleCells; }
public UserKickedProcessor(IMultiplayerSession session) { this.session = session; }
public SimulationOwnership(IMultiplayerSession muliplayerSession, IPacketSender packetSender) { this.muliplayerSession = muliplayerSession; this.packetSender = packetSender; }
public void Awake() { multiplayerSession = NitroxServiceLocator.LocateService <IMultiplayerSession>(); DontDestroyOnLoad(gameObject); }
public WeldActionProcessor(IMultiplayerSession multiplayerSession, SimulationOwnership simulationOwnership) { this.multiplayerSession = multiplayerSession; this.simulationOwnership = simulationOwnership; }
public override void Patch(Harmony harmony) { sessionManager = NitroxServiceLocator.LocateService <IMultiplayerSession>(); PatchPostfix(harmony, targetMethod); }
public static void Prefix() { IMultiplayerSession multiplayerSession = NitroxServiceLocator.LocateService <IMultiplayerSession>(); multiplayerSession.Disconnect(); }
public void Awake() { multiplayerSession = NitroxServiceLocator.LocateService <IMultiplayerSession>(); chatBroadcaster = NitroxServiceLocator.LocateService <GameLogic.Chat>(); }
public EscapePodManager(IPacketSender packetSender, IMultiplayerSession multiplayerSession) { this.packetSender = packetSender; this.multiplayerSession = multiplayerSession; }
public override void Patch(Harmony harmony) { sessionManager = NitroxServiceLocator.LocateService <IMultiplayerSession>(); PatchPostfix(harmony, TARGET_METHOD); }