This repository has been archived by the owner on Mar 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from avans-alga-dpa/feature/commands
Commands
- Loading branch information
Showing
13 changed files
with
219 additions
and
3 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/Avans.FlatGalaxy.Simulation/Commands/AddAsteroidCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Avans.FlatGalaxy.Simulation.Commands.Common; | ||
|
||
namespace Avans.FlatGalaxy.Simulation.Commands | ||
{ | ||
public class AddAsteroidCommand : ICommand | ||
{ | ||
public void Execute(ISimulator simulator) | ||
{ | ||
simulator.AddAsteroid(); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Avans.FlatGalaxy.Simulation/Commands/CollisionSwitchCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Avans.FlatGalaxy.Simulation.Commands.Common; | ||
|
||
namespace Avans.FlatGalaxy.Simulation.Commands | ||
{ | ||
public class CollisionSwitchCommand : ICommand | ||
{ | ||
public void Execute(ISimulator simulator) | ||
{ | ||
simulator.SwitchCollisionAlgo(); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Avans.FlatGalaxy.Simulation/Commands/CollisionVisibilityCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Avans.FlatGalaxy.Simulation.Commands.Common; | ||
|
||
namespace Avans.FlatGalaxy.Simulation.Commands | ||
{ | ||
public class CollisionVisibilityCommand : ICommand | ||
{ | ||
public void Execute(ISimulator simulator) | ||
{ | ||
simulator.ToggleCollisionVisibility(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Avans.FlatGalaxy.Simulation.Commands.Common | ||
{ | ||
public interface ICommand | ||
{ | ||
void Execute(ISimulator simulator); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Avans.FlatGalaxy.Simulation.Commands.Common; | ||
|
||
namespace Avans.FlatGalaxy.Simulation.Commands | ||
{ | ||
public class PauseCommand : ICommand | ||
{ | ||
public void Execute(ISimulator simulator) | ||
{ | ||
simulator.Pause(); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Avans.FlatGalaxy.Simulation/Commands/RemoveAsteroidCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Avans.FlatGalaxy.Simulation.Commands.Common; | ||
|
||
namespace Avans.FlatGalaxy.Simulation.Commands | ||
{ | ||
public class RemoveAsteroidCommand : ICommand | ||
{ | ||
public void Execute(ISimulator simulator) | ||
{ | ||
simulator.RemoveAsteroid(); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Avans.FlatGalaxy.Simulation/Commands/RestoreCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Avans.FlatGalaxy.Simulation.Commands.Common; | ||
|
||
namespace Avans.FlatGalaxy.Simulation.Commands | ||
{ | ||
public class RestoreCommand : ICommand | ||
{ | ||
public void Execute(ISimulator simulator) | ||
{ | ||
simulator.Restore(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Avans.FlatGalaxy.Simulation.Commands.Common; | ||
|
||
namespace Avans.FlatGalaxy.Simulation.Commands | ||
{ | ||
public class ResumeCommand : ICommand | ||
{ | ||
public void Execute(ISimulator simulator) | ||
{ | ||
simulator.Resume(); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Avans.FlatGalaxy.Simulation/Commands/SpeedDownCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Avans.FlatGalaxy.Simulation.Commands.Common; | ||
|
||
namespace Avans.FlatGalaxy.Simulation.Commands | ||
{ | ||
public class SpeedDownCommand : ICommand | ||
{ | ||
private readonly double _speedDiff; | ||
|
||
public SpeedDownCommand(double speedDiff = ISimulator.SpeedDiff) | ||
{ | ||
_speedDiff = speedDiff; | ||
} | ||
|
||
public void Execute(ISimulator simulator) | ||
{ | ||
simulator.SpeedDown(_speedDiff); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Avans.FlatGalaxy.Simulation/Commands/SpeedUpCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Avans.FlatGalaxy.Simulation.Commands.Common; | ||
|
||
namespace Avans.FlatGalaxy.Simulation.Commands | ||
{ | ||
public class SpeedUpCommand : ICommand | ||
{ | ||
private readonly double _speedDiff; | ||
|
||
public SpeedUpCommand(double speedDiff = ISimulator.SpeedDiff) | ||
{ | ||
_speedDiff = speedDiff; | ||
} | ||
|
||
public void Execute(ISimulator simulator) | ||
{ | ||
simulator.SpeedUp(_speedDiff); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Avans.FlatGalaxy.Simulation/Extensions/ListExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Avans.FlatGalaxy.Simulation.Extensions | ||
{ | ||
public static class ListExtensions | ||
{ | ||
public static T Random<T>(this IEnumerable<T> source) | ||
{ | ||
return source.Random(1).Single(); | ||
} | ||
|
||
public static IEnumerable<T> Random<T>(this IEnumerable<T> source, int count) | ||
{ | ||
return source.Shuffle().Take(count); | ||
} | ||
|
||
public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source) | ||
{ | ||
return source.OrderBy(x => Guid.NewGuid()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters