private void AddAssignmentForInterpolationForVariable(ICodeBlock curBlock, VariableSave variable, ElementSave container) { string memberNameInCode = variable.MemberNameInCode(container, VariableNamesToReplaceForStates); ElementSave categoryContainer; StateSaveCategory stateSaveCategory; if (variable.IsState(container, out categoryContainer, out stateSaveCategory, recursive: false) && !string.IsNullOrEmpty(variable.SourceObject)) { string line = string.Format( "{0}.InterpolateBetween({1}FirstValue, {1}SecondValue, interpolationValue);", SaveObjectExtensionMethods.InstanceNameInCode(variable.SourceObject), memberNameInCode.Replace(".", "")); curBlock.Line(line); } else { switch (variable.Type) { case "int": curBlock.Line(string.Format("{0} = FlatRedBall.Math.MathFunctions.RoundToInt({1}FirstValue* (1 - interpolationValue) + {1}SecondValue * interpolationValue);", memberNameInCode, memberNameInCode.Replace(".", ""))); break; case "float": case "double": curBlock.Line(string.Format("{0} = {1}FirstValue * (1 - interpolationValue) + {1}SecondValue * interpolationValue;", memberNameInCode, memberNameInCode.Replace(".", ""))); break; } } }
public string GetEventName(VariableSave variable, ElementSave container) { if (!string.IsNullOrEmpty(variable.ExposedAsName)) { return($"{variable.ExposedAsName.Replace(" ", "")}Changed"); } else { return($"{variable.MemberNameInCode(container)}Changed"); } }