Skip to content

Commit

Permalink
Update code format
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway authored and ArchangelWTF committed Jan 8, 2025
1 parent fd77a53 commit 769aa2c
Show file tree
Hide file tree
Showing 95 changed files with 23,801 additions and 23,766 deletions.
48 changes: 24 additions & 24 deletions Fika.Core/Coop/BotClasses/CoopBotInventoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public override bool HasDiscardLimits
private readonly CoopBot coopBot;
private readonly IPlayerSearchController searchController;

public CoopBotInventoryController(Player player, Profile profile, bool examined, MongoID currentId, ushort nextOperationId) : base(player, profile, examined)
{
coopBot = (CoopBot)player;
mongoID_0 = currentId;
ushort_0 = nextOperationId;
searchController = new BotSearchControllerClass(profile);
}
public CoopBotInventoryController(Player player, Profile profile, bool examined, MongoID currentId, ushort nextOperationId) : base(player, profile, examined)
{
coopBot = (CoopBot)player;
mongoID_0 = currentId;
ushort_0 = nextOperationId;
searchController = new BotSearchControllerClass(profile);
}

public override IPlayerSearchController PlayerSearchController
{
Expand All @@ -45,22 +45,22 @@ public override void CallMalfunctionRepaired(Weapon weapon)
// Do nothing
}

