Beispiel #1
0
        public void ProcessPacket(ILSShipDock packet, NebulaConnection conn)
        {
            // a fake entry should already have been created
            StationComponent stationComponent = GameMain.data.galacticTransport.stationPool[packet.stationGId];

            stationComponent.shipDockPos = DataStructureExtensions.ToVector3(packet.shipDockPos);
            stationComponent.shipDockRot = DataStructureExtensions.ToQuaternion(packet.shipDockRot);

            for (int i = 0; i < ILSShipManager.ILSMaxShipCount; i++)
            {
                stationComponent.shipDiskRot[i] = Quaternion.Euler(0f, 360f / (float)ILSShipManager.ILSMaxShipCount * (float)i, 0f);
                stationComponent.shipDiskPos[i] = stationComponent.shipDiskRot[i] * new Vector3(0f, 0f, 11.5f);
            }
            for (int j = 0; j < ILSShipManager.ILSMaxShipCount; j++)
            {
                stationComponent.shipDiskRot[j] = stationComponent.shipDockRot * stationComponent.shipDiskRot[j];
                stationComponent.shipDiskPos[j] = stationComponent.shipDockPos + stationComponent.shipDockRot * stationComponent.shipDiskPos[j];
            }

            // sync the current position of the ships as they might have been calculated wrong while we did not have the correct dock position and rotation.
            for (int i = 0; i < packet.shipOtherGId.Length; i++)
            {
                stationComponent = GameMain.data.galacticTransport.stationPool[packet.shipOtherGId[i]];

                stationComponent.workShipDatas[packet.shipIndex[i]].uPos     = DataStructureExtensions.ToVectorLF3(packet.shipPos[i]);
                stationComponent.workShipDatas[packet.shipIndex[i]].uRot     = DataStructureExtensions.ToQuaternion(packet.shipRot[i]);
                stationComponent.workShipDatas[packet.shipIndex[i]].pPosTemp = DataStructureExtensions.ToVectorLF3(packet.shipPPosTemp[i]);
                stationComponent.workShipDatas[packet.shipIndex[i]].pRotTemp = DataStructureExtensions.ToQuaternion(packet.shipPRotTemp[i]);
            }
        }
        public void ProcessPacket(ILSShipDock packet, NebulaConnection conn)
        {
            // a fake entry should already have been created
            StationComponent stationComponent = GameMain.data.galacticTransport.stationPool[packet.stationGId];

            stationComponent.shipDockPos = DataStructureExtensions.ToVector3(packet.shipDockPos);
            stationComponent.shipDockRot = DataStructureExtensions.ToQuaternion(packet.shipDockRot);

            for (int i = 0; i < 10; i++)
            {
                stationComponent.shipDiskRot[i] = Quaternion.Euler(0f, 360f / (float)10 * (float)i, 0f);
                stationComponent.shipDiskPos[i] = stationComponent.shipDiskRot[i] * new Vector3(0f, 0f, 11.5f);
            }
            for (int j = 0; j < 10; j++)
            {
                stationComponent.shipDiskRot[j] = stationComponent.shipDockRot * stationComponent.shipDiskRot[j];
                stationComponent.shipDiskPos[j] = stationComponent.shipDockPos + stationComponent.shipDockRot * stationComponent.shipDiskPos[j];
            }

            for (int i = 0; i < packet.shipOtherGId.Length; i++)
            {
                stationComponent = GameMain.data.galacticTransport.stationPool[packet.shipOtherGId[i]];

                stationComponent.workShipDatas[packet.shipIndex[i]].uPos     = DataStructureExtensions.ToVectorLF3(packet.shipPos[i]);
                stationComponent.workShipDatas[packet.shipIndex[i]].uRot     = DataStructureExtensions.ToQuaternion(packet.shipRot[i]);
                stationComponent.workShipDatas[packet.shipIndex[i]].pPosTemp = DataStructureExtensions.ToVectorLF3(packet.shipPPosTemp[i]);
                stationComponent.workShipDatas[packet.shipIndex[i]].pRotTemp = DataStructureExtensions.ToQuaternion(packet.shipPRotTemp[i]);
            }
        }
 public void ProcessPacket(ILSAddStationComponentRequest packet, NebulaConnection conn)
 {
     StationComponent[] gStationPool = GameMain.data.galacticTransport.stationPool;
     foreach (StationComponent stationComponent in gStationPool)
     {
         if (stationComponent != null && stationComponent.planetId == packet.planetId)
         {
             if (stationComponent.shipDockPos == DataStructureExtensions.ToVector3(packet.shipDockPos))
             {
                 conn.SendPacket(new ILSAddStationComponentResponse(stationComponent.gid, packet.planetId, stationComponent.shipDockPos));
                 return;
             }
         }
     }
 }
 public void ProcessPacket(DysonSphereBulletCorrectionPacket packet, NebulaConnection conn)
 {
     //Check if the bullet that needs to be corrected exists
     if (GameMain.data.dysonSpheres[packet.StarIndex]?.swarm?.bulletPool[packet.BulletId] != null)
     {
         //Update destination values for the bullet
         SailBullet bullet = GameMain.data.dysonSpheres[packet.StarIndex].swarm.bulletPool[packet.BulletId];
         bullet.uEnd    = DataStructureExtensions.ToVector3(packet.UEnd);
         bullet.uEndVel = DataStructureExtensions.ToVector3(packet.UEndVel);
     }
     else
     {
         //TODO: Maybe queue it and check next frame if the bullet already exist?
         //Note: this situation was not observed during test, but maybe it can due to the severe lags?
     }
 }
