Exemplo n.º 1
0
        public AnimatedSpritePart(Actor self, AnimatedSpritePartInfo info) : base(self)
        {
            this.info   = info;
            renderables = new BatchSequence[info.Facings];
            var frameCountPerIdleAnim = info.Textures.Length / info.Facings;

            if (frameCountPerIdleAnim * info.Facings != info.Textures.Length)
            {
                throw new InvalidNodeException($"Idle Frame '{info.Textures.Length}' count cannot be matched with the given Facings '{info.Facings}'.");
            }

            for (int i = 0; i < renderables.Length; i++)
            {
                var anim = new Texture[frameCountPerIdleAnim];
                for (int x = 0; x < frameCountPerIdleAnim; x++)
                {
                    anim[x] = info.Textures[i * frameCountPerIdleAnim + x];
                }

                renderables[i] = new BatchSequence(anim, info.Tick, startRandom: info.StartRandom);
            }

            if (info.ColorVariation != Color.Black)
            {
                var random = Program.SharedRandom;
                variation = new Color((float)(random.NextDouble() - 0.5f) * info.ColorVariation.R, (float)(random.NextDouble() - 0.5f) * info.ColorVariation.G, (float)(random.NextDouble() - 0.5f) * info.ColorVariation.B, 0f);
            }
            cachedColor = info.Color + variation;

            self.ZOffset = info.Offset.Z;
        }
Exemplo n.º 2
0
        public Terrain(World world, MPos position, TerrainType type)
        {
            this.world = world;
            Position   = position;
            Type       = type;

            renderable = new StaticBatchRenderable(Position.ToCPos(), VAngle.Zero, type.Texture);
            if (type.Overlay != null)
            {
                overlay = new BatchSequence(type.Overlay, startRandom: true);
                overlay.SetPosition(Position.ToCPos());
            }
            edges   = new StaticBatchRenderable[4];
            corners = new StaticBatchRenderable[4];
        }
Exemplo n.º 3
0
        public SilverbackIntegrationLoggerBenchmark()
        {
            _integrationLogger = new SilverbackIntegrationLogger(
                new FakeLogger(),
                new LogTemplates().ConfigureAdditionalData <TestConsumerEndpoint>("offset"));

            _singleMessageContext = ConsumerPipelineContextHelper.CreateSubstitute(
                new RawInboundEnvelope(
                    Array.Empty <byte>(),
                    new MessageHeaderCollection
            {
                new MessageHeader("Test", "Test"),
                new MessageHeader(DefaultMessageHeaders.FailedAttempts, 1),
                new MessageHeader(DefaultMessageHeaders.MessageType, "Something.Xy"),
                new MessageHeader(DefaultMessageHeaders.MessageId, "1234"),
            },
                    new TestConsumerEndpoint("Test"),
                    "Test",
                    new TestOffset("abc", "1"),
                    new Dictionary <string, string>
            {
                ["offset"] = "1@42"
            }));

            _sequenceContext = ConsumerPipelineContextHelper.CreateSubstitute(
                new RawInboundEnvelope(
                    Array.Empty <byte>(),
                    new MessageHeaderCollection
            {
                new MessageHeader("Test", "Test"),
                new MessageHeader(DefaultMessageHeaders.FailedAttempts, 1),
                new MessageHeader(DefaultMessageHeaders.MessageType, "Something.Xy"),
                new MessageHeader(DefaultMessageHeaders.MessageId, "5678"),
                new MessageHeader(DefaultMessageHeaders.BatchId, "1234"),
                new MessageHeader(DefaultMessageHeaders.BatchSize, "11"),
            },
                    new TestConsumerEndpoint("Test"),
                    "Test",
                    new TestOffset("abc", "2"),
                    new Dictionary <string, string>
            {
                ["offset"] = "1@43"
            }));
            var sequence = new BatchSequence("123", _sequenceContext);

            sequence.AddAsync(_sequenceContext.Envelope, null, false);
            _sequenceContext.SetSequence(sequence, true);
        }
Exemplo n.º 4
0
        public BatchRenderable GetRenderable()
        {
            var color = Color + ParticleUtils.Variety(ColorVariety);

            if (Texture == null)
            {
                var renderable = new BatchObject(MeshSize * MasterRenderer.PixelMultiplier + ParticleUtils.Variety(MeshSizeVariety));
                renderable.SetColor(color);
                return(renderable);
            }

            var sequence = new BatchSequence(Texture);

            sequence.SetColor(color);
            return(sequence);
        }
Exemplo n.º 5
0
        public void Tick()
        {
            if (self.Angle != angle)
            {
                angle         = self.Angle;
                currentFacing = FacingFromAngle(angle);
            }
            var last = renderable;

            renderable = (BatchSequence)GetRenderable(self.Actions, currentFacing);

            if (last == null)
            {
                renderable?.Reset();
            }

            renderable?.Tick();
        }
Exemplo n.º 6
0
        public SilverbackIntegrationLoggerTests()
        {
            _logger = new LoggerSubstitute <SilverbackIntegrationLoggerTests>();

            _integrationLogger =
                new SilverbackIntegrationLogger <SilverbackIntegrationLoggerTests>(
                    _logger,
                    new LogTemplates()
                    .ConfigureAdditionalData <TestConsumerEndpoint>("offset-in")
                    .ConfigureAdditionalData <TestProducerEndpoint>("offset-out"));

            _singleInboundMessageContext = ConsumerPipelineContextHelper.CreateSubstitute(
                new InboundEnvelope(
                    new MemoryStream(),
                    new MessageHeaderCollection
            {
                new MessageHeader(DefaultMessageHeaders.FailedAttempts, 1),
                new MessageHeader(DefaultMessageHeaders.MessageType, "Something.Xy"),
                new MessageHeader(DefaultMessageHeaders.MessageId, "1234")
            },
                    new TestOffset(),
                    new TestConsumerEndpoint("Test"),
                    "TestActual",
                    new Dictionary <string, string>
            {
                ["offset-in"] = "9"
            }));

            _inboundSequenceContext = ConsumerPipelineContextHelper.CreateSubstitute(
                new InboundEnvelope(
                    new MemoryStream(),
                    new MessageHeaderCollection
            {
                new MessageHeader(DefaultMessageHeaders.FailedAttempts, 1),
                new MessageHeader(DefaultMessageHeaders.MessageType, "Something.Xy"),
                new MessageHeader(DefaultMessageHeaders.MessageId, "1234"),
                new MessageHeader(DefaultMessageHeaders.BatchId, "3"),
                new MessageHeader(DefaultMessageHeaders.BatchSize, "10")
            },
                    new TestOffset(),
                    new TestConsumerEndpoint("Test")
            {
                Batch = new BatchSettings
                {
                    Size = 5
                }
            },
                    "TestActual",
                    new Dictionary <string, string>
            {
                ["offset-in"] = "9"
            }));
            var sequence = new BatchSequence("123", _inboundSequenceContext);

            sequence.AddAsync(_inboundSequenceContext.Envelope, null, false);
            _inboundSequenceContext.SetSequence(sequence, true);

            _outboundEnvelope = new RawOutboundEnvelope(
                new MemoryStream(),
                new MessageHeaderCollection
            {
                new MessageHeader(DefaultMessageHeaders.MessageType, "Something.Xy"),
                new MessageHeader(DefaultMessageHeaders.MessageId, "1234")
            },
                new TestProducerEndpoint("Test"),
                null,
                new Dictionary <string, string>
            {
                ["offset-out"] = "9"
            });
        }