本文整理汇总了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);
}
}
}
}
}
示例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;
}