Beispiel #5
0
        public void ProcessPacket(ILSAddStationComponentResponse packet, NebulaConnection conn)
        {
            Vector3 shipDockPos = DataStructureExtensions.ToVector3(packet.shipDockPos);

            for (int i = 0; i < ILSShipManager.AddStationComponentQueue[packet.planetId].Count; i++)
            {
                if (ILSShipManager.AddStationComponentQueue[packet.planetId][i].shipDockPos == shipDockPos)
                {
                    using (ILSShipManager.PatchLockILS.On())
                    {
                        ILSShipManager.AddStationComponentQueue[packet.planetId][i].gid = packet.stationGId;
                        GameMain.data.galacticTransport.AddStationComponent(packet.planetId, ILSShipManager.AddStationComponentQueue[packet.planetId][i]);
                        ILSShipManager.AddStationComponentQueue[packet.planetId].RemoveAt(i);
                    }
                    return;
                }
            }
        }
Beispiel #6
0
        public override void ProcessPacket(ILSShipDock packet, NebulaConnection conn)
        {
            if (IsHost)
            {
                return;
            }

            // a fake entry should already have been created
            StationComponent stationComponent = GameMain.data.galacticTransport.stationPool[packet.stationGId];

            stationComponent.shipDockPos = DataStructureExtensions.ToVector3(packet.shipDockPos);
            stationComponent.shipDockRot = DataStructureExtensions.ToQuaternion(packet.shipDockRot);

            for (int i = 0; i < ILSShipManager.ILSMaxShipCount; i++)
            {
                stationComponent.shipDiskRot[i] = Quaternion.Euler(0f, 360f / (float)ILSShipManager.ILSMaxShipCount * (float)i, 0f);
                stationComponent.shipDiskPos[i] = stationComponent.shipDiskRot[i] * new Vector3(0f, 0f, 11.5f);
            }
            for (int j = 0; j < ILSShipManager.ILSMaxShipCount; j++)
            {
                stationComponent.shipDiskRot[j] = stationComponent.shipDockRot * stationComponent.shipDiskRot[j];
                stationComponent.shipDiskPos[j] = stationComponent.shipDockPos + stationComponent.shipDockRot * stationComponent.shipDiskPos[j];
            }

            // sync the current position of the ships as they might have been calculated wrong while we did not have the correct dock position and rotation.
            for (int i = 0; i < packet.shipOtherGId.Length; i++)
            {
                /*
                 * fix for #251
                 * for some reason shipOtherGId can be 0 in some cases.
                 * i thought about idle ships not having it set but im not sure. However checking for a 0 here fixes the issue.
                 */
                if (packet.shipOtherGId[i] > 0 && packet.shipOtherGId[i] < GameMain.data.galacticTransport.stationPool.Length)
                {
                    stationComponent = GameMain.data.galacticTransport.stationPool[packet.shipOtherGId[i]];

                    stationComponent.workShipDatas[packet.shipIndex[i]].uPos     = DataStructureExtensions.ToVectorLF3(packet.shipPos[i]);
                    stationComponent.workShipDatas[packet.shipIndex[i]].uRot     = DataStructureExtensions.ToQuaternion(packet.shipRot[i]);
                    stationComponent.workShipDatas[packet.shipIndex[i]].pPosTemp = DataStructureExtensions.ToVectorLF3(packet.shipPPosTemp[i]);
                    stationComponent.workShipDatas[packet.shipIndex[i]].pRotTemp = DataStructureExtensions.ToQuaternion(packet.shipPRotTemp[i]);
                }
            }
        }
 public void ProcessPacket(DysonSphereAddLayerPacket packet, NebulaConnection conn)
 {
     using (DysonSphere_Manager.IncomingDysonSpherePacket.On())
     {
         GameMain.data.dysonSpheres[packet.StarIndex]?.AddLayer(packet.OrbitRadius, DataStructureExtensions.ToQuaternion(packet.OrbitRotation), packet.OrbitAngularSpeed);
     }
 }
 public void ProcessPacket(DysonSphereAddNodePacket packet, NebulaConnection conn)
 {
     using (DysonSphere_Manager.IncomingDysonSpherePacket.On())
     {
         int?addedID = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId)?.NewDysonNode(packet.NodeProtoId, DataStructureExtensions.ToVector3(packet.Position));
         //Try to add frames that failed due to the missing nodes
         DysonSphereLayer          dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId);
         DysonSphereAddFramePacket queuedPacked;
         for (int i = DysonSphere_Manager.QueuedAddFramePackets.Count - 1; i >= 0; i--)
         {
             queuedPacked = DysonSphere_Manager.QueuedAddFramePackets[i];
             if (dsl?.nodePool[queuedPacked.NodeAId]?.id != 0 && dsl?.nodePool[queuedPacked.NodeBId]?.id != 0)
             {
                 dsl.NewDysonFrame(queuedPacked.ProtoId, queuedPacked.NodeAId, queuedPacked.NodeBId, queuedPacked.Euler);
                 DysonSphere_Manager.QueuedAddFramePackets.RemoveAt(i);
             }
         }
     }
 }
        public void ProcessPacket(DysonSwarmAddOrbitPacket packet, NebulaConnection conn)
        {
            Log.Info($"Processing DysonSwarm New Orbit notification for system {GameMain.data.galaxy.stars[packet.StarIndex].name} (Index: {GameMain.data.galaxy.stars[packet.StarIndex].index})");
            Player player = playerManager.GetPlayer(conn);

            if (player != null)
            {
                playerManager.SendPacketToOtherPlayers(packet, player);
                using (DysonSphere_Manager.IncomingDysonSwarmPacket.On())
                {
                    GameMain.data.dysonSpheres[packet.StarIndex]?.swarm?.NewOrbit(packet.Radius, DataStructureExtensions.ToQuaternion(packet.Rotation));
                }
            }
        }
