Пример #1
0
 public void AttachMultiblock(Multiblock m)
 {
     if (!_multiblocks.Contains(m))
     {
         _multiblocks.Add(m);
         OnContainerUpdated();
     }
 }
Пример #2
0
 public void RegisterSmallMultiblock(Multiblock mb, Vector3 pos)
 {
     if (_smallMultiblocks.ContainsKey(pos))
     {
         Object.Destroy(_smallMultiblocks[pos].gameObject);
     }
     _smallMultiblocks[pos] = mb;
 }
Пример #3
0
        private void UpdateModel()
        {
            if (Crop != null)
            {
                Object.Destroy(Crop.gameObject);
            }

            if (Stage != 0)
            {
                Crop = MultiblockLoader.LoadMultiblock(Type.GrowStages[_stage], Position + new Vector3(-0.5f, 0.5f, -0.5f), _parent, 1);
            }
        }
Пример #4
0
        private Multiblock CreateMultiblock(List <VData> list, string name)
        {
            var dict = new Dictionary <VoxelMaterial, List <Vector3> >();

            foreach (var data in list)
            {
                var color = MaterialRegistry.Instance.GetColorIndex(new Color(data.Color.X / 256f, data.Color.Y / 256f, data.Color.Z / 256f));
                if (!dict.ContainsKey(color))
                {
                    dict.Add(color, new List <Vector3>());
                }
                dict[color].Add(new Vector3(data.VPos.X, data.VPos.Y, data.VPos.Z));
            }

            return(Multiblock.InstantiateVoxels(new Vector3(-1, 0, 0), dict, name));
        }
Пример #5
0
        private void Initialize(TreeConfig config, Vector3 position)
        {
            var voxels = new Dictionary <VoxelMaterial, List <Vector3> >();
            var data   = GetRandomizedTreeValues(config);

            Position = position;
            var strainVoxels = GenerateStrain(data);

            voxels.Add(MaterialRegistry.Instance.GetMaterialFromName(config.StainMaterial), strainVoxels);

            var topOfStain    = new Vector3(-data.TreeTopDia / 2f + (data.TreeStainDia) / 2f, data.TreeStainHeight, -data.TreeTopDia / 2f + (data.TreeStainDia) / 2f);
            var treeTopVoxels = GenerateTreeTop(topOfStain, data);

            voxels.Add(MaterialRegistry.Instance.GetMaterialFromName(config.LeafMaterial), treeTopVoxels);

            Multiblock = Multiblock.InstantiateVoxels(position, voxels, "Tree");
            Multiblock.EnableWind(1);
        }