public static CustomizationResult SkipModule(Guid vesselId, uint partFlightId, string moduleName, string fieldName, bool receive, out FieldDefinition fieldCustomization) { fieldCustomization = FieldModuleStore.GetCustomFieldDefinition(moduleName, fieldName); if (fieldCustomization.Ignore) { return(CustomizationResult.Ignore); } if (receive) { AddValuesToReceiveDictionaryIfMissing(vesselId, partFlightId, moduleName, fieldName, fieldCustomization); if (!LastReceiveUpdatedDictionary[vesselId][partFlightId][moduleName][fieldName].IntervalIsOk()) { return(CustomizationResult.TooEarly); } LastReceiveUpdatedDictionary[vesselId][partFlightId][moduleName][fieldName].Update(); return(CustomizationResult.Ok); } AddValuesToSendDictionaryIfMissing(vesselId, partFlightId, moduleName, fieldName, fieldCustomization); if (!LastSendUpdatedDictionary[vesselId][partFlightId][moduleName][fieldName].IntervalIsOk()) { return(CustomizationResult.TooEarly); } LastSendUpdatedDictionary[vesselId][partFlightId][moduleName][fieldName].Update(); return(CustomizationResult.Ok); }
public void SendVesselPartSyncMsg(Guid vesselId, uint partFlightId, string moduleName, string baseModuleName, string fieldName, string value) { var msgData = NetworkMain.CliMsgFactory.CreateNewMessageData <VesselPartSyncMsgData>(); msgData.ServerIgnore = FieldModuleStore.GetCustomFieldDefinition(moduleName, fieldName)?.ServerIgnore ?? false; msgData.GameTime = TimeSyncerSystem.UniversalTime; msgData.VesselId = vesselId; msgData.PartFlightId = partFlightId; msgData.ModuleName = moduleName; msgData.BaseModuleName = baseModuleName; msgData.FieldName = fieldName; msgData.Value = value; VesselsProtoStore.UpdateVesselProtoPartModules(msgData); SendMessage(msgData); }
public static CustomizationResult SkipModule(Guid vesselId, uint partFlightId, string moduleName, string fieldName, bool receive, out CustomFieldDefinition fieldCustomization) { fieldCustomization = FieldModuleStore.GetCustomFieldDefinition(moduleName, fieldName); if (fieldCustomization.Ignore) { return(CustomizationResult.Ignore); } if (receive) { try { if (!LastReceiveUpdatedDictionary[vesselId][partFlightId][moduleName][fieldName].IntervalIsOk()) { return(CustomizationResult.TooEarly); } LastReceiveUpdatedDictionary[vesselId][partFlightId][moduleName][fieldName].Update(); return(CustomizationResult.Ok); } catch (Exception) { if (!LastReceiveUpdatedDictionary.ContainsKey(vesselId)) { LastReceiveUpdatedDictionary.Add(vesselId, new Dictionary <uint, Dictionary <string, Dictionary <string, PartSyncUpdateEntry> > >()); } if (!LastReceiveUpdatedDictionary[vesselId].ContainsKey(partFlightId)) { LastReceiveUpdatedDictionary[vesselId].Add(partFlightId, new Dictionary <string, Dictionary <string, PartSyncUpdateEntry> >()); } if (!LastReceiveUpdatedDictionary[vesselId][partFlightId].ContainsKey(moduleName)) { LastReceiveUpdatedDictionary[vesselId][partFlightId].Add(moduleName, new Dictionary <string, PartSyncUpdateEntry>()); } if (!LastReceiveUpdatedDictionary[vesselId][partFlightId][moduleName].ContainsKey(fieldName)) { LastReceiveUpdatedDictionary[vesselId][partFlightId][moduleName].Add(fieldName, new PartSyncUpdateEntry(fieldCustomization.Interval)); } } return(CustomizationResult.Ok); } try { if (!LastSendUpdatedDictionary[vesselId][partFlightId][moduleName][fieldName].IntervalIsOk()) { return(CustomizationResult.TooEarly); } LastSendUpdatedDictionary[vesselId][partFlightId][moduleName][fieldName].Update(); return(CustomizationResult.Ok); } catch (Exception) { if (!LastSendUpdatedDictionary.ContainsKey(vesselId)) { LastSendUpdatedDictionary.Add(vesselId, new Dictionary <uint, Dictionary <string, Dictionary <string, PartSyncUpdateEntry> > >()); } if (!LastSendUpdatedDictionary[vesselId].ContainsKey(partFlightId)) { LastSendUpdatedDictionary[vesselId].Add(partFlightId, new Dictionary <string, Dictionary <string, PartSyncUpdateEntry> >()); } if (!LastSendUpdatedDictionary[vesselId][partFlightId].ContainsKey(moduleName)) { LastSendUpdatedDictionary[vesselId][partFlightId].Add(moduleName, new Dictionary <string, PartSyncUpdateEntry>()); } if (!LastSendUpdatedDictionary[vesselId][partFlightId][moduleName].ContainsKey(fieldName)) { LastSendUpdatedDictionary[vesselId][partFlightId][moduleName].Add(fieldName, new PartSyncUpdateEntry(fieldCustomization.Interval)); } } return(CustomizationResult.Ok); }