コード例 #1
0
        public static void On_DoorCode(CodeLock doorLock, BaseEntity.RPCMessage rpc)
        {
            if (!doorLock.IsLocked())
            {
                return;
            }
            string        code = rpc.read.String();
            DoorCodeEvent dc   = new DoorCodeEvent(doorLock, rpc.player, code);

            OnNext("On_DoorCode", dc);
            if ((!dc.IsCorrect() || !dc.allowed) && !dc.forceAllow)
            {
                Effect.server.Run(doorLock.effectDenied.resourcePath, doorLock, 0u, Vector3.zero, Vector3.forward);
                rpc.player.Hurt(1f, Rust.DamageType.ElectricShock, doorLock, true);
                return;
            }
            Effect.server.Run(doorLock.effectUnlocked.resourcePath, doorLock, 0u, Vector3.zero, Vector3.forward);
            doorLock.SetFlag(BaseEntity.Flags.Locked, false);
            doorLock.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
            List <ulong> whitelist = new List <ulong>();

            whitelist = (List <ulong>)doorLock.GetFieldValue("whitelistPlayers");
            if (!whitelist.Contains(rpc.player.userID))
            {
                whitelist.Add(rpc.player.userID);
                doorLock.SetFieldValue("whitelistPlayers", whitelist);
            }
        }