public void HandleMessage(IServerMessageBase msg) { if (!(msg.Data is VesselFairingMsgData msgData) || !System.FairingSystemReady) { return; } //Vessel might exist in the store but not in game (if the vessel is in safety bubble for example) VesselsProtoStore.UpdateVesselProtoPartFairing(msgData); var vessel = FlightGlobals.FindVessel(msgData.VesselId); if (vessel == null) { return; } var part = VesselCommon.FindProtoPartInProtovessel(vessel.protoVessel, msgData.PartFlightId); if (part != null) { var module = VesselCommon.FindProtoPartModuleInProtoPart(part, "ModuleProceduralFairing"); module?.moduleValues.SetValue("fsm", "st_flight_deployed"); module?.moduleValues.RemoveNodesStartWith("XSECTION"); (module?.moduleRef as ModuleProceduralFairing)?.DeployFairing(); } }
public void SendVesselFairingDeployed(Vessel vessel, uint partFlightId) { if (vessel == null) { return; } var msgData = NetworkMain.CliMsgFactory.CreateNewMessageData <VesselFairingMsgData>(); msgData.VesselId = vessel.id; msgData.PartFlightId = partFlightId; VesselsProtoStore.UpdateVesselProtoPartFairing(msgData); SendMessage(msgData); }
public void HandleMessage(IServerMessageBase msg) { if (!(msg.Data is VesselFairingMsgData msgData) || !System.FairingSystemReady) { return; } //We received a msg for our own controlled/updated vessel so ignore it if (!VesselCommon.DoVesselChecks(msgData.VesselId)) { return; } //Vessel might exist in the store but not in game (if the vessel is in safety bubble for example) VesselsProtoStore.UpdateVesselProtoPartFairing(msgData); var vessel = FlightGlobals.FindVessel(msgData.VesselId); if (vessel == null) { return; } var part = VesselCommon.FindProtoPartInProtovessel(vessel.protoVessel, msgData.PartFlightId); if (part != null) { var module = VesselCommon.FindProtoPartModuleInProtoPart(part, "ModuleProceduralFairing"); module?.moduleValues.SetValue("fsm", "st_flight_deployed"); module?.moduleValues.RemoveNodesStartWith("XSECTION"); try { (module?.moduleRef as ModuleProceduralFairing)?.DeployFairing(); } catch (Exception) { //TODO reload the module } } }