public void OnFundsChangedHandler(double funds, TransactionReasons reason) { if (funds != this.CurrentFunds) { if (Math.Abs(funds - this.CurrentFunds) < 0.01) { this.CurrentFunds = funds; return; } CurrencyTransaction correction = new CurrencyTransaction( Planetarium.GetUniversalTime(), TransactionReasons.None, (float)(funds - this.CurrentFunds), 0f, 0f ); this.AddTransaction(correction); this.Log("Detected discrepancy in funds totals: admin shows {0}, VCT shows {1}; correcting with {2}.", funds, this.CurrentFunds, correction ); } }
/*************************************************************************************************************************/ void rep_changed(float rep, TransactionReasons reason) { #if DEBUG //if (Debug_Level_1_Active) Log.PushStackInfo("FMRS_Core.rep_changed", "enter rep_changed(float rep, TransactionReasons reason) " + rep.ToString() + " " + reason.ToString()); #endif if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER) { return; } last_rep_change = rep - current_rep; #if DEBUG if (Debug_Active) { Log.Info("rep changed: " + rep.ToString() + " " + last_rep_change.ToString()); } #endif current_rep = rep; #if DEBUG //if (Debug_Level_1_Active) Log.PopStackInfo("leave rep_changed(float rep)"); #endif }
public StatisticsChange(double time, float change, float after, TransactionReasons reason) { Time = time; Change = change; After = after; Reason = reason; }
public void OnScienceChangedHandler(float science, TransactionReasons reason) { if (science != this.CurrentScience) { if (Mathf.Abs(science - this.CurrentScience) < 0.01) { this.CurrentScience = science; return; } CurrencyTransaction correction = new CurrencyTransaction( Planetarium.GetUniversalTime(), TransactionReasons.None, 0f, science - this.CurrentScience, 0f ); this.AddTransaction(correction); this.Log("Detected discrepancy in science totals: R&D shows {0}, VCT shows {1}; correcting with {2}.", science, this.CurrentScience, correction ); } }
public void OnReputationChangedHandler(float reputation, TransactionReasons reason) { if (reputation != this.CurrentReputation) { if (Mathf.Abs(reputation - this.CurrentReputation) < 0.01) { this.CurrentReputation = reputation; return; } CurrencyTransaction correction = new CurrencyTransaction( Planetarium.GetUniversalTime(), TransactionReasons.None, 0f, 0f, reputation - this.CurrentReputation ); this.AddTransaction(correction); this.Log("Detected discrepancy in rep totals: admin shows {0}, VCT shows {1}; correcting with {2}.", reputation, this.CurrentReputation, correction ); } }
private void AddPopup(Currency currency, double amount, TransactionReasons transactionReason, string reason, Transform referencePosition, AnchorType anchorType, bool isDelta, bool isFacility = false) { Popup popup = new Popup(); popup.currency = currency; popup.amount = amount; popup.transactionReason = transactionReason; popup.reason = reason; popup.anchorType = anchorType; popup.referencePosition = referencePosition; popup.isFacility = isFacility; popup.isDelta = isDelta; // Special stuff if (isFacility) { popup.initialized = false; } // Attempt to combine duplicates Popup last = popups.LastOrDefault(); if (last != null && last.currency == currency && last.transactionReason == transactionReason && last.reason == reason) { last.amount += amount; } else { popups.Add(popup); } }
private void OnScienceChanged(float amount, TransactionReasons reason) { if (reason == TransactionReasons.VesselRecovery) { scienceTransmitted += amount; } }
public CurrencyTransaction(double timestamp, TransactionReasons reason, float f0, float s0, float r0) { this.TimeStamp = timestamp; this.Reason = reason; this.FundsDelta = f0; this.ScienceDelta = s0; this.ReputationDelta = r0; }
public static void addFunds(double add, TransactionReasons reason = TransactionReasons.None) { if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER) { return; } global::Funding.Instance.AddFunds(add, reason); }
public static double AdjustFunds(double fundsToAdd, TransactionReasons reason = TransactionReasons.None) { if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER) { Funding.Instance.AddFunds(fundsToAdd, reason); return Funding.Instance.Funds; } return 0; }
public StatisticsChange(string nodeKey) { Vector4 vec = ConfigNode.ParseVector4(nodeKey); Time = vec.x; Change = vec.y; After = vec.z; Reason = (TransactionReasons)vec.w; }
private void OnReputationChanged(float reputation, TransactionReasons reason) { // We only care about vessel loss (= crew killed). if (reason != TransactionReasons.VesselLoss) return; // Reimburse reputation lost when crew is killed. Reputation.Instance.AddReputation(-GameVariables.Instance.reputationKerbalDeath * HighLogic.CurrentGame.Parameters.Career.RepLossMultiplier, TransactionReasons.Any); }
/// <summary> /// Constructor for creating an InvoiceItem. /// </summary> /// <param name="modifier">The IFundingModifierBase that generated this InvoiceItem.</param> /// <param name="revenue">The revenue tied to this invoice.</param> /// <param name="expenses">The expenses tied to this invoice.</param> /// <param name="reason">(Optional parameter) The category for the invoice.</param> public InvoiceItem(IFundingModifierBase modifier, double revenue, double expenses, string itemName = "", TransactionReasons reason = TransactionReasons.None) { Modifier = modifier; Revenue = revenue; Expenses = expenses; InvoiceReason = reason; ItemName = itemName; RegisterEvents(); }
public void ScienceChanged(float science, TransactionReasons reason) { if (System.IgnoreEvents) { return; } System.MessageSender.SendScienceMessage(science, reason.ToString()); }
/// <summary> /// Constructor for creating an InvoiceItem. /// </summary> /// <param name="modifier">The IFundingModifier that generated this InvoiceItem.</param> /// <param name="revenue">The revenue tied to this invoice.</param> /// <param name="expenses">The expenses tied to this invoice.</param> /// <param name="reason">(Optional parameter) The category for the invoice.</param> public InvoiceItem(IFundingModifier modifier, double revenue, double expenses, TransactionReasons reason = TransactionReasons.None) { this.modifier = modifier; InvoiceName = modifier != null? modifier.GetName() : string.Empty; Revenue = revenue; Expenses = expenses; InvoiceReason = reason; RegisterEvents(); }
// We have been billed! Now we can initialise the Refunding on the vessels! private void OnFundsChanged(double amount, TransactionReasons reason) { Log.dbg("OnFundsChanged {0} due {1}", amount, reason); if (!TransactionReasons.VesselRollout.Equals(reason)) { return; } this.ImmediateUpdateAllAndClear(); }
public void FundsChanged(double funds, TransactionReasons reason) { if (System.IgnoreEvents) { return; } LunaLog.Log($"Funds changed to: {funds} reason: {reason}"); System.MessageSender.SendFundsMessage(funds, reason.ToString()); }
public void ReputationChanged(float reputation, TransactionReasons reason) { if (System.IgnoreEvents) { return; } LunaLog.Log($"Reputation changed to: {reputation} reason: {reason}"); System.MessageSender.SendReputationMsg(reputation, reason.ToString()); }
public void FundsChanged(double amount, TransactionReasons reason) { if (!CareerManagerGUI.GetOption(CareerOptions.LOCKFUNDS)) { return; } if (reason != TransactionReasons.Cheating) // we don't want an ugly infinite loop here, do we? { LockMoney(); } }
private void FundsChanged(float changeDelta, TransactionReasons reason) { Debug.Log($"[RP-0] FundsChanged {changeDelta} for {reason}"); _prevFundsChangeAmount = changeDelta; _prevFundsChangeReason = reason; if (reason == TransactionReasons.ContractPenalty || reason == TransactionReasons.ContractDecline || reason == TransactionReasons.ContractAdvance || reason == TransactionReasons.ContractReward) { CurrentPeriod.ContractRewards += changeDelta; return; } if (CareerEventScope.Current?.EventType == CareerEventType.Maintenance) { Debug.Log($"[RP-0] Adding {changeDelta} to maintenance fees"); CurrentPeriod.MaintenanceFees -= changeDelta; return; } if (CareerEventScope.Current?.EventType == CareerEventType.Tooling) { Debug.Log($"[RP-0] Adding {changeDelta} to tooling fees"); CurrentPeriod.ToolingFees -= changeDelta; return; } if (reason == TransactionReasons.VesselRollout || reason == TransactionReasons.VesselRecovery) { Debug.Log($"[RP-0] Adding {changeDelta} to launch fees"); CurrentPeriod.LaunchFees -= changeDelta; return; } if (reason == TransactionReasons.RnDPartPurchase) { Debug.Log($"[RP-0] Adding {changeDelta} to entry costs"); CurrentPeriod.EntryCosts -= changeDelta; return; } if (changeDelta > 0) { Debug.Log($"[RP-0] Adding {changeDelta} to OtherFundsEarned"); CurrentPeriod.OtherFundsEarned += changeDelta; } else { Debug.Log($"[RP-0] Adding {changeDelta} to other fees"); CurrentPeriod.OtherFees -= changeDelta; } }
public void ScienceChanged(float amount, TransactionReasons reason) { if (!CareerManagerGUI.GetOption(CareerOptions.LOCKSCIENCE)) { return; } if (reason != TransactionReasons.Cheating) // we don't want an ugly infinite loop here, do we? { LockScience(); } }
public void ScienceChanged(float amount, TransactionReasons reason) { //bool flag = !this.CareerManagerGUI.GetOption(CareerOptions.LOCKSCIENCE); //if (!flag) if (this.CareerManagerGUI.GetOption(CareerOptions.LOCKSCIENCE)) { bool flag2 = reason != TransactionReasons.Cheating; if (flag2) { this.LockScience(); } } }
public void FundsChanged(double amount, TransactionReasons reason) { //bool flag = !this.CareerManagerGUI.GetOption(CareerOptions.LOCKFUNDS); //if (!flag) if (this.CareerManagerGUI.GetOption(CareerOptions.LOCKFUNDS)) { bool flag2 = reason != TransactionReasons.Cheating; if (flag2) { this.LockMoney(); } } }
private void OnReputationChanged(float totalValue, TransactionReasons reason) { if (reason == TransactionReasons.VesselLoss) { if (!repLoss) { repLoss = true; repEventTimer = Client.realtimeSinceStartup; } repLost += currentRep - totalValue; } currentRep = totalValue; }
private void FundsChanged(float changeDelta, TransactionReasons reason) { if (CareerEventScope.ShouldIgnore) { return; } _prevFundsChangeAmount = changeDelta; _prevFundsChangeReason = reason; if (reason == TransactionReasons.ContractPenalty || reason == TransactionReasons.ContractDecline || reason == TransactionReasons.ContractAdvance || reason == TransactionReasons.ContractReward) { CurrentPeriod.ContractRewards += changeDelta; return; } if (CareerEventScope.Current?.EventType == CareerEventType.Maintenance) { CurrentPeriod.MaintenanceFees -= changeDelta; return; } if (CareerEventScope.Current?.EventType == CareerEventType.Tooling) { CurrentPeriod.ToolingFees -= changeDelta; return; } if (reason == TransactionReasons.VesselRollout || reason == TransactionReasons.VesselRecovery) { CurrentPeriod.LaunchFees -= changeDelta; return; } if (reason == TransactionReasons.RnDPartPurchase) { CurrentPeriod.EntryCosts -= changeDelta; return; } if (changeDelta > 0) { CurrentPeriod.OtherFundsEarned += changeDelta; } else { CurrentPeriod.OtherFees -= changeDelta; } }
public void AddValue(double time, float value, TransactionReasons reason) { var newChange = new StatisticsChange(time, value - previousValue, value, reason); previousValue = CurrentValue(); if (changes.Count > 0 && changes[changes.Count - 1].CanMerge(newChange)) { changes[changes.Count - 1] = changes[changes.Count - 1].MergeWith(newChange); } else { changes.Add(newChange); } SumCutoffIndex = SumCutoffIndex; }
/*************************************************************************************************************************/ void rep_changed(float rep, TransactionReasons reason) { Log.PushStackInfo("FMRS_Core.rep_changed", "enter rep_changed(float rep, TransactionReasons reason) " + rep.ToString() + " " + reason.ToString()); if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER) { return; } last_rep_change = rep - current_rep; Log.dbg("rep changed: {0} {1}", rep, last_rep_change); current_rep = rep; Log.PopStackInfo("leave rep_changed(float rep)"); }
private void rewardLabel(TransactionReasons t, ref Rect r) { float right = 0; switch (t) { case TransactionReasons.ContractAdvance: { GUILayout.Label("Advance: ", CapComSkins.advance, GUILayout.Width(80)); right = 62; break; } case TransactionReasons.ContractPenalty: { GUILayout.Label("Failure: ", CapComSkins.failure, GUILayout.Width(80)); right = 50; break; } case TransactionReasons.ContractReward: { GUILayout.Label("Completion: ", CapComSkins.completion, GUILayout.Width(80)); right = 76; break; } case TransactionReasons.ContractDecline: { GUILayout.Label("Decline: ", CapComSkins.failure, GUILayout.Width(80)); right = 50; break; } default: return; } r = GUILayoutUtility.GetLastRect(); r.x += right; }
private void sizedContent(string funds, string sci, string rep, TransactionReasons type) { bool b1 = string.IsNullOrEmpty(funds); bool b2 = string.IsNullOrEmpty(sci); bool b3 = string.IsNullOrEmpty(rep); if (b1 && b2 && b3) return; Rect r = new Rect(); rewardLabel(type, ref r); GUIStyle s; Vector2 sz = new Vector2(); if (!b1) { r.width = 16; r.height = 16; GUI.DrawTexture(r, currencyIcon(Currency.Funds)); s = currencyStyle(Currency.Funds); sz = s.CalcSize(new GUIContent(funds)); r.x += 20; r.width = sz.x; r.height = sz.y; GUI.Label(r, funds, s); r.x += sz.x + 14; } if (!b2) { r.width = 16; r.height = 16; GUI.DrawTexture(r, currencyIcon(Currency.Science)); s = currencyStyle(Currency.Science); sz = s.CalcSize(new GUIContent(sci)); r.x += 20; r.width = sz.x; r.height = sz.y; GUI.Label(r, sci, s); r.x += sz.x + 14; } if (!b3) { r.width = 16; r.height = 16; GUI.DrawTexture(r, currencyIcon(Currency.Reputation)); s = currencyStyle(Currency.Reputation); sz = s.CalcSize(new GUIContent(rep)); r.x += 20; r.width = sz.x; r.height = sz.y; GUI.Label(r, rep, s); } }
public static double AddFunds(double toAdd, TransactionReasons reason) { if (!CurrentGameIsCareer()) return 0; KCTDebug.Log("Adding funds: " + toAdd + ", New total: " + (Funding.Instance.Funds + toAdd)); Funding.Instance.AddFunds(toAdd, reason); return Funding.Instance.Funds; }
private void OnFundsChanged(double newValue, TransactionReasons reason) { SendScenarioModules(false); }
public void AddScience(float value, TransactionReasons reason);
public void AddPopup(Currency currency, double amount, TransactionReasons transactionReason, string reason, bool isDelta) { AddPopup(currency, amount, transactionReason, reason, null, AnchorType.None, isDelta); }
public static double SpendFunds(double toSpend, TransactionReasons reason) { if (!CurrentGameIsCareer()) return 0; KCTDebug.Log("Removing funds: " + toSpend + ", New total: " + (Funding.Instance.Funds - toSpend)); if (toSpend < Funding.Instance.Funds) Funding.Instance.AddFunds(-toSpend, reason); return Funding.Instance.Funds; }
public static void AddScienceWithMessage(float science, TransactionReasons reason) { if (science > 0) { //ResearchAndDevelopment.Instance.Science += science; ResearchAndDevelopment.Instance.AddScience(science, reason); var message = new ScreenMessage("[KCT] " + science + " science added.", 4.0f, ScreenMessageStyle.UPPER_LEFT); ScreenMessages.PostScreenMessage(message); } }
private void ScienceChanged( float V, TransactionReasons R ) { // _logger.Trace( "Callback: ScienceChanged" ); ScheduleExperimentUpdate( ); }
void OnDoshChanged(double amount, TransactionReasons reason) { //PersistenceUtils.savePersistenceBackup(); }
private void FundsChanged(double finalValue, TransactionReasons reason) { AddValue(Planetarium.GetUniversalTime(), (float)finalValue, reason); }
void OnDoshChanged(double amount, TransactionReasons reason) { // Debug.Log("KK: Funds changed - " + amount + " because " + reason); }
/// <summary> /// Fires every time our Funds change. Logs the transaction, and does some magic to determine /// if the transaction was modified by an active Strategy, and logs that as well. /// </summary> /// <param name="newfunds">The new total Funds balance.</param> /// <param name="reason">The reason this change happened.</param> public void fundsChangedEvent(double newfunds, TransactionReasons reason) { // TODO: funds CAN change without this event firing. WHAT TO DO????? BeanCounter.LogFormatted_DebugOnly("--------- fundsChangedEvent ------------"); // BeanCounter.LogFormatted_DebugOnly("Stack Trace? {0}", System.Environment.StackTrace); double diff = newfunds - OATBeanCounterData.data.funds; BeanCounter.LogFormatted_DebugOnly("Funds changed. New funds: {0:f2}", newfunds); BeanCounter.LogFormatted_DebugOnly("Change amount: {0:f2}", diff); BCTransactionData transaction = new BCTransactionData(true); OATBeanCounterData.data.transactions.Add(transaction); transaction.time = HighLogic.fetch.currentGame.UniversalTime; transaction.reason = reason; transaction.amount = diff; transaction.balance = newfunds; if (currencyModTime == HighLogic.CurrentGame.UniversalTime) { BeanCounter.LogFormatted_DebugOnly(" Checking cached queries. Count: {0}", lastCurrencyMods.Count()); // We now take in to account EVERY modifierquery run on this frame. //CurrencyModifierQuery modquery = lastCurrencyMods.Find( // q => q.GetInput(Currency.Funds) + q.GetEffectDelta(Currency.Funds) == diff); if (lastCurrencyMods.Count() > 0) { // TODO: Record the reason for this transaction in addition to it being a strategy mod float delta = lastCurrencyMods.Sum(q => q.GetEffectDelta(Currency.Funds)); double realcost = diff - delta; BeanCounter.LogFormatted_DebugOnly(" Total modified by queries: Delta: {0}, Real Cost: {1}", delta, realcost); transaction.amount = realcost; transaction.balance = OATBeanCounterData.data.funds - delta; BCTransactionData modtrans = new BCTransactionData(true); OATBeanCounterData.data.transactions.Add(modtrans); modtrans.time = HighLogic.fetch.currentGame.UniversalTime; modtrans.reason = TransactionReasons.Strategies; modtrans.balance = newfunds; modtrans.amount = delta; } } OATBeanCounterData.data.funds = newfunds; // TODO this is awful // Also, it doesn't work anymore? This used to fire after the required events, but now it is before switch (transaction.reason) { case TransactionReasons.VesselRecovery: BCRecoveryData recovery = (from rec in OATBeanCounterData.data.recoveries where rec.time == HighLogic.fetch.currentGame.UniversalTime select rec).SingleOrDefault(); if(recovery != null) { recovery.transactionID = transaction.id; transaction.dataID = recovery.id; } break; case TransactionReasons.VesselRollout: BCLaunchData launch = (from l in OATBeanCounterData.data.launches where l.launchTime == HighLogic.fetch.currentGame.UniversalTime select l).SingleOrDefault(); if(launch != null) { launch.transactionID = transaction.id; transaction.dataID = launch.id; } break; } BeanCounter.LogFormatted_DebugOnly("-------- /fundsChangedEvent ------------"); }
public static string ScienceTransmissionRewardString(float amount, TransactionReasons reason = TransactionReasons.ScienceTransmission);
void OnScienceChanged(float sci, TransactionReasons scitxreason) { if (sstv_on_science_toggle && scitxreason == TransactionReasons.VesselRecovery || scitxreason == TransactionReasons.ScienceTransmission) { science_transmitted = true; if (debugging) Debug.Log("[CHATR] Event scienceTX PASS"); } if (debugging) Debug.Log("[CHATR] Event scienceTX triggered, reason : " + scitxreason.ToString()); }
public void AddFacilityPopup(Currency currency, double amount, TransactionReasons transactionReason, string reason, bool isDelta) { AddPopup(currency, amount, transactionReason, reason, null, AnchorType.Transform, isDelta, true); }
/// <summary> /// Fires every time our Funds change. Logs the transaction, and does some magic to determine /// if the transaction was modified by an active Strategy, and logs that as well. /// </summary> /// <param name="newfunds">The new total Funds balance.</param> /// <param name="reason">The reason this change happened.</param> public void fundsChangedEvent(double newfunds, TransactionReasons reason) { // TODO: funds CAN change without this event firing. WHAT TO DO????? BeanCounter.LogFormatted_DebugOnly("--------- fundsChangedEvent ------------"); // BeanCounter.LogFormatted_DebugOnly("Stack Trace? {0}", System.Environment.StackTrace); double diff = newfunds - OATBeanCounterData.data.funds; BeanCounter.LogFormatted_DebugOnly("Funds changed. New funds: {0:f2}", newfunds); BeanCounter.LogFormatted_DebugOnly("Change amount: {0:f2}", diff); BCTransactionData transaction = new BCTransactionData(true); OATBeanCounterData.data.transactions.Add(transaction); transaction.time = HighLogic.fetch.currentGame.UniversalTime; transaction.reason = reason; transaction.amount = diff; transaction.balance = newfunds; if (currencyModTime == HighLogic.CurrentGame.UniversalTime) { BeanCounter.LogFormatted_DebugOnly(" Checking cached queries. Count: {0}", lastCurrencyMods.Count()); // We now take in to account EVERY modifierquery run on this frame. //CurrencyModifierQuery modquery = lastCurrencyMods.Find( // q => q.GetInput(Currency.Funds) + q.GetEffectDelta(Currency.Funds) == diff); if (lastCurrencyMods.Count() > 0) { // TODO: Record the reason for this transaction in addition to it being a strategy mod float delta = lastCurrencyMods.Sum(q => q.GetEffectDelta(Currency.Funds)); double realcost = diff - delta; BeanCounter.LogFormatted_DebugOnly(" Total modified by queries: Delta: {0}, Real Cost: {1}", delta, realcost); transaction.amount = realcost; transaction.balance = OATBeanCounterData.data.funds - delta; BCTransactionData modtrans = new BCTransactionData(true); OATBeanCounterData.data.transactions.Add(modtrans); modtrans.time = HighLogic.fetch.currentGame.UniversalTime; modtrans.reason = TransactionReasons.Strategies; modtrans.balance = newfunds; modtrans.amount = delta; } } OATBeanCounterData.data.funds = newfunds; // TODO this is awful // Also, it doesn't work anymore? This used to fire after the required events, but now it is before switch (transaction.reason) { case TransactionReasons.VesselRecovery: BCRecoveryData recovery = (from rec in OATBeanCounterData.data.recoveries where rec.time == HighLogic.fetch.currentGame.UniversalTime select rec).SingleOrDefault(); if (recovery != null) { recovery.transactionID = transaction.id; transaction.dataID = recovery.id; } break; case TransactionReasons.VesselRollout: BCLaunchData launch = (from l in OATBeanCounterData.data.launches where l.launchTime == HighLogic.fetch.currentGame.UniversalTime select l).SingleOrDefault(); if (launch != null) { launch.transactionID = transaction.id; transaction.dataID = launch.id; } break; } BeanCounter.LogFormatted_DebugOnly("-------- /fundsChangedEvent ------------"); }
public void AddPopup(Currency currency, double amount, TransactionReasons transactionReason, string reason, Transform referencePosition, bool isDelta) { AddPopup(currency, amount, transactionReason, reason, referencePosition, AnchorType.Transform, isDelta); }
public CurrencyOperationNonZero(Strategy parent, float minValue, float maxValue, Currency currency, CurrencyOperation.Operator op, TransactionReasons AffectReasons, string description) : base(parent, minValue, maxValue, currency, op, AffectReasons, description) { }
private void OnScienceChanged(float data0, TransactionReasons data1) { SendScenarioModules(false); }