Beispiel #10
0
 public void ProcessPacket(ILSAddStationComponentResponse packet, NebulaConnection conn)
 {
     for (int i = 0; i < ILSShipManager.AddStationComponentQueue[packet.planetId].Count; i++)
     {
         if (ILSShipManager.AddStationComponentQueue[packet.planetId][i].shipDockPos == DataStructureExtensions.ToVector3(packet.shipDockPos))
         {
             LocalPlayer.PatchLocks["GalacticTransport"] = true;
             ILSShipManager.AddStationComponentQueue[packet.planetId][i].gid = packet.stationGId;
             GameMain.data.galacticTransport.AddStationComponent(packet.planetId, ILSShipManager.AddStationComponentQueue[packet.planetId][i]);
             ILSShipManager.AddStationComponentQueue[packet.planetId].RemoveAt(i);
             LocalPlayer.PatchLocks["GalacticTransport"] = false;
             return;
         }
     }
 }
        public void ProcessPacket(DysonSphereAddNodePacket packet, NebulaConnection conn)
        {
            Log.Info($"Processing DysonSphere Add Node notification for system {GameMain.data.galaxy.stars[packet.StarIndex].name} (Index: {GameMain.data.galaxy.stars[packet.StarIndex].index})");
            Player player = playerManager.GetPlayer(conn);

            if (player != null)
            {
                playerManager.SendPacketToOtherPlayers(packet, player);
                DysonSphere_Manager.IncomingDysonSpherePacket = true;
                GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId)?.NewDysonNode(packet.NodeProtoId, DataStructureExtensions.ToUnity(packet.Position));
                DysonSphereLayer dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId);
                //Try to add queued Dyson Frames that failed due to the missing nodes
                DysonSphereAddFramePacket queuedPacked;
                for (int i = DysonSphere_Manager.QueuedAddFramePackets.Count - 1; i >= 0; i--)
                {
                    queuedPacked = DysonSphere_Manager.QueuedAddFramePackets[i];
                    if (dsl?.nodePool[queuedPacked.NodeAId]?.id != 0 && dsl?.nodePool[queuedPacked.NodeBId]?.id != 0)
                    {
                        dsl.NewDysonFrame(queuedPacked.ProtoId, queuedPacked.NodeAId, queuedPacked.NodeBId, queuedPacked.Euler);
                        DysonSphere_Manager.QueuedAddFramePackets.RemoveAt(i);
                    }
                }
                DysonSphere_Manager.IncomingDysonSpherePacket = false;
            }
        }
        public void ProcessPacket(DysonSwarmAddOrbitPacket packet, NebulaConnection conn)
        {
            Player player = playerManager.GetPlayer(conn);

            if (player != null)
            {
                playerManager.SendPacketToOtherPlayers(packet, player);
                using (DysonSphere_Manager.IncomingDysonSwarmPacket.On())
                {
                    GameMain.data.dysonSpheres[packet.StarIndex]?.swarm?.NewOrbit(packet.Radius, DataStructureExtensions.ToQuaternion(packet.Rotation));
                }
            }
        }
