public void ReadProfile(IProfile driverProfile) { OCSimulator.LogMessage("Sensor.ReadProfile", "Starting to read profile values"); SimFromValue = Convert.ToDouble(driverProfile.GetValue(SensorName + OCSimulator.SIMFROMVALUE_PROFILENAME, OCSimulator.SimulatorDefaultFromValues[SensorName].ToString(CultureInfo.InvariantCulture)), CultureInfo.InvariantCulture); OCSimulator.LogMessage("Sensor.ReadProfile" + " SimFromValue: " + SimFromValue); SimToValue = Convert.ToDouble(driverProfile.GetValue(SensorName + OCSimulator.SIMTOVALUE_PROFILENAME, OCSimulator.SimulatorDefaultToValues[SensorName].ToString(CultureInfo.InvariantCulture)), CultureInfo.InvariantCulture); OCSimulator.LogMessage("Sensor.ReadProfile" + " SimToValue: " + SimToValue); IsImplemented = Convert.ToBoolean(driverProfile.GetValue(SensorName + OCSimulator.IS_IMPLEMENTED_PROFILENAME, OCSimulator.IS_IMPLEMENTED_DEFAULT), CultureInfo.InvariantCulture); OCSimulator.LogMessage("Sensor.ReadProfile" + " Is Implemented: " + IsImplemented.ToString()); ShowNotReady = Convert.ToBoolean(driverProfile.GetValue(SensorName + OCSimulator.SHOW_NOT_READY_PROFILENAME, OCSimulator.SHOW_NOT_READY_DEFAULT), CultureInfo.InvariantCulture); OCSimulator.LogMessage("Sensor.ReadProfile" + " ShowNotReady: " + ShowNotReady.ToString()); NotReadyDelay = Convert.ToDouble(driverProfile.GetValue(SensorName + OCSimulator.NOT_READY_DELAY_PROFILENAME, OCSimulator.NOT_READY_DELAY_DEFAULT), CultureInfo.InvariantCulture); OCSimulator.LogMessage("Sensor.ReadProfile" + " NotReadyDelay: " + NotReadyDelay.ToString()); ValueCycleTime = Convert.ToDouble(driverProfile.GetValue(SensorName + OCSimulator.VALUE_CYCLE_TIME_PROFILE_NAME, OCSimulator.VALUE_CYCLE_TIME_DEFAULT), CultureInfo.InvariantCulture); OCSimulator.LogMessage("Sensor.ReadProfile" + " Value CycleTime: " + ValueCycleTime.ToString()); Override = Convert.ToBoolean(driverProfile.GetValue(SensorName + OCSimulator.OVERRIDE_PROFILENAME, OCSimulator.OVERRIDE_DEFAULT), CultureInfo.InvariantCulture); OCSimulator.LogMessage("Sensor.ReadProfile" + " Override: " + Override.ToString()); OverrideValue = Convert.ToDouble(driverProfile.GetValue(SensorName + OCSimulator.OVERRIDE_VALUE_PROFILENAME, OCSimulator.SimulatorDefaultFromValues[SensorName].ToString(CultureInfo.InvariantCulture)), CultureInfo.InvariantCulture); OCSimulator.LogMessage("Sensor.ReadProfile" + " OverrideValue: " + OverrideValue.ToString()); OCSimulator.LogMessage("Sensor.ReadProfile", "Completed reading profile values"); }
public void WriteProfile(IProfile driverProfile) { OCSimulator.LogMessage("Sensor.WriteProfile", "Starting to write profile values"); OCSimulator.LogMessage("Sensor.WriteProfile" + " SimFromValue: " + SimFromValue); driverProfile.WriteValue(SensorName + OCSimulator.SIMFROMVALUE_PROFILENAME, SimFromValue.ToString(CultureInfo.InvariantCulture)); OCSimulator.LogMessage("Sensor.WriteProfile" + " SimToValue: " + SimToValue); driverProfile.WriteValue(SensorName + OCSimulator.SIMTOVALUE_PROFILENAME, SimToValue.ToString(CultureInfo.InvariantCulture)); OCSimulator.LogMessage("Sensor.WriteProfile" + " Is Implemented: " + IsImplemented); driverProfile.WriteValue(SensorName + OCSimulator.IS_IMPLEMENTED_PROFILENAME, IsImplemented.ToString(CultureInfo.InvariantCulture)); OCSimulator.LogMessage("Sensor.WriteProfile" + " ShowNotReady: " + ShowNotReady); driverProfile.WriteValue(SensorName + OCSimulator.SHOW_NOT_READY_PROFILENAME, ShowNotReady.ToString(CultureInfo.InvariantCulture)); OCSimulator.LogMessage("Sensor.WriteProfile" + " NotReadyDelay: " + NotReadyDelay); driverProfile.WriteValue(SensorName + OCSimulator.NOT_READY_DELAY_PROFILENAME, NotReadyDelay.ToString(CultureInfo.InvariantCulture)); OCSimulator.LogMessage("Sensor.WriteProfile" + " Value Cycle Time: " + ValueCycleTime); driverProfile.WriteValue(SensorName + OCSimulator.VALUE_CYCLE_TIME_PROFILE_NAME, ValueCycleTime.ToString(CultureInfo.InvariantCulture)); OCSimulator.LogMessage("Sensor.WriteProfile" + " Override: " + Override); driverProfile.WriteValue(SensorName + OCSimulator.OVERRIDE_PROFILENAME, Override.ToString(CultureInfo.InvariantCulture)); OCSimulator.LogMessage("Sensor.WriteProfile" + " OverrideValue: " + OverrideValue); driverProfile.WriteValue(SensorName + OCSimulator.OVERRIDE_VALUE_PROFILENAME, OverrideValue.ToString(CultureInfo.InvariantCulture)); OCSimulator.LogMessage("Sensor.WriteProfile" + " Completed writing profile values"); }
internal static void ApplyOverride(Override obj) { AdvancedLocationLoaderMod.Logger.Log(obj.ToString(), LogLevel.Trace); try { ContentRegistry.RegisterXnb(obj.FileName, obj.FileName); Game1.locations[Game1.locations.FindIndex(l => l.name == obj.MapName)] = (GameLocation)Activator.CreateInstance(Game1.getLocationFromName(obj.MapName).GetType(), Game1.content.Load <xTile.Map>(obj.FileName), obj.MapName); } catch (Exception err) { AdvancedLocationLoaderMod.Logger.ExitGameImmediately("Unable to override location, a unexpected error occured: " + obj.ToString(), err); } }
public override void WriteXml(XmlWriter writer) { writer.WriteAttributeString("override", Override.ToString().ToLower()); StringBuilder configString = new StringBuilder(); foreach (char c in BackingList) { if (configString.Length > 0) { configString.Append(" "); } if (c == '\\' || c == ' ') { configString.Append('\\'); } configString.Append(c); } writer.WriteString(configString.ToString()); }
public override void WriteXml(XmlWriter writer) { writer.WriteAttributeString("override", Override.ToString().ToLower()); foreach (BaseSubstitution baseSubstitution in this) { if (baseSubstitution is AnySubstitution) { writer.WriteStartElement("SubstituteAny"); } else if (baseSubstitution is WholeSubstitution) { writer.WriteStartElement("SubstituteWhole"); } writer.WriteAttributeString("replace", baseSubstitution.Replace); writer.WriteAttributeString("with", baseSubstitution.With); writer.WriteAttributeString("caseSensitive", baseSubstitution.CaseSensitive.ToString().ToLower()); writer.WriteEndElement(); } //writer.WriteString(string.Join(" ", BackingList.ToArray())); }
public override void WriteXml(XmlWriter writer) { writer.WriteAttributeString("override", Override.ToString().ToLower()); writer.WriteString(string.Join(" ", BackingList.ToArray())); }
internal static void ApplyOverride(IContentPack contentPack, Override obj) { try { Game1.locations[Game1.locations.FindIndex(l => l.name == obj.MapName)] = (GameLocation)Activator.CreateInstance(Game1.getLocationFromName(obj.MapName).GetType(), contentPack.LoadAsset <xTile.Map>(obj.FileName), obj.MapName); } catch (Exception err) { ModEntry.Logger.ExitGameImmediately("Unable to override location, a unexpected error occured: " + obj.ToString(), err); } }