/// <summary> /// Initializes a new instance of the <see cref="AddedMutations"/> class. /// </summary> /// <param name="other">The other.</param> public AddedMutations([NotNull] IReadOnlyAddedMutations other) { foreach (IReadOnlyMutationData mData in other) { Add(mData); } }
private int GetMutationDuration(IReadOnlyAddedMutations addedMutations) { const float averageValue = 10; const float averageMaxPossible = 30; float maxTime = 60000 * TF_ANIMAL_DURATION; float minTime = 60000 * TF_ANIMAL_DURATION / 10; float tValue = 0; foreach (IReadOnlyMutationData mutation in addedMutations) { tValue += mutation.Mutation.value; } tValue /= (averageValue * averageMaxPossible); var t = Mathf.Clamp(tValue * maxTime, minTime, maxTime); return(Mathf.RoundToInt(t)); }
private void WindowClosed(Dialog_PartPicker sender, IReadOnlyAddedMutations addedmutations) { sender.WindowClosed -= WindowClosed; if (_innerState != ChamberState.Idle) { Log.Message("state is not idle!"); return; } if (addedmutations?.Any() != true) { return; } _addedMutationData = new AddedMutations(addedmutations); _timer = GetMutationDuration(addedmutations); _currentUse = ChamberUse.Mutation; _innerState = ChamberState.Active; SetActive(); _lastTotal = _timer; sender.Reset(); //remove any mutations left over var pawn = innerContainer.FirstOrDefault() as Pawn; if (pawn == null) { return; } foreach (IReadOnlyMutationData mData in _addedMutationData.Where(m => !m.Removing)) { var hediff = pawn.health?.hediffSet?.hediffs?.FirstOrDefault(h => h.def == mData.Mutation && h.Part == mData.Part) as Hediff_AddedMutation; hediff?.MarkForRemoval(); } SelectorComp.Enabled = false; }
private void WindowClosed(Dialog_PartPicker sender, IReadOnlyAddedMutations addedmutations) { sender.WindowClosed -= WindowClosed; if (_innerState != ChamberState.Idle) { Log.Message("state is not idle!"); return; } if (addedmutations?.Any() != true) { return; } //TODO get wait time based on number of mutations added/removed _timer = Mathf.RoundToInt(TF_ANIMAL_DURATION * 60000); _currentUse = ChamberUse.Mutation; _innerState = ChamberState.Active; _lastTotal = _timer; }