// TODO: Add Target and AOE everything around it? Use OnBeforeUses on every target in UseInternal? Or only on selected Target? protected override void UpdateTarget() { foreach (PlayerControl player in AllPlayers) { if (player == LocalPlayer) { continue; } if (owner.Owner.GetRole().Faction == Faction.Mafia && player.GetRole().Faction == Faction.Mafia) { continue; } if (!PlayerTools.IsPlayerInUseRange(owner.Owner, player)) { player.myRend.material.SetFloat(ShaderOutline, 0F); continue; } player.myRend.material.SetFloat(ShaderOutline, 1F); player.myRend.material.SetColor(ShaderOutlineColor, Color.green); } Button.SetTarget(LocalPlayer == owner.Owner ? PlayerTools.FindClosestTarget(owner.Owner) : null); }
public bool CheckCooldown(KillButtonManager instance) { if (!CanKill) { return(false); } PlayerControl closest = PlayerTools.FindClosestTarget(player); if (closest == null || SpecialRoleIsAssigned(out KeyValuePair <byte, Doctor> doctorKvp) && doctorKvp.Value.protectedPlayer?.PlayerId == closest.PlayerId) { return(false); // Sound is already checked with the impostor role, so no need to play here } if (!instance.isCoolingDown) { return(true); } if (DoubleKillUsed || closest.Data.IsImpostor) { return(false); } SoundManager.Instance.PlaySound(ninjaTwo, false, 100f); DoubleKillUsed = true; player.MurderPlayer(closest); MessageWriter writer = GetWriter(RPC.NinjaDoubleKill); writer.Write(player.PlayerId); writer.Write(closest.PlayerId); CloseWriter(writer); player.SetKillTimer(player.killTimer + PlayerControl.GameOptions.KillCooldown * 2); return(false); }
protected override void UpdateTarget() { if (owner.Faction == Faction.Mafia || owner.Faction == Faction.Coven) { Button.SetTarget(PlayerTools.FindClosestTarget(owner.Owner, (player) => player.GetRole()?.Faction != owner.Faction)); } else { base.UpdateTarget(); } }
public bool SetProtectedPlayer(KillButtonManager instance) { if (protectedPlayer != null || instance.isCoolingDown) { return(false); } protectedPlayer = PlayerTools.FindClosestTarget(player); shieldUsed = true; MessageWriter writer = GetWriter(RPC.SetProtected); writer.Write(protectedPlayer.PlayerId); CloseWriter(writer); return(false); }
public void CheckShieldButton(HudManager instance) { if (instance.UseButton == null || !instance.UseButton.isActiveAndEnabled || player.Data.IsDead) { return; } KillButtonManager killButton = instance.KillButton; killButton.gameObject.SetActive(true); killButton.renderer.enabled = true; killButton.isActive = true; killButton.renderer.sprite = specialButton; killButton.SetTarget(!shieldUsed ? PlayerTools.FindClosestTarget(player) : null); }
public bool KillOrCommitSuicide(KillButtonManager instance) { if (instance.isCoolingDown) { return(false); } PlayerControl target = PlayerTools.FindClosestTarget(player); if (target == null) { return(false); } if (SpecialRoleIsAssigned <Doctor>(out var doctorKvp) && doctorKvp.Value.protectedPlayer?.PlayerId == target.PlayerId) { // Sound effekt doctorKvp.Value.AttemptKillShielded(); player.SetKillTimer(cooldown); if (doctorKvp.Value.shieldKillAttemptIndicator) { WriteImmediately(RPC.AttemptShield); } return(false); } if ( //check if they're Maniac and the setting is configured (SpecialRoleIsAssigned(out KeyValuePair <byte, Maniac> maniacKvp) && target.PlayerId == maniacKvp.Key && maniacKvp.Value.maniacCanDieToDetective) //or if they're an impostor || target.Data.IsImpostor ) { KillPlayer(target); } //else, they're innocent or shielded by the doctor else { KillPlayer(player); } return(false); }
protected override void UpdateTarget() { Button.SetTarget(LocalPlayer == owner.Owner ? PlayerTools.FindClosestTarget(owner.Owner, player => !Vampires.Contains(player)) : null); }