Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Sep 6, 2024
1 parent ffd3ad2 commit e43ca36
Show file tree
Hide file tree
Showing 25 changed files with 625 additions and 626 deletions.
32 changes: 16 additions & 16 deletions Fika.Dedicated/Classes/DedicatedMovementContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@

namespace Fika.Core.Coop.ObservedClasses
{
public class DedicatedMovementContext : MovementContext
{
public override void ApplyGravity(ref Vector3 motion, float deltaTime, bool stickToGround)
{
// Do nothing
}
public class DedicatedMovementContext : MovementContext
{
public override void ApplyGravity(ref Vector3 motion, float deltaTime, bool stickToGround)
{
// Do nothing
}

public new static DedicatedMovementContext Create(Player player, Func<IAnimator> animatorGetter, Func<ICharacterController> characterControllerGetter, LayerMask groundMask)
{
DedicatedMovementContext movementContext = Create<DedicatedMovementContext>(player, animatorGetter, characterControllerGetter, groundMask);
return movementContext;
}
public new static DedicatedMovementContext Create(Player player, Func<IAnimator> animatorGetter, Func<ICharacterController> characterControllerGetter, LayerMask groundMask)
{
DedicatedMovementContext movementContext = Create<DedicatedMovementContext>(player, animatorGetter, characterControllerGetter, groundMask);
return movementContext;
}

public override void DirectApplyMotion(Vector3 motion, float deltaTime)
{
// Do nothing
}
}
public override void DirectApplyMotion(Vector3 motion, float deltaTime)
{
// Do nothing
}
}
}
116 changes: 58 additions & 58 deletions Fika.Dedicated/Classes/DedicatedRaidController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,86 +8,86 @@

namespace Fika.Dedicated.Classes
{
public class DedicatedRaidController : MonoBehaviour
{
public CoopPlayer MainPlayer { get; set; }
private CoopPlayer targetPlayer;
private ManualLogSource logger;
private float counter;
private bool paused;
public class DedicatedRaidController : MonoBehaviour
{
public CoopPlayer MainPlayer { get; set; }
private CoopPlayer targetPlayer;
private ManualLogSource logger;
private float counter;
private bool paused;
private Core.Coop.FreeCamera.FreeCamera freeCam;
private FreeCameraController freeCameraController;

private void Start()
{
counter = 0;
logger = BepInEx.Logging.Logger.CreateLogSource(nameof(DedicatedRaidController));
paused = false;
private void Start()
{
counter = 0;
logger = BepInEx.Logging.Logger.CreateLogSource(nameof(DedicatedRaidController));
paused = false;
freeCam = CameraClass.Instance.Camera.gameObject.GetComponent<Core.Coop.FreeCamera.FreeCamera>();
freeCameraController = Singleton<GameWorld>.Instance.gameObject.GetComponent<FreeCameraController>();
}

private void Pause(bool state)
{
paused = state;
}
private void Pause(bool state)
{
paused = state;
}

private void Update()
{
if (paused)
{
return;
}
private void Update()
{
if (paused)
{
return;
}

counter += Time.deltaTime;
counter += Time.deltaTime;

if (counter > 10)
{
counter = 0;
if (counter > 10)
{
counter = 0;

if (targetPlayer != null)
{
if (!targetPlayer.HealthController.IsAlive)
{
FindNewPlayer();
return;
}
if (targetPlayer != null)
{
if (!targetPlayer.HealthController.IsAlive)
{
FindNewPlayer();
return;
}

Vector3 currentPosition = targetPlayer.Position;
Vector3 currentPosition = targetPlayer.Position;
MainPlayer.Teleport(new(currentPosition.x, currentPosition.y - 75, currentPosition.z));
MainPlayer.MovementContext.SetPitchSmoothly(new(-90, -90));
}
else
{
FindNewPlayer();
}
}
}
else
{
FindNewPlayer();
}
}
}

public void FindNewPlayer()
{
if (CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler))
{
foreach (CoopPlayer player in coopHandler.HumanPlayers)
{
if (player.HealthController.IsAlive && !player.IsYourPlayer)
{
targetPlayer = player;
logger.LogInfo("DedicatedRaidController: New player: " + player.Profile.Info.MainProfileNickname);
public void FindNewPlayer()
{
if (CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler))
{
foreach (CoopPlayer player in coopHandler.HumanPlayers)
{
if (player.HealthController.IsAlive && !player.IsYourPlayer)
{
targetPlayer = player;
logger.LogInfo("DedicatedRaidController: New player: " + player.Profile.Info.MainProfileNickname);
if (!freeCam.IsActive)
{
freeCameraController.ToggleCamera();
}
freeCam.SetCurrentPlayer(targetPlayer);
freeCam.AttachDedicated(targetPlayer);
return;
}
}
}
}
}
}

targetPlayer = null;
logger.LogWarning("No more players found as targets");
Destroy(this);
}
}
targetPlayer = null;
logger.LogWarning("No more players found as targets");
Destroy(this);
}
}
}
Loading

0 comments on commit e43ca36

Please sign in to comment.