Beispiel #1
0
 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);
 }
Beispiel #2
0
        public void Awake()
        {
            multiplayerSession = NitroxServiceLocator.LocateService <IMultiplayerSession>();
            preferencesManager = NitroxServiceLocator.LocateService <PlayerPreferenceManager>();

            InitializeJoinMenu();
            SubscribeColorChanged();

            DontDestroyOnLoad(gameObject);
        }
Beispiel #3
0
        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();
        }
Beispiel #4
0
        public LocalPlayer(IMultiplayerSession multiplayerSession, IPacketSender packetSender)
        {
            this.multiplayerSession = multiplayerSession;
            this.packetSender       = packetSender;

            Body        = Player.main.RequireGameObject("body");
            PlayerModel = Body.RequireGameObject("player_view");

            BodyPrototype = CreateBodyPrototype();
        }
Beispiel #5
0
        public void Awake()
        {
            Log.InGame(Language.main.Get("Nitrox_MultiplayerLoaded"));

            multiplayerSession = NitroxServiceLocator.LocateService <IMultiplayerSession>();
            packetReceiver     = NitroxServiceLocator.LocateService <PacketReceiver>();

            Main = this;
            DontDestroyOnLoad(gameObject);
        }
Beispiel #6
0
        public void Awake()
        {
            multiplayerSession = NitroxServiceLocator.LocateService <IMultiplayerSession>();

            DevConsole.RegisterConsoleCommand(this, "mplayer", false);
            DevConsole.RegisterConsoleCommand(this, "warpto", false);
            DevConsole.RegisterConsoleCommand(this, "disconnect", false);

            DontDestroyOnLoad(gameObject);
        }
Beispiel #7
0
        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();
        }
Beispiel #8
0
        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();
        }
Beispiel #9
0
 public Vehicles(IPacketSender packetSender, PlayerManager playerManager, IMultiplayerSession multiplayerSession)
 {
     this.packetSender       = packetSender;
     this.playerManager      = playerManager;
     this.multiplayerSession = multiplayerSession;
 }
Beispiel #10
0
 public BroadcastEscapePodsProcessor(IPacketSender packetSender, IMultiplayerSession multiplayerSession)
 {
     this.packetSender       = packetSender;
     this.multiplayerSession = multiplayerSession;
 }
 public void Awake()
 {
     session    = NitroxServiceLocator.LocateService <IMultiplayerSession>();
     inputGroup = gameObject.AddComponent <uGUI_InputGroup>();
 }
Beispiel #12
0
 public SimulationOwnershipChangeProcessor(IMultiplayerSession multiplayerSession, SimulationOwnership simulationOwnershipManager)
 {
     this.multiplayerSession         = multiplayerSession;
     this.simulationOwnershipManager = simulationOwnershipManager;
 }
Beispiel #13
0
 public AddEscapePodProcessor(IMultiplayerSession multiplayerSession, EscapePodManager escapePodManager)
 {
     this.multiplayerSession = multiplayerSession;
     this.escapePodManager   = escapePodManager;
 }
Beispiel #14
0
 public ExosuitModuleEvent(IPacketSender packetSender, IMultiplayerSession multiplayerSession, Vehicles vehicles)
 {
     this.packetSender       = packetSender;
     this.multiplayerSession = multiplayerSession;
     this.vehicles           = vehicles;
 }
Beispiel #15
0
 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);
        }
Beispiel #17
0
 public Chat(IMultiplayerSession multiplayerSession)
 {
     this.multiplayerSession = multiplayerSession;
 }
Beispiel #18
0
        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;
 }
Beispiel #20
0
 public PlayerChatManager(IMultiplayerSession multiplayerSession)
 {
     this.multiplayerSession = multiplayerSession;
     Player.main.StartCoroutine(LoadChatLogAsset());
 }
Beispiel #21
0
 public Terrain(IMultiplayerSession multiplayerSession, IPacketSender packetSender, VisibleCells visibleCells)
 {
     this.multiplayerSession = multiplayerSession;
     this.packetSender       = packetSender;
     this.visibleCells       = visibleCells;
 }
 public UserKickedProcessor(IMultiplayerSession session)
 {
     this.session = session;
 }
Beispiel #23
0
 public SimulationOwnership(IMultiplayerSession muliplayerSession, IPacketSender packetSender)
 {
     this.muliplayerSession = muliplayerSession;
     this.packetSender      = packetSender;
 }
Beispiel #24
0
 public void Awake()
 {
     multiplayerSession = NitroxServiceLocator.LocateService <IMultiplayerSession>();
     DontDestroyOnLoad(gameObject);
 }
Beispiel #25
0
 public WeldActionProcessor(IMultiplayerSession multiplayerSession, SimulationOwnership simulationOwnership)
 {
     this.multiplayerSession  = multiplayerSession;
     this.simulationOwnership = simulationOwnership;
 }
Beispiel #26
0
 public override void Patch(Harmony harmony)
 {
     sessionManager = NitroxServiceLocator.LocateService <IMultiplayerSession>();
     PatchPostfix(harmony, targetMethod);
 }
        public static void Prefix()
        {
            IMultiplayerSession multiplayerSession = NitroxServiceLocator.LocateService <IMultiplayerSession>();

            multiplayerSession.Disconnect();
        }
Beispiel #28
0
 public void Awake()
 {
     multiplayerSession = NitroxServiceLocator.LocateService <IMultiplayerSession>();
     chatBroadcaster    = NitroxServiceLocator.LocateService <GameLogic.Chat>();
 }
Beispiel #29
0
 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);
 }