public override void vmethod_1(BaseInventoryOperationClass operation, [CanBeNull] Callback callback)
{
// Check for GClass increments
// Tripwire kit is always null on AI so we cannot use ToDescriptor as it throws a nullref
if (operation is not GClass3274)
{
public override void vmethod_1(BaseInventoryOperationClass operation, [CanBeNull] Callback callback)
{
// Check for GClass increments
// Tripwire kit is always null on AI so we cannot use ToDescriptor as it throws a nullref
if (operation is not GClass3274)
{
#if DEBUG
FikaPlugin.Instance.FikaLogger.LogInfo($"Sending bot operation {operation.GetType()} from {coopBot.Profile.Nickname}");
#endif
EFTWriterClass writer = new();
writer.WritePolymorph(operation.ToDescriptor());
InventoryPacket packet = new()
{
CallbackId = operation.Id,
OperationBytes = writer.ToArray()
};
EFTWriterClass writer = new();
writer.WritePolymorph(operation.ToDescriptor());
InventoryPacket packet = new()
{
CallbackId = operation.Id,
OperationBytes = writer.ToArray()
};

coopBot.PacketSender.InventoryPackets.Enqueue(packet);
}
Expand Down Expand Up @@ -88,10 +88,10 @@ private void RunBotOperation(BaseInventoryOperationClass operation, Callback cal
handler.Callback?.Fail($"Can't execute {handler.Operation}", 1);
}

public override SearchContentOperation vmethod_2(SearchableItemItemClass item)
{
return new GClass3296(method_12(), this, PlayerSearchController, Profile, item);
}
public override SearchContentOperation vmethod_2(SearchableItemItemClass item)
{
return new GClass3296(method_12(), this, PlayerSearchController, Profile, item);
}

private class BotInventoryOperationHandler(CoopBotInventoryController controller, BaseInventoryOperationClass operation, Callback callback)
{
Expand Down
32 changes: 16 additions & 16 deletions Fika.Core/Coop/ClientClasses/CoopClientGameWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ public static CoopClientGameWorld Create(GameObject gameObject, PoolManager obje
return gameWorld;
}

public override GrenadeFactoryClass CreateGrenadeFactory()
{
return new GClass746();
}
public override GrenadeFactoryClass CreateGrenadeFactory()
{
return new GClass746();
}

public override void PlayerTick(float dt)
{
method_10(smethod_2);
}
public override void PlayerTick(float dt)
{
method_10(smethod_2);
}

public override void vmethod_1(float dt)
{
Expand All @@ -48,14 +48,14 @@ public override void InitAirdrop(string lootTemplateId = null, bool takeNearbyPo
// Do nothing
}

public override SyncObjectProcessorClass SyncObjectProcessorFactory()
{
ClientSynchronizableObjectLogicProcessor = new SynchronizableObjectLogicProcessorClass
{
TripwireManager = new(Singleton<GameWorld>.Instance)
};
return ClientSynchronizableObjectLogicProcessor;
}
public override SyncObjectProcessorClass SyncObjectProcessorFactory()
{
ClientSynchronizableObjectLogicProcessor = new SynchronizableObjectLogicProcessorClass
{
TripwireManager = new(Singleton<GameWorld>.Instance)
};
return ClientSynchronizableObjectLogicProcessor;
}

public override void Dispose()
{
Expand Down
122 changes: 61 additions & 61 deletions Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,17 @@ private void RunClientOperation(BaseInventoryOperationClass operation, Callback
return;
}

// Do not replicate picking up quest items, throws an error on the other clients
if (operation is GClass3259 moveOperation)
{
Item lootedItem = moveOperation.Item;
if (lootedItem.QuestItem)
{
if (coopPlayer.AbstractQuestControllerClass is CoopClientSharedQuestController sharedQuestController && sharedQuestController.ContainsAcceptedType("PlaceBeacon"))
{
if (!sharedQuestController.CheckForTemplateId(lootedItem.TemplateId))
{
sharedQuestController.AddLootedTemplateId(lootedItem.TemplateId);
// Do not replicate picking up quest items, throws an error on the other clients
if (operation is GClass3259 moveOperation)
{
Item lootedItem = moveOperation.Item;
if (lootedItem.QuestItem)
{
if (coopPlayer.AbstractQuestControllerClass is CoopClientSharedQuestController sharedQuestController && sharedQuestController.ContainsAcceptedType("PlaceBeacon"))
{
if (!sharedQuestController.CheckForTemplateId(lootedItem.TemplateId))
{
sharedQuestController.AddLootedTemplateId(lootedItem.TemplateId);

// We use templateId because each client gets a unique itemId
QuestItemPacket questPacket = new()
Expand All @@ -128,21 +128,21 @@ private void RunClientOperation(BaseInventoryOperationClass operation, Callback
}
}

// Do not replicate quest operations / search operations
// Check for GClass increments, ReadPolymorph
if (operation is GClass3296 or GClass3300 or GClass3301 or GClass3302)
{
base.vmethod_1(operation, callback);
return;
}
// Do not replicate quest operations / search operations
// Check for GClass increments, ReadPolymorph
if (operation is GClass3296 or GClass3300 or GClass3301 or GClass3302)
{
base.vmethod_1(operation, callback);
return;
}

EFTWriterClass writer = new();
ClientInventoryOperationHandler handler = new()
{
Operation = operation,
Callback = callback,
InventoryController = this
};
EFTWriterClass writer = new();
ClientInventoryOperationHandler handler = new()
{
Operation = operation,
Callback = callback,
InventoryController = this
};

uint operationNum = AddOperationCallback(operation, handler.ReceiveStatusFromServer);
writer.WritePolymorph(operation.ToDescriptor());
Expand Down Expand Up @@ -181,10 +181,10 @@ private uint AddOperationCallback(BaseInventoryOperationClass operation, Action<
return id;
}

public override SearchContentOperation vmethod_2(SearchableItemItemClass item)
{
return new GClass3296(method_12(), this, PlayerSearchController, Profile, item);
}
public override SearchContentOperation vmethod_2(SearchableItemItemClass item)
{
return new GClass3296(method_12(), this, PlayerSearchController, Profile, item);
}

private class ClientInventoryOperationHandler
{
Expand Down Expand Up @@ -224,38 +224,38 @@ private void ExecuteResult(IResult executeResult)
HandleFinalResult(executeResult);
}

private void HandleFinalResult(IResult result)
{
IResult result2 = OperationResult;
if (result2 == null || !result2.Failed)
{
OperationResult = result;
}
EOperationStatus serverStatus = ServerStatus.Status;
if (!serverStatus.Finished())
{
return;
}
EOperationStatus localStatus = Operation.Status;
if (localStatus.InProgress())
{
if (Operation is GInterface414 ginterface)
{
ginterface.Terminate();
}
return;
}
Operation.Dispose();
if (serverStatus != localStatus)
{
if (localStatus.Finished())
{
InventoryController.logger.LogError($"{InventoryController.ID} - Operation critical failure - status mismatch: {Operation.Id} server status: {serverStatus} client status: {localStatus} - {Operation}");
}
}
Callback?.Invoke(OperationResult);
}
}
private void HandleFinalResult(IResult result)
{
IResult result2 = OperationResult;
if (result2 == null || !result2.Failed)
{
OperationResult = result;
}
EOperationStatus serverStatus = ServerStatus.Status;
if (!serverStatus.Finished())
{
return;
}
EOperationStatus localStatus = Operation.Status;
if (localStatus.InProgress())
{
if (Operation is GInterface414 ginterface)
{
ginterface.Terminate();
}
return;
}
Operation.Dispose();
if (serverStatus != localStatus)
{
if (localStatus.Finished())
{
InventoryController.logger.LogError($"{InventoryController.ID} - Operation critical failure - status mismatch: {Operation.Id} server status: {serverStatus} client status: {localStatus} - {Operation}");
}
}
Callback?.Invoke(OperationResult);
}
}

public readonly struct ServerOperationStatus(EOperationStatus status, string error)
{
Expand Down
Loading

0 comments on commit 769aa2c

Please sign in to comment.