using System; using System.Linq; using System.Runtime.CompilerServices; using UnityEngine; using UnityEngine.VFX; namespace UnityEditor.VFX { class VFXExpressionCastUintToFloat : VFXExpression { public VFXExpressionCastUintToFloat() : this(VFXValue.Default) { } public VFXExpressionCastUintToFloat(VFXExpression from) : base(Flags.None, new VFXExpression[1] { from }) { if (from.valueType != VFXValueType.Uint32) throw new InvalidCastException("Invalid VFXExpressionCastUintToFloat"); } sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.CastUintToFloat; } } sealed protected override VFXExpression Evaluate(VFXExpression[] reducedParents) { return VFXValue.Constant((float)reducedParents[0].Get()); } sealed public override string GetCodeString(string[] parents) { return string.Format("(float){0}", parents[0]); } } class VFXExpressionCastIntToFloat : VFXExpression { public VFXExpressionCastIntToFloat() : this(VFXValue.Default) { } public VFXExpressionCastIntToFloat(VFXExpression from) : base(Flags.None, new VFXExpression[1] { from }) { if (from.valueType != VFXValueType.Int32) throw new InvalidCastException("Invalid VFXExpressionCastIntToFloat"); } sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.CastIntToFloat; } } sealed protected override VFXExpression Evaluate(VFXExpression[] reducedParents) { return VFXValue.Constant((float)reducedParents[0].Get()); } sealed public override string GetCodeString(string[] parents) { return string.Format("(float){0}", parents[0]); } } class VFXExpressionCastFloatToUint : VFXExpression { public VFXExpressionCastFloatToUint() : this(VFXValue.Default) { } public VFXExpressionCastFloatToUint(VFXExpression from) : base(Flags.None, new VFXExpression[1] { from }) { if (from.valueType != VFXValueType.Float) throw new InvalidCastException("Invalid VFXExpressionCastFloatToUint"); } sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.CastFloatToUint; } } sealed protected override VFXExpression Evaluate(VFXExpression[] reducedParents) { return VFXValue.Constant((uint)reducedParents[0].Get()); } sealed public override string GetCodeString(string[] parents) { return string.Format("(uint){0}", parents[0]); } } class VFXExpressionCastIntToUint : VFXExpression { public VFXExpressionCastIntToUint() : this(VFXValue.Default) { } public VFXExpressionCastIntToUint(VFXExpression from) : base(Flags.None, new VFXExpression[1] { from }) { if (from.valueType != VFXValueType.Int32) throw new InvalidCastException("Invalid VFXExpressionCastIntToUint"); } sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.CastIntToUint; } } sealed protected override VFXExpression Evaluate(VFXExpression[] reducedParents) { return VFXValue.Constant((uint)reducedParents[0].Get()); } sealed public override string GetCodeString(string[] parents) { return string.Format("(uint){0}", parents[0]); } } class VFXExpressionCastFloatToInt : VFXExpression { public VFXExpressionCastFloatToInt() : this(VFXValue.Default) { } public VFXExpressionCastFloatToInt(VFXExpression from) : base(Flags.None, new VFXExpression[1] { from }) { if (from.valueType != VFXValueType.Float) throw new InvalidCastException("Invalid VFXExpressionCastFloatToInt"); } sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.CastFloatToInt; } } sealed protected override VFXExpression Evaluate(VFXExpression[] reducedParents) { return VFXValue.Constant((int)reducedParents[0].Get()); } sealed public override string GetCodeString(string[] parents) { return string.Format("(int){0}", parents[0]); } } class VFXExpressionCastUintToInt : VFXExpression { public VFXExpressionCastUintToInt() : this(VFXValue.Default) { } public VFXExpressionCastUintToInt(VFXExpression from) : base(Flags.None, new VFXExpression[1] { from }) { if (from.valueType != VFXValueType.Uint32) throw new InvalidCastException("Invalid VFXExpressionCastUintToInt"); } sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.CastUintToInt; } } sealed protected override VFXExpression Evaluate(VFXExpression[] reducedParents) { return VFXValue.Constant((int)reducedParents[0].Get()); } sealed public override string GetCodeString(string[] parents) { return string.Format("(int){0}", parents[0]); } } }