Пример #1
0
        public override void Received(ref RelayMode relay)
        {
            // no way to check if creative tools is enabled for sender but it's enough to check their access level.
            if (Main.IsServer && MyAPIGateway.Session.GetUserPromoteLevel(OriginalSenderSteamId) < MyPromoteLevel.SpaceMaster)
            {
                MyLog.Default.WriteLineAndConsole($"{PaintGunMod.MOD_NAME} Warning: Player {Utils.PrintPlayerName(OriginalSenderSteamId)} tried to use replace paint while not being at least SpaceMaster promote level.");
                Main.NetworkLibHandler.PacketWarningMessage.Send(OriginalSenderSteamId, "Failed to replace paint server side, access denied.");
                return;
            }

            bool modified = false;

            if (!Main.Palette.ValidateSkinOwnership(NewPaint.Skin, OriginalSenderSteamId))
            {
                NewPaint = new SerializedPaintMaterial(NewPaint.ColorMaskPacked, null);
                modified = true;
            }

            MyCubeGrid grid = Utils.GetEntityOrError <MyCubeGrid>(this, GridEntId, Constants.NETWORK_DESYNC_ERROR_LOGGING);

            if (grid == null)
            {
                if (Main.IsServer)
                {
                    Main.NetworkLibHandler.PacketWarningMessage.Send(OriginalSenderSteamId, "Failed to replace paint server side, grid no longer exists.");
                }

                return;
            }

            if (Main.IsServer)
            {
                // ensure server side if safezone permissions are respected
                if (!Utils.SafeZoneCanPaint(grid, OriginalSenderSteamId))
                {
                    Main.NetworkLibHandler.PacketWarningMessage.Send(OriginalSenderSteamId, "Failed to replace paint server side, denied by safe zone.");
                    return;
                }

                long identity = MyAPIGateway.Players.TryGetIdentityId(OriginalSenderSteamId);
                if (!Utils.AllowedToPaintGrid(grid, identity))
                {
                    Main.NetworkLibHandler.PacketWarningMessage.Send(OriginalSenderSteamId, "Failed to replace paint server side, ship not allied.");
                    return;
                }
            }

            PaintMaterial newPaint = new PaintMaterial(NewPaint);
            BlockMaterial oldPaint = new BlockMaterial(OldPaint);

            Main.Painting.ReplaceColorInGrid(false, grid, oldPaint, newPaint, IncludeSubgrids, OriginalSenderSteamId);

            if (Main.IsServer)
            {
                relay = modified ? RelayMode.RelayWithChanges : RelayMode.RelayOriginal;
            }
        }
Пример #2
0
        }                               // Empty constructor required for deserialization

        public void Send(IMyCubeGrid grid, BlockMaterial oldPaint, PaintMaterial newPaint, bool includeSubgrids)
        {
            GridEntId       = grid.EntityId;
            OldPaint        = new SerializedBlockMaterial(oldPaint);
            NewPaint        = new SerializedPaintMaterial(newPaint);
            IncludeSubgrids = includeSubgrids;

            Network.SendToServer(this);

            // do the action for local client too
            if (!MyAPIGateway.Session.IsServer)
            {
                Main.Painting.ReplaceColorInGrid(false, grid, oldPaint, newPaint, includeSubgrids, OriginalSenderSteamId);
            }
        }
Пример #3
0
        }                        // Empty constructor required for deserialization

        public void Send(IMyCubeGrid grid, Vector3I blockPosition, PaintMaterial paint, bool useMirroring)
        {
            GridEntId     = grid.EntityId;
            BlockPosition = blockPosition;
            Paint         = new SerializedPaintMaterial(paint);
            MirrorData    = (useMirroring ? new MirrorData(grid) : default(MirrorData));

            Network.SendToServer(this);

            // do the action for local client too
            if (!MyAPIGateway.Session.IsServer)
            {
                DoAction(grid);
            }
        }