Skip to content

Commit

Permalink
v0.2-beta
Browse files Browse the repository at this point in the history
v0.2-beta
  • Loading branch information
LDami authored Aug 10, 2022
2 parents fc078eb + a6b9d8c commit 89a4f36
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions SampSharpGameMode1/Commands/DerbyCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class DerbyCommandsClass
[Command("create")]
private static void CreateDerby(Player player)
{
if (player.pEvent != null)
if (player.pEvent != null || player.mapCreator != null)
return;
if (!(player.eventCreator is DerbyCreator))
{
Expand All @@ -93,7 +93,7 @@ private static void CreateDerby(Player player)
[Command("loadc")]
public static void LoadDerbyCreator(Player player, int id)
{
if (player.pEvent != null)
if (player.pEvent != null || player.mapCreator != null)
return;
if (!(player.eventCreator is DerbyCreator))
{
Expand Down
11 changes: 10 additions & 1 deletion SampSharpGameMode1/Commands/MappingCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ private static void HelpCommand(Player player)
$"{ColorPalette.Primary.Main}/mapping dupl [objectid] {ColorPalette.Primary.Darken}Duplicate the object" + "\n" +
$"{ColorPalette.Primary.Main}/mapping marker [1-2] {ColorPalette.Primary.Darken}Edit the marker position to get distance" + "\n" +
$"{ColorPalette.Primary.Main}/mapping dist {ColorPalette.Primary.Darken}Displays the distance between the markers" + "\n" +
$"{ColorPalette.Primary.Main}/mapping edit [objectid] {ColorPalette.Primary.Darken}Edit position/rotation of object";
$"{ColorPalette.Primary.Main}/mapping edit [objectid] {ColorPalette.Primary.Darken}Edit position/rotation of object" + "\n" +
$"{ColorPalette.Primary.Main}/mapping magnet {ColorPalette.Primary.Darken}Toggle magnet on objects during edition";
;
MessageDialog dialog = new MessageDialog("Command list", list, "Close");
dialog.Show(player);
Expand Down Expand Up @@ -275,6 +276,14 @@ private static void EditCommand(Player player, int objectid)
else
player.SendClientMessage(Color.Red, $"Map creator is not initialized, create or load a map first");
}
[Command("magnet")]
private static void MagnetCommand(Player player)
{
if (!(player.mapCreator is null))
player.mapCreator.Magnet = !player.mapCreator.Magnet;
else
player.SendClientMessage(Color.Red, $"Map creator is not initialized, create or load a map first");
}

[Command("info")]
public static void GetInfo(Player player, int id)
Expand Down
4 changes: 2 additions & 2 deletions SampSharpGameMode1/Commands/RaceCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private static void HelpRace(Player player)
[Command("create")]
private static void CreateRace(Player player)
{
if (player.pEvent != null)
if (player.pEvent != null || player.mapCreator != null)
return;
if (!(player.eventCreator is RaceCreator))
{
Expand All @@ -121,7 +121,7 @@ private static void CreateRace(Player player)
[Command("loadc")]
public static void LoadRaceCreator(Player player, int id)
{
if (player.pEvent != null)
if (player.pEvent != null || player.mapCreator != null)
return;
if (!(player.eventCreator is RaceCreator))
{
Expand Down
10 changes: 5 additions & 5 deletions SampSharpGameMode1/Events/Races/RaceCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ private void LoadingRace_Loaded(object sender, RaceLoadedEventArgs e)
checkpointIndex = 0;
editingRace = e.race;
spawnVehicles = new BaseVehicle[Race.MAX_PLAYERS_IN_RACE];
UpdatePlayerCheckpoint();

if (map != null)
map.Unload();
Expand All @@ -154,9 +153,6 @@ private void SetPlayerInEditor()
{
player.VirtualWorld = (int)VirtualWord.EventCreators + player.Id;
player.EnablePlayerCameraTarget(true);
player.KeyStateChanged += Player_KeyStateChanged;
player.EnterCheckpoint += Player_EnterCheckpoint;
player.EnterRaceCheckpoint += Player_EnterRaceCheckpoint;

Vector3 pos;
float rot = 0;
Expand Down Expand Up @@ -193,6 +189,10 @@ private void SetPlayerInEditor()
player.SendClientMessage(" keypad 6: Go to next checkpoint");
player.SendClientMessage(" submission key (2/é): Open Race menu");
player.SendClientMessage(" /race help Show the controls list");
player.KeyStateChanged += Player_KeyStateChanged;
player.EnterCheckpoint += Player_EnterCheckpoint;
player.EnterRaceCheckpoint += Player_EnterRaceCheckpoint;
UpdatePlayerCheckpoint();
}

public void Unload()
Expand Down Expand Up @@ -956,7 +956,7 @@ public void UpdatePlayerCheckpoint()
Vector3 nextPos = (nextCp != null) ? nextCp.Position : Vector3.Zero;

if (shownCheckpoint == null || shownCheckpoint.IsDisposed)
shownCheckpoint = new DynamicRaceCheckpoint(cp.Type, cp.Position, nextPos, cp.Size, player.VirtualWorld);
shownCheckpoint = new DynamicRaceCheckpoint(cp.Type, cp.Position, nextPos, cp.Size, player.VirtualWorld, streamdistance: 500);
else
{
shownCheckpoint.Position = cp.Position;
Expand Down
5 changes: 2 additions & 3 deletions SampSharpGameMode1/MapCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ private void SetPlayerInEditor()
Magnet = true;
player.SendClientMessage("Here are the controls:");
player.SendClientMessage(" Y/N: Unfreeze/Freeze (usefull in Jetpack !)");
player.SendClientMessage(" Z/LShift: Move camera during object edition");
}

private void Player_Disconnected(object sender, DisconnectEventArgs e)
Expand Down Expand Up @@ -260,7 +261,7 @@ public int AddObject(int modelid, Vector3? position = null, Vector3? rotation =
{
Vector3 newPosition = e.Position;
Vector3 newRotation = e.Rotation;
if(magnet)
if(Magnet)
{
if (newPosition.X != lastObjectPos.X)
editedAxis = Axis.X;
Expand Down Expand Up @@ -291,8 +292,6 @@ public int AddObject(int modelid, Vector3? position = null, Vector3? rotation =
}
if(nearestObjectDistance < 3.0f)
{
Console.WriteLine("Nearest object detected: " + nearestObject.Id + " " + nearestObjectDistance);
Console.WriteLine("edited axis: " + editedAxis.ToString());
if (Math.Abs(nearestObject.Position.X - mapObject.Position.X) < 3.0f && editedAxis == Axis.X)
newPosition = new Vector3(nearestObject.Position.X, newPosition.Y, newPosition.Z);
if (Math.Abs(nearestObject.Position.Y - mapObject.Position.Y) < 3.0f && editedAxis == Axis.Y)
Expand Down

0 comments on commit 89a4f36

Please sign in to comment.