Ejemplo n.º 1
0
        public override void Register()
        {
            ModePacket     = new DetachModePacket();
            ProgressPacket = new DetachProgressPacket();

            if (Networking.IsPlayer)
            {
                Local_DetachData = new DetachData();
                Main.GrinderHandler.GrinderChanged += Local_EquippedGrinderChanged;
                DetachProgressPacket.OnReceive     += Player_DetachProgressPacketReceived;
            }

            if (MyAPIGateway.Session.IsServer)
            {
                Server_DetachData = new Dictionary <ulong, DetachData>();
                Main.GrindDamageHandler.GrindingBlock          += Server_GrindingBlock;
                DetachModePacket.OnReceive                     += Server_DetachModePacketReceived;
                MyVisualScriptLogicProvider.PlayerDisconnected += Server_PlayerDisconnected;
            }
        }
Ejemplo n.º 2
0
        void Server_DetachModePacketReceived(DetachModePacket packet)
        {
            if (packet.Mode)
            {
                DetachData data;
                if (!Server_DetachData.TryGetValue(packet.OriginalSenderSteamId, out data))
                {
                    data = new DetachData();
                    Server_DetachData[packet.OriginalSenderSteamId] = data;
                }

                data.DetachMode         = packet.Mode;
                data.GrindedBlock       = null;
                data.GrindedTimes       = 0;
                data.GrindExpiresAtTick = 0;
            }
            else
            {
                Server_DetachData.Remove(packet.OriginalSenderSteamId);
            }
        }