Inheritance: MonoBehaviour
        /// <summary>
        /// Renders the specified Emitter, applying the specified transformation offset.
        /// </summary>
        public override void RenderEmitter(Emitter emitter, ref Matrix transform)
        {
            Guard.ArgumentNull("emitter", emitter);
            Guard.IsTrue(this.Batch == null, "SpriteBatchRenderer is not ready! Did you forget to LoadContent?");

            if (emitter.ParticleTexture != null && emitter.ActiveParticlesCount > 0)
            {
                // Bail if the emitter blend mode is "None"...
                if (emitter.BlendMode == EmitterBlendMode.None)
                    return;

                // Calculate the source rectangle and origin offset of the Particle texture...
                Rectangle source = new Rectangle(0, 0, emitter.ParticleTexture.Width, emitter.ParticleTexture.Height);
                Vector2 origin = new Vector2(source.Width / 2f, source.Height / 2f);

                BlendState blendState = this.GetBlendState(emitter.BlendMode);

                this.Batch.Begin(SpriteSortMode.Deferred, blendState);

                for (int i = 0; i < emitter.ActiveParticlesCount; i++)
                {
                    Particle particle = emitter.Particles[i];

                    float scale = particle.Scale / emitter.ParticleTexture.Width;

                    this.Batch.Draw(emitter.ParticleTexture, particle.Position, source, new Color(particle.Colour), particle.Rotation, origin, scale, SpriteEffects.None, 0f);
                }

                this.Batch.End();
            }
        }
Ejemplo n.º 2
0
 public void ListenersWithoutHandlers()
 {
     LogManager.SetupLogManager();
     var emitter = new Emitter();
     var expected = new IListener[] {};
     Assert.Equal(expected, emitter.Listeners("foo").ToArray());
 }
Ejemplo n.º 3
0
        public override void Compile(Emitter.Emitter emitter)
        {
            var method = emitter.AssemblyImport(typeof(MirelleStdlib.Events.Simulation).GetMethod("Process", new[] { typeof(int), typeof(int) }));

              // processor count
              if(Processors == null)
            emitter.EmitLoadInt(1);
              else
              {
            if(Processors.GetExpressionType(emitter) != "int")
              Error(Resources.errSimulateProcessorsInt);

            Processors.Compile(emitter);
              }

              // queue length
              if(MaxQueue == null)
            emitter.EmitLoadInt(0);
              else
              {
            if(MaxQueue.GetExpressionType(emitter) != "int")
              Error(Resources.errSimulateQueueInt);

            MaxQueue.Compile(emitter);
              }

              emitter.EmitCall(method);
        }
 public void TestHostedInstance()
 {
     var r = GetRealSink();
     var emitter = new Emitter(r);
     var evt = CreateIdSrvEvent(DateTimeOffset.UtcNow);
     emitter.Emit(evt);
 }
Ejemplo n.º 5
0
        public override void Compile(Emitter.Emitter emitter)
        {
            var leftType = Left.GetExpressionType(emitter);
              var rightType = Right.GetExpressionType(emitter);

              var type = GetExpressionType(emitter);

              // subtract matrices
              if(type == "matrix")
              {
            Left.Compile(emitter);
            Right.Compile(emitter);

            var matrixType = typeof(MN.Matrix<double>);
            var method = emitter.AssemblyImport(matrixType.GetMethod("Subtract", new [] { matrixType } ));
            emitter.EmitCall(method);
              }

              // subtract dicts
              else if (type == "dict")
              {
            Left.Compile(emitter);
            Right.Compile(emitter);

            var dictType = typeof(Dict);
            var method = emitter.AssemblyImport(dictType.GetMethod("Subtract", new[] { dictType }));
            emitter.EmitCall(method);
              }

              // subtract complex numbers
              else if (type == "complex")
              {
            Left.Compile(emitter);
            if (leftType != "complex")
            {
              emitter.EmitUpcastBasicType(leftType, "float");
              emitter.EmitLoadFloat(0);
              emitter.EmitNewObj(emitter.FindMethod("complex", ".ctor", "float", "float"));
            }

            Right.Compile(emitter);
            if (rightType != "complex")
            {
              emitter.EmitUpcastBasicType(rightType, "float");
              emitter.EmitLoadFloat(0);
              emitter.EmitNewObj(emitter.FindMethod("complex", ".ctor", "float", "float"));
            }

            emitter.EmitCall(emitter.AssemblyImport(typeof(SN.Complex).GetMethod("op_Subtraction", new[] { typeof(SN.Complex), typeof(SN.Complex) })));
              }
              // add floating point numbers or integers
              else if (type.IsAnyOf("int", "float"))
              {
            Left.Compile(emitter);
            emitter.EmitUpcastBasicType(leftType, type);
            Right.Compile(emitter);
            emitter.EmitUpcastBasicType(rightType, type);
            emitter.EmitSub();
              }
        }
Ejemplo n.º 6
0
        public override string GetExpressionType(Emitter.Emitter emitter)
        {
            if (ExpressionType != "")
            return ExpressionType;

              var leftType = Left.GetExpressionType(emitter);
              var rightType = Right.GetExpressionType(emitter);

              // mathematic operations
              var supportedTypes = new[] { "int", "float", "complex" };

              // subtract matrices
              if (leftType == "matrix" && rightType == "matrix")
            ExpressionType = "matrix";

              // subtract dicts
              else if (leftType == "dict" && rightType == "dict")
            ExpressionType = "dict";

              else if (leftType.IsAnyOf(supportedTypes) && rightType.IsAnyOf(supportedTypes))
              {
            if ("complex".IsAnyOf(leftType, rightType))
              ExpressionType = "complex";
            else if ("float".IsAnyOf(leftType, rightType))
              ExpressionType = "float";
            else
              ExpressionType = "int";
              }
              else
            Error(String.Format(Resources.errOperatorTypesMismatch, "-", leftType, rightType));

              return ExpressionType;
        }
