本文整理汇总了C#中BasePlayer.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# BasePlayer.GetComponent方法的具体用法?C# BasePlayer.GetComponent怎么用?C# BasePlayer.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BasePlayer
的用法示例。
在下文中一共展示了BasePlayer.GetComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: cmdWaypointsClose
void cmdWaypointsClose(BasePlayer player, string command, string[] args)
{
if (!hasAccess(player)) return;
if (!isEditingWP(player, 1)) return;
SendReply(player, "Waypoints: Closed without saving");
GameObject.Destroy(player.GetComponent<WaypointEditor>());
}
示例2: cmdWaypointsAdd
void cmdWaypointsAdd(BasePlayer player, string command, string[] args)
{
if (!hasAccess(player)) return;
if (!isEditingWP(player, 1)) return;
var WaypointEditor = player.GetComponent<WaypointEditor>();
if (WaypointEditor.targetWaypoint == null)
{
SendReply(player, "Waypoints: Something went wrong while getting your WaypointList");
return;
}
float speed = 3f;
if (args.Length > 0) float.TryParse(args[0], out speed);
WaypointEditor.targetWaypoint.AddWaypoint(player.transform.position, speed);
SendReply(player, string.Format("Waypoint Added: {0} {1} {2} - Speed: {3}", player.transform.position.x.ToString(), player.transform.position.y.ToString(), player.transform.position.z.ToString(), speed.ToString()));
}
示例3: hasNoArguments
/////////////////////////////////////////////////////
/// hasNoArguments(BasePlayer player, string[] args)
/// Action when no arguments were written in the commands
/////////////////////////////////////////////////////
bool hasNoArguments(BasePlayer player, string[] args)
{
if (args == null || args.Length == 0)
{
var buildPlayer = player.GetComponent<BuildPlayer>();
if (buildPlayer != null)
{
buildPlayer.DestroyGui();
UnityEngine.Object.Destroy(buildPlayer);
SendReply(player, "Build Tool Deactivated");
}
else
SendReply(player, "For more informations say: /buildhelp");
return true;
}
return false;
}
示例4: TeleportPlayerHome
void TeleportPlayerHome(BasePlayer player)
{
EventPlayer eventplayer = player.GetComponent<EventPlayer>();
if (eventplayer == null) return;
if (player.IsDead() || player.health < 1)
return;
if (eventplayer.savedHome)
{
eventplayer.TeleportHome();
}
}
示例5: SaveHomeLocation
void SaveHomeLocation(BasePlayer player)
{
EventPlayer eventplayer = player.GetComponent<EventPlayer>();
if (eventplayer == null) return;
eventplayer.SaveHome();
}
示例6: OnPlayerRespawned
void OnPlayerRespawned(BasePlayer player)
{
if (!(player.GetComponent<EventPlayer>())) return;
if (player.GetComponent<EventPlayer>().savedInventory || player.GetComponent<EventPlayer>().savedHome)
{
player.GetComponent<EventPlayer>().inEvent = false;
updateGUI(player);
RedeemInventory(player);
TeleportPlayerHome(player);
EventPlayers.Remove(player.GetComponent<EventPlayer>());
TryErasePlayer(player);
player.health = 100f;
}
}
示例7: LeaveEvent
object LeaveEvent(BasePlayer player)
{
if (player.GetComponent<EventPlayer>() == null)
{
return "You are not currently in the Event.";
}
if (!EventPlayers.Contains(player.GetComponent<EventPlayer>()))
{
return "You are not currently in the Event.";
}
player.GetComponent<EventPlayer>().inEvent = false;
//BroadcastToChat(string.Format(MessagesEventLeft, player.displayName.ToString(), (EventPlayers.Count - 1).ToString()));
updateGUI(player);
addBackSpawn(player);
player.inventory.Strip();
RedeemInventory(player);
TeleportPlayerHome(player);
EventPlayers.Remove(player.GetComponent<EventPlayer>());
EjectPlayer(player);
TryErasePlayer(player);
CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player.net.connection }, null, "DestroyUI", new Facepunch.ObjectList("event_blackout", null, null, null, null));
return true;
}
示例8: addBackSpawn
void addBackSpawn(BasePlayer player)
{
if(!EventLimitPlayers)
spawns.Add(player.GetComponent<EventPlayer>().spawnVec);
}
示例9: OnPlayerAttack
void OnPlayerAttack(BasePlayer attacker, HitInfo hit)
{
if (attacker.GetComponent<EventPlayerTeleporting>() != null)
{
hit.damageTypes = new Rust.DamageTypeList();
hit.HitMaterial = 0;
hit.PointStart = Vector3.zero;
attacker.metabolism.bleeding.Reset();
return;
}
if (!EventLobby && eventPlayers.Count > 0)
{
if (hit.HitEntity is BasePlayer)
{
OnAttackShared(attacker, hit.HitEntity as BasePlayer, ref hit);
}
}
}
示例10: OnAttackShared
private object OnAttackShared(BasePlayer attacker, BasePlayer victim, ref HitInfo hit)
{
if (victim.GetComponent<EventPlayerTeleporting>() != null)
{
hit.damageTypes = new Rust.DamageTypeList();
hit.HitMaterial = 0;
hit.PointStart = Vector3.zero;
victim.metabolism.bleeding.Reset();
return false;
}
if (!EventLobby && eventPlayers.Count > 0 && victim.GetComponent<EventPlayer>() == null)
{
hit.damageTypes = new Rust.DamageTypeList();
hit.HitMaterial = 0;
hit.PointStart = Vector3.zero;
victim.metabolism.bleeding.Reset();
return false;
}
return true;
}
示例11: PlayerInit
void PlayerInit(BasePlayer player)
{
if (jaildata[player.userID.ToString()] != null)
{
if (!inJail(player.GetComponent<BaseEntity>()))
SendPlayerToJail(player);
}
}
示例12: cmdChatJailConfig
void cmdChatJailConfig(BasePlayer player, string command, string[] args)
{
if (player.GetComponent<BaseNetworkable>().net.connection.authLevel < 1)
{
SendReply(player, "You are not allowed to use this command.");
return;
}
if (args.Length < 2)
{
SendReply(player, "/jail_config jail_spawnfile jailspawnfile => set the spawns where players will be jailed");
SendReply(player, "/jail_config free_spawnfile freespawnfile => set the spawns where players will be freed");
SendReply(player, "/jail_config zone RADIUS");
SendReply(player, "You must stand in the center of the radius zone of the jail.");
return;
}
if (args[0] == "zone")
{
float radius = Convert.ToSingle(args[1]);
jailconfig["radius"] = radius.ToString();
jailconfig["zonex"] = player.transform.position.x.ToString();
jailconfig["zoney"] = player.transform.position.y.ToString();
jailconfig["zonez"] = player.transform.position.z.ToString();
SendReply(player, "New Zone {0} {1} {2} with Radius {3}", jailconfig["zonex"].ToString(), jailconfig["zoney"].ToString(), jailconfig["zonez"].ToString(), jailconfig["radius"].ToString());
LoadZone();
}
else if (args[0] == "free_spawnfile")
{
var count = Interface.GetMod().CallHook("GetSpawnsCount", new object[] { args[1] });
if (count == null)
{
SendReply(player, "SpawnFile {0} is not a valid spawnfile", jailconfig["free_spawnfile"].ToString());
jailconfig["free_spawnfile"] = null;
}
else
{
jailconfig["free_spawnfile"] = args[1];
SendReply(player, "New SpawnFile for Freed players: {0}", jailconfig["free_spawnfile"].ToString());
LoadSpawnfile();
}
}
else if (args[0] == "jail_spawnfile")
{
var count = Interface.GetMod().CallHook("GetSpawnsCount", new object[] { args[1] });
if (count == null)
{
SendReply(player, "SpawnFile {0} is not a valid spawnfile", jailconfig["jail_spawnfile"].ToString());
jailconfig["jail_spawnfile"] = null;
}
else
{
jailconfig["jail_spawnfile"] = args[1];
SendReply(player, "New SpawnFile for Jaild Players: {0}", jailconfig["jail_spawnfile"].ToString());
LoadSpawnfile();
}
}
SaveDataConfig();
}
示例13: GetBuildPlayer
/////////////////////////////////////////////////////
/// GetBuildPlayer(BasePlayer player)
/// Create or Get the BuildPlayer from a player, where all informations of current action is stored
/////////////////////////////////////////////////////
BuildPlayer GetBuildPlayer(BasePlayer player)
{
if (player.GetComponent<BuildPlayer>() == null)
return player.gameObject.AddComponent<BuildPlayer>();
else
return player.GetComponent<BuildPlayer>();
}
示例14: cmdChatErase
void cmdChatErase(BasePlayer player, string command, string[] args)
{
if (!hasAccess(player)) return;
BuildPlayer buildplayer = GetBuildPlayer(player);
if (buildplayer.currentType != null && buildplayer.currentType == "erase")
{
UnityEngine.GameObject.Destroy(player.GetComponent<BuildPlayer>());
SendReply(player, "Building Tool: Remove Deactivated");
}
else
{
buildplayer.currentType = "erase";
SendReply(player, "Building Tool: Remove Activated");
}
}
示例15: EventReward
void EventReward(BasePlayer player)
{
EventWinner winner = player.GetComponent<EventWinner>();
if (winner != null)
{
clearGUI(player);
player.GiveItem(ItemManager.CreateByPartialName("supply.signal", winner.amount));
UnityEngine.GameObject.Destroy(winner);
PrintChat(player, "Your reward has been added to your inventory.");
}
else
{
PrintChat(player, "You haven't won the event.");
}
}