Beispiel #13
0
 public void ProcessPacket(DysonSwarmAddOrbitPacket packet, NebulaConnection conn)
 {
     Log.Info($"Processing DysonSwarm New Orbit notification for system {GameMain.data.galaxy.stars[packet.StarIndex].name} (Index: {GameMain.data.galaxy.stars[packet.StarIndex].index})");
     DysonSphere_Manager.IncomingDysonSwarmPacket = true;
     GameMain.data.dysonSpheres[packet.StarIndex]?.swarm?.NewOrbit(packet.Radius, DataStructureExtensions.ToUnity(packet.Rotation));
     DysonSphere_Manager.IncomingDysonSwarmPacket = false;
 }
        public void ProcessPacket(DysonSphereAddLayerPacket packet, NebulaConnection conn)
        {
            Player player = playerManager.GetPlayer(conn);

            if (player != null)
            {
                playerManager.SendPacketToOtherPlayers(packet, player);
                using (DysonSphere_Manager.IncomingDysonSpherePacket.On())
                    GameMain.data.dysonSpheres[packet.StarIndex]?.AddLayer(packet.OrbitRadius, DataStructureExtensions.ToQuaternion(packet.OrbitRotation), packet.OrbitAngularSpeed);
            }
        }
 public void ProcessPacket(DysonSwarmAddOrbitPacket packet, NebulaConnection conn)
 {
     using (DysonSphere_Manager.IncomingDysonSwarmPacket.On())
     {
         GameMain.data.dysonSpheres[packet.StarIndex]?.swarm?.NewOrbit(packet.Radius, DataStructureExtensions.ToQuaternion(packet.Rotation));
     }
 }