Ejemplo n.º 7
0
		static MethodDefinition CreateTestMethod(Emitter emitter)
		{
			TypeReference type = new TypeReference("", "Test", null, null);
			MethodDefinition test = new MethodDefinition("Test", MethodAttributes.Public, type);
			emitter(test.Body.GetILProcessor());
			return test;
		}
Ejemplo n.º 8
0
        public override void Compile(Emitter.Emitter emitter)
        {
            var numTypes = new[] { "int", "float" };

              var fromType = From.GetExpressionType(emitter);
              var toType = To.GetExpressionType(emitter);
              var stepType = Step.GetExpressionType(emitter);

              // validate parameters
              if (!fromType.IsAnyOf(numTypes) || !toType.IsAnyOf(numTypes) || !stepType.IsAnyOf(numTypes))
            Error(Resources.errIntFloatExpected);

              // from, to, step
              From.Compile(emitter);
              if (fromType != "float")
            emitter.EmitConvertToFloat();

              To.Compile(emitter);
              if (toType != "float")
            emitter.EmitConvertToFloat();

              Step.Compile(emitter);
              if (stepType != "float")
            emitter.EmitConvertToFloat();

              // invoke method
              var method = typeof(MirelleStdlib.ArrayHelper).GetMethod("CreateRangedArray", new[] { typeof(double), typeof(double), typeof(double) });
              emitter.EmitCall(emitter.AssemblyImport(method));
        }
Ejemplo n.º 9
0
        public override void Compile(Emitter.Emitter emitter)
        {
            foreach (var curr in Types)
            Types[curr].Compile(emitter);

              GlobalMethod.Compile(emitter);
        }
Ejemplo n.º 10
0
        public override void Compile(Emitter.Emitter emitter)
        {
            // ensure this is a matrix
              if (ExpressionPrefix.GetExpressionType(emitter) != "matrix")
            Error(Resources.errIndexingNotAMatrix);

              // ensure indexes are integers
              if (Index1.GetExpressionType(emitter) != "int")
            Error(Resources.errIntIndexExpected, Index1.Lexem);

              if (Index2.GetExpressionType(emitter) != "int")
            Error(Resources.errIntIndexExpected, Index2.Lexem);

              // ensure assigned value is either int or float
              var exprType = Expression.GetExpressionType(emitter);
              if (!exprType.IsAnyOf("int", "float"))
            Error(Resources.errMatrixItemTypeMismatch);

              ExpressionPrefix.Compile(emitter);

              Index1.Compile(emitter);
              Index2.Compile(emitter);

              Expression.Compile(emitter);
              if(exprType != "float")
            emitter.EmitConvertToFloat();

              var method = emitter.AssemblyImport(typeof(MN.DenseMatrix).GetMethod("At", new[] { typeof(int), typeof(int), typeof(double) }));
              emitter.EmitCall(method);
        }
Ejemplo n.º 11
0
        public override void Compile(Emitter.Emitter emitter)
        {
            try
              {
            Resolve(emitter);

            if (!emitter.TypeIsParent(IdentifierType, Expression.GetExpressionType(emitter)))
              Error(String.Format(Resources.errAssignTypeMismatch, Expression.GetExpressionType(emitter), IdentifierType));
              }
              catch(CompilerException ex)
              {
            ex.AffixToLexem(Lexem);
            throw;
              }

              switch (Kind)
              {

            case IdentifierKind.StaticField:  Expression.Compile(emitter);
                                          emitter.EmitSaveField(emitter.FindField(OwnerType, Name)); break;

            case IdentifierKind.Field:        if (ExpressionPrefix != null)
                                            ExpressionPrefix.Compile(emitter);
                                          else
                                            emitter.EmitLoadThis();
                                          Expression.Compile(emitter);
                                          emitter.EmitSaveField(emitter.FindField(OwnerType, Name)); break;

            case IdentifierKind.Variable:     Expression.Compile(emitter);
                                          emitter.EmitSaveVariable(emitter.CurrentMethod.Scope.Find(Name)); break;

            case IdentifierKind.Parameter:    Expression.Compile(emitter);
                                          emitter.EmitSaveParameter(emitter.CurrentMethod.Parameters[Name].Id); break;
              }
        }
Ejemplo n.º 12
0
        public override void Compile(Emitter.Emitter emitter)
        {
            var leftType = Left.GetExpressionType(emitter);
              var rightType = Right.GetExpressionType(emitter);

              // an array of values
              if (rightType == leftType + "[]")
              {
            Right.Compile(emitter);
            Left.Compile(emitter);
            if (leftType.IsAnyOf("int", "bool", "float", "complex"))
              emitter.EmitBox(emitter.ResolveType(leftType));

            var method = typeof(MirelleStdlib.ArrayHelper).GetMethod("Has", new[] { typeof(object), typeof(object) });
            emitter.EmitCall(emitter.AssemblyImport(method));
              }

              // an object has a "has" method that accepts the lefthand expression
              else
              {
            try
            {
              Expr.IdentifierInvoke("has", Right, Left).Compile(emitter);
              return;
            }
            catch { }

            Error(String.Format(Resources.errOperatorTypesMismatch, "in", leftType, rightType));
              }
        }
Ejemplo n.º 13
0
        public override void Compile(Emitter.Emitter emitter)
        {
            // declare variables and methods
              var tmpVar = emitter.CurrentMethod.Scope.Introduce("dict", emitter.ResolveType("dict"));
              var ctor = emitter.AssemblyImport(typeof(MirelleStdlib.Dict).GetConstructor(new Type[] { }));
              var set = emitter.FindMethod("dict", "set", "string", "string");

              // var tmp = new dict
              emitter.EmitNewObj(ctor);
              emitter.EmitSaveVariable(tmpVar);

              // tmp[key] = value
              foreach(var curr in Data)
              {
            var keyType = curr.Item1.GetExpressionType(emitter);
            var valueType = curr.Item2.GetExpressionType(emitter);

            if (keyType != "string")
              Error(Resources.errDictItemTypeMismatch, curr.Item1.Lexem);

            if (valueType != "string")
              Error(Resources.errDictItemTypeMismatch, curr.Item2.Lexem);

            emitter.EmitLoadVariable(tmpVar);
            curr.Item1.Compile(emitter);
            curr.Item2.Compile(emitter);
            emitter.EmitCall(set);
              }

              emitter.EmitLoadVariable(tmpVar);
        }
