public bool LoadSettings() { if (Block?.Storage == null) { return(false); } string rawData; bool loadedSomething = false; CompSettingsValues loadedSettings = null; if (Block.Storage.TryGetValue(Comp.Session.LogicSettingsGuid, out rawData)) { try { var base64 = Convert.FromBase64String(rawData); loadedSettings = MyAPIGateway.Utilities.SerializeFromBinary <CompSettingsValues>(base64); } catch (Exception e) { //Log.Line("Invalid Stettings Loaded, Re-init"); } } if (loadedSettings?.Weapons != null && loadedSettings.Version == VersionControl) { Value = loadedSettings; loadedSomething = true; } else { Value = new CompSettingsValues { Weapons = new WeaponSettingsValues[Comp.Platform.Weapons.Length] }; for (int i = 0; i < Value.Weapons.Length; i++) { Value.Weapons[i] = new WeaponSettingsValues(); } Value.Range = -1; } return(loadedSomething); }
public void Sync(WeaponComponent comp, CompSettingsValues syncFrom) { Guidance = syncFrom.Guidance; Modes = syncFrom.Modes; Range = syncFrom.Range; foreach (var w in comp.Platform.Weapons) { w.UpdateWeaponRange(); } Overrides.Sync(syncFrom.Overrides); if (Overload != syncFrom.Overload || RofModifier != syncFrom.RofModifier || DpsModifier != syncFrom.DpsModifier) { Overload = syncFrom.Overload; RofModifier = syncFrom.RofModifier; WepUi.SetDps(comp, syncFrom.DpsModifier, true); } }
public void Sync(WeaponComponent comp, CompSettingsValues sync) { Guidance = sync.Guidance; Range = sync.Range; SetRange(comp); Overrides.Sync(sync.Overrides); var rofChange = Math.Abs(RofModifier - sync.RofModifier) > 0.0001f; var dpsChange = Math.Abs(DpsModifier - sync.DpsModifier) > 0.0001f; if (Overload != sync.Overload || rofChange || dpsChange) { Overload = sync.Overload; RofModifier = sync.RofModifier; DpsModifier = sync.DpsModifier; if (rofChange) { SetRof(comp); } } }
public override void CleanUp() { base.CleanUp(); Data = null; }