mirror of
https://github.com/Impostor/Impostor.git
synced 2026-10-20 01:46:11 +00:00
Add TaskTypes enum, PlayerCompletedTaskEvent, and updated ITaskInfo to use TaskTypes (#144)
This commit is contained in:
1 parent
ad0408d0de
commit
d590da0d27
8 files changed
+97
-9
No files matched your search
@@ -0,0 +1,9 @@
|
||||
using Impostor.Api.Innersloth;
|
||||
|
||||
namespace Impostor.Api.Events.Player
|
||||
{
|
||||
public interface IPlayerCompletedTaskEvent : IPlayerEvent
|
||||
{
|
||||
TaskTypes Task { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
namespace Impostor.Api.Innersloth
|
||||
{
|
||||
public enum TaskTypes : uint
|
||||
{
|
||||
SubmitScan = 0,
|
||||
PrimeShields = 1,
|
||||
FuelEngines = 2,
|
||||
ChartCourse = 3,
|
||||
StartReactor = 4,
|
||||
SwipeCard = 5,
|
||||
ClearAsteroids = 6,
|
||||
UploadData = 7,
|
||||
InspectSample = 8,
|
||||
EmptyChute = 9,
|
||||
EmptyGarbage = 10,
|
||||
AlignEngineOutput = 11,
|
||||
FixWiring = 12,
|
||||
CalibrateDistributor = 13,
|
||||
DivertPower = 14,
|
||||
UnlockManifolds = 15,
|
||||
ResetReactor = 16,
|
||||
FixLights = 17,
|
||||
Filter = 18,
|
||||
FixComms = 19,
|
||||
RestoreOxy = 20,
|
||||
StabilizeSteering = 21,
|
||||
AssembleArtifact = 22,
|
||||
SortSamples = 23,
|
||||
MeasureWeather = 24,
|
||||
EnterIdCode = 25,
|
||||
BuyBeverage = 26,
|
||||
ProcessData = 27,
|
||||
RunDiagnostics = 28,
|
||||
WaterPlants = 29,
|
||||
MonitorOxygen = 30,
|
||||
StoreArtifact = 31,
|
||||
FillCanisters = 32,
|
||||
ActivateWeatherNodes = 33,
|
||||
InsertKeys = 34,
|
||||
ResetSeismic = 35,
|
||||
ScanBoardingPass = 36,
|
||||
OpenWaterways = 37,
|
||||
ReplaceWaterJug = 38,
|
||||
RepairDrill = 39,
|
||||
AlignTelescope = 40,
|
||||
RecordTemperature = 41,
|
||||
RebootWifi = 42,
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
using Impostor.Api.Net.Messages;
|
||||
using Impostor.Api.Innersloth;
|
||||
using Impostor.Api.Net.Messages;
|
||||
|
||||
namespace Impostor.Api.Net.Inner.Objects
|
||||
{
|
||||
public interface ITaskInfo
|
||||
{
|
||||
uint Id { get; }
|
||||
TaskTypes Type { get; }
|
||||
|
||||
bool Complete { get; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using Impostor.Api.Events.Player;
|
||||
using Impostor.Api.Games;
|
||||
using Impostor.Api.Innersloth;
|
||||
using Impostor.Api.Net;
|
||||
using Impostor.Api.Net.Inner.Objects;
|
||||
|
||||
namespace Impostor.Server.Events.Player
|
||||
{
|
||||
public class PlayerCompletedTaskEvent : IPlayerCompletedTaskEvent
|
||||
{
|
||||
public PlayerCompletedTaskEvent(IGame game, IClientPlayer clientPlayer, IInnerPlayerControl playerControl, uint taskID)
|
||||
{
|
||||
Game = game;
|
||||
ClientPlayer = clientPlayer;
|
||||
PlayerControl = playerControl;
|
||||
Task = (TaskTypes)taskID;
|
||||
}
|
||||
|
||||
public IGame Game { get; }
|
||||
|
||||
public IClientPlayer ClientPlayer { get; }
|
||||
|
||||
public IInnerPlayerControl PlayerControl { get; }
|
||||
|
||||
public TaskTypes Task { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Impostor.Api.Net.Inner.Objects;
|
||||
using Impostor.Api.Innersloth;
|
||||
using Impostor.Api.Net.Inner.Objects;
|
||||
using Impostor.Api.Net.Messages;
|
||||
|
||||
namespace Impostor.Server.Net.Inner.Objects
|
||||
@@ -7,19 +8,19 @@ namespace Impostor.Server.Net.Inner.Objects
|
||||
{
|
||||
public class TaskInfo : ITaskInfo
|
||||
{
|
||||
public uint Id { get; internal set; }
|
||||
public TaskTypes Type { get; internal set; }
|
||||
|
||||
public bool Complete { get; internal set; }
|
||||
|
||||
public void Serialize(IMessageWriter writer)
|
||||
{
|
||||
writer.WritePacked(Id);
|
||||
writer.WritePacked((uint)Type);
|
||||
writer.Write(Complete);
|
||||
}
|
||||
|
||||
public void Deserialize(IMessageReader reader)
|
||||
{
|
||||
this.Id = reader.ReadPackedUInt32();
|
||||
this.Type = (TaskTypes)reader.ReadPackedUInt32();
|
||||
this.Complete = reader.ReadBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Impostor.Api;
|
||||
using Impostor.Api.Innersloth;
|
||||
using Impostor.Api.Net;
|
||||
using Impostor.Api.Net.Inner.Objects;
|
||||
using Impostor.Api.Net.Messages;
|
||||
@@ -176,7 +177,7 @@ namespace Impostor.Server.Net.Inner.Objects
|
||||
|
||||
foreach (var taskId in taskTypeIds.ToArray())
|
||||
{
|
||||
player.Tasks.Add(new TaskInfo { Id = taskId });
|
||||
player.Tasks.Add(new TaskInfo { Type = (TaskTypes)taskId });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,8 @@ namespace Impostor.Server.Net.Inner.Objects
|
||||
throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.CompleteTask)} to a specific player instead of broadcast");
|
||||
}
|
||||
|
||||
var index = reader.ReadPackedUInt32();
|
||||
var taskId = reader.ReadPackedUInt32();
|
||||
await _eventManager.CallAsync(new PlayerCompletedTaskEvent(_game, sender, this, taskId));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus
|
||||
|
||||
public DoorsSystemType(IGame game)
|
||||
{
|
||||
// TODO: Check
|
||||
var doorCount = game.Options.Map switch
|
||||
{
|
||||
MapTypes.Skeld => 13,
|
||||
|
||||
Reference in new issue
Block a user