Exemplo n.º 1
0
        private static EntityModel SaturateBasicItemModel(
            Entity itemEntity,
            EntityData entityData,
            bool toLowercase)
        {
            EntityWorld     world       = itemEntity.EntityWorld;
            EntityDataCache entityDatas = WorldCache.GetCache(world).EntityDatas;
            EntityModel     entityModel = new EntityModel();

            // Get basic item details.
            if (toLowercase)
            {
                entityModel.Name = entityData.Name.ToLower();
            }
            else
            {
                entityModel.Name = entityData.Name;
            }
            entityModel.Id = itemEntity.UniqueId;
            // entityModel.Type = entityDatas.GetBasePrototype(itemEntity).Name;

            // Get quantity.
            EntityStack entityStack = itemEntity.GetComponent <EntityStack>();

            if (entityStack == null)
            {
                entityModel.Quantity = 1;
            }
            else
            {
                entityModel.Quantity = entityStack.Quantity;
            }

            return(entityModel);
        }
Exemplo n.º 2
0
        private void AddNewPlayerInventory(Entity entity)
        {
            EntityWorld     gameWorld   = entity.EntityWorld;
            EntityDataCache entityDatas = WorldCache.GetCache(gameWorld).EntityDatas;

            Container inventory = new Container(10);

            entity.AddComponent(inventory);

            Entity itemStack = gameWorld.CreateEntity();

            itemStack.AddComponent(new EntityStack(3, 3));
            itemStack.AddComponent(entityDatas[EntityType.Consumable]);

            Entity itemSingle = gameWorld.CreateEntity();

            itemSingle.AddComponent(entityDatas[EntityType.Consumable]);

            Entity     bag           = gameWorld.CreateEntity();
            Container  bagContainer  = new Container(3);
            EntityData bagEntityData = new EntityData(
                Guid.NewGuid(),
                "Bag",
                "Just some bag.",
                null,
                EntityType.Container);

            entityDatas.Add(bagEntityData);
            bag.AddComponent(bagEntityData);
            bag.AddComponent(bagContainer);
            bagContainer.AddEntity(itemStack);

            Entity     backpack           = gameWorld.CreateEntity();
            Container  backpackContainer  = new Container(3);
            EntityData backpackEntityData = new EntityData(
                Guid.NewGuid(),
                "Backpack",
                "A weathered old backpack.",
                null,
                EntityType.Container);

            entityDatas.Add(backpackEntityData);
            backpack.AddComponent(backpackEntityData);
            backpack.AddComponent(backpackContainer);

            inventory.AddEntity(bag);
            inventory.AddEntity(backpack);
            inventory.AddEntity(itemSingle);
        }
Exemplo n.º 3
0
        public void SetUp()
        {
            this.world  = MockWorld.Generate();
            this.entity = this.world.CreateEntity();

            this.interpreter = new Interpreter(Assembly.GetAssembly(typeof(ReverieGame)));

            Container inventory = new Container(10);

            this.entity.AddComponent(inventory);

            EntityDataCache entityDatas = WorldCache.GetCache(this.world).EntityDatas;

            Entity itemStack = this.world.CreateEntity();

            itemStack.AddComponent(new EntityStack(3, 3));
            itemStack.AddComponent(entityDatas[EntityType.Consumable]);

            Entity itemSingle = this.world.CreateEntity();

            itemSingle.AddComponent(entityDatas[EntityType.Consumable]);

            Entity     bag           = this.world.CreateEntity();
            Container  container     = new Container(3);
            EntityData bagEntityData = new EntityData(
                Guid.NewGuid(),
                "Bag",
                "Just a bag.",
                null,
                EntityType.Container);

            bag.AddComponent(bagEntityData);
            bag.AddComponent(container);
            container.AddEntity(itemStack);

            inventory.AddEntity(bag);
            inventory.AddEntity(itemSingle);
        }