Beispiel #16
0
        public void ProcessPacket(DysonSphereAddLayerPacket packet, NebulaConnection conn)
        {
            //Log.Info($"Processing DysonSphere Add Layer notification for system {GameMain.data.galaxy.stars[packet.StarIndex].name} (Index: {GameMain.data.galaxy.stars[packet.StarIndex].index})");
            Player player = playerManager.GetPlayer(conn);

            if (player != null)
            {
                playerManager.SendPacketToOtherPlayers(packet, player);
                using (DysonSphere_Manager.IncomingDysonSpherePacket.On())
                    GameMain.data.dysonSpheres[packet.StarIndex]?.AddLayer(packet.OrbitRadius, DataStructureExtensions.ToQuaternion(packet.OrbitRotation), packet.OrbitAngularSpeed);
            }
        }
        public void ProcessPacket(DysonSphereAddNodePacket packet, NebulaConnection conn)
        {
            Player player = playerManager.GetPlayer(conn);

            if (player != null)
            {
                playerManager.SendPacketToOtherPlayers(packet, player);

                using (DysonSphere_Manager.IncomingDysonSpherePacket.On())
                {
                    GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId)?.NewDysonNode(packet.NodeProtoId, DataStructureExtensions.ToVector3(packet.Position));
                    DysonSphereLayer dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId);

                    // DysonSphereLayer is missing, we can't do anything now.
                    if (dsl == null)
                    {
                        NebulaModel.Logger.Log.Warn("Could not add Dyson Sphere Node, DysonSphereLayer is null.");
                        return;
                    }

                    //Try to add queued Dyson Frames that failed due to the missing nodes
                    DysonSphereAddFramePacket queuedPacked;
                    for (int i = DysonSphere_Manager.QueuedAddFramePackets.Count - 1; i >= 0; i--)
                    {
                        queuedPacked = DysonSphere_Manager.QueuedAddFramePackets[i];
                        if (dsl.nodePool[queuedPacked.NodeAId].id != 0 && dsl.nodePool[queuedPacked.NodeBId].id != 0)
                        {
                            dsl.NewDysonFrame(queuedPacked.ProtoId, queuedPacked.NodeAId, queuedPacked.NodeBId, queuedPacked.Euler);
                            DysonSphere_Manager.QueuedAddFramePackets.RemoveAt(i);
                        }
                    }
                }
            }
        }
 public void ProcessPacket(DysonSphereAddLayerPacket packet, NebulaConnection conn)
 {
     Log.Info($"Processing DysonSphere Add Layer notification for system {GameMain.data.galaxy.stars[packet.StarIndex].name} (Index: {GameMain.data.galaxy.stars[packet.StarIndex].index})");
     DysonSphere_Manager.IncomingDysonSpherePacket = true;
     GameMain.data.dysonSpheres[packet.StarIndex]?.AddLayer(packet.OrbitRadius, DataStructureExtensions.ToUnity(packet.OrbitRotation), packet.OrbitAngularSpeed);
     DysonSphere_Manager.IncomingDysonSpherePacket = false;
 }
