/// <summary> /// This callback is called for every point that changes materials in a digging operation. /// </summary> public static void PointCallback(float x, float y, float z, int matPrev, int matNow, int lod) { // If material was changed from non-air to air: add a particle animation. if (matPrev != 0 && matNow == 0) { // Create particle systems on demand. if (!instance.stoneParticles.ContainsKey(matPrev)) { SolidTerrainResource res = TerrainResource.FromIndex(matPrev) as SolidTerrainResource; if (res != null) { instance.stoneParticles.Add(matPrev, new StoneParticles(res, LocalScript.world)); } else { instance.stoneParticles.Add(matPrev, null); } } // Add particle. StoneParticles particles = instance.stoneParticles[matPrev]; if (particles != null) { /*instance.stoneParticles[matPrev].particlesStones.AddParticle3D( * new vec3(x, y, z) + RandomDir() * (float)random.NextDouble() * .3f, * RandomDir() * (float)random.NextDouble() * .4f, * new vec4(1), * .4f + (float)random.NextDouble() * .3f, * .2f + (float)random.NextDouble() * .3f, * RandomDir(), * RandomDir(), * new vec3(0));*/ } } }
/// <summary> /// This callback is called once per changed material in a chunk and reports the amount of volume changed (in m^3). /// </summary> public static void StatCallback(int mat, float volume, int lod) { if (mat != 0) { // Resolve terrain material. TerrainResource material = TerrainResource.FromIndex(mat); Debug.Assert(material != null, "Invalid terrain material"); // Add proper amount of material to player inventory. // If the material changed by a negative volume we want to collect a positive amount. instance.player.Inventory.AddResource(material, -volume); } }