internal override bool Read(System.IO.BinaryReader binaryReader, System.Net.EndPoint senderEndPoint, int gameVersion) { if (!base.Read(binaryReader, senderEndPoint, gameVersion)) return NetworkError(); Templates = ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_SmallShipTemplates; if (Templates == null || !Templates.Read(binaryReader, senderEndPoint, gameVersion)) return NetworkError(); return true; }
internal override bool Read(System.IO.BinaryReader binaryReader, System.Net.EndPoint senderEndPoint, int gameVersion) { if (!base.Read(binaryReader, senderEndPoint, gameVersion)) { return(NetworkError()); } Templates = ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_SmallShipTemplates; if (Templates == null || !Templates.Read(binaryReader, senderEndPoint, gameVersion)) { return(NetworkError()); } return(true); }
public static void SaveToServer(bool displaySuccessMessage = false) { MyMwcLog.WriteLine("MySmallShipTemplates.SaveToServer() - START"); MyMwcLog.IncreaseIndent(); List<MyMwcObjectBuilder_SmallShipTemplate> templates = new List<MyMwcObjectBuilder_SmallShipTemplate>(); foreach (var templatesForType in m_templates) { foreach (var template in templatesForType) { template.SavedToServer = true; templates.Add(template.GetObjectBuilder()); } } try { var client = GetSectorServiceClient(); var templatesBuilder = new MyMwcObjectBuilder_SmallShipTemplates(templates); client.SaveSmallShipTemplates(templatesBuilder.ToBytes()); MySectorServiceClient.SafeClose(); MyMwcLog.WriteLine("Save state - OK"); if (displaySuccessMessage) { MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.MESSAGE, Localization.MyTextsWrapperEnum.TemplatesSaveSuccess, Localization.MyTextsWrapperEnum.Success, Localization.MyTextsWrapperEnum.Ok, null)); } } catch (Exception ex) { MyMwcLog.WriteLine("Save state - ERROR"); MyMwcLog.WriteLine(ex.Message); MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, Localization.MyTextsWrapperEnum.TemplatesSaveError, Localization.MyTextsWrapperEnum.Error, Localization.MyTextsWrapperEnum.Ok, null)); } MyMwcLog.DecreaseIndent(); MyMwcLog.WriteLine("MySmallShipTemplates.SaveToServer() - END"); }