Beispiel #1
0
        private void OnChange(string args)
        {
            Blob blob = BlobAllocator.Blob(true);

            blob.ReadJson(args);

            string      message  = blob.GetString("message");
            float       scale    = (float)blob.GetDouble("scale");
            Vector3I    colorVec = blob.FetchBlob("color").GetVector3I();
            Color       color    = new Color(colorVec.X, colorVec.Y, colorVec.Z);
            BmFontAlign align    = (BmFontAlign)blob.GetLong("align");

            Blob.Deallocate(ref blob);

            Blob cmd = BlobAllocator.Blob(true);

            cmd.SetString("action", "changeSign");
            cmd.SetLong("id", this._currentSignId.Id);
            cmd.SetString("message", message);
            cmd.SetLong("color", color.PackedValue);
            cmd.SetDouble("scale", scale);
            cmd.SetLong("align", (long)align);

            ClientContext.OverlayController.AddCommand(cmd);

            this.Hide();
        }
        public BlobDatabase(FileStream stream, Action <string> errorLogger)
        {
            _databaseFile = stream;
            _database     = BlobAllocator.Blob(true);

            _databaseFile.Seek(0L, SeekOrigin.Begin);

            try {
                using (var ms = new MemoryStream()) {
                    _databaseFile.CopyTo(ms);
                    ms.Seek(0, SeekOrigin.Begin);
                    _database.LoadJsonStream(ms);
                }

                stream.Seek(0, SeekOrigin.Begin);

                File.WriteAllBytes(stream.Name + ".bak", stream.ReadAllBytes());
            } catch {
                if (File.Exists(stream.Name + ".bak"))
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    errorLogger($"{stream.Name} was corrupt. Will revert to backup file");
                    Console.ResetColor();

                    using (var ms = new MemoryStream(File.ReadAllBytes(stream.Name + ".bak"))) {
                        _database.LoadJsonStream(ms);
                    }
                }
            }

            NeedsStore();
            Save();
        }
Beispiel #3
0
        /// <summary>
        /// Reads the JSON provided by the UI from the WebOverlayRenderer
        /// and parses the Layout information
        /// </summary>
        /// <param name="arg"></param>
        private void BindSlots(string arg)
        {
            Blob blob = BlobAllocator.Blob(true);

            blob.ReadJson(arg);
            List <BlobEntry> layout = blob.FetchList("layout");

            this.Layout = new Vector2F[layout.Count];

            for (int k = 0; k < layout.Count; k++)
            {
                Blob entry = layout[k].Blob();
                this.Layout[k] = new Vector2F((float)entry.GetLong("left"), (float)entry.GetLong("top"));
            }

            List <BlobEntry> layoutOrigins = blob.FetchList("layoutOrigins");

            this.LayoutOrigin = new Vector2F[layoutOrigins.Count];
            for (int j = 0; j < layoutOrigins.Count; j++)
            {
                Blob entry2 = layoutOrigins[j].Blob();
                this.LayoutOrigin[j] = new Vector2F((float)entry2.GetLong("left"), (float)entry2.GetLong("top"));
            }

            List <BlobEntry> layoutSizes = blob.FetchList("layoutSizes");

            this.LayoutSizes = new Vector2F[layoutSizes.Count];
            for (int i = 0; i < layoutSizes.Count; i++)
            {
                Blob entry3 = layoutSizes[i].Blob();
                this.LayoutSizes[i] = new Vector2F((float)entry3.GetLong("width"), (float)entry3.GetLong("height"));
            }

            Blob.Deallocate(ref blob);
        }
Beispiel #4
0
        public void UniverseUpdateBefore(Universe universe, Timestep step)
        {
            Universe = universe;
            if (universe.Server)
            {
                if (ServerMainLoop == null)
                {
                    ServerMainLoop =
                        ServerContext.VillageDirector?.UniverseFacade?
                        .GetPrivateFieldValue <ServerMainLoop>("_serverMainLoop");
                }

                if (SettingsManager.UpdateList.Count > 0)
                {
                    var blob = BlobAllocator.Blob(true);

                    var settings = blob.FetchBlob("settings");

                    foreach (var item in SettingsManager.UpdateList)
                    {
                        settings.FetchBlob(item).MergeFrom(SettingsManager.ModsSettings[item]);
                    }

                    using (var ms = new MemoryStream()) {
                        blob.Write(ms);
                        ms.Seek(0, SeekOrigin.Begin);
                        FxCore.MessageAllPlayers(blob.ToString());
                    }

                    Blob.Deallocate(ref blob);

                    SettingsManager.UpdateList.Clear();
                }
            }
        }
        public static Blob SerializeObject <T>(T data)
        {
            var blob = BlobAllocator.AcquireAllocator().NewBlob(true);

            blob.ObjectToBlob(null, data);
            return(blob);
        }
Beispiel #6
0
        public static List <TInterface> GetDependencies <TInterface>(string key)
        {
            var output   = new List <TInterface>();
            var assembly = Assembly.GetAssembly(typeof(Fox_Core));
            var dir      = assembly.Location.Substring(0, assembly.Location.LastIndexOf(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal));

            foreach (var file in new DirectoryInfo(dir).GetFiles("*.mod"))
            {
                var data = BlobAllocator.AcquireAllocator().NewBlob(true);
                data.ReadJson(File.ReadAllText(file.FullName));
                if (data.Contains("fxdependencykeys"))
                {
                    var current = data.GetStringList("fxdependencykeys");
                    if (current.Any(x => string.Equals(x, key, StringComparison.CurrentCultureIgnoreCase)))
                    {
                        var item = Assembly.Load(Assembly.LoadFile(file.FullName.Replace(".mod", ".dll")).GetName());
                        foreach (var module in item.DefinedTypes)
                        {
                            if (module.GetInterfaces().Contains(typeof(TInterface)))
                            {
                                output.Add((TInterface)Activator.CreateInstance(module));
                            }
                        }
                    }
                }
            }

            return(output);
        }
Beispiel #7
0
        public static bool ReceiveConsoleResponse(Blob blob)
        {
            string str1          = blob.GetString("response");
            var    handleMessage = false;

            if (str1.IsNullOrEmpty())
            {
                return(handleMessage);
            }


            try {
                var settings = BlobAllocator.Blob(true);
                settings.ReadJson(str1);

                if (settings.Contains("settings"))
                {
                    foreach (var entry in settings.FetchBlob("settings").KeyValueIteratable)
                    {
                        try {
                            SettingsManager.UpdateSettings(entry.Key, entry.Value.Blob());
                            handleMessage = true;
                        } catch {
                            // ignore
                        }
                    }
                }
            } catch {
                // ignore
            }
            return(!handleMessage);
        }
Beispiel #8
0
        internal static void CreateTile(Tile baseTile, Dictionary <Color, Color> replaceColorsWith, string newVariantTileCode, DirectoryManager directory, Blob overrides)
        {
            if (GameContext.TileDatabase.AllMaterials().Any(x =>
                                                            string.Equals(x.Code, newVariantTileCode, StringComparison.CurrentCultureIgnoreCase)))
            {
                return;
            }

            var file = Regex.Replace(baseTile.Configuration.Source, @"\/|\\", Path.DirectorySeparatorChar.ToString());

            var stream = GameContext.ContentLoader.ReadStream(file).ReadAllText();

            var blob = BlobAllocator.AcquireAllocator().NewBlob(false);

            blob.ReadJson(stream);

            var voxelFile = Regex.Replace(blob.GetString("voxels"), @"\/|\\", Path.DirectorySeparatorChar.ToString());

            var output = ChangeColor(voxelFile, replaceColorsWith);

            directory.WriteQBFile(newVariantTileCode, output);

            blob.SetString("code", newVariantTileCode);
            blob.SetString("voxels", directory.GetPath('/') + newVariantTileCode + ".qb");

            blob.MergeFrom(overrides);

            var wait = true;

            directory.WriteFile(newVariantTileCode + ".tile", blob, () => { wait = false; }, true);

            while (wait)
            {
            }
        }
        public override void Update(Timestep timestep, EntityUniverseFacade entityUniverseFacade)
        {
            if (TilePower == null)
            {
                return;
            }

            Universe = entityUniverseFacade;

            if (entityUniverseFacade.ReadTile(Location, TileAccessFlags.SynchronousWait, out var tile))
            {
                var config = GameContext.TileDatabase.GetTileConfiguration(Tile);
                if (config.Components.Select <ChargeableComponent>().Any() && tile.Configuration.Code != "staxel.tile.Sky")
                {
                    TilePower.GetPowerFromComponent(config.Components.Select <ChargeableComponent>().First());
                }
                else
                {
                    var itemBlob = BlobAllocator.Blob(true);
                    itemBlob.SetString("kind", "staxel.item.Placer");
                    itemBlob.SetString("tile", Tile);
                    var item = GameContext.ItemDatabase.SpawnItemStack(itemBlob, null);
                    ItemEntityBuilder.SpawnDroppedItem(Entity, entityUniverseFacade, item, Entity.Physics.Position, new Vector3D(0, 1, 0), Vector3D.Zero, SpawnDroppedFlags.None);
                    entityUniverseFacade.RemoveEntity(Entity.Id);
                    return;
                }
                Cycle.RunCycle(RunCycle);
            }
        }
        public void ReadFile <T>(string filename, Action <T> onLoad, bool inputIsText = false)
        {
            new Thread(() => {
                if (FileExists(filename))
                {
                    var stream =
                        GameContext.ContentLoader.ReadLocalStream(Path.Combine(_localContentLocation, filename));
                    Blob input;
                    if (!inputIsText)
                    {
                        input = stream.ReadBlob();
                    }
                    else
                    {
                        input  = BlobAllocator.AcquireAllocator().NewBlob(false);
                        var sr = new StreamReader(stream);
                        input.ReadJson(sr.ReadToEnd());
                    }

                    stream.Seek(0L, SeekOrigin.Begin);
                    if (typeof(T) == input.GetType())
                    {
                        onLoad((T)(object)input);
                    }

                    onLoad(input.BlobToObject(null, (T)Activator.CreateInstance(typeof(T))));
                }

                onLoad((T)Activator.CreateInstance(typeof(T)));
            }).Start();
        }
        /// <summary>
        /// Replicate all keyframes of <paramref name="animationCurve"> into the struct,
        /// making this independent from the original reference type curve.
        /// </summary>
        public JobAnimationCurve(AnimationCurve animationCurve, Allocator allocator)
        {
            List <Keyframe> sortedKeyframes = new List <Keyframe>(animationCurve.keys);

            if (sortedKeyframes.Any(x => x.weightedMode != WeightedMode.None))
            {
                throw new NotSupportedException($"Found a keyframe in the curve that has a weighted node. This is not supported until I figured out where to put the weight.");
            }
            sortedKeyframes.Sort(KeyframeTimeSort);

            //Debug.Log(string.Join("\n", sortedKeyframes.Select(x => $"{x.time} {x.value} | {x.inTangent} {x.outTangent} | {x.inWeight} {x.outWeight} {x.weightedMode}")));

            var sortedTimes = sortedKeyframes.Select(x => x.time).ToArray();

            using (var ba = new BlobAllocator(-1))
            {
                ref var root           = ref ba.ConstructRoot <AnimationData>();
                int     processorCount = SystemInfo.processorCount + 1;
                ba.Allocate(sortedKeyframes.Count, ref root.keyframes);
                ba.Allocate(sortedKeyframes.Count, ref root.soaTimes);
                ba.Allocate(processorCount, ref root.cachedIndex);
                for (int i = 0; i < sortedKeyframes.Count; i++)
                {
                    root.keyframes[i] = sortedKeyframes[i];
                    root.soaTimes[i]  = sortedTimes[i];
                }
                for (int i = 0; i < processorCount; i++)
                {
                    root.cachedIndex[i] = 0;
                }

                bar = ba.CreateBlobAssetReference <AnimationData>(allocator);
            }
Beispiel #12
0
        public Blob ToStaxelBlob()
        {
            var temp = BlobAllocator.Blob(true);

            temp.ReadJson(Blob.ToString());

            return(temp);
        }
Beispiel #13
0
        public static void SetObject(this Blob blob, object obj)
        {
            var tempBlob = BlobAllocator.Blob(true);

            tempBlob.ReadJson(JsonConvert.SerializeObject(obj));
            blob.MergeFrom(tempBlob);
            Blob.Deallocate(ref tempBlob);
        }
Beispiel #14
0
        public Blob CopyBlob()
        {
            var tempBlob = BlobAllocator.Blob(true);

            tempBlob.AssignFrom(Blob);

            return(tempBlob);
        }
Beispiel #15
0
        public unsafe void SerializeEntitiesWorksWithBlobAssetReferences()
        {
            var archetype1  = m_Manager.CreateArchetype(typeof(EcsTestSharedComp), typeof(EcsTestData));
            var archetype2  = m_Manager.CreateArchetype(typeof(EcsTestSharedComp2), typeof(EcsTestData2));
            var dummyEntity = CreateEntityWithDefaultData(0); //To ensure entity indices are offset

            var     allocator = new BlobAllocator(-1);
            ref var blobArray = ref allocator.ConstructRoot <BlobArray <float> >();
        internal static void UpdateSettings(string id, Blob blob)
        {
            if (!ModsSettings.ContainsKey(id))
            {
                ModsSettings.Add(id, BlobAllocator.Blob(true));
            }

            ModsSettings[id].MergeFrom(blob);
        }
        public override void Construct(Blob arguments, EntityUniverseFacade entityUniverseFacade)
        {
            _constructBlob = BlobAllocator.Blob(true);
            _constructBlob.MergeFrom(arguments);
            Entity.Physics.ForcedPosition(arguments.FetchBlob("location").GetVector3I().ToVector3D());
            Owner = arguments.GetLong("owner");

            NeedsStore();
        }
Beispiel #18
0
        public void GameContextInitializeInit()
        {
            ToRender      = new Dictionary <Guid, List <RenderItem> >();
            ForbidEditing = new Dictionary <Guid, VectorCubeI>();
            NextTick      = 0;
            WorldEditManager.Init();
            if (!WorldEditManager.FoxCore.ModDirectory.FileExists("ignore.flag"))
            {
                var msgBox = MessageBox.Show(@"Would you like to customise the selection region's colors?", @"Customize World Edit", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (msgBox == DialogResult.Yes)
                {
                    var defaultPrimary   = ColorMath.ParseString("F5C900");
                    var defaultSecondary = Color.Black;

                    var colorPicker = new ColorPicker();

                    Application.Run(colorPicker);

                    var primary   = ColorMath.ToString(colorPicker.Primary).Substring(2);
                    var secondary = ColorMath.ToString(colorPicker.Secondary).Substring(2);

                    var blob = BlobAllocator.AcquireAllocator().NewBlob(false);

                    var blob2 = blob.FetchBlob("Custom");

                    blob2.SetString(ColorMath.ToString(defaultPrimary).Substring(2), primary);
                    blob2.SetString(ColorMath.ToString(defaultSecondary).Substring(2), secondary);

                    var wait = true;

                    WorldEditManager.FoxCore.ModDirectory.WriteFile("palettes.json", blob, () => { wait = false; }, true);

                    while (wait)
                    {
                    }

                    colorPicker.Dispose();
                }

                var ms = new MemoryStream();
                var sw = new StreamWriter(ms);

                sw.Write("");
                sw.Flush();

                var streamWait = true;

                WorldEditManager.FoxCore.ModDirectory.WriteFileStream("ignore.flag", ms, () => { streamWait = false; });

                while (streamWait)
                {
                }
            }
        }
        /// <summary>
        /// Pass the changed control hints to the UI
        /// </summary>
        /// <param name="controlHints"></param>
        public void ChangeControlHints(ControlHintVerbs controlHints)
        {
            bool   hasMain  = !string.IsNullOrEmpty(controlHints.VerbMain);
            bool   hasAlt   = !string.IsNullOrEmpty(controlHints.VerbAlt);
            string hintMain = "";
            string hintAlt  = "";

            ControlHintContext context = default(ControlHintContext);

            if (hasMain)
            {
                if (controlHints.Rotate)
                {
                    if (ClientContext.InputSource.TryGetControlHintContext(GameLogicalButton.Next, "staxel.controlHint.itemWheel.Rotate", out context))
                    {
                        hintMain = context.Class;
                    }
                    else if (ClientContext.InputSource.TryGetControlHintContext(GameLogicalButton.Previous, "staxel.controlHint.itemWheel.Rotate", out context))
                    {
                        hintMain = context.Class;
                    }
                }
                else if (ClientContext.InputSource.TryGetControlHintContext(GameLogicalButton.Main, "staxel.controlHint.itemWheel.Main", out context))
                {
                    hintMain = context.Class;
                }
            }

            if (hasAlt && ClientContext.InputSource.TryGetControlHintContext(GameLogicalButton.Alt, "staxel.controlHint.itemWheel.Alt", out context))
            {
                hintAlt = context.Class;
            }

            string verbMain = hasMain ? ClientContext.LanguageDatabase.GetTranslationString(controlHints.VerbMain) : "";
            string verbAlt  = hasAlt ? ClientContext.LanguageDatabase.GetTranslationString(controlHints.VerbAlt) : "";

            Quad <string, string, string, string> key = new Quad <string, string, string, string>(hintMain, hintAlt, verbMain, verbAlt);
            string commandString = default(string);

            if (!this.ControlHintJsonCache.TryGetValue(key, out commandString))
            {
                Blob blob = BlobAllocator.Blob(true);
                blob.SetString("hintMain", hintMain);
                blob.SetString("hintAlt", hintAlt);
                blob.SetString("verbMain", verbMain);
                blob.SetString("verbAlt", verbAlt);

                commandString = ClientContext.WebOverlayRenderer.PrepareCallFunction("updateControlHint", blob.ToString());

                this.ControlHintJsonCache.Add(key, commandString);
                Blob.Deallocate(ref blob);
            }

            ClientContext.WebOverlayRenderer.CallPreparedFunction(commandString);
        }
        public override void Construct(Blob arguments, EntityUniverseFacade entityUniverseFacade)
        {
            _despawn      = arguments.GetBool("despawn", false);
            Location      = arguments.FetchBlob("location").GetVector3I();
            Configuration = GameContext.TileDatabase.GetTileConfiguration(arguments.GetString("tile"));
            if (_logicOwner == EntityId.NullEntityId)
            {
                var blob = BlobAllocator.Blob(true);

                blob.SetString("tile", Configuration.Code);
                blob.FetchBlob("location").SetVector3I(Location);
                blob.SetBool("ignoreSpawn", _despawn);

                var entities = new Lyst <Entity>();

                entityUniverseFacade.FindAllEntitiesInRange(entities, Location.ToVector3D(), 1F, entity => {
                    if (entity.Removed)
                    {
                        return(false);
                    }

                    if (entity.Logic is GeneratorTileEntityLogic logic)
                    {
                        return(Location == logic.Location);
                    }

                    return(false);
                });

                var tileEntity = entities.FirstOrDefault();

                if (tileEntity != default(Entity))
                {
                    _logicOwner = tileEntity.Id;
                }
                else
                {
                    var components = Configuration.Components.Select <GeneratorComponent>().ToList();
                    if (components.Any())
                    {
                        var component = components.First();

                        if (component.Type == "solar")
                        {
                            _logicOwner = ChargeableTileEntityBuilder.Spawn(Location, blob, entityUniverseFacade, SolarPanelTileEntityBuilder.KindCode).Id;
                        }
                        else if (component.Type == "waterMill")
                        {
                            _logicOwner = ChargeableTileEntityBuilder.Spawn(Location, blob, entityUniverseFacade, WaterMillTileEntityBuilder.KindCode).Id;
                        }
                    }
                }
            }
        }
        public static Blob GetBaseBlob(Tile tile, Vector3I location)
        {
            var blob = BlobAllocator.Blob(true);

            blob.SetString("tile", tile.Configuration.Code);
            blob.SetLong("variant", tile.Variant());
            blob.FetchBlob("location").SetVector3I(location);
            blob.FetchBlob("velocity").SetVector3D(Vector3D.Zero);

            return(blob);
        }
        public static Blob SerializeObject <T>(T data)
        {
            if (data is Blob o)
            {
                return(o);
            }
            var blob = BlobAllocator.AcquireAllocator().NewBlob(true);

            blob.ReadJson(JsonConvert.SerializeObject(data));
            return(blob);
        }
Beispiel #23
0
        public void CreateBlobWithInputBytes()
        {
            byte[]     bytes      = { 0, 1, 2, 3, 4 };
            SpookyHash spookyHash = new SpookyHash();

            BlobAllocator allocator = new BlobAllocator();
            IBlob         blob      = allocator.CreateBlob(bytes);

            Assert.AreEqual((ulong)5, blob.Length);
            Assert.AreEqual(spookyHash.CalculateHash(bytes), blob.BlobId);
        }
        public override void Construct(Blob arguments, EntityUniverseFacade entityUniverseFacade)
        {
            _constructBlob = BlobAllocator.Blob(true);
            _constructBlob.MergeFrom(arguments);
            Entity.Physics.ForcedPosition(arguments.FetchBlob("location").GetVector3I().ToVector3D() + BotComponent.TileOffset);
            Owner    = arguments.GetString("owner");
            OwnerUid = arguments.GetString("uid");

            _destination = Entity.Physics.Position;

            NeedsStore();
        }
Beispiel #25
0
 public static BlobAssetReference <Collider> CreateTriangle(float3 vertex0, float3 vertex1, float3 vertex2, CollisionFilter?filter = null, Material?material = null)
 {
     if (math.any(!math.isfinite(vertex0)) || math.any(!math.isfinite(vertex1)) || math.any(!math.isfinite(vertex2)))
     {
         throw new System.ArgumentException("Tried to create triangle collider with nan/inf vertex");
     }
     using (var allocator = new BlobAllocator(-1))
     {
         ref PolygonCollider collider = ref allocator.ConstructRoot <PolygonCollider>();
         collider.InitAsTriangle(vertex0, vertex1, vertex2, filter ?? CollisionFilter.Default, material ?? Material.Default);
         return(allocator.CreateBlobAssetReference <Collider>(Allocator.Persistent));
     }
        public new static Entity Spawn(EntityUniverseFacade facade, Tile tile, Vector3I location)
        {
            var entity = new Entity(facade.AllocateNewEntityId(), false, KindCode, true);
            var blob   = BlobAllocator.Blob(true);

            blob.SetString(nameof(tile), tile.Configuration.Code);
            blob.SetLong("variant", tile.Variant());
            blob.FetchBlob(nameof(location)).SetVector3I(location);
            blob.FetchBlob("velocity").SetVector3D(Vector3D.Zero);
            entity.Construct(blob, facade);
            facade.AddEntity(entity);
            return(entity);
        }
Beispiel #27
0
        internal static void ReadSettings()
        {
            settings = new Classes.Settings();

            if (!InitSettings)
            {
                var blob = BlobAllocator.AcquireAllocator().NewBlob(false);

                blob.ReadJson(File.ReadAllText("./Settings.json"));

                settings.FromBlob(blob);
            }
        }
Beispiel #28
0
        internal void LoadContent(GraphicsDevice graphics)
        {
            _fonts.Clear();
            _backgrounds.Clear();
            _images.Clear();

            foreach (var asset in GameContext.AssetBundleManager.FindByExtension("uifont"))
            {
                using (var stream = GameContext.ContentLoader.ReadStream(asset)) {
                    stream.Seek(0L, SeekOrigin.Begin);
                    var blob = BlobAllocator.Blob(true);

                    blob.LoadJsonStream(stream);

                    if (Process.GetCurrentProcess().ProcessName.Contains("Staxel.Client"))
                    {
                        _fonts.Add(blob.GetString("code"), ContentManager.Load <SpriteFont>(blob.GetString("xnb")));
                    }
                }
            }

            foreach (var asset in GameContext.AssetBundleManager.FindByExtension("uiBackground"))
            {
                using (var stream = GameContext.ContentLoader.ReadStream(asset)) {
                    stream.Seek(0L, SeekOrigin.Begin);
                    var blob = BlobAllocator.Blob(true);

                    blob.LoadJsonStream(stream);

                    _backgrounds.Add(blob.GetString("code"), new UiBackground(graphics, blob));
                }
            }

            foreach (var asset in GameContext.AssetBundleManager.FindByExtension("uiPicture"))
            {
                using (var stream = GameContext.ContentLoader.ReadStream(asset)) {
                    stream.Seek(0L, SeekOrigin.Begin);
                    var blob = BlobAllocator.Blob(true);

                    blob.LoadJsonStream(stream);

                    var image = new UiTexture2D(context =>
                                                Texture2D.FromStream(context.Graphics.GraphicsDevice,
                                                                     GameContext.ContentLoader.ReadStream(blob.GetString("picture"))));

                    _images.Add(blob.GetString("code"), image);
                }
            }

            LoadUIContent?.Invoke(graphics);
        }
Beispiel #29
0
        public void CreateBlobWithInputSubStream()
        {
            byte[]     bytes      = { 0, 1, 2, 3, 4 };
            SpookyHash spookyHash = new SpookyHash();

            using (MemoryStream ms = new MemoryStream(bytes))
            {
                BlobAllocator allocator = new BlobAllocator();
                IBlob         blob      = allocator.CreateBlob(ms, 4);

                Assert.AreEqual((ulong)4, blob.Length);
                Assert.AreEqual(spookyHash.CalculateHash(new byte[] { 0, 1, 2, 3 }), blob.BlobId);
            }
        }
        public override void Interact(Entity entity, EntityUniverseFacade facade, ControlState main, ControlState alt)
        {
            if (alt.DownClick)
            {
                Blob blob = BlobAllocator.Blob(true);
                blob.SetLong("id", this.Entity.Id.Id);
                blob.SetString("message", this._message);
                blob.SetLong("color", this._color.PackedValue);
                blob.SetDouble("scale", this._scale);
                blob.SetLong("align", (long)this._align);

                entity.Effects.Trigger(ShowSignInterfaceEffectBuilder.BuildTrigger(blob));
            }
        }