public override void EquipWeapon() { base.EquipWeapon(); HeldEntity heldEntity = base.GetHeldEntity(); if (heldEntity != null) { Item item = heldEntity.GetItem(); if (item != null && item.contents != null) { if (UnityEngine.Random.Range(0, 3) == 0) { Item item1 = ItemManager.CreateByName("weapon.mod.flashlight", 1, (ulong)0); if (!item1.MoveToContainer(item.contents, -1, true)) { item1.Remove(0f); return; } this.lightsOn = false; base.InvokeRandomized(new Action(this.LightCheck), 0f, 30f, 5f); base.LightCheck(); return; } Item item2 = ItemManager.CreateByName("weapon.mod.lasersight", 1, (ulong)0); if (!item2.MoveToContainer(item.contents, -1, true)) { item2.Remove(0f); } base.SetLightsOn(true); this.lightsOn = true; } } }
private void OnEntityBuilt(HeldEntity heldentity, GameObject gameobject) { if (!DisableOnlyOnConstructions) { return; } var player = heldentity.ownerPlayer; if (player.CanBuild()) { return; } var entity = gameobject.GetComponent <BaseCombatEntity>(); if (!entity || !entity.LookupPrefabName().StartsWith(LadderPrefabs)) { return; } if (Physics.CheckSphere(entity.transform.position, 1.2f, LayerMasks)) { entity.Kill(BaseNetworkable.DestroyMode.Gib); player.ChatMessage(BuildingBlockedMsg); TryReturnLadder(player, entity); } }
private void Reappear(BasePlayer basePlayer) { if (onlinePlayers[basePlayer] != null) { onlinePlayers[basePlayer].IsInvisible = false; } basePlayer.SendNetworkUpdate(); basePlayer.limitNetworking = false; HeldEntity heldEnity = basePlayer.GetHeldEntity(); if (heldEnity != null) { heldEnity.UpdateVisibility_Hand(); heldEnity.SendNetworkUpdate(); } basePlayer.UpdatePlayerCollider(true); string gui; if (guiInfo.TryGetValue(basePlayer.userID, out gui)) { CuiHelper.DestroyUi(basePlayer, gui); } Message(basePlayer.IPlayer, "VanishDisabled"); if (onlinePlayers.Values.Count(p => p.IsInvisible) <= 0) { Unsubscribe(nameof(CanNetworkTo)); } }
void HideSleeper(BasePlayer player) { List <Connection> connections = new List <Connection>(); foreach (BasePlayer target in BasePlayer.activePlayerList) { if (player == target || !target.IsConnected) { continue; } connections.Add(target.net.connection); } HeldEntity heldEntity = player.GetHeldEntity(); if (heldEntity != null) { heldEntity.SetHeld(false); heldEntity.UpdateVisiblity_Invis(); heldEntity.SendNetworkUpdate(); } if (Net.sv.write.Start()) { Net.sv.write.PacketID(Message.Type.EntityDestroy); Net.sv.write.EntityID(player.net.ID); Net.sv.write.UInt8((byte)BaseNetworkable.DestroyMode.None); Net.sv.write.Send(new SendInfo(connections)); } player.UpdatePlayerCollider(false); }
public void SetHeldEntity(BaseEntity ent) { if (!BaseEntityEx.IsValid(ent)) { this.heldEntity.Set(null); MarkDirty(); } else { if (this.heldEntity.uid == ent.net.ID) { return; } this.heldEntity.Set(ent); MarkDirty(); if (BaseEntityEx.IsValid(ent)) { HeldEntity heldEntity = ent as HeldEntity; if (heldEntity != null) { heldEntity.SetupHeldEntity(this); } } } }
public bool IsValidWeapon(Item item) { ItemDefinition info = item.info; if (item.isBroken) { return(false); } ItemModEntity component = info.GetComponent <ItemModEntity>(); if (component == null) { return(false); } HeldEntity component2 = component.entityPrefab.Get().GetComponent <HeldEntity>(); if (component2 == null) { return(false); } if (!component2.IsUsableByTurret) { return(false); } return(true); }
// Player place item or building void OnEntityBuilt(Planner plan, GameObject go, HeldEntity heldentity) { string name = plan.GetOwnerPlayer().displayName; //Playername ulong playerID = plan.GetOwnerPlayer().userID; //steam_id var placedObject = go.ToBaseEntity(); if (placedObject is BuildingBlock) { string item_name = ((BuildingBlock)placedObject).blockDefinition.info.name.english; //Puts(playerID + name + item_name + getDate()); executeQuery("INSERT INTO player_place_building (player_id, player_name, building, date) VALUES (@0, @1, @2, @3)" + "ON DUPLICATE KEY UPDATE amount = amount + 1", playerID, name, item_name, getDate()); } else if (plan.isTypeDeployable) { string item_name = plan.GetOwnerItemDefinition().displayName.english; //Puts(playerID + name + item_name + getDate()); executeQuery("INSERT INTO player_place_deployable (player_id, player_name, deployable, date) VALUES (@0, @1, @2, @3)" + "ON DUPLICATE KEY UPDATE amount = amount + 1", playerID, name, item_name, getDate()); } if (plan.GetOwnerItemDefinition().shortname == "cupboard.tool") { var cupboard = go.GetComponent <BuildingPrivlidge>(); BasePlayer player = plan.GetOwnerPlayer(); OnCupboardAuthorize(cupboard, player); OnCupboardAuthorize(cupboard, player); // Dirty fix for set access to 1 } }
private void Repeater() { if (basePlayer == null || !basePlayer.IsConnected) { GameObject.Destroy(this); return; } var activeItem = basePlayer.svActiveItemID; if (activeItem == svActiveItemID) { return; } svActiveItemID = activeItem; if (ins.IsInvisible(basePlayer)) { HeldEntity heldEntity = basePlayer.GetHeldEntity(); if (heldEntity != null) { heldEntity.SetHeld(false); } } }
public void SetHeldEntity(BaseEntity ent) { if (!ent.IsValid()) { this.heldEntity.Set((BaseEntity)null); this.MarkDirty(); } else { if ((int)this.heldEntity.uid == ent.net.ID) { return; } this.heldEntity.Set(ent); this.MarkDirty(); if (!ent.IsValid()) { return; } HeldEntity heldEntity = ent as HeldEntity; if (!Object.op_Inequality((Object)heldEntity, (Object)null)) { return; } heldEntity.SetupHeldEntity(this); } }
void OnEntityBuilt(HeldEntity heldentity, GameObject gameobject) { if (!serverInitialized) { return; } var block = gameobject.GetComponent <BuildingBlock>(); if (block == null) { return; } var player = heldentity.GetOwnerPlayer(); if (player == null) { return; } var blockdata = FindBlockData(block); if (blockdata is string) { return; } SetBlockData(block, player.userID.ToString()); }
/// <summary> /// Called right before a Syringe or Medkit item is used /// </summary> /// <param name="item">Item</param> /// <param name="target">Target</param> /// <returns></returns> object OnHealingItemUse(HeldEntity item, BasePlayer target) { if (item is MedicalTool && item.ShortPrefabName.Contains("syringe")) { target.health = target.health + healAmount; return(true); } return(null); }
public void UpdatedVisibleHolsteredItems() { List <HeldEntity> list = Facepunch.Pool.GetList <HeldEntity>(); List <Item> items = Facepunch.Pool.GetList <Item>(); this.AllItemsNoAlloc(ref items); foreach (Item item in items) { if (!item.info.isHoldable || item.GetHeldEntity() == null) { continue; } HeldEntity component = item.GetHeldEntity().GetComponent <HeldEntity>(); if (component == null) { continue; } list.Add(component); } Facepunch.Pool.FreeList <Item>(ref items); List <HeldEntity> heldEntities = list; bool flag = true; bool flag1 = true; bool flag2 = true; foreach (HeldEntity heldEntity in from x in heldEntities orderby x.hostileScore descending select x) { if (heldEntity == null || !heldEntity.holsterInfo.displayWhenHolstered) { continue; } if (flag2 && !heldEntity.IsDeployed() && heldEntity.holsterInfo.slot == HeldEntity.HolsterInfo.HolsterSlot.BACK) { heldEntity.SetVisibleWhileHolstered(true); flag2 = false; } else if (flag1 && !heldEntity.IsDeployed() && heldEntity.holsterInfo.slot == HeldEntity.HolsterInfo.HolsterSlot.RIGHT_THIGH) { heldEntity.SetVisibleWhileHolstered(true); flag1 = false; } else if (!flag || heldEntity.IsDeployed() || heldEntity.holsterInfo.slot != HeldEntity.HolsterInfo.HolsterSlot.LEFT_THIGH) { heldEntity.SetVisibleWhileHolstered(false); } else { heldEntity.SetVisibleWhileHolstered(true); flag = false; } } Facepunch.Pool.FreeList <HeldEntity>(ref list); }
float hotTime = 10f; // Heal-over-time time object OnHealingItemUse(HeldEntity item, BasePlayer target) { if (item is MedicalTool && item.ShortPrefabName.Contains("syringe")) { target.health = target.health + healAmount; target.metabolism.ApplyChange(MetabolismAttribute.Type.HealthOverTime, hotAmount, hotTime); return(true); } return(null); }
public void UpdateAttachedWeapon() { Item slot = base.inventory.GetSlot(0); HeldEntity heldEntity = null; if (slot != null && (slot.info.category == ItemCategory.Weapon || slot.info.category == ItemCategory.Fun)) { BaseEntity heldEntity2 = slot.GetHeldEntity(); if (heldEntity2 != null) { HeldEntity component = heldEntity2.GetComponent <HeldEntity>(); if (component != null && component.IsUsableByTurret) { heldEntity = component; } } } SetFlag(Flags.Reserved3, heldEntity != null); if (heldEntity == null) { if ((bool)GetAttachedWeapon()) { GetAttachedWeapon().SetGenericVisible(false); GetAttachedWeapon().SetLightsOn(false); } AttachedWeapon = null; return; } heldEntity.SetLightsOn(true); Transform transform = heldEntity.transform; Transform muzzleTransform = heldEntity.MuzzleTransform; heldEntity.SetParent(null); transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; Quaternion quaternion = transform.rotation * Quaternion.Inverse(muzzleTransform.rotation); heldEntity.limitNetworking = false; heldEntity.SetFlag(Flags.Disabled, false); heldEntity.SetParent(this, StringPool.Get(socketTransform.name)); transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; transform.rotation *= quaternion; Vector3 vector = socketTransform.InverseTransformPoint(muzzleTransform.position); transform.localPosition = Vector3.left * vector.x; float num = Vector3.Distance(muzzleTransform.position, transform.position); transform.localPosition += Vector3.forward * num * attachedWeaponZOffsetScale; heldEntity.SetGenericVisible(true); AttachedWeapon = heldEntity; totalAmmoDirty = true; Reload(); UpdateTotalAmmo(); }
private void OnHealingItemUse(HeldEntity item, BasePlayer target) { if (logHealingItems) { Log("Combat", Lang("Log Player Healing1", target.displayName, target.userID, item.GetItem().info.displayName.english, logPositions ? $"{Lang("Log At")} {EntityPosition(target)}" : null)); } if (putHealingItems) { Puts(Lang("Log Player Healing1", target.displayName, target.userID, item.GetItem().info.displayName.english, logPositions ? $"{Lang("Log At")} {EntityPosition(target)}" : null)); } }
private void OnPlayerTick(BasePlayer basePlayer) { if (onlinePlayers[basePlayer] != null && onlinePlayers[basePlayer].IsInvisible) { HeldEntity heldEntity = basePlayer.GetHeldEntity(); if (heldEntity != null && basePlayer.IPlayer.HasPermission(permAbilitiesWeapons)) { heldEntity.SetHeld(false); } } }
public override void OnKilled(HitInfo info) { BaseProjectile attachedWeapon = GetAttachedWeapon(); if (attachedWeapon != null) { attachedWeapon.SetGenericVisible(false); attachedWeapon.SetLightsOn(false); } AttachedWeapon = null; base.OnKilled(info); }
public void UpdatedVisibleHolsteredItems() { List <HeldEntity> list1 = (List <HeldEntity>)Pool.GetList <HeldEntity>(); List <Item> list2 = (List <Item>)Pool.GetList <Item>(); this.AllItemsNoAlloc(ref list2); foreach (Item obj in list2) { if (obj.info.isHoldable && !Object.op_Equality((Object)obj.GetHeldEntity(), (Object)null)) { HeldEntity component = (HeldEntity)((Component)obj.GetHeldEntity()).GetComponent <HeldEntity>(); if (!Object.op_Equality((Object)component, (Object)null)) { list1.Add(component); } } } // ISSUE: cast to a reference type Pool.FreeList <Item>((List <M0>&) ref list2); IOrderedEnumerable <HeldEntity> orderedEnumerable = list1.OrderByDescending <HeldEntity, float>((Func <HeldEntity, float>)(x => x.hostileScore)); bool flag1 = true; bool flag2 = true; bool flag3 = true; foreach (HeldEntity heldEntity in (IEnumerable <HeldEntity>)orderedEnumerable) { if (!Object.op_Equality((Object)heldEntity, (Object)null) && heldEntity.holsterInfo.displayWhenHolstered) { if (flag3 && !heldEntity.IsDeployed() && heldEntity.holsterInfo.slot == HeldEntity.HolsterInfo.HolsterSlot.BACK) { heldEntity.SetVisibleWhileHolstered(true); flag3 = false; } else if (flag2 && !heldEntity.IsDeployed() && heldEntity.holsterInfo.slot == HeldEntity.HolsterInfo.HolsterSlot.RIGHT_THIGH) { heldEntity.SetVisibleWhileHolstered(true); flag2 = false; } else if (flag1 && !heldEntity.IsDeployed() && heldEntity.holsterInfo.slot == HeldEntity.HolsterInfo.HolsterSlot.LEFT_THIGH) { heldEntity.SetVisibleWhileHolstered(true); flag1 = false; } else { heldEntity.SetVisibleWhileHolstered(false); } } } // ISSUE: cast to a reference type Pool.FreeList <HeldEntity>((List <M0>&) ref list1); }
void OnHealingItemUse(HeldEntity item, BasePlayer target) { var player = item.GetOwnerPlayer(); if (player == null) { return; } if (player != target && configData.ActiveChallengeTypes[CTypes.Healed.ToString()]) { AddPoints(player, CTypes.Healed, 1); } }
public void ServerCommand(string command, BasePlayer player) { HeldEntity heldEntity = this.GetHeldEntity() as HeldEntity; if (Object.op_Inequality((Object)heldEntity, (Object)null)) { heldEntity.ServerCommand(this, command, player); } foreach (ItemMod itemMod in this.info.itemMods) { itemMod.ServerCommand(this, command, player); } }
public static bool ShouldNetworkToInvisible(BaseNetworkable net, BasePlayer player) { BasePlayer basePlayer; if ((basePlayer = (net as BasePlayer)) == null) { HeldEntity heldEntity = net as HeldEntity; basePlayer = ((heldEntity != null) ? heldEntity.GetOwnerPlayer() : null); } BasePlayer basePlayer2 = basePlayer; return(basePlayer2 == null || player == null || basePlayer2 == player || player.IsAdmin || !basePlayer2.IsInvisible); }
public override void ReturnedFromCancelledCraft(Item item, BasePlayer crafter) { BaseEntity heldEntity = item.GetHeldEntity(); if (!(heldEntity == null)) { HeldEntity heldEntity2 = heldEntity as HeldEntity; if (!(heldEntity2 == null)) { heldEntity2.ReturnedFromCancelledCraft(item, crafter); } } }
public override void CollectedForCrafting(Item item, BasePlayer crafter) { BaseEntity heldEntity = item.GetHeldEntity(); if (!(heldEntity == null)) { HeldEntity heldEntity2 = heldEntity as HeldEntity; if (!(heldEntity2 == null)) { heldEntity2.CollectedForCrafting(item, crafter); } } }
private void OnHealingItemUse(HeldEntity item, BasePlayer target) { var player = item.GetOwnerPlayer(); if (player == null || player is NPCPlayer) { return; } if (player != target && configData.ChallengeSettings[Challenges.PlayersHealed].Enabled) { AddPoints(player, Challenges.PlayersHealed, 1); } }
private void OnHealingItemUse(HeldEntity item, BasePlayer player) { Debug($"Heal : {item.ShortPrefabName}"); if (item is MedicalTool && item.ShortPrefabName == "syringe_medical.entity") { player.Heal(6f); } if (item is MedicalTool && item.ShortPrefabName == "bandage.entity") { player.Heal(5f); } }
public void ServerCommand(string command, BasePlayer player) { HeldEntity heldEntity = this.GetHeldEntity() as HeldEntity; if (heldEntity != null) { heldEntity.ServerCommand(this, command, player); } ItemMod[] itemModArray = this.info.itemMods; for (int i = 0; i < (int)itemModArray.Length; i++) { itemModArray[i].ServerCommand(this, command, player); } }
private void StartTeleportTimer(BasePlayer player, string town) { TeleportTimers[player] = timer.Once(teleportCountdown, () => { HeldEntity heldEntity = player.GetHeldEntity(); if (heldEntity != null) { heldEntity.SetHeld(false); } var canTeleport = CanTownTeleport(player, town, false); if (canTeleport is string) { player.ChatMessage(canTeleport as string); return; } if (town == "outpost") { Teleport(player, OutpostSpawns[new System.Random().Next(OutpostSpawns.Count)]); } else if (town == "bandit") { Teleport(player, BanditSpawns[new System.Random().Next(BanditSpawns.Count)]); } int currentTime = GetUnix(); if (!storedData.Cooldowns.ContainsKey(player.userID)) { storedData.Cooldowns.Add(player.userID, currentTime); } else { storedData.Cooldowns[player.userID] = currentTime; } SaveData(); TeleportTimers[player]?.Destroy(); if (TeleportTimers.ContainsKey(player)) { TeleportTimers.Remove(player); } player.ChatMessage(Lang("TeleportSuccessMessage", player.UserIDString)); }); }
private static float LightDetection(BasePlayer option) { bool flag = false; Item activeItem = option.GetActiveItem(); if (activeItem != null) { HeldEntity heldEntity = activeItem.GetHeldEntity() as HeldEntity; if (Object.op_Inequality((Object)heldEntity, (Object)null)) { flag = heldEntity.LightsOn(); } } return(!flag ? 0.0f : 0.1f); }
public static Item FindTool(NPCHumanContext c, NPCPlayerApex.ToolTypeEnum tool) { foreach (Item allItem in c.Human.inventory.AllItems()) { if (allItem.info.category == ItemCategory.Tool) { HeldEntity heldEntity = allItem.GetHeldEntity() as HeldEntity; if (Object.op_Inequality((Object)heldEntity, (Object)null) && heldEntity.toolType == tool) { return(allItem); } } } return((Item)null); }
void OnEntityBuilt(HeldEntity heldentity, GameObject gameobject) { if (!serverInitialized) return; var block = gameobject.GetComponent<BuildingBlock>(); if (block == null) return; var player = heldentity.GetOwnerPlayer(); if (player == null) return; var blockdata = FindBlockData(block); if (blockdata is string) return; SetBlockData(block, player.userID.ToString()); }
private void Reappear(BasePlayer basePlayer) { if (onlinePlayers[basePlayer] != null) { onlinePlayers[basePlayer].IsInvisible = false; onlinePlayers[basePlayer].groupSwitchTimer?.Destroy(); if (basePlayer.GetComponent <WeaponBlock>() != null) { GameObject.Destroy(basePlayer.GetComponent <WeaponBlock>()); } if (basePlayer.GetComponent <Runner>() != null) { GameObject.Destroy(basePlayer.GetComponent <Runner>()); } } basePlayer.syncPosition = true; basePlayer.SendNetworkUpdate(); basePlayer.limitNetworking = false; HeldEntity heldEnity = basePlayer.GetHeldEntity(); if (heldEnity != null) { heldEnity.UpdateVisibility_Hand(); heldEnity.SendNetworkUpdate(); } basePlayer.UpdatePlayerCollider(true); string gui; if (guiInfo.TryGetValue(basePlayer.userID, out gui)) { CuiHelper.DestroyUi(basePlayer, gui); } Message(basePlayer.IPlayer, "VanishDisabled"); if (!AnyInvisible) { Unsubscribe(nameof(CanNetworkTo)); } Interface.CallHook("OnVanishReappear", basePlayer); storedData.Invisible.Remove(basePlayer.userID); }
void OnEntityBuilt(HeldEntity heldentity, GameObject gameobject) { if (serverInitialized) { var buildingblock = gameobject.GetComponent<BuildingBlock>(); if (buildingblock == null) return; float posy = buildingblock.transform.position.y; if (!(OwnersData.ContainsKey(posy))) { string userid = heldentity.ownerPlayer.userID.ToString(); OwnersData.Add(posy, userid); if (ReverseData[userid] == null) ReverseData[userid] = new List<object>(); var list = ReverseData[userid] as List<object>; list.Add(posy); ReverseData[userid] = list; } } }