Beispiel #19
0
        public void ProcessPacket(ILSgStationPoolSync packet, NebulaConnection conn)
        {
            GalacticTransport gTransport = GameMain.data.galacticTransport;

            StationComponent[] gStationPool = GameMain.data.galacticTransport.stationPool;

            for (int i = 0; i < packet.stationGId.Length; i++)
            {
                ILSShipManager.CreateFakeStationComponent(packet.stationGId[i], packet.planetId[i], false); // handles array resizing
                gStationPool = GameMain.data.galacticTransport.stationPool;                                 // dont remove or you get an ArrayOutOfBounds

                gStationPool[packet.stationGId[i]].shipDockPos = DataStructureExtensions.ToVector3(packet.DockPos[i]);

                gStationPool[packet.stationGId[i]].shipDockRot = DataStructureExtensions.ToQuaternion(packet.DockRot[i]);

                gStationPool[packet.stationGId[i]].id              = packet.stationId[i];
                gStationPool[packet.stationGId[i]].planetId        = packet.planetId[i];
                gStationPool[packet.stationGId[i]].workShipCount   = packet.workShipCount[i];
                gStationPool[packet.stationGId[i]].idleShipCount   = packet.idleShipCount[i];
                gStationPool[packet.stationGId[i]].workShipIndices = packet.workShipIndices[i];
                gStationPool[packet.stationGId[i]].idleShipIndices = packet.idleShipIndices[i];
                gStationPool[packet.stationGId[i]].shipRenderers   = new ShipRenderingData[ILSShipManager.ILSMaxShipCount];
                gStationPool[packet.stationGId[i]].shipUIRenderers = new ShipUIRenderingData[ILSShipManager.ILSMaxShipCount];

                gStationPool[packet.stationGId[i]].shipDiskPos = new Vector3[ILSShipManager.ILSMaxShipCount];
                gStationPool[packet.stationGId[i]].shipDiskRot = new Quaternion[ILSShipManager.ILSMaxShipCount];

                // theese are the individual landing places for the ships on the station's disk at the top
                for (int j = 0; j < ILSShipManager.ILSMaxShipCount; j++)
                {
                    gStationPool[packet.stationGId[i]].shipDiskRot[j] = Quaternion.Euler(0f, 360f / (float)ILSShipManager.ILSMaxShipCount * (float)j, 0f);
                    gStationPool[packet.stationGId[i]].shipDiskPos[j] = gStationPool[packet.stationGId[i]].shipDiskRot[j] * new Vector3(0f, 0f, 11.5f);
                }
                for (int j = 0; j < ILSShipManager.ILSMaxShipCount; j++)
                {
                    gStationPool[packet.stationGId[i]].shipDiskRot[j] = gStationPool[packet.stationGId[i]].shipDockRot * gStationPool[packet.stationGId[i]].shipDiskRot[j];
                    gStationPool[packet.stationGId[i]].shipDiskPos[j] = gStationPool[packet.stationGId[i]].shipDockPos + gStationPool[packet.stationGId[i]].shipDockRot * gStationPool[packet.stationGId[i]].shipDiskPos[j];
                }
            }

            // thanks Baldy for the fix :D
            // nearly lost all my hairs because of it
            for (int i = 0; i < packet.shipStationGId.Length; i++)
            {
                ShipData shipData = gStationPool[packet.shipStationGId[i]].workShipDatas[i % ILSShipManager.ILSMaxShipCount];
                shipData.stage     = packet.shipStage[i];
                shipData.direction = packet.shipDirection[i];
                shipData.warpState = packet.shipWarpState[i];
                shipData.warperCnt = packet.shipWarperCnt[i];
                shipData.itemId    = packet.shipItemID[i];
                shipData.itemCount = packet.shipItemCount[i];
                shipData.planetA   = packet.shipPlanetA[i];
                shipData.planetB   = packet.shipPlanetB[i];
                shipData.otherGId  = packet.shipOtherGId[i];
                shipData.t         = packet.shipT[i];
                shipData.shipIndex = packet.shipIndex[i];

                shipData.uPos        = DataStructureExtensions.ToVectorLF3(packet.shipPos[i]);
                shipData.uRot        = DataStructureExtensions.ToQuaternion(packet.shipRot[i]);
                shipData.uVel        = DataStructureExtensions.ToVector3(packet.shipVel[i]);
                shipData.uSpeed      = packet.shipSpeed[i];
                shipData.uAngularVel = DataStructureExtensions.ToVector3(packet.shipAngularVel[i]);
                shipData.pPosTemp    = DataStructureExtensions.ToVectorLF3(packet.shipPPosTemp[i]);
                shipData.pRotTemp    = DataStructureExtensions.ToQuaternion(packet.shipPRotTemp[i]);

                gStationPool[packet.shipStationGId[i]].workShipDatas[i % ILSShipManager.ILSMaxShipCount] = shipData;
            }

            gTransport.Arragement();
        }
Beispiel #20
0
        public override void ProcessPacket(DysonSphereAddLayerPacket packet, NebulaConnection conn)
        {
            bool valid = true;

            if (IsHost)
            {
                Player player = playerManager.GetPlayer(conn);
                if (player != null)
                {
                    playerManager.SendPacketToOtherPlayers(packet, player);
                }
                else
                {
                    valid = false;
                }
            }

            if (valid)
            {
                using (DysonSphereManager.IsIncomingRequest.On())
                {
                    GameMain.data.dysonSpheres[packet.StarIndex]?.AddLayer(packet.OrbitRadius, DataStructureExtensions.ToQuaternion(packet.OrbitRotation), packet.OrbitAngularSpeed);
                }
            }
        }