Ejemplo n.º 14
0
        public void CompileArray(Emitter.Emitter emitter)
        {
            // make sure it's an array
              var type = emitter.GetArrayItemType(ExpressionPrefix.GetExpressionType(emitter));
              if (type == "")
            Error(Resources.errIndexingNotAnArray);

              // make sure expression type matches array type
              var exprType = Expression.GetExpressionType(emitter);
              if (!emitter.TypeIsParent(type, exprType))
            Error(String.Format(Resources.errAssignTypeMismatch, exprType, type));

              ExpressionPrefix.Compile(emitter);
              Index.Compile(emitter);

              if (type == "complex")
              {
            // special case of valuetypes
            var typeRef = emitter.ResolveType(type);
            emitter.EmitLoadIndexAddress(typeRef);
            Expression.Compile(emitter);
            emitter.EmitSaveObject(typeRef);
              }
              else
              {
            Expression.Compile(emitter);
            emitter.EmitSaveIndex(type);
              }
        }
Ejemplo n.º 15
0
        public override void Compile(Emitter.Emitter emitter)
        {
            if (emitter.CurrentLoop == null)
            Error(Resources.errBreakRedoOutsideLoop);

              emitter.EmitBranch(emitter.CurrentLoop.BodyStart);
        }
Ejemplo n.º 16
0
        public override void Compile(Emitter.Emitter emitter)
        {
            try
              {
            Resolve(emitter);
              }
              catch (CompilerException ex)
              {
            ex.AffixToLexem(Lexem);
            throw;
              }

              var method = emitter.FindMethod(OwnerType, Name, GetSignature(emitter));

              // load 'this'
              if (ExpressionPrefix != null)
            ExpressionPrefix.Compile(emitter);
              else if (!Static)
            emitter.EmitLoadThis();

              // load parameters
              for (int idx = 0; idx < Parameters.Count; idx++)
              {
            Parameters[idx].Compile(emitter);
            emitter.EmitUpcastBasicType(Parameters[idx].GetExpressionType(emitter), method.Parameters[idx].Type.Signature);
              }

              // invoke
              emitter.EmitCall(method);
        }
Ejemplo n.º 17
0
        public override void Compile(Emitter.Emitter emitter)
        {
            // check for variable definitions being the only expressions in a block
              if (Statements.Count == 1 && (Statements[0] is VarDeclarationNode || Statements[0] is VarSplatNode))
            Error(Resources.errVariableDefinitionOnly, Statements[0].Lexem);

              emitter.CurrentMethod.Scope.EnterSubScope();

              foreach (var curr in Statements)
              {
            curr.Compile(emitter);

            // eliminate dead code
            if (curr is ReturnNode || (curr is IfNode && (curr as IfNode).AllPathsReturn))
            {
              AllPathsReturn = true;
              break;
            }

            // remove clutter from stack
            if (!curr.GetExpressionType(emitter).IsAnyOf("", "void"))
              emitter.EmitPop();
              }

              emitter.CurrentMethod.Scope.LeaveSubScope();
        }
Ejemplo n.º 18
0
 public override void Compile(Emitter.Emitter emitter)
 {
     var type = ExpressionPrefix.GetExpressionType(emitter);
       if (type == "dict")
     CompileDict(emitter);
       else
     CompileArray(emitter);
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Renders the specified Emitter.
        /// </summary>
        public virtual void RenderEmitter(Emitter emitter)
        {
            Guard.ArgumentNull("emitter", emitter);

            Matrix ident = Matrix.Identity;

            this.RenderEmitter(emitter, ref ident);
        }
Ejemplo n.º 20
0
        public void Emit(Emitter e)
        {
            Expr.Emit(e);
            e.EmitLine("stloc " + id);

            if (ExprMode)
                e.EmitLine("ldloc " + id);
        }
Ejemplo n.º 21
0
        public void HasListenersWithoutHandlers()
        {
            var log = LogManager.GetLogger(Global.CallerName());
            log.Info("Start");

            var emitter = new Emitter();
            Assert.AreEqual(false, emitter.HasListeners("foo"));
        }
Ejemplo n.º 22
0
 public void ListenersWithoutHandlers()
 {
     var emitter = new Emitter();
     var expected = new IListener[] {};
     //Assert.AreEqual(expected, emitter.Listeners("foo").ToArray());
     Assert.AreEqual(expected.Count(), emitter.Listeners("foo").ToArray().Count());
     CollectionAssert.AreEqual(expected, emitter.Listeners("foo").ToArray());
 }
Ejemplo n.º 23
0
        public override void Compile(Emitter.Emitter emitter)
        {
            var leftType = Left.GetExpressionType(emitter);
              var rightType = Right.GetExpressionType(emitter);

              var type = GetExpressionType(emitter);

              // divide matrix by a number
              if(type == "matrix")
              {
            Left.Compile(emitter);

            // division is broken, therefore multiply by an inverse value
            emitter.EmitLoadFloat(1);
            Right.Compile(emitter);

            if (rightType != "float")
              emitter.EmitConvertToFloat();

            emitter.EmitDiv();

            var matrixType = typeof(MN.Matrix<double>);
            var method = emitter.AssemblyImport(matrixType.GetMethod("Multiply", new[] { typeof(double) }));
            emitter.EmitCall(method);
              }

              // divide complex numbers
              else if (type == "complex")
              {
            Left.Compile(emitter);
            if (leftType != "complex")
            {
              emitter.EmitUpcastBasicType(leftType, "float");
              emitter.EmitLoadFloat(0);
              emitter.EmitNewObj(emitter.FindMethod("complex", ".ctor", "float", "float"));
            }

            Right.Compile(emitter);
            if (rightType != "complex")
            {
              emitter.EmitUpcastBasicType(rightType, "float");
              emitter.EmitLoadFloat(0);
              emitter.EmitNewObj(emitter.FindMethod("complex", ".ctor", "float", "float"));
            }

            emitter.EmitCall(emitter.AssemblyImport(typeof(SN.Complex).GetMethod("op_Division", new[] { typeof(SN.Complex), typeof(SN.Complex) })));
              }

              // divide floating point numbers or integers
              else if (type.IsAnyOf("int", "float"))
              {
            Left.Compile(emitter);
            emitter.EmitUpcastBasicType(leftType, type);
            Right.Compile(emitter);
            emitter.EmitUpcastBasicType(rightType, type);
            emitter.EmitDiv();
              }
        }
 public void Map(IDictionary<string, object> document, Emitter emitter)
 {
     bool vacant = (bool)document.Get("vacant");
     string name = (string)document.Get("name");
     if (vacant && name != null)
     {
         emitter.Emit(name, vacant);
     }
 }
Ejemplo n.º 25
0
        public void HasListenersWithoutHandlers()
        {
            LogManager.SetupLogManager();
            var log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod());
            log.Info("Start");

            var emitter = new Emitter();
            Assert.Equal(false, emitter.HasListeners("foo"));
        }
Ejemplo n.º 26
0
        public override string GetExpressionType(Emitter.Emitter emitter)
        {
            if (Expression == null) return "void";

              if(ExpressionType == "")
            ExpressionType = Expression.GetExpressionType(emitter);

              return ExpressionType;
        }
Ejemplo n.º 27
0
        public override void Compile(Emitter.Emitter emitter)
        {
            if (Expression.GetExpressionType(emitter) != "bool")
            Error(Resources.errBoolExpected);

              Expression.Compile(emitter);
              emitter.EmitLoadBool(false);
              emitter.EmitCompareEqual();
        }
 /// <summary>
 /// Creates an instance of the Transmitter class that can be used to transmit IR codes.
 /// </summary>
 /// <param name="defaultEmitter">The emitter to transmit the IR code with</param>
 /// <param name="defaultCodeFormat">The format of the IR code.</param>
 /// <param name="defaultRepeatCount">Indicates how many iterations of the code should be 
 /// sent (in the case of a 2-piece code, the first stream is sent once followed 
 /// by the second stream sent repeatCount times).</param>
 /// <param name="defaultInactivityWaitTime">Time in milliseconds since the last received 
 /// IR activity to wait before sending an IR code. Normally, pass 0 for this parameter.</param>
 /// <remarks>This class should be disposed if using this constructor.</remarks>
 public Transmitter(Emitter defaultEmitter = Emitter.All, 
     CodeFormat defaultCodeFormat = CodeFormat.Pronto,
     int defaultRepeatCount = 1,
     int defaultInactivityWaitTime = 0)
 {
     _defaultEmitter = defaultEmitter;
     _defaultCodeFormat = defaultCodeFormat;
     _defaultRepeatCount = defaultRepeatCount;
     _defaultInactivityWaitTime = defaultInactivityWaitTime;
 }
Ejemplo n.º 29
0
 public Fireball(Texture2D[] textures, Vector2 position, Vector2 direction, FireballConfig config = null)
     : this(position, direction, config)
 {
     Random = new Random((int) (textures.GetHashCode() + position.GetHashCode() + direction.GetHashCode() + DateTime.Now.Ticks));
     _one = new Emitter(textures);
     _two = new Emitter(textures);
     _three = new Emitter(textures);
     _smokeOne = new Emitter(textures);
     _smokeTwo = new Emitter(textures);
 }
Ejemplo n.º 30
0
        public override string GetExpressionType(Emitter.Emitter emitter)
        {
            if (ExpressionType == "")
              {
            if (Values.Count > 0)
              ExpressionType = Values[0].GetExpressionType(emitter) + "[]";
              }

              return ExpressionType;
        }
Ejemplo n.º 31
0
 public override void PreUpdate(Emitter emitter, float time)
 {
     _limitSq = Limit * Limit;
 }
Ejemplo n.º 32
0
    protected void Init()
    {
        //added 2012.6.24
        InitCollision();

        Owner = transform.parent.gameObject.GetComponent <XffectComponent>();
        if (Owner == null)
        {
            Debug.LogError("you must set EffectLayer to be XffectComponent's child.");
        }

        //fixed 2012.6.2. ignoring the red errors.
        if (ClientTransform == null)
        {
            Debug.LogWarning("effect layer: " + gameObject.name + " haven't assign a client transform, automaticly set to itself.");
            ClientTransform = transform;
        }
        AvailableENodes = new EffectNode[MaxENodes];
        ActiveENodes    = new EffectNode[MaxENodes];
        for (int i = 0; i < MaxENodes; i++)
        {
            EffectNode      n    = new EffectNode(i, ClientTransform, SyncClient, this);
            List <Affector> afts = InitAffectors(n);
            n.SetAffectorList(afts);
            if (RenderType == 0)
            {
                n.SetType(SpriteWidth, SpriteHeight, (STYPE)SpriteType, (ORIPOINT)OriPoint, SpriteUVStretch, 60f);
            }
            else if (RenderType == 1)
            {
                float rwidth = RibbonWidth;
                float rlen   = RibbonLen;
                if (UseRandomRibbon)
                {
                    rwidth = Random.Range(RibbonWidthMin, RibbonWidthMax);
                    rlen   = Random.Range(RibbonLenMin, RibbonLenMax);
                }
                n.SetType(FaceToObject, FaceObject, rwidth, MaxRibbonElements, rlen, ClientTransform.position + EmitPoint, StretchType, 60f, IsWeapon, IsScale);
            }
            else if (RenderType == 2)
            {
                n.SetType(ConeSize, ConeSegment, ConeAngle, transform.rotation * OriVelocityAxis, 0, 60f, UseConeAngleChange, ConeDeltaAngle);
            }
            else if (RenderType == 3)
            {
                Vector3 dir = Vector3.zero;
                if (OriVelocityAxis == Vector3.zero)
                {
                    OriVelocityAxis = Vector3.up;
                }

                dir = transform.rotation * OriVelocityAxis;

                n.SetType(CMesh, dir, 60f);
            }

            AvailableENodes[i] = n;
        }
        AvailableNodeCount = MaxENodes;
        emitter            = new Emitter(this);

        mStopped = false;
    }
Ejemplo n.º 33
0
        public void TestEvaluation()
        {
            object evaluated = mExpressionParser.EvaluateExpression("3.1f", new CodeContext(null));

            if ((evaluated is float) == false)
            {
                throw new Exception("Values with 'f' should be floats");
            }

            TestEvaluation("-16", -16);

            TestEvaluation("1+1", 2);

            TestEvaluation("2.3f - 1", 2.3f - 1);

            TestEvaluation("1 + (2 * 3.0)", 1 + (2 * 3.0));

            TestEvaluation("4/2.0f", 4 / 2.0f);

            TestEvaluation("true || false", true || false);
            TestEvaluation("true && false", true && false);



            // Test full evaluations and verify the results
            TestEvaluation("System.Math.Max(3, 5)", 5);
            TestEvaluation("System.Math.Min(8-1, 8)", 7);

            TestEvaluation("this", mElementRuntime, mElementRuntime);

            TestEvaluation("this.X", mElementRuntime.X, mElementRuntime);

            TestEvaluation("this.SomeNewVar", 3.333, mElementRuntime);

            TestEvaluation("System.Math.Max(this.X, this.Y)", System.Math.Max(mElementRuntime.X, mElementRuntime.Y), mElementRuntime);

            TestEvaluation("float.PositiveInfinity", float.PositiveInfinity);

            TestEvaluation("System.Math.Max(float.PositiveInfinity, 0)", float.PositiveInfinity);
            TestEvaluation("VariableState.Left", mElementRuntime.GetStateRecursively("Left"), mElementRuntime);

            TestEvaluation("new Vector3()", new Vector3());

            TestEvaluation("Color.Red", Color.Red);
            // need this, but first need to be able to reorder cast properly
            TestEvaluation("new Color(.3f, .4f, .5f, .6f)", new Color(.3f, .4f, .5f, .6f));

            TestEvaluation("\"a\" + \"b\"", "ab", null);
            TestEvaluation("1 + \"a\" + 2", "1a2", null);

            TestEvaluation("this.SpriteObject.ScaleX", 3.0f, mElementRuntime);

            EmitterList emitterList = new EmitterList();
            var         first       = new Emitter();

            first.Name = "First";
            emitterList.Add(first);

            var second = new Emitter();

            second.Name = "Second";
            emitterList.Add(second);

            TestEvaluation("FindByName(\"First\")", emitterList.FindByName("First"), emitterList);
        }
Ejemplo n.º 34
0
 /// <summary>
 /// Sets the audio output level.
 /// </summary>
 /// <param name="level">The audio level.</param>
 public void SetAudioLevel(Message <double> level)
 {
     this.wasapiRender.AudioLevel = (float)level.Data;
 }
Ejemplo n.º 35
0
 /// <summary>
 /// Saves the current node to the specified emitter.
 /// </summary>
 /// <param name="emitter">The emitter where the node is to be saved.</param>
 /// <param name="state">The state.</param>
 internal abstract void Emit(Emitter emitter, EmitterState state);
Ejemplo n.º 36
0
        public void Emit_InvalidOpCode_ThrowsNotSupportedException()
        {
            var emitter = new Emitter(null, new Type[] {});

            Assert.Throws <NotSupportedException>(() => emitter.Emit(OpCodes.Xor));
        }
Ejemplo n.º 37
0
 public override void updateEmitter(Emitter emitter)
 {
     EmitterData       emitterData   = (EmitterData)emitter.data();
     GeneratorPeriodic generator     = (GeneratorPeriodic)emitter.generator();
     GeneratorImpl     generatorImpl = (GeneratorImpl)generator.impl();
 }
Ejemplo n.º 38
0
 public HandleImpl(Emitter obj, string ev, IListener fn)
 {
     _obj = obj;
     _ev  = ev;
     _fn  = fn;
 }
 public override bool TestTrigger(Emitter emitter, Particle particle, float time)
 {
     return(particle.IsDeflected);
 }
Ejemplo n.º 40
0
        public bool IsPrintable(int offset)
        {
            char character = buffer.Peek(offset);

            return(Emitter.IsPrintable(character));
        }
Ejemplo n.º 41
0
 /// <summary>
 /// Serializes the specified object.
 /// </summary>
 /// <param name="emitter">The <see cref="Emitter" /> where to serialize the object.</param>
 /// <param name="graph">The object to serialize.</param>
 public void Serialize(Emitter emitter, object graph)
 {
     Serialize(emitter, graph, graph != null ? graph.GetType() : typeof(object));
 }
Ejemplo n.º 42
0
 private static void           Same(Emitter _) => Assert.AreSame(emitter, _);
Ejemplo n.º 43
0
            public override void updateParticle(Emitter emitter, Particle particle, float dt)
            {
                ParticleImpl particleImpl = (ParticleImpl)particle;
                EmitterData  emitterData  = (EmitterData)emitter.data();

                GeneratorPeriodic generator     = (GeneratorPeriodic)emitter.generator();
                GeneratorImpl     generatorImpl = (GeneratorImpl)generator.impl();

                particleImpl._lifetime += dt;
                _math.vec3 value_  = _math.vec3_(0F, -100F, 0F);
                _math.vec3 noise_a = _math.mulv3scalar_(_math.vec3_(100F, 50F, 30F), emitter.effect().time());
                _math.addv3(out noise_a, noise_a, particleImpl._Position);
                _math.vec3 noise_i = _math.mulv3scalar_(noise_a, 1.0F / 1000F);
                _math.vec3 noise   = _math.noisePixelLinear3_(noise_i);
                _math.mulv3(out noise, noise, _math.vec3_(0.0078125F, 0.0078125F, 0.0078125F));
                _math.addv3(out noise, noise, _math.vec3_(-1F, -1F, -1F));
                _math.mulv3scalar(out noise, noise, 400F);
                _math.vec3 fmove_fs = value_;
                _math.addv3(out fmove_fs, fmove_fs, noise);
                _math.vec3 fmove_vs  = _math.vec3_(0F, 0F, 0F);
                float      fmove_dtl = dt;

                _math.vec3 fmove_v = particleImpl._Velocity;
                _math.vec3 fmove_p = particleImpl._Position;
                while (fmove_dtl > 0.0001F)
                {
                    float      fmove_dtp = fmove_dtl;
                    _math.vec3 fmove_fsd = fmove_fs;
                    _math.vec3 fmove_rw  = _math.subv3_(fmove_vs, fmove_v);
                    float      fmove_rwl = _math.lengthv3sq_(fmove_rw);
                    if (fmove_rwl > 0.0001F)
                    {
                        fmove_rwl = (float)Math.Sqrt(fmove_rwl);
                        _math.vec3 fmove_rwn = _math.divv3scalar_(fmove_rw, fmove_rwl);
                        float      fmove_df  = 0.01F * 1F * fmove_rwl;
                        if (fmove_df * fmove_dtp > 0.2F)
                        {
                            fmove_dtp = 0.2F / fmove_df;
                        }
                        _math.addv3(out fmove_fsd, fmove_fsd, _math.mulv3scalar_(fmove_rwn, fmove_rwl * fmove_df));
                    }
                    _math.addv3(out fmove_v, fmove_v, _math.mulv3scalar_(fmove_fsd, fmove_dtp));
                    _math.addv3(out fmove_p, fmove_p, _math.mulv3scalar_(fmove_v, fmove_dtp));
                    fmove_dtl -= fmove_dtp;
                }
                particleImpl._Position = fmove_p;
                particleImpl._Velocity = fmove_v;
                particle.position_     = particleImpl._Position;
                float value_a = 2F;

                if (particleImpl._lifetime > value_a)
                {
                    particle.dead_ = true;
                }
                float expr_ = (particleImpl._lifetime / value_a);
                float _plota_out;
                float _plota_in0 = (expr_ < 0F?0F:(expr_ > 1F?1F:expr_));

                _math.PathRes _plota_srch0 = _plota_in0 < 0.956383?_math.pathRes(0, (_plota_in0 - 0F) * 1.04561F):_math.pathRes(1, (_plota_in0 - 0.956383F) * 22.9268F);
                _math.funcLerp(out _plota_out, this._plota[0][_plota_srch0.s], _plota_srch0.i);
                particleImpl.alpha_ = _plota_out;
            }
Ejemplo n.º 44
0
 public void Read(AssetReader reader)
 {
     Emitter.Read(reader);
     Type       = (ParticleSystemSubEmitterType)reader.ReadInt32();
     Properties = (ParticleSystemSubEmitterProperties)reader.ReadInt32();
 }
Ejemplo n.º 45
0
 /// <a href="http://bit.ly/2QNmw2q">On a change the listener needs a copy of the changed data to react to</a>
 protected override void OnChange(Emitter emitter) => componentValueToSet.Invoke(Asset.Value);
Ejemplo n.º 46
0
        public void Emit_InvalidOpCodeWithConstructorInfo_ThrowsNotSupportedException()
        {
            var emitter = new Emitter(null, new Type[] {});

            Assert.Throws <NotSupportedException>(() => emitter.Emit(OpCodes.Ldarg_0, (ConstructorInfo)null));
        }
Ejemplo n.º 47
0
        public void StackType_EmptyMethod_IsNull()
        {
            var emitter = new Emitter(null, new Type[] {});

            Assert.Null(emitter.StackType);
        }
Ejemplo n.º 48
0
        public void Emit_InvalidOpCodeWithSignedByte_ThrowsNotSupportedException()
        {
            var emitter = new Emitter(null, new Type[] {});

            Assert.Throws <NotSupportedException>(() => emitter.Emit(OpCodes.Ldarg_0, (sbyte)42));
        }
Ejemplo n.º 49
0
 public static IHandle Create(Emitter obj, string ev, IListener fn)
 {
     obj.On(ev, fn);
     return(new HandleImpl(obj, ev, fn));
 }
Ejemplo n.º 50
0
 public IEnumerable <Object> FetchDependencies(ISerializedFile file, bool isLog = false)
 {
     yield return(Emitter.FetchDependency(file, isLog, () => nameof(SubEmitterData), "emitter"));
 }
Ejemplo n.º 51
0
 private void Emit(int opcode)
 {
     Emitter.EmitBeUInt16(opcode);
     EmitConstants();
 }
Ejemplo n.º 52
0
 internal void Cnop(int extra, int align)
 {
     Emitter.Align(extra, align);
 }
Ejemplo n.º 53
0
 public void Nop()
 {
     Emitter.EmitBeUInt16(0x4E71);
 }
Ejemplo n.º 54
0
        protected override AutoCastMode DoEmitWithoutCast(CancellationToken cancellationToken = default(CancellationToken))
        {
            if (Node.Expression is IdentifierNameSyntax)
            {
                var value = Emitter.GetConstantValue(Node);
                if (value.HasValue)
                {
                    Write(value.Value);
                    return(AutoCastMode.Default);
                }
            }

            var symbol       = Emitter.GetSymbolInfo(Node.Expression).Symbol;
            var methodSymbol = symbol as IMethodSymbol;

            if (methodSymbol == null && symbol != null)
            {
                switch (symbol.Kind)
                {
                case SymbolKind.Parameter:
                    if (((IParameterSymbol)symbol).Type != null &&
                        ((IParameterSymbol)symbol).Type.TypeKind == TypeKind.Delegate)
                    {
                        methodSymbol = ((INamedTypeSymbol)((IParameterSymbol)symbol).Type).DelegateInvokeMethod;
                    }
                    break;

                case SymbolKind.Property:
                    if (((IPropertySymbol)symbol).Type != null &&
                        ((IPropertySymbol)symbol).Type.TypeKind == TypeKind.Delegate)
                    {
                        methodSymbol = ((INamedTypeSymbol)((IPropertySymbol)symbol).Type).DelegateInvokeMethod;
                    }
                    break;

                case SymbolKind.Field:
                    if (((IFieldSymbol)symbol).Type != null &&
                        ((IFieldSymbol)symbol).Type.TypeKind == TypeKind.Delegate)
                    {
                        methodSymbol = ((INamedTypeSymbol)((IFieldSymbol)symbol).Type).DelegateInvokeMethod;
                    }
                    break;

                case SymbolKind.Local:
                    if (((ILocalSymbol)symbol).Type != null &&
                        ((ILocalSymbol)symbol).Type.TypeKind == TypeKind.Delegate)
                    {
                        methodSymbol = ((INamedTypeSymbol)((ILocalSymbol)symbol).Type).DelegateInvokeMethod;
                    }
                    break;
                }
            }

            var arguments = Node.ArgumentList.Arguments.Select(a => new ParameterInvocationInfo(a)).ToList();

            if (methodSymbol != null)
            {
                if (methodSymbol.IsExtensionMethod)
                {
                    methodSymbol = methodSymbol.ReducedFrom;
                    arguments.Insert(0, new ParameterInvocationInfo(GetInvokeExpression(Node.Expression)));
                }

                var template = Emitter.GetTemplate(methodSymbol);
                if (template != null)
                {
                    SkipSemicolonOnStatement = template.SkipSemicolonOnStatements;
                    if (template.Variables.TryGetValue("this", out var thisVar))
                    {
                        PushWriter();
                        if (methodSymbol.IsStatic)
                        {
                            Write(Emitter.GetTypeName(methodSymbol.ContainingType, false, true));
                        }
                        else
                        {
                            EmitTree(Node.Expression, cancellationToken);
                        }
                        thisVar.RawValue = PopWriter();
                    }

                    var methodInvocation = BuildMethodInvocation(methodSymbol, arguments);
                    foreach (var param in methodSymbol.Parameters)
                    {
                        if (template.Variables.TryGetValue(param.Name, out var variable))
                        {
                            var values = methodInvocation[param.Name].ToArray();
                            PushWriter();
                            if (param.IsParams)
                            {
                                if (values.Length == 1)
                                {
                                    var singleParamType = Emitter.GetTypeInfo(values[0]);
                                    if (singleParamType.ConvertedType.Equals(param.Type))
                                    {
                                        EmitTree(values[0], cancellationToken);
                                    }
                                    else
                                    {
                                        if (variable.Modifier != "raw")
                                        {
                                            Write("[");
                                        }
                                        EmitTree(values[0], cancellationToken);
                                        if (variable.Modifier != "raw")
                                        {
                                            Write("]");
                                        }
                                    }
                                }
                                else
                                {
                                    if (variable.Modifier != "raw")
                                    {
                                        Write("[");
                                    }
                                    for (int j = 0; j < values.Length; j++)
                                    {
                                        if (j > 0)
                                        {
                                            WriteComma();
                                        }
                                        EmitTree(values[0], cancellationToken);
                                    }
                                    if (variable.Modifier != "raw")
                                    {
                                        Write("]");
                                    }
                                }
                            }
                            else
                            {
                                if (variable.Modifier == "raw")
                                {
                                    var constValue = Emitter.GetConstantValue(values[0], cancellationToken);
                                    if (constValue.HasValue)
                                    {
                                        Write(constValue);
                                    }
                                    else
                                    {
                                        EmitTree(values[0], cancellationToken);
                                    }
                                }
                                else
                                {
                                    EmitTree(values[0], cancellationToken);
                                }
                            }
                            var paramOutput = PopWriter();
                            variable.RawValue = paramOutput;
                        }
                    }

                    for (int i = 0; i < methodSymbol.TypeArguments.Length; i++)
                    {
                        var argument = methodSymbol.TypeArguments[i];
                        var param    = methodSymbol.TypeParameters[i];
                        if (template.Variables.TryGetValue(param.Name, out var variable))
                        {
                            variable.RawValue = Emitter.GetTypeName(argument);
                        }
                    }

                    Write(template.ToString());
                }
                else if (Emitter.IsMethodRedirected(methodSymbol, out var targetType))
                {
                    Write(targetType);
                    WriteDot();
                    Write(Emitter.GetMethodName(methodSymbol));
                    if (methodSymbol.IsStatic)
                    {
                        WriteMethodInvocation(methodSymbol, arguments, Node, cancellationToken);
                    }
                    else
                    {
                        arguments.Insert(0, new ParameterInvocationInfo(GetInvokeExpression(Node.Expression), true));
                        WriteMethodInvocation(methodSymbol, arguments, Node, cancellationToken);
                    }
                }
                else if (methodSymbol.IsStatic)
                {
                    Write(Emitter.GetTypeName(methodSymbol.ContainingType, false, true));
                    WriteDot();
                    Write(Emitter.GetMethodName(methodSymbol));
                    WriteMethodInvocation(methodSymbol, arguments, Node, cancellationToken);
                }
                else
                {
                    EmitTree(Node.Expression, cancellationToken);
                    WriteMethodInvocation(methodSymbol, arguments, Node, cancellationToken);
                }
            }
            else
            {
                EmitTree(Node.Expression, cancellationToken);
                WriteMethodInvocation(null, arguments, Node, cancellationToken);
            }

            return(AutoCastMode.Default);
        }
Ejemplo n.º 55
0
 public void Bchg(int c, MachineOperand eaDst)
 {
     Emit(0x0840 | Ea(eaDst));
     Emitter.EmitBeUInt16(c);
 }
Ejemplo n.º 56
0
        public void Emit_InvalidOpCodeWithType_ThrowsNotSupportedException()
        {
            var emitter = new Emitter(null, new Type[] {});

            Assert.Throws <NotSupportedException>(() => emitter.Emit(OpCodes.Ldarg_0, typeof(object)));
        }
Ejemplo n.º 57
0
 public override void Emit(Emitter emitter, int index, float x, float y)
 {
     emitter.Recycle <ForceParticle>().Reset(x, y);
 }
Ejemplo n.º 58
0
        public ParticleEditorScreen()
        {
            cam = new Camera();

            leftPanel = new GUIFrame(new RectTransform(new Vector2(0.07f, 1.0f), Frame.RectTransform)
            {
                MinSize = new Point(150, 0)
            },
                                     style: "GUIFrameLeft");
            var paddedLeftPanel = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.95f), leftPanel.RectTransform, Anchor.CenterLeft)
            {
                RelativeOffset = new Vector2(0.02f, 0.0f)
            })
            {
                Stretch = true
            };

            rightPanel = new GUIFrame(new RectTransform(new Vector2(0.25f, 1.0f), Frame.RectTransform, Anchor.TopRight)
            {
                MinSize = new Point(450, 0)
            },
                                      style: "GUIFrameRight");
            var paddedRightPanel = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), rightPanel.RectTransform, Anchor.Center)
            {
                RelativeOffset = new Vector2(0.02f, 0.0f)
            })
            {
                Stretch         = true,
                RelativeSpacing = 0.01f
            };

            var saveAllButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.03f), paddedRightPanel.RectTransform),
                                              TextManager.Get("ParticleEditorSaveAll"))
            {
                OnClicked = (btn, obj) =>
                {
                    SerializeAll();
                    return(true);
                }
            };

            var serializeToClipBoardButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.03f), paddedRightPanel.RectTransform),
                                                           TextManager.Get("ParticleEditorCopyToClipboard"))
            {
                OnClicked = (btn, obj) =>
                {
                    SerializeToClipboard(selectedPrefab);
                    return(true);
                }
            };

            emitter = new Emitter();
            var emitterEditorContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.25f), paddedRightPanel.RectTransform), style: null);
            var emitterEditor          = new SerializableEntityEditor(emitterEditorContainer.RectTransform, emitter, false, true, elementHeight: 20);

            emitterEditor.RectTransform.RelativeSize = Vector2.One;
            emitterEditorContainer.RectTransform.Resize(new Point(emitterEditorContainer.RectTransform.NonScaledSize.X, emitterEditor.ContentHeight), false);

            var listBox = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.6f), paddedRightPanel.RectTransform));

            prefabList             = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.8f), paddedLeftPanel.RectTransform));
            prefabList.OnSelected += (GUIComponent component, object obj) =>
            {
                selectedPrefab = obj as ParticlePrefab;
                listBox.ClearChildren();
                particlePrefabEditor = new SerializableEntityEditor(listBox.Content.RectTransform, selectedPrefab, false, true, elementHeight: 20);
                //listBox.Content.RectTransform.NonScaledSize = particlePrefabEditor.RectTransform.NonScaledSize;
                //listBox.UpdateScrollBarSize();
                return(true);
            };
        }
Ejemplo n.º 59
0
        protected override void CreateChildren()
        {
            _shield = new NinePatch(Assets.STATUS, 80, 0, 30 + 18, 0);
            Add(_shield);

            var touchArea = new TouchArea(0, 1, 30, 30);

            touchArea.ClickAction = touch =>
            {
                var sprite = Dungeon.Hero.Sprite;
                if (!sprite.Visible)
                {
                    Camera.Main.FocusOn(sprite);
                }
                GameScene.Show(new WndHero());
            };
            Add(touchArea);

            _btnMenu = new MenuButton();
            Add(_btnMenu);

            _avatar = HeroSprite.Avatar(Dungeon.Hero.heroClass, _lastTier);
            Add(_avatar);

            _blood = new Emitter();
            _blood.Pos(_avatar);
            _blood.Pour(BloodParticle.Factory, 0.3f);
            _blood.AutoKill = false;
            _blood.On       = false;
            Add(_blood);

            _compass = new Compass(Dungeon.Level.exit);
            Add(_compass);

            _hp = new Image(Assets.HP_BAR);
            Add(_hp);

            _exp = new Image(Assets.XP_BAR);
            Add(_exp);

            _level = new BitmapText(PixelScene.font1x);
            _level.Hardlight(0xFFEBA4);
            Add(_level);

            _depth = new BitmapText(Dungeon.Depth.ToString(CultureInfo.InvariantCulture), PixelScene.font1x);
            _depth.Hardlight(0xCACFC2);
            _depth.Measure();
            Add(_depth);

            Dungeon.Hero.Belongings.CountIronKeys();
            _keys = new BitmapText(PixelScene.font1x);
            _keys.Hardlight(0xCACFC2);
            Add(_keys);

            _danger = new DangerIndicator();
            Add(_danger);

            _loot = new LootIndicator();
            Add(_loot);

            _buffs = new BuffIndicator(Dungeon.Hero);
            Add(_buffs);
        }
Ejemplo n.º 60
0
        public void Emit_InvalidOpCodeWithLocalBuilder_ThrowsNotSupportedException()
        {
            var emitter = new Emitter(null, new Type[] {});

            Assert.Throws <NotSupportedException>(() => emitter.Emit(OpCodes.Ldarg_0, (LocalBuilder)null));
        }