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


C# BasePlayer.CallMethod方法代码示例

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


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

示例1: On_PlayerDied

        /// <summary>
        /// Called from <c>BasePlayer.Die(HitInfo)</c> .
        /// </summary>
        public static void On_PlayerDied(BasePlayer basePlayer, HitInfo info)
        {
            using (TimeWarning.New("Player.Die", 0.1f)) {
                if (!basePlayer.IsDead()) {
                    if (info == null) {
                        info = new HitInfo();
                        info.damageTypes.Add(basePlayer.lastDamage, Single.MaxValue);
                        info.Initiator = (BaseEntity)basePlayer;
                    }

                    Player victim = Server.GetPlayer(basePlayer);

                    if (!((bool)basePlayer.CallMethod("WoundInsteadOfDying", info))) {
                        var pde = new PlayerDeathEvent(victim, info);

                        OnNext("On_PlayerDied", pde);

                        if (pde.Die) {
                            if (info.Initiator != null) {
                                // PlayerStats statsV = victim.Stats;

                                if (info.Initiator is BasePlayer) {
                                    Server.GetPlayer(info.Initiator as BasePlayer).Stats.AddKill(true, false);
                                    victim.Stats.AddDeath(true, false);
                                } else if (info.Initiator is BaseNPC) {
                                        victim.Stats.AddDeath(false, true);
                                    }
                            }

                            if (!pde.dropLoot) {
                                if (basePlayer.belt != null) {
                                    Vector3 vector = new Vector3(UnityEngine.Random.Range(-2f, 2f),
                                                                 0.2f,
                                                                 UnityEngine.Random.Range(-2f, 2f));

                                    basePlayer.belt.DropActive(vector.normalized * 3f);
                                }

                                basePlayer.inventory.Strip();
                            }

                            basePlayer.CallMethodOnBase(typeof(BaseCombatEntity), "Die", info);
                        }
                    }
                }
            }
        }
开发者ID:Notulp,项目名称:Pluton.Rust,代码行数:50,代码来源:Hooks.cs

示例2: On_PlayerDied

        // BasePlayer.Die()
        public static bool On_PlayerDied(BasePlayer player, HitInfo info)
        {
            if (info == null) {
                info = new HitInfo();
                info.damageTypes.Add(player.lastDamage, Single.MaxValue);
                info.Initiator = player as BaseEntity;
            }

            Player victim = Server.GetPlayer(player);
            if (!((bool)player.CallMethod("WoundInsteadOfDying", info))) {
                if (info.Initiator != null) {
                    PlayerStats statsV = victim.Stats;

                    if (info.Initiator is BasePlayer) {
                        Server.GetPlayer(info.Initiator as BasePlayer).Stats.AddKill(true, false);
                        victim.Stats.AddDeath(true, false);
                    } else if (info.Initiator is BaseNPC) {
                        victim.Stats.AddDeath(false, true);
                    }
                }

                Events.PlayerDeathEvent pde = new Events.PlayerDeathEvent(victim, info);
                OnNext("On_PlayerDied", pde);

                if (!pde.dropLoot)
                    player.inventory.Strip();
                return false;
            }
            return true;
        }
开发者ID:iScripters,项目名称:Pluton,代码行数:31,代码来源:Hooks.cs


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