private void DisplayModifier(float indent, SimulationModifierProvider provider, SimulationObject context) { string text = string.Empty; if (provider.ModifierDescriptor is SingleSimulationModifierDescriptor) { SingleSimulationModifierDescriptor singleSimulationModifierDescriptor = provider.ModifierDescriptor as SingleSimulationModifierDescriptor; text = text + provider.ModifierDescriptor.Operation.ToString() + " "; text += singleSimulationModifierDescriptor.Value; } else if (provider.ModifierDescriptor is BinarySimulationModifierDescriptor) { BinarySimulationModifierDescriptor binarySimulationModifierDescriptor = provider.ModifierDescriptor as BinarySimulationModifierDescriptor; text += string.Format("{0} ({1} {2} {3})", new object[] { provider.ModifierDescriptor.Operation.ToString(), binarySimulationModifierDescriptor.Left, binarySimulationModifierDescriptor.BinaryOperation.ToString(), binarySimulationModifierDescriptor.Right }); } else if (provider.ModifierDescriptor is CountSimulationModifierDescriptor) { CountSimulationModifierDescriptor countSimulationModifierDescriptor = provider.ModifierDescriptor as CountSimulationModifierDescriptor; text += string.Format("{0} ({1} {2})", provider.ModifierDescriptor.Operation.ToString(), countSimulationModifierDescriptor.Value, countSimulationModifierDescriptor.XmlSerializableCountPath); } provider.DisplayContent = this.IndentedToggle(indent, provider.DisplayContent, text, new object[0]); if (provider.DisplayContent) { indent += 20f; this.IndentedLabel(indent, "Target:", " <b>{0}</b>", new object[] { provider.ModifierDescriptor.TargetPropertyName }); this.IndentedLabel(indent, "Operation:", " <b>{0}</b>", new object[] { provider.ModifierDescriptor.Operation.ToString() }); this.IndentedLabel(indent, "Value:", " <b>{0}</b>", new object[] { provider.ModifierDescriptor.ComputeValue(context, provider.DescriptorHolder.Context, SimulationPropertyRefreshContext.GetContext(-1)).ToString() }); this.IndentedLabel(indent, "Path:", " <b>{0}</b>", new object[] { provider.ModifierDescriptor.Path.ToString() }); this.IndentedLabel(indent, "Source:", " <b>{0} ({1})</b>", new object[] { provider.DescriptorHolder.Context.Name, provider.DescriptorHolder.Descriptor.Name }); indent -= 20f; } }
internal float Process(SimulationPropertyRefreshContext propertyRefreshContext, SimulationModifierProvider provider, SimulationObject target) { float num = 0f; if (this.ValueMustBePositive && propertyRefreshContext.InternalCurrentValue < 0f) { return(0f); } float num2 = this.ComputeValue(target, provider.InternalDescriptorHolder.Context, propertyRefreshContext); float num3 = propertyRefreshContext.InternalCurrentValue; switch (this.Operation) { case SimulationModifierDescriptor.ModifierOperation.Force: num = num2; propertyRefreshContext.InternalCurrentValue = num2; propertyRefreshContext.InternalPercentBaseValue = num2; num3 = 0f; break; case SimulationModifierDescriptor.ModifierOperation.Addition: if (this.MultiplicativeStacking) { num = propertyRefreshContext.InternalCurrentValue + (1f - propertyRefreshContext.InternalCurrentValue) * num2; propertyRefreshContext.InternalPercentBaseValue = num; propertyRefreshContext.InternalCurrentValue = num; } else { num = propertyRefreshContext.InternalCurrentValue + num2; propertyRefreshContext.InternalPercentBaseValue = num; propertyRefreshContext.InternalCurrentValue = num; } break; case SimulationModifierDescriptor.ModifierOperation.Subtraction: num = propertyRefreshContext.InternalCurrentValue - num2; propertyRefreshContext.InternalPercentBaseValue = num; propertyRefreshContext.InternalCurrentValue = num; break; case SimulationModifierDescriptor.ModifierOperation.Multiplication: num = propertyRefreshContext.InternalCurrentValue * num2; propertyRefreshContext.InternalPercentBaseValue = num; propertyRefreshContext.InternalCurrentValue = num; break; case SimulationModifierDescriptor.ModifierOperation.Division: if (num2 != 0f) { num = propertyRefreshContext.InternalCurrentValue / num2; propertyRefreshContext.InternalPercentBaseValue = num; propertyRefreshContext.InternalCurrentValue = num; } break; case SimulationModifierDescriptor.ModifierOperation.Power: num = Mathf.Pow(propertyRefreshContext.InternalCurrentValue, num2); propertyRefreshContext.InternalPercentBaseValue = num; propertyRefreshContext.InternalCurrentValue = num; break; case SimulationModifierDescriptor.ModifierOperation.Percent: num = propertyRefreshContext.InternalCurrentValue + propertyRefreshContext.InternalPercentBaseValue * num2; propertyRefreshContext.InternalCurrentValue = num; break; case SimulationModifierDescriptor.ModifierOperation.Maximum: num = ((propertyRefreshContext.InternalCurrentValue >= num2) ? propertyRefreshContext.InternalCurrentValue : num2); propertyRefreshContext.InternalPercentBaseValue = num; propertyRefreshContext.InternalCurrentValue = num; break; case SimulationModifierDescriptor.ModifierOperation.Minimum: num = ((propertyRefreshContext.InternalCurrentValue <= num2) ? propertyRefreshContext.InternalCurrentValue : num2); propertyRefreshContext.InternalPercentBaseValue = num; propertyRefreshContext.InternalCurrentValue = num; break; } return(num - num3); }
protected float GetValue(object value, SimulationObject context, SimulationObject modifierSource, SimulationPropertyRefreshContext propertyRefreshContext) { if (value is float) { return((float)value); } if (!(value is StaticString)) { return(0f); } if (this.IsBindOnSource) { modifierSource.Unsafe_PropertyRefresh(value as StaticString, propertyRefreshContext.InternalRequestId); return(modifierSource.Unsafe_GetPropertyValue(value as StaticString)); } context.Unsafe_PropertyRefresh(value as StaticString, propertyRefreshContext.InternalRequestId); return(context.Unsafe_GetPropertyValue(value as StaticString)); }
public abstract float ComputeValue(SimulationObject context, SimulationObject source, SimulationPropertyRefreshContext propertyRefreshContext);