예제 #1
0
        public SyncedMoveBlock(EntityData data, Vector2 offset)
            : base(data.Position + offset, data.Width, data.Height, data.Enum("direction", Directions.Left), data.Bool("canSteer"), false)
        {
            // 0.73f and 0.7f are constant to give the same shade as the original color
            // Hue is capped to 360 (degrees)
            Color = Calc.HsvToColor((Hue = Math.Max(0, Math.Min(data.Int("colorHue", 122), 360))) / 360f, 0.73f, 0.7f);

            CustomSpeed = data.Float("customSpeed", 60f);

            Add(Broadcaster = new Broadcaster("nyahhelper/syncedmoveblock/" + Hue));

            // Listen to the trigger event
            Broadcaster.AddHandler((e) =>
            {
                Trigger = true;
            }, "trigger");

            Broadcaster.AddHandler((e) =>
            {
                Move = true;
            }, "move");
        }