private void createSpriteForItem(EcsEntity entity) { ItemComponent item = entity.Get <ItemComponent>(); ItemVisualComponent visual = new ItemVisualComponent(); Vector3 spritePosition = ViewUtil.fromModelToScene(entity.pos()); visual.go = Object.Instantiate(itemPrefab, spritePosition + new Vector3(0, 0, -0.1f), Quaternion.identity); visual.go.transform.SetParent(GameView.get().mapHolder); visual.spriteRenderer = visual.go.GetComponent <SpriteRenderer>(); visual.spriteRenderer.sprite = createSprite(ItemTypeMap.getItemType(item.type)); entity.Replace(visual); }
public EcsEntity generateItem(string typeName, string materialName, Vector3Int position, EcsEntity entity) { ItemType type = ItemTypeMap.getItemType(typeName); if (type == null) { Debug.LogError("Type " + typeName + " not found."); } Material_ material = MaterialMap.get().material(materialName); entity.Replace(new ItemComponent { material = material.id, type = typeName, materialString = material.name, volume = 1, weight = material.density * 1 }); entity.Replace(new PositionComponent { position = position }); entity.Replace(new NameComponent()); // entity.Replace(new ItemVisualComponent()); return(entity); }
public ItemType processExtendedType(RawItemType rawType, string namePrefix) { ItemType baseType = ItemTypeMap.getItemType(rawType.baseItem); // get base type return(addAspectsFromRawType(new ItemType(baseType, rawType, namePrefix), rawType)); }