当前位置: 首页>>代码示例>>C#>>正文


C# Door.GetSlot方法代码示例

本文整理汇总了C#中Door.GetSlot方法的典型用法代码示例。如果您正苦于以下问题:C# Door.GetSlot方法的具体用法?C# Door.GetSlot怎么用?C# Door.GetSlot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Door的用法示例。


在下文中一共展示了Door.GetSlot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: On_DoorUse

        /// <summary>
        /// Called from <c>Door.RPC_OpenDoor(BaseEntity.RPCMessage)</c> and <c>Door.RPC_CloseDoor(BaseEntity.RPCMessage)</c> .
        /// </summary>
        public static void On_DoorUse(Door door, BaseEntity.RPCMessage msg, bool open)
        {
            if ((open && door.IsOpen()) || (!open && !door.IsOpen()))
                return;

            var preDoorUseEvent = new Pre<DoorUseEvent>(door, msg, open);

            OnNext("Pre_DoorUse", preDoorUseEvent);

            if (preDoorUseEvent.IsCanceled) {
                if (preDoorUseEvent.Event.DenyReason != "")
                    msg.player.SendConsoleCommand("chat.add",
                                                  0,
                                                  String.Format("{0}: {1}",
                                                  Server.server_message_name.ColorText("fa5"),
                                                  preDoorUseEvent.Event.DenyReason));

                return;
            }

            bool doAction = true;
            BaseLock baseLock = door.GetSlot(BaseEntity.Slot.Lock) as BaseLock;

            if (baseLock != null && preDoorUseEvent.Event.IgnoreLock == false) {
                doAction = open ? baseLock.OnTryToOpen(msg.player) : baseLock.OnTryToClose(msg.player);

                if (doAction && open && (baseLock.IsLocked() && Time.realtimeSinceStartup - (float)door.GetFieldValue("decayResetTimeLast") > 60)) {
                    Decay.RadialDecayTouch(door.transform.position, 40, 270532608);
                    door.SetFieldValue("decayResetTimeLast", Time.realtimeSinceStartup);
                }
            }

            if (doAction) {
                door.SetFlag(BaseEntity.Flags.Open, open);
                door.SendNetworkUpdateImmediate(false);
                door.CallMethod("UpdateDoorAnimationParameters", false);

                OnNext("On_DoorUse", preDoorUseEvent.Event);
            }
        }
开发者ID:Notulp,项目名称:Pluton.Rust,代码行数:43,代码来源:Hooks.cs

示例2: DoorUse

        // Door.RPC_CloseDoor()/RPC_OpenDoor()
        public static void DoorUse(Door door, BaseEntity.RPCMessage rpc, bool open)
        {
            DoorUseEvent due = new DoorUseEvent(new Entity(door), Server.GetPlayer(rpc.player), open);
            OnDoorUse.OnNext(due);

            BaseLock baseLock = door.GetSlot(BaseEntity.Slot.Lock) as BaseLock;
            if (baseLock != null && !due.IgnoreLock) {
                bool TryCloseOpen = open ? !baseLock.OnTryToOpen(rpc.player) : !baseLock.OnTryToClose(rpc.player);
                if (TryCloseOpen)
                    return;
            }

            door.SetFlag(BaseEntity.Flags.Open, due.Open);
            door.Invoke("UpdateLayer", 0f);
            door.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);

            if (due.DenyReason != "")
                rpc.player.SendConsoleCommand("chat.add", 0, String.Format("{0}: {1}", Server.server_message_name.ColorText("fa5"), due.DenyReason));
        }
开发者ID:Viproz,项目名称:Pluton,代码行数:20,代码来源:Hooks.cs


注:本文中的Door.GetSlot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。