public override ActionEventData HandleMouse(MouseData mouse, IDataRogueControlRenderer renderer, ISystemContainer systemContainer) { MapCoordinate mapCoordinate = GetMapCoordinate(mouse, systemContainer); systemContainer.ControlSystem.HoveredCoordinate = mapCoordinate; var player = systemContainer.PlayerSystem.Player; if (mouse.IsLeftClick && systemContainer.TimeSystem.WaitingForInput && CanAutowalkToCoordinate(systemContainer, mapCoordinate)) { var playerLocation = systemContainer.PositionSystem.CoordinateOf(player); var map = systemContainer.MapSystem.MapCollection[systemContainer.RendererSystem.CameraPosition.Key]; var path = _pathfindingAlgorithm.Path(map, playerLocation, mapCoordinate); if (path != null) { var action = new ActionEventData { Action = ActionType.FollowPath, Parameters = string.Join(";", path.Select(m => m.ToString())) }; return(action); } } if (mouse.IsRightClick && systemContainer.TimeSystem.WaitingForInput) { var map = systemContainer.MapSystem.MapCollection[systemContainer.RendererSystem.CameraPosition.Key]; if (map.SeenCoordinates.Contains(mapCoordinate)) { var playerFov = FOVHelper.CalculatePlayerFov(systemContainer); var entities = systemContainer.PositionSystem.EntitiesAt(mapCoordinate); if (!playerFov.Contains(mapCoordinate)) { entities = entities.Where(e => e.Has <Memorable>()).ToList(); } IEntity entityToShow = entities.OrderByDescending(e => e.Has <Appearance>() ? e.Get <Appearance>().ZOrder : int.MinValue).First(); var action = new ActionEventData { Action = ActionType.Examine, Parameters = entityToShow.EntityId.ToString() }; return(action); } } return(null); }
public override void AI() { if (++animationCounter >= 5) { animationCounter = 0; if (++frame >= Main.projFrames[projectile.type]) { frame = 0; } } projectile.frameCounter = 0; projectile.frame = frame; var owner = Main.player[projectile.owner]; if (owner.active && owner.HasBuff(ModContent.BuffType <HarpyPetBuff>())) { projectile.timeLeft = 2; } if (projectile.owner != Main.myPlayer) { return; } if (Timer > 0) { --Timer; return; } float direction; if (projectile.direction < 0) { direction = FOVHelper.POS_X_DIR + projectile.rotation; } else { direction = FOVHelper.NEG_X_DIR - projectile.rotation; } var origin = projectile.Center; var fov = new FOVHelper(); fov.AdjustCone(origin, FOV, direction); float maxDistSquared = Max_Range * Max_Range; for (int i = 0; i < Main.maxNPCs; ++i) { NPC npc = Main.npc[i]; Vector2 npcPos = npc.Center; if (npc.CanBeChasedBy() && fov.IsInCone(npcPos) && Vector2.DistanceSquared(origin, npcPos) < maxDistSquared && Collision.CanHitLine(origin, 0, 0, npc.position, npc.width, npc.height)) { if (Main.rand.NextBool(10)) { ShootFeathersAt(npcPos); } Timer = 140; break; } } }
public IDataRogueControl GetControlFromMousePosition(ISystemContainer systemContainer, IActivity activity, MapCoordinate cameraPosition, int x, int y) { var playerFov = systemContainer.ActivitySystem.GameplayActivity.Running ? FOVHelper.CalculatePlayerFov(systemContainer) : null; DoLayout(systemContainer, activity, playerFov); var mousePoint = new Point(x, y); var onControls = activity.Controls.Where(c => c.Position.Contains(mousePoint)); return(onControls.LastOrDefault()); }
public void Render(ISystemContainer systemContainer, IActivity activity, int activityIndex) { if (activity.RendersEntireSpace) { _console.Clear(); } var playerFov = systemContainer.ActivitySystem.GameplayActivity.Running ? FOVHelper.CalculatePlayerFov(systemContainer) : null; DoLayout(systemContainer, activity, playerFov); foreach (var control in activity.Controls) { control.SetActivityIndex(activityIndex); IDataRogueControlRenderer controlRenderer = GetRendererFor(control); controlRenderer.Paint(_console, control, systemContainer, playerFov); } }
public void Render(ISystemContainer systemContainer, IActivity activity, int activityIndex) { if (activity.RendersEntireSpace) { BLT.Clear(); } var playerFov = systemContainer.ActivitySystem.GameplayActivity.Running ? FOVHelper.CalculatePlayerFov(systemContainer) : null; activity.Layout(_controlRenderers, systemContainer, playerFov, _spriteManager); Paint(systemContainer, activity, playerFov, activityIndex); }
public IDataRogueControl GetControlFromMousePosition(ISystemContainer systemContainer, IActivity activity, MapCoordinate cameraPosition, int x, int y) { var playerFov = systemContainer.ActivitySystem.GameplayActivity.Running ? FOVHelper.CalculatePlayerFov(systemContainer) : null; activity.Layout(_controlRenderers, systemContainer, playerFov, _spriteManager); var allControls = activity.Controls.GetControlsRecursive(); var mousePoint = new Point(x, y); var onControls = allControls.Where(c => c.CanHandleMouse && c.Position.Contains(mousePoint)); return(onControls.LastOrDefault()); }