protected override void Draw(DrawingHandle handle)
        {
            var worldHandle = (DrawingHandleWorld)handle;
            var viewport    = _eyeManager.GetWorldViewport();

            worldHandle.DrawRect(viewport, Color.White);
        }
Example #2
0
            protected override void Draw(DrawingHandle handle)
            {
                var map = _owner.eyeManager.CurrentMap;

                var shaded   = (DrawingHandleWorld)handle;
                var unshaded = (DrawingHandleWorld)NewHandle(_unshadedShader);

                foreach (var effect in _owner._Effects)
                {
                    if (_mapManager.GetGrid(effect.Coordinates.GridID).ParentMapId != map)
                    {
                        continue;
                    }

                    // NOTE TO FUTURE READERS:
                    // Yes, due to how this is implemented, unshaded is always on top of shaded.
                    // If you want to rework it to be properly defined, be my guest.
                    var usingHandle = effect.Shaded ? shaded : unshaded;

                    usingHandle.SetTransform(
                        effect.Coordinates.ToWorld(_mapManager).Position,
                        new Angle(-effect.Rotation), effect.Size);
                    var effectSprite = effect.EffectSprite;
                    usingHandle.DrawTexture(effectSprite, -((Vector2)effectSprite.Size / EyeManager.PIXELSPERMETER) / 2, ToColor(effect.Color));
                }
            }
Example #3
0
        private void Redraw()
        {
            var map = eyeManager.CurrentMap;

            VS.CanvasItemClear(ShadedCanvasItem);
            VS.CanvasItemClear(UnshadedCanvasItem);
            using (var shadedhandle = new DrawingHandle(ShadedCanvasItem))
                using (var unshadedhandle = new DrawingHandle(UnshadedCanvasItem))
                {
                    foreach (var effect in _Effects)
                    {
                        if (effect.Coordinates.MapID != map)
                        {
                            continue;
                        }

                        // NOTE TO FUTURE READERS:
                        // Yes, due to how this is implemented, unshaded is always on top of shaded.
                        // If you want to rework it to be properly defined, be my guest.
                        var handle = effect.Shaded ? shadedhandle : unshadedhandle;

                        handle.SetTransform(effect.Coordinates.ToWorld().Position *EyeManager.PIXELSPERMETER, new Angle(effect.Rotation), effect.Size);
                        Texture effectsprite = effect.EffectSprite;
                        handle.DrawTexture(effectsprite, -((Vector2)effectsprite.Size) / 2, ToColor(effect.Color));
                    }
                }
        }
Example #4
0
        protected override void Draw(DrawingHandle handle)
        {
            if (!TryGetHands(out IHandsComponent hands))
            {
                return;
            }

            var leftActive = hands.ActiveIndex == "left";

            handle.DrawStyleBox(handBox, leftActive ? handL : handR);
            handle.DrawStyleBox(inactiveHandBox, leftActive ? handR : handL);

            if (LeftHand.Entity != null && LeftHand.HeldSprite != null)
            {
                var bounds = LeftHand.HeldSprite.Size;
                handle.DrawTextureRect(LeftHand.HeldSprite,
                                       Box2i.FromDimensions(handL.Left + (int)(handL.Width / 2f - bounds.X / 2f),
                                                            handL.Top + (int)(handL.Height / 2f - bounds.Y / 2f),
                                                            (int)bounds.X, (int)bounds.Y), tile: false);
            }

            if (RightHand.Entity != null && RightHand.HeldSprite != null)
            {
                var bounds = RightHand.HeldSprite.Size;
                handle.DrawTextureRect(RightHand.HeldSprite,
                                       Box2i.FromDimensions(handR.Left + (int)(handR.Width / 2f - bounds.Y / 2f),
                                                            handR.Top + (int)(handR.Height / 2f - bounds.Y / 2f),
                                                            (int)bounds.X, (int)bounds.Y), tile: false);
            }
        }
        protected override void Draw(DrawingHandle handle)
        {
            if (_parallaxTexture == null)
            {
                return;
            }

            var(sizeX, sizeY) = _parallaxTexture.Size;
            var(posX, posY)   = _eyeManager.ScreenToWorld(Vector2.Zero).ToWorld().Position;
            var(ox, oy)       = (Vector2i) new Vector2(-posX / Slowness, posY / Slowness);
            ox = MathHelper.Mod(ox, sizeX);
            oy = MathHelper.Mod(oy, sizeY);

            handle.DrawTexture(_parallaxTexture, new Vector2(ox, oy));
            handle.DrawTexture(_parallaxTexture, new Vector2(ox - sizeX, oy));
            handle.DrawTexture(_parallaxTexture, new Vector2(ox, oy - sizeY));
            handle.DrawTexture(_parallaxTexture, new Vector2(ox - sizeX, oy - sizeY));
        }
        protected override void Draw(DrawingHandle handle)
        {
            var worldHandle = (DrawingHandleWorld)handle;
            var viewport    = _eyeManager.GetWorldViewport();

            foreach (var boundingBox in _componentManager.GetAllComponents <ClientBoundingBoxComponent>())
            {
                // all entities have a TransformComponent
                var transform = boundingBox.Owner.Transform;

                // if not on the same map, continue
                if (transform.MapID != _eyeManager.CurrentMap || !transform.IsMapTransform)
                {
                    continue;
                }

                // This entity isn't lerping, no need to draw debug info for it
                if (transform.LocalPosition == transform.LerpDestination)
                {
                    continue;
                }

                var aabb = boundingBox.AABB;

                // if not on screen, or too small, continue
                if (!aabb.Translated(transform.WorldPosition).Intersects(viewport) || aabb.IsEmpty())
                {
                    continue;
                }

                var timing = IoCManager.Resolve <IGameTiming>();
                timing.InSimulation = true;

                var boxOffset   = transform.LerpDestination - transform.LocalPosition;
                var boxPosWorld = transform.WorldPosition + boxOffset;

                timing.InSimulation = false;

                worldHandle.DrawLine(transform.WorldPosition, boxPosWorld, Color.Yellow);
                worldHandle.DrawRect(aabb.Translated(boxPosWorld), Color.Yellow.WithAlpha(0.5f), false);
            }
        }
        protected override void Draw(DrawingHandle handle)
        {
            if (_playerManager?.LocalPlayer == null)
            {
                return;
            }

            IEntity entity = _playerManager.LocalPlayer.ControlledEntity;

            if (entity == null || !entity.TryGetComponent <IHandsComponent>(out var hands))
            {
                return;
            }

            var leftActive = hands.ActiveIndex == "left";

            handle.DrawStyleBox(handBox, leftActive ? handL : handR);
            handle.DrawStyleBox(inactiveHandBox, leftActive ? handR : handL);

            if (LeftHand.Entity != null && LeftHand.HeldSprite != null)
            {
                var bounds = LeftHand.HeldSprite.Size;
                handle.DrawTextureRect(LeftHand.HeldSprite,
                                       Box2i.FromDimensions(handL.Left + (int)(handL.Width / 2f - bounds.X / 2f),
                                                            handL.Top + (int)(handL.Height / 2f - bounds.Y / 2f),
                                                            (int)bounds.X, (int)bounds.Y), tile: false);
            }

            if (RightHand.Entity != null && RightHand.HeldSprite != null)
            {
                var bounds = RightHand.HeldSprite.Size;
                handle.DrawTextureRect(RightHand.HeldSprite,
                                       Box2i.FromDimensions(handR.Left + (int)(handR.Width / 2f - bounds.Y / 2f),
                                                            handR.Top + (int)(handR.Height / 2f - bounds.Y / 2f),
                                                            (int)bounds.X, (int)bounds.Y), tile: false);
            }
        }
 protected override void Draw(DrawingHandle handle)
 {
     _manager.Render((DrawingHandleWorld)handle);
 }
 protected override void Draw(DrawingHandle handle)
 {
     //TODO: Make me actually work!
     handle.DrawLine(new Vector2(50, 50), new Vector2(100, 100), Color.Green);
     DrawString((DrawingHandleScreen)handle, _font, new Vector2(60, 50), "Hello World!");
 }
Example #10
0
 protected abstract void Draw(DrawingHandle handle);