using LuckerGame.Components.Lucker.Cameras; using LuckerGame.EntityComponents.Lucker; using LuckerGame.Events; using Sandbox; namespace LuckerGame.Entities; /// /// Represents a person playing the game. /// This could belong to a Client or a Bot and represents a common entity to operate on for games and keeping score /// public partial class Lucker : Entity { /// /// The entity this lucker controls. This value is networked and should be accessed through . /// [Net] private Entity InternalPawn { get; set; } /// /// Accesses or sets the entity this lucker currently controls /// public Entity Pawn { get => InternalPawn; set { InternalPawn = value; if ( value != null ) { value.Owner = this; } } } /// /// Before the round has started, this lucker indicated they were ready /// [Net] public bool Ready { get; set; } /// /// This Lucker's camera /// [BindComponent] public AbstractCamera Camera { get; } [BindComponent] public LuckerStats Stats { get; } /// /// Creates and properly sets up a entity for a given client /// /// the client to own the lucker /// the newly created lucker public static Lucker CreateLuckerForClient( IClient client ) { var lucker = new Lucker(); client.Pawn = lucker; lucker.Owner = client as Entity; lucker.Name = client.Name; lucker.Components.Create(); lucker.Components.Create(); return lucker; } /// /// Allows clients to request setting their ready state /// /// whether they are readying up or calming down [ConCmd.Server("set_ready")] public static void ReadyUpCommand(bool readyState) { var client = ConsoleSystem.Caller; var lucker = client.Pawn as Lucker; lucker.SetReady( readyState ); } /// /// Sets this lucker's ready state /// /// the ready state being set public void SetReady(bool ready) { Ready = ready; if ( Game.IsServer ) { Event.Run( LuckerEvent.LuckerReady, this, ready ); } } /// public override void Simulate( IClient cl ) { base.Simulate( cl ); } public override void FrameSimulate( IClient cl ) { base.FrameSimulate( cl ); Camera?.Update(); } public override void BuildInput() { base.BuildInput(); Camera?.BuildInput(); } }