private bool MakeSurePlaceHolderExists() { if (m_placeholder != null) { return(true); } var untouchPlaceholders = WeaponManager.GetUntouchedTurretPlaceholders(); if (untouchPlaceholders.Count() > 0) { foreach (var p in untouchPlaceholders) { if (p.Value.Placeholder.GetAABB().Intersects(Player.GetAABB())) { m_placeholder = p.Value.Placeholder; m_buildProgress = (int)Math.Round(m_placeholder.BuildProgress * MaxProgress); WeaponManager.AddBuilderToTurretPlaceholder(m_placeholder.UniqueID, Player); return(true); } } } return(false); }
private void StopBuilding() { m_hitTimer = 0f; m_targetPlaceholder = null; Player.AddCommand(new PlayerCommand(PlayerCommandType.StopCrouch)); Player.SetInputEnabled(true); m_state = EngineerState.Normal; }
private void StopOccupying() { m_buildProgress = 0; if (m_placeholder != null) { WeaponManager.RemoveBuilderFromTurretPlaceholder(m_placeholder.UniqueID); m_placeholder = null; } }
private bool CheckExistingPlaceholder() { var untouchPlaceholders = WeaponManager.GetUntouchedTurretPlaceholders(); if (untouchPlaceholders.Count() > 0) { var minDistanceToPlaceholder = float.PositiveInfinity; foreach (var p in untouchPlaceholders) { var distanceToPlayer = Vector2.Distance(p.Value.Placeholder.Position, Actor.Position); if (minDistanceToPlaceholder > distanceToPlayer) { minDistanceToPlaceholder = distanceToPlayer; m_targetPlaceholder = p.Value.Placeholder; } } } return(m_targetPlaceholder != null); }
public bool CreateNewTurret() { if (HasEnoughEnergy) { if (!CanBuildTurretHere()) { Game.PlayEffect(EffectName.CustomFloatText, Position, "Cannot build here"); return(false); } var direction = Player.FacingDirection == -1 ? TurretDirection.Left : TurretDirection.Right; m_placeholder = WeaponManager.CreateTurretPlaceholder(Player, direction); m_createNewTurretCooldown = 0f; m_notifyCooldownOver = false; return(true); } else { Game.PlayEffect(EffectName.CustomFloatText, Position, "Not enough energy"); return(false); } }