public static bool AddStationComponent_Prefix(GalacticTransport __instance, int planetId, StationComponent station) { if (!SimulatedWorld.Initialized || LocalPlayer.IsMasterClient || LocalPlayer.PatchLocks["GalacticTransport"]) { return(true); } if (!ILSShipManager.AddStationComponentQueue.ContainsKey(planetId)) { ILSShipManager.AddStationComponentQueue.Add(planetId, new List <StationComponent>()); } ILSShipManager.AddStationComponentQueue[planetId].Add(station); LocalPlayer.SendPacket(new ILSAddStationComponentRequest(planetId, station.shipDockPos)); /* * // if we are a client and have a fake station already saved, update it with the full data given now * // this should happen when this client arrives at a planet for the first time whichs interplanetar logistic * // he was already syncing * while (__instance.stationRecycleCursor > 0 && __instance.stationPool[__instance.stationRecycle[__instance.stationRecycleCursor - 1]] != null) * { * Debug.Log("increase because " + (__instance.stationRecycleCursor - 1) + " is ptr to " + __instance.stationRecycle[__instance.stationRecycleCursor - 1] + " which is " + GameMain.galaxy.PlanetById(__instance.stationPool[__instance.stationRecycle[__instance.stationRecycleCursor - 1]].planetId).displayName); * __instance.stationRecycleCursor++; * if(__instance.stationRecycleCursor >= __instance.stationPool.Length) * { * __instance.stationRecycleCursor = 0; * } * } * int debug = 0; * if (__instance.stationRecycleCursor > 0) * { * Debug.Log((__instance.stationPool[__instance.stationRecycle[__instance.stationRecycleCursor - 1]] == null) ? "ITS NULL" : "ITS NOT NULL"); * Debug.Log("recycle " + __instance.stationRecycleCursor); * debug = __instance.stationRecycle[__instance.stationRecycleCursor-1]; * } * else * { * Debug.Log("no recycle"); * debug = __instance.stationCursor; * } * Debug.Log("adding station id " + station.id + " on " + GameMain.galaxy.PlanetById(planetId).displayName + " to gid " + debug); */ /* * for (int i = 0; i < GameMain.data.galacticTransport.stationPool.Length; i++) * { * if(GameMain.data.galacticTransport.stationPool[i]?.id == station.id && GameMain.data.galacticTransport.stationPool[i]?.planetId == planetId) * { * Debug.Log("replacing station " + station.id + " on " + GameMain.galaxy.PlanetById(planetId).displayName + " at gid " + station.gid + " with provided one from server"); * GameMain.data.galacticTransport.stationPool[i] = null; * GameMain.data.galacticTransport.stationRecycle[GameMain.data.galacticTransport.stationRecycleCursor++] = i; * return true; * } * } * // if we are a client and have no fake station then just add the new one normally * // this should happen when a player places an ILS on a FactoryData known to this client * // or when this client arrives at a planet for the first time which contains ILS */ return(true); }
public static void RemoveStationComponent_Postfix(GalacticTransport __instance, int gid) { if (__instance.stationRecycleCursor > 0) { Debug.Log("REM: CURSOR NOW AT: " + __instance.stationCursor + " recycle: " + __instance.stationRecycleCursor + "(" + __instance.stationRecycle[__instance.stationRecycleCursor - 1] + ")"); } else { Debug.Log("REM: CURSOR NOW AT: " + __instance.stationCursor + " recycle: " + __instance.stationRecycleCursor); } }
public void ProcessPacket(ILSShipDataUpdate packet, NebulaConnection conn) { GalacticTransport gTransport = GameMain.data.galacticTransport; if (packet.stationGId < gTransport.stationCursor) { for (int i = 0; i < packet.shipIndex.Length; i++) { gTransport.stationPool[packet.stationGId].workShipDatas[i].shipIndex = packet.shipIndex[i]; gTransport.stationPool[packet.stationGId].workShipDatas[i].otherGId = packet.otherGId[i]; gTransport.stationPool[packet.stationGId].workShipDatas[i].direction = packet.direction[i]; gTransport.stationPool[packet.stationGId].workShipDatas[i].itemId = packet.itemId[i]; } } }
public override void ProcessPacket(ILSRematchRemotePairs packet, NebulaConnection conn) { GalacticTransport gTransport = GameMain.data.galacticTransport; if (packet.GId < gTransport.stationCursor) { for (int i = 0; i < packet.ShipIndex.Length; i++) { if (gTransport.stationPool[packet.GId] != null) { gTransport.stationPool[packet.GId].workShipDatas[packet.ShipIndex[i]].otherGId = packet.OtherGId[i]; gTransport.stationPool[packet.GId].workShipDatas[packet.ShipIndex[i]].direction = packet.Direction[i]; gTransport.stationPool[packet.GId].workShipDatas[packet.ShipIndex[i]].itemId = packet.ItemId[i]; } } } }
public static void AddStationComponent_Postfix(GalacticTransport __instance) { if (__instance.stationRecycleCursor > 0) { Debug.Log("CURSOR NOW AT: " + __instance.stationCursor + " recycle: " + __instance.stationRecycleCursor + "(" + __instance.stationRecycle[__instance.stationRecycleCursor - 1] + ")"); } else { Debug.Log("CURSOR NOW AT: " + __instance.stationCursor + " recycle: " + __instance.stationRecycleCursor); } for (int i = 0; i < __instance.stationPool.Length; i++) { if (__instance.stationPool[i] != null) { Debug.Log(i + ": " + __instance.stationPool[i].gid + " " + __instance.stationPool[i].id + " " + __instance.stationPool[i].planetId); } else { Debug.Log(i + ": null"); } } }
public static bool AddStationComponent_Prefix(GalacticTransport __instance, int planetId, StationComponent station) { if (!SimulatedWorld.Initialized || LocalPlayer.IsMasterClient || ILSShipManager.PatchLockILS) { return(true); } if (!ILSShipManager.AddStationComponentQueue.ContainsKey(planetId)) { ILSShipManager.AddStationComponentQueue.Add(planetId, new List <StationComponent>()); } // use a queue here as we need to wait for the GId sent by server ILSShipManager.AddStationComponentQueue[planetId].Add(station); LocalPlayer.SendPacket(new ILSAddStationComponentRequest(planetId, station.shipDockPos)); // if we are a client and have no fake station then just add the new one normally // this should happen when a player places an ILS on a FactoryData known to this client // or when this client arrives at a planet for the first time which contains ILS //TODO: i think this should be false and only added via ILSAddStationComponentResponseProcessor // but when client builds a ILS on a remote planet the shipDockPos is 0 and thus the checks fail. // all in all there is some investigation needed here return(true); }
public void ProcessPacket(ILSAddStationComponent packet, NebulaConnection conn) { Log.Info($"ILSAddStationComponentProcessor processing packet for planet {packet.PlanetId}, station {packet.StationId} with gId of {packet.StationGId}"); using (ILSShipManager.PatchLockILS.On()) { GalacticTransport galacticTransport = GameMain.data.galacticTransport; if (packet.PlanetId == GameMain.localPlanet?.id) { // If we're on the same planet as the new station was created on, should be able to find // it in our local PlanetTransport.stationPool StationComponent stationComponent = GameMain.localPlanet.factory.transport.stationPool[packet.StationId]; galacticTransport.AddStationComponent(packet.PlanetId, stationComponent); } else { // If we're not on the same planet as the new station was create on, we need to create a // "fake" station that we can put into the GalacticTransport.stationPool instead of a real on ILSShipManager.CreateFakeStationComponent(packet.StationGId, packet.PlanetId, true); } } }
public override void ProcessPacket(ILSShipDataUpdate packet, NebulaConnection conn) { GalacticTransport gTransport = GameMain.data.galacticTransport; if (packet.stationGId < gTransport.stationCursor) { for (int i = 0; i < packet.shipIndex.Length; i++) { /* * fix for #261 * RematchRemotePairs() goes through all GId's on the server, but client may not have a fake/true entry for each one of them * for example if someone places an ILS but never uses it, then other players (except host) would not have an entry for them * in their gStationPool. So skip those */ if (gTransport.stationPool[packet.stationGId] != null) { gTransport.stationPool[packet.stationGId].workShipDatas[i].shipIndex = packet.shipIndex[i]; gTransport.stationPool[packet.stationGId].workShipDatas[i].otherGId = packet.otherGId[i]; gTransport.stationPool[packet.stationGId].workShipDatas[i].direction = packet.direction[i]; gTransport.stationPool[packet.stationGId].workShipDatas[i].itemId = packet.itemId[i]; } } } }
public override void ProcessPacket(ILSAddStationComponent packet, NebulaConnection conn) { Log.Info($"ILSAddStationComponentProcessor processing packet for planet {packet.PlanetId}, station {packet.StationId} with gId of {packet.StationGId}"); using (Multiplayer.Session.Ships.PatchLockILS.On()) { GalacticTransport galacticTransport = GameMain.data.galacticTransport; StationComponent[] stationPool = GameMain.galaxy.PlanetById(packet.PlanetId).factory?.transport.stationPool; if (stationPool != null) { // If we have loaded the factory where the new station was created on, should be able to find // it in our PlanetTransport.stationPool // Assgin gid here so this station will go to galacticTransport.stationPool[gid] stationPool[packet.StationId].gid = packet.StationGId; galacticTransport.AddStationComponent(packet.PlanetId, stationPool[packet.StationId]); } else { // If we haven't loaded the factory the new station was create on, we need to create a // "fake" station that we can put into the GalacticTransport.stationPool instead of a real on Multiplayer.Session.Ships.CreateFakeStationComponent(packet.StationGId, packet.PlanetId, packet.MaxShipCount); } } }
public static bool RemoveStationComponent_Prefix(GalacticTransport __instance, int gid) { return(!SimulatedWorld.Initialized || LocalPlayer.IsMasterClient || ILSShipManager.PatchLockILS); }
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(); }
public override void ProcessPacket(ILSgStationPoolSync packet, NebulaConnection conn) { GalacticTransport gTransport = GameMain.data.galacticTransport; StationComponent[] gStationPool = GameMain.data.galacticTransport.stationPool; int arrayStartPos = 0; for (int i = 0; i < packet.stationGId.Length; i++) { Multiplayer.Session.Ships.CreateFakeStationComponent(packet.stationGId[i], packet.planetId[i], packet.stationMaxShipCount[i], false); // handles array resizing gStationPool = GameMain.data.galacticTransport.stationPool; // dont remove or you get an ArrayOutOfBounds gStationPool[packet.stationGId[i]].shipDockPos = packet.DockPos[i].ToVector3(); gStationPool[packet.stationGId[i]].shipDockRot = packet.DockRot[i].ToQuaternion(); 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[packet.stationMaxShipCount[i]]; gStationPool[packet.stationGId[i]].shipUIRenderers = new ShipUIRenderingData[packet.stationMaxShipCount[i]]; gStationPool[packet.stationGId[i]].shipDiskPos = new Vector3[packet.stationMaxShipCount[i]]; gStationPool[packet.stationGId[i]].shipDiskRot = new Quaternion[packet.stationMaxShipCount[i]]; // these are the individual landing places for the ships on the station's disk at the top for (int j = 0; j < packet.stationMaxShipCount[i]; j++) { gStationPool[packet.stationGId[i]].shipDiskRot[j] = Quaternion.Euler(0f, 360f / packet.stationMaxShipCount[i] * 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 < packet.stationMaxShipCount[i]; 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]; } for (int j = 0; j < packet.stationMaxShipCount[i]; j++) { int index = arrayStartPos + j; ShipData shipData = gStationPool[packet.stationGId[i]].workShipDatas[j]; shipData.stage = packet.shipStage[index]; shipData.direction = packet.shipDirection[index]; shipData.warpState = packet.shipWarpState[index]; shipData.warperCnt = packet.shipWarperCnt[index]; shipData.itemId = packet.shipItemID[index]; shipData.itemCount = packet.shipItemCount[index]; shipData.planetA = packet.shipPlanetA[index]; shipData.planetB = packet.shipPlanetB[index]; shipData.otherGId = packet.shipOtherGId[index]; shipData.t = packet.shipT[index]; shipData.shipIndex = packet.shipIndex[index]; shipData.uPos = packet.shipPos[index].ToVectorLF3(); shipData.uRot = packet.shipRot[index].ToQuaternion(); shipData.uVel = packet.shipVel[index].ToVector3(); shipData.uSpeed = packet.shipSpeed[index]; shipData.uAngularVel = packet.shipAngularVel[index].ToVector3(); shipData.pPosTemp = packet.shipPPosTemp[index].ToVectorLF3(); shipData.pRotTemp = packet.shipRot[index].ToQuaternion(); gStationPool[packet.stationGId[i]].workShipDatas[j] = shipData; } arrayStartPos += packet.stationMaxShipCount[i]; } gTransport.Arragement(); }