/// <summary>
        /// Sets a terrain node's worth of data to the world's terrain. Thread-safe.
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// Thrown when passed null for node, instead of a <see cref="TerrainNode"/>
        /// reference
        /// </exception>
        public void SetNode(TerrainNode node, int tileX, int tileZ)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node", "Expected a terrain node to send");
            }

            lock (instance.Mutex)
            {
                var refNum  = nextReference;
                var refNode = new Tuple <TerrainNode, int, int> (node, tileX, tileZ);
                nodeReferences.Add(refNum, refNode);

                Functions.vp_int_set(instance.Pointer, IntAttributes.ReferenceNumber, refNum);

                try
                {
                    Functions.Call(() =>
                                   Functions.vp_terrain_node_set(
                                       instance.Pointer,
                                       tileX, tileZ,
                                       node.X, node.Z,
                                       DataHandlers.NodeToNodeData(node))
                                   );
                }
                catch
                {
                    nodeReferences.Remove(refNum);
                    throw;
                }
            }
        }
        internal void OnTerrainNode(IntPtr sender)
        {
            if (GetNode == null)
            {
                return;
            }

            var tileX = Functions.vp_int(sender, IntAttributes.TerrainTileX);
            var tileZ = Functions.vp_int(sender, IntAttributes.TerrainTileZ);

            var node = new TerrainNode(sender);

            GetNode(instance, node, tileX, tileZ);
        }
Esempio n. 3
0
        /// <summary>
        /// Sets a terrain node data to world
        /// </summary>
        public void SetNode(TerrainNode node, int tileX, int tileZ)
        {
            int rc;

            lock (instance)
                rc = Functions.vp_terrain_node_set(
                    instance.pointer,
                    tileX, tileZ,
                    node.X, node.Z,
                    node.Cells);

            if (rc != 0)
                throw new VPException((ReasonCode)rc);
        }
Esempio n. 4
0
        internal void OnTerrainNode(IntPtr sender)
        {
            if (GetNode == null) return;
            var tileX = Functions.vp_int(sender, IntAttributes.TerrainTileX);
            var tileZ = Functions.vp_int(sender, IntAttributes.TerrainTileZ);

            var node = new TerrainNode(sender);
            GetNode(instance, node, tileX, tileZ);
        }