private void InitalizeSerialCommunication() { var serial = new SerialPort("COM4"); serial.Open(); if (serial.BytesToRead > 0) { byte[] buffer = new byte[serial.BytesToRead]; serial.Read(buffer, 0, (int)buffer.Length); } transport = new SerialCommunication(serial); Exiting += delegate { serial.Close(); }; }
public override void EndQuest(Caravan caravan = null, EndCondition condition = EndCondition.None) { base.EndQuest(caravan, condition); var interaction = QuestsManager.Communications.FactionManager.GetInteraction(Faction); if (condition == EndCondition.Timeout) { if (savedPawns != null) { if (saved && savedPawns.Count > 0) { foreach (var pawn in savedPawns) { if (pawn != null && pawn.Faction != Faction) { pawn.SetFaction(Faction); } } Faction.TryAffectGoodwillWith(Faction.OfPlayer, -50); Find.LetterStack.ReceiveLetter("Quest_MissingPeople_ThiefTitle".Translate(), "Quest_MissingPeople_Thief".Translate(), LetterDefOf.NegativeEvent); for (int i = 0; i < QuestsManager.Communications.Components.Count; i++) { CommunicationComponent comp = QuestsManager.Communications.Components[i]; if (comp is ScoutingComp comp2 && comp2.Faction == Faction) { QuestsManager.Communications.RemoveComponent(comp); } } CommOption_GetHelp.AddComponentWithStack(Faction, -999); } if (interaction != null) { interaction.Trust -= 5; } } } if (condition == EndCondition.Fail) { Faction.TryAffectGoodwillWith(Faction.OfPlayer, -25); if (interaction != null) { interaction.Trust -= 15; } } if (condition == EndCondition.Success) { Faction.TryAffectGoodwillWith(Faction.OfPlayer, 20); if (savedPawns != null) { if (interaction != null) { interaction.Trust += savedPawns.Count * 5; } } } }