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]); } } class VFXExpressionCastIntToBool : VFXExpression { public VFXExpressionCastIntToBool() : this(VFXValue.Default) {} public VFXExpressionCastIntToBool(VFXExpression from) : base(Flags.None, new VFXExpression[1] { from }) {} sealed public override VFXExpressionOperation operation => VFXExpressionOperation.CastIntToBool; sealed protected override VFXExpression Evaluate(VFXExpression[] reducedParents) { return VFXValue.Constant(reducedParents[0].Get() != 0); } sealed public override string GetCodeString(string[] parents) { return string.Format("(bool){0}", parents[0]); } } class VFXExpressionCastUintToBool : VFXExpression { public VFXExpressionCastUintToBool() : this(VFXValue.Default) { } public VFXExpressionCastUintToBool(VFXExpression from) : base(Flags.None, new VFXExpression[1] { from }) { } sealed public override VFXExpressionOperation operation => VFXExpressionOperation.CastUintToBool; sealed protected override VFXExpression Evaluate(VFXExpression[] reducedParents) { return VFXValue.Constant(reducedParents[0].Get() != 0u); } sealed public override string GetCodeString(string[] parents) { return string.Format("(bool){0}", parents[0]); } } class VFXExpressionCastFloatToBool : VFXExpression { public VFXExpressionCastFloatToBool() : this(VFXValue.Default) { } public VFXExpressionCastFloatToBool(VFXExpression from) : base(Flags.None, new VFXExpression[1] { from }) { } sealed public override VFXExpressionOperation operation => VFXExpressionOperation.CastFloatToBool; sealed protected override VFXExpression Evaluate(VFXExpression[] reducedParents) { return VFXValue.Constant(reducedParents[0].Get() != 0.0f); } sealed public override string GetCodeString(string[] parents) { return string.Format("(bool){0}", parents[0]); } } class VFXExpressionCastBoolToInt : VFXExpression { public VFXExpressionCastBoolToInt() : this(VFXValue.Default) { } public VFXExpressionCastBoolToInt(VFXExpression from) : base(Flags.None, new VFXExpression[1] { from }) { } sealed public override VFXExpressionOperation operation => VFXExpressionOperation.CastBoolToInt; sealed protected override VFXExpression Evaluate(VFXExpression[] reducedParents) { return VFXValue.Constant(reducedParents[0].Get() ? 1 : 0); } sealed public override string GetCodeString(string[] parents) { return string.Format("(int){0}", parents[0]); } } class VFXExpressionCastBoolToUint : VFXExpression { public VFXExpressionCastBoolToUint() : this(VFXValue.Default) { } public VFXExpressionCastBoolToUint(VFXExpression from) : base(Flags.None, new VFXExpression[1] { from }) { } sealed public override VFXExpressionOperation operation => VFXExpressionOperation.CastBoolToUint; sealed protected override VFXExpression Evaluate(VFXExpression[] reducedParents) { return VFXValue.Constant(reducedParents[0].Get() ? 1u : 0u); } sealed public override string GetCodeString(string[] parents) { return string.Format("(uint){0}", parents[0]); } } class VFXExpressionCastBoolToFloat : VFXExpression { public VFXExpressionCastBoolToFloat() : this(VFXValue.Default) { } public VFXExpressionCastBoolToFloat(VFXExpression from) : base(Flags.None, new VFXExpression[1] { from }) { } sealed public override VFXExpressionOperation operation => VFXExpressionOperation.CastBoolToFloat; sealed protected override VFXExpression Evaluate(VFXExpression[] reducedParents) { return VFXValue.Constant(reducedParents[0].Get() ? 1.0f : 0.0f); } sealed public override string GetCodeString(string[] parents) { return string.Format("(float){0}", parents[0]); } } }