Ejemplo n.º 1
0
 // This method allows you to prepare painting using a brush
 public void SetBrush(P3D_Brush newBrush)
 {
     paintOperation = newBrush.Create();
     Size           = newBrush.Size;
     Angle          = newBrush.Angle;
     Opacity        = newBrush.Opacity;
 }
Ejemplo n.º 2
0
        private static void DoOperationClient(PaintOperation data)
        {
            MyVoxelBase target;

            if (!MyEntities.TryGetEntityById(data.VoxelId, out target))
            {
                return;
            }

            var miningDef = MyDefinitionManager.Get <MyVoxelMiningDefinition>(data.MiningId);

            if (miningDef == null)
            {
                return;
            }

            var filter = new bool[256];

            for (var i = 0; i < filter.Length; i++)
            {
                filter[i] = miningDef.MiningEntries.ContainsKey(i);
            }

            PaintVoxels(target, data.Position, data.Radius, data.Plane, data.Material, filter, null);
        }
Ejemplo n.º 3
0
        private void DoOperationServer(MyVoxelBase target, Vector3 localPos, float radius, Plane plane)
        {
            var operation = new PaintOperation()
            {
                PainterId = Holder.EntityId,
                VoxelId   = target.EntityId,
                MiningId  = _mining.Id,
                Position  = localPos,
                Plane     = plane,
                Radius    = radius,
                Material  = _fillMaterial,
            };

            if (PaintVoxels(target, localPos, radius, plane, _fillMaterial, _filter, _cutAmmounts))
            {
                int maxMaterial = MyVoxelMaterialDefinition.MaterialCount;

                for (int i = 0; i < maxMaterial; ++i)
                {
                    if (_cutAmmounts[i] > 0)
                    {
                        CollectAmount(i, ref _cutAmmounts[i]);
                    }
                }

                MyAPIGateway.Multiplayer.RaiseStaticEvent(x => DoOperationClient, operation);
            }
        }
Ejemplo n.º 4
0
    // This allows you to change which texture is currently used when doing painting
    public void SetTexture(Texture newTexture, Vector2 newTiling, Vector2 newOffset)
    {
        var newTexture2D = newTexture as Texture2D;

        if (newTexture2D != null && tiling.x != 0.0f && tiling.y != 0.0f && P3D_Helper.IsWritableFormat(newTexture2D.format) == true)
        {
            texture = newTexture2D;
            tiling  = newTiling;
            offset  = newOffset;
#if UNITY_EDITOR
            P3D_Helper.MakeTextureReadable(texture);
#endif
        }
        else
        {
            texture        = null;
            paintOperation = null;
        }
    }
Ejemplo n.º 5
0
 // This method allows you to prepare painting using a paint operation
 public void SetOperation(PaintOperation newPaintOperation)
 {
     paintOperation = newPaintOperation;
 }
Ejemplo n.º 6
0
 public PaintManager()
 {
     _paintOperation = PaintOperation.BasicDraw;
     _pen = new Pen(Color.Black);
     _history = new Caretaker();
 }