Skip to content

Commit

Permalink
Merge pull request Impostor#377 from Impostor/airship
Browse files Browse the repository at this point in the history
  • Loading branch information
js6pak authored Apr 11, 2021
2 parents 0a30fe5 + 8d27016 commit f0434f0
Show file tree
Hide file tree
Showing 134 changed files with 1,676 additions and 4,631 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "src/Impostor.Hazel"]
path = src/Impostor.Hazel
url = https://github.com/Impostor/Impostor.Hazel
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ WORKDIR /source
# Copy csproj and restore.
COPY src/Impostor.Server/Impostor.Server.csproj ./src/Impostor.Server/Impostor.Server.csproj
COPY src/Impostor.Api/Impostor.Api.csproj ./src/Impostor.Api/Impostor.Api.csproj
COPY src/Impostor.Hazel/Impostor.Hazel.csproj ./src/Impostor.Hazel/Impostor.Hazel.csproj
COPY src/Impostor.Hazel/Hazel/Hazel.csproj ./src/Impostor.Hazel/Hazel/Hazel.csproj

RUN case "$TARGETARCH" in \
amd64) NETCORE_PLATFORM='linux-x64';; \
Expand All @@ -21,7 +21,7 @@ RUN case "$TARGETARCH" in \
esac && \
dotnet restore -r "$NETCORE_PLATFORM" ./src/Impostor.Server/Impostor.Server.csproj && \
dotnet restore -r "$NETCORE_PLATFORM" ./src/Impostor.Api/Impostor.Api.csproj && \
dotnet restore -r "$NETCORE_PLATFORM" ./src/Impostor.Hazel/Impostor.Hazel.csproj
dotnet restore -r "$NETCORE_PLATFORM" ./src/Impostor.Hazel/Hazel/Hazel.csproj

# Copy everything else.
COPY src/. ./src/
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Impostor is one of the first **Among Us** private servers, written in C#.
|-|-|-|-|
| 1.1.0 | 2020.09.07 - 2020.09.22 | No | [![Download](https://img.shields.io/badge/Download-v1.1.0-blue?style=flat-square)](https://github.com/Impostor/Impostor/releases/tag/v1.1.0) |
| 1.2.2 | 2020.09.22 - 2020.11.17 | No | [![Download](https://img.shields.io/badge/Download-v1.2.2-blue?style=flat-square)](https://github.com/Impostor/Impostor/releases/tag/v1.2.2) |
| 1.3.0 | 2021.3.5 | Yes | [![Download](https://img.shields.io/badge/Download-master-blue?style=flat-square)](https://ci.appveyor.com/project/Impostor/Impostor/branch/master/artifacts) |
| 1.3.0 | 2021.3.5 | No | [![Download](https://img.shields.io/badge/Download-v1.3.0-blue?style=flat-square)](https://github.com/Impostor/Impostor/releases/tag/v1.3.0) |
| 1.4.0 | 2021.3.31 - 2021.4.2 | Yes | [![Download](https://img.shields.io/badge/Download-master-blue?style=flat-square)](https://ci.appveyor.com/project/Impostor/Impostor/branch/master/artifacts) |

## Features

Expand Down
2 changes: 1 addition & 1 deletion src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ csharp_new_line_between_query_expression_clauses = true
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = true
csharp_indent_case_contents_when_block = false
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left

Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>1.3.0</VersionPrefix>
<VersionPrefix>1.4.0</VersionPrefix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Impostor.Api/CheatContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Impostor.Server.Net.Inner;
using Impostor.Api.Net.Inner;

namespace Impostor.Api
{
Expand Down
5 changes: 4 additions & 1 deletion src/Impostor.Api/Events/Game/IGamePlayerJoinedEvent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
namespace Impostor.Api.Events
using Impostor.Api.Net;

namespace Impostor.Api.Events
{
public interface IGamePlayerJoinedEvent : IGameEvent
{
IClientPlayer Player { get; }
}
}
7 changes: 6 additions & 1 deletion src/Impostor.Api/Events/Game/IGamePlayerLeftEvent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
namespace Impostor.Api.Events
using Impostor.Api.Net;

namespace Impostor.Api.Events
{
public interface IGamePlayerLeftEvent : IGameEvent
{
IClientPlayer Player { get; }

bool IsBan { get; }
}
}
15 changes: 15 additions & 0 deletions src/Impostor.Api/Events/Game/Player/IPlayerEnterVentEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Impostor.Api.Innersloth;

namespace Impostor.Api.Events.Player
{
/// <summary>
/// Called whenever a player enters a vent.
/// </summary>
public interface IPlayerEnterVentEvent : IPlayerEvent
{
/// <summary>
/// Gets the entered vent.
/// </summary>
public IVent Vent { get; }
}
}
15 changes: 15 additions & 0 deletions src/Impostor.Api/Events/Game/Player/IPlayerExitVentEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Impostor.Api.Innersloth;

namespace Impostor.Api.Events.Player
{
/// <summary>
/// Called whenever a player exits a vent.
/// </summary>
public interface IPlayerExitVentEvent : IPlayerEvent
{
/// <summary>
/// Gets the exited vent.
/// </summary>
public IVent Vent { get; }
}
}
12 changes: 5 additions & 7 deletions src/Impostor.Api/Events/Game/Player/IPlayerVentEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

namespace Impostor.Api.Events.Player
{
/// <summary>
/// Called whenever a player moves to another vent.
/// </summary>
public interface IPlayerVentEvent : IPlayerEvent
{
/// <summary>
/// Gets get the id of the used vent.
/// Gets the vent player moved to.
/// </summary>
public VentLocation VentId { get; }

/// <summary>
/// Gets a value indicating whether the vent was entered or exited.
/// </summary>
public bool VentEnter { get; }
public IVent NewVent { get; }
}
}
19 changes: 19 additions & 0 deletions src/Impostor.Api/Extensions/DictionaryExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace Impostor.Api
{
public static class DictionaryExtensions
{
/// <summary>Returns a read-only <see cref="ReadOnlyDictionary{TKey,TValue}" /> wrapper for the dictionary.</summary>
/// <param name="dictionary">An <see cref="IDictionary{TKey,TValue}" /> to create a <see cref="ReadOnlyDictionary{TKey,TValue}" /> from.</param>
/// <typeparam name="TKey">The type of the keys of <paramref name="dictionary" />.</typeparam>
/// <typeparam name="TValue">The type of the values of <paramref name="dictionary" />.</typeparam>
/// <returns>An object that acts as a read-only wrapper around the <see cref="IDictionary{TKey,TValue}" />.</returns>
public static ReadOnlyDictionary<TKey, TValue> AsReadOnly<TKey, TValue>(this IDictionary<TKey, TValue> dictionary)
where TKey : notnull
{
return new ReadOnlyDictionary<TKey, TValue>(dictionary);
}
}
}
10 changes: 1 addition & 9 deletions src/Impostor.Api/Extensions/SpanReaderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ public static float ReadSingle(this ref ReadOnlySpan<byte> input)
{
var original = Advance<float>(ref input);

// BitConverter.Int32BitsToSingle
// Doesn't exist in net 2.0 for some reason
return Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(original));
return BitConverter.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(original));
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -46,12 +44,6 @@ public static bool ReadBoolean(this ref ReadOnlySpan<byte> input)
return input.ReadByte() != 0;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static unsafe float Int32BitsToSingle(int value)
{
return *((float*)&value);
}

/// <summary>
/// Advances the position of <paramref name="input" /> by the size of <typeparamref name="T" />.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Impostor.Api/Innersloth/Customization/ColorType.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Impostor.Api.Innersloth.Customization
{
public enum ColorType : byte
public enum ColorType
{
Red = 0,
Blue = 1,
Expand Down
19 changes: 19 additions & 0 deletions src/Impostor.Api/Innersloth/IVent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Numerics;

namespace Impostor.Api.Innersloth
{
public interface IVent
{
int Id { get; }

string Name { get; }

Vector2 Position { get; }

IVent? Left { get; }

IVent? Center { get; }

IVent? Right { get; }
}
}
45 changes: 0 additions & 45 deletions src/Impostor.Api/Innersloth/MapSpawn.cs

This file was deleted.

1 change: 1 addition & 0 deletions src/Impostor.Api/Innersloth/MapTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ public enum MapTypes : byte
Skeld = 0,
MiraHQ = 1,
Polus = 2,
Airship = 4,
}
}
38 changes: 38 additions & 0 deletions src/Impostor.Api/Innersloth/Maps/AirshipData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using Impostor.Api.Innersloth.Maps.Vents;

namespace Impostor.Api.Innersloth.Maps
{
public class AirshipData : IMapData
{
private readonly IReadOnlyDictionary<int, IVent> _vents;

public AirshipData()
{
var vents = new[]
{
new AirshipVent(this, AirshipVent.Ids.Vault, new Vector2(-12.6322f, 8.4735f), left: AirshipVent.Ids.Cockpit),
new AirshipVent(this, AirshipVent.Ids.Cockpit, new Vector2(-22.099f, -1.512f), left: AirshipVent.Ids.Vault, right: AirshipVent.Ids.ViewingDeck),
new AirshipVent(this, AirshipVent.Ids.ViewingDeck, new Vector2(-15.659f, -11.6991f), left: AirshipVent.Ids.Cockpit),
new AirshipVent(this, AirshipVent.Ids.EngineRoom, new Vector2(0.203f, -2.5361f), left: AirshipVent.Ids.Kitchen, right: AirshipVent.Ids.MainHallBottom),
new AirshipVent(this, AirshipVent.Ids.Kitchen, new Vector2(-2.6019f, -9.338f), left: AirshipVent.Ids.EngineRoom, right: AirshipVent.Ids.MainHallBottom),
new AirshipVent(this, AirshipVent.Ids.MainHallBottom, new Vector2(7.021f, -3.730999f), left: AirshipVent.Ids.EngineRoom, right: AirshipVent.Ids.Kitchen),
new AirshipVent(this, AirshipVent.Ids.GapRight, new Vector2(9.814f, 3.206f), left: AirshipVent.Ids.MainHallTop, right: AirshipVent.Ids.GapLeft),
new AirshipVent(this, AirshipVent.Ids.GapLeft, new Vector2(12.663f, 5.922f), left: AirshipVent.Ids.MainHallTop, right: AirshipVent.Ids.GapRight),
new AirshipVent(this, AirshipVent.Ids.MainHallTop, new Vector2(3.605f, 6.923f), left: AirshipVent.Ids.GapLeft, right: AirshipVent.Ids.GapRight),
new AirshipVent(this, AirshipVent.Ids.Showers, new Vector2(23.9869f, -1.386f), left: AirshipVent.Ids.Records, right: AirshipVent.Ids.CargoBay),
new AirshipVent(this, AirshipVent.Ids.Records, new Vector2(23.2799f, 8.259998f), left: AirshipVent.Ids.Showers, right: AirshipVent.Ids.CargoBay),
new AirshipVent(this, AirshipVent.Ids.CargoBay, new Vector2(30.4409f, -3.577f), left: AirshipVent.Ids.Showers, right: AirshipVent.Ids.Records),
};

Vents = vents.ToDictionary(x => x.Id, x => x).AsReadOnly();
_vents = vents.ToDictionary(x => (int)x.Id, x => (IVent)x).AsReadOnly();
}

public IReadOnlyDictionary<AirshipVent.Ids, AirshipVent> Vents { get; }

IReadOnlyDictionary<int, IVent> IMapData.Vents => _vents;
}
}
17 changes: 17 additions & 0 deletions src/Impostor.Api/Innersloth/Maps/IMapData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Collections.Generic;

namespace Impostor.Api.Innersloth.Maps
{
public interface IMapData
{
public static IReadOnlyDictionary<MapTypes, IMapData> Maps { get; } = new Dictionary<MapTypes, IMapData>
{
[MapTypes.Skeld] = new SkeldData(),
[MapTypes.MiraHQ] = new MiraData(),
[MapTypes.Polus] = new PolusData(),
[MapTypes.Airship] = new AirshipData(),
}.AsReadOnly();

IReadOnlyDictionary<int, IVent> Vents { get; }
}
}
37 changes: 37 additions & 0 deletions src/Impostor.Api/Innersloth/Maps/MiraData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using Impostor.Api.Innersloth.Maps.Vents;

namespace Impostor.Api.Innersloth.Maps
{
public class MiraData : IMapData
{
private readonly IReadOnlyDictionary<int, IVent> _vents;

public MiraData()
{
var vents = new[]
{
new MiraVent(this, MiraVent.Ids.Balcony, new Vector2(23.77f, -1.94f), left: MiraVent.Ids.Medbay, right: MiraVent.Ids.Cafeteria),
new MiraVent(this, MiraVent.Ids.Cafeteria, new Vector2(23.9f, 7.18f), left: MiraVent.Ids.Admin, right: MiraVent.Ids.Balcony),
new MiraVent(this, MiraVent.Ids.Reactor, new Vector2(0.4800001f, 10.697f), left: MiraVent.Ids.Laboratory, center: MiraVent.Ids.Decontamination, right: MiraVent.Ids.Launchpad),
new MiraVent(this, MiraVent.Ids.Laboratory, new Vector2(11.606f, 13.816f), left: MiraVent.Ids.Reactor, center: MiraVent.Ids.Decontamination, right: MiraVent.Ids.Office),
new MiraVent(this, MiraVent.Ids.Office, new Vector2(13.28f, 20.13f), left: MiraVent.Ids.Laboratory, center: MiraVent.Ids.Admin, right: MiraVent.Ids.Greenhouse),
new MiraVent(this, MiraVent.Ids.Admin, new Vector2(22.39f, 17.23f), left: MiraVent.Ids.Greenhouse, center: MiraVent.Ids.Cafeteria, right: MiraVent.Ids.Office),
new MiraVent(this, MiraVent.Ids.Greenhouse, new Vector2(17.85f, 25.23f), left: MiraVent.Ids.Admin, right: MiraVent.Ids.Office),
new MiraVent(this, MiraVent.Ids.Medbay, new Vector2(15.41f, -1.82f), left: MiraVent.Ids.Balcony, right: MiraVent.Ids.LockerRoom),
new MiraVent(this, MiraVent.Ids.Decontamination, new Vector2(6.83f, 3.145f), left: MiraVent.Ids.Reactor, center: MiraVent.Ids.LockerRoom, right: MiraVent.Ids.Laboratory),
new MiraVent(this, MiraVent.Ids.LockerRoom, new Vector2(4.29f, 0.5299997f), left: MiraVent.Ids.Medbay, center: MiraVent.Ids.Launchpad, right: MiraVent.Ids.Decontamination),
new MiraVent(this, MiraVent.Ids.Launchpad, new Vector2(-6.18f, 3.56f), left: MiraVent.Ids.Reactor, right: MiraVent.Ids.LockerRoom),
};

Vents = vents.ToDictionary(x => x.Id, x => x).AsReadOnly();
_vents = vents.ToDictionary(x => (int)x.Id, x => (IVent)x).AsReadOnly();
}

public IReadOnlyDictionary<MiraVent.Ids, MiraVent> Vents { get; }

IReadOnlyDictionary<int, IVent> IMapData.Vents => _vents;
}
}
38 changes: 38 additions & 0 deletions src/Impostor.Api/Innersloth/Maps/PolusData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using Impostor.Api.Innersloth.Maps.Vents;

namespace Impostor.Api.Innersloth.Maps
{
public class PolusData : IMapData
{
private readonly IReadOnlyDictionary<int, IVent> _vents;

public PolusData()
{
var vents = new[]
{
new PolusVent(this, PolusVent.Ids.Security, new Vector2(1.929f, -9.558001f), left: PolusVent.Ids.O2, right: PolusVent.Ids.Electrical),
new PolusVent(this, PolusVent.Ids.Electrical, new Vector2(6.9f, -14.41f), left: PolusVent.Ids.O2, right: PolusVent.Ids.Security),
new PolusVent(this, PolusVent.Ids.O2, new Vector2(3.51f, -16.58f), left: PolusVent.Ids.Electrical, right: PolusVent.Ids.Security),
new PolusVent(this, PolusVent.Ids.Communications, new Vector2(12.304f, -18.898f), left: PolusVent.Ids.Storage, right: PolusVent.Ids.Office),
new PolusVent(this, PolusVent.Ids.Office, new Vector2(16.379f, -19.599f), left: PolusVent.Ids.Communications, right: PolusVent.Ids.Storage),
new PolusVent(this, PolusVent.Ids.Admin, new Vector2(20.089f, -25.517f), left: PolusVent.Ids.OutsideAdmin, right: PolusVent.Ids.Lava),
new PolusVent(this, PolusVent.Ids.Laboratory, new Vector2(32.963f, -9.526f), right: PolusVent.Ids.Lava),
new PolusVent(this, PolusVent.Ids.Lava, new Vector2(30.907f, -11.86f), left: PolusVent.Ids.Laboratory, right: PolusVent.Ids.Admin),
new PolusVent(this, PolusVent.Ids.Storage, new Vector2(22f, -12.19f), left: PolusVent.Ids.Communications, right: PolusVent.Ids.Office),
new PolusVent(this, PolusVent.Ids.RightStabilizer, new Vector2(24.02f, -8.39f), left: PolusVent.Ids.LeftStabilizer),
new PolusVent(this, PolusVent.Ids.LeftStabilizer, new Vector2(9.64f, -7.72f), left: PolusVent.Ids.RightStabilizer),
new PolusVent(this, PolusVent.Ids.OutsideAdmin, new Vector2(18.93f, -24.85f), right: PolusVent.Ids.Admin),
};

Vents = vents.ToDictionary(x => x.Id, x => x).AsReadOnly();
_vents = vents.ToDictionary(x => (int)x.Id, x => (IVent)x).AsReadOnly();
}

public IReadOnlyDictionary<PolusVent.Ids, PolusVent> Vents { get; }

IReadOnlyDictionary<int, IVent> IMapData.Vents => _vents;
}
}
Loading

0 comments on commit f0434f0

Please sign in to comment.