public PlayerController(PlayerCharacter player, PlayerData playerData, PlayerControls controls, ControlSettings settings, AbstractController[] controllers) { this.player = player; this.playerData = playerData; this.controls = controls; this.settings = settings; aerialController = (AerialController)controllers[PlayerCharacter.ControllerIndexes.Air]; groundController = (GroundController)controllers[PlayerCharacter.ControllerIndexes.Ground]; platformController = (PlatformController)controllers[PlayerCharacter.ControllerIndexes.Platform]; wallController = (WallController)controllers[PlayerCharacter.ControllerIndexes.Wall]; ladderController = (LadderController)controllers[PlayerCharacter.ControllerIndexes.Ladder]; // TODO: Make this class reloadable. // Create buffers. var accessor = Properties.Access(); var grab = accessor.GetFloat("player.grab.buffer"); var ascend = accessor.GetFloat("player.ascend.buffer"); // Actual values for requiresHold on each buffer are set when control settings are applied. attackBuffer = new InputBuffer(false, controls.Attack); grabBuffer = new InputBuffer(grab, false, controls.Grab); ascendBuffer = new InputBuffer(ascend, false, controls.Jump); ascendBuffer.RequiredChords = controls.Ascend; settings.ApplyEvent += OnApply; MessageSystem.Subscribe(this, CoreMessageTypes.Input, (messageType, data, dt) => { ProcessInput((FullInputData)data, dt); }); }
public AerialSession(float maximumJumpHeight, bool enforceMaxJumpHeight, int maximumNumJumps, AerialController controller, Rigidbody rigidBody) { maxJumpHeight = maximumJumpHeight; shoulEnforceMaxJumpHeight = enforceMaxJumpHeight; maxNumJumps = maximumNumJumps; aerialController = controller; jumpsUsed = 0; startingJumpHeight = aerialController.transform.position.y; this.rigidBody = rigidBody; }
// TODO: Use actor flags to optimize controller creation (and to return early from some functions). protected Actor(EntityGroups group, bool canTraverseGround = true) : base(group) { aerialController = new AerialController(this); platformController = new PlatformController(this); // Some actors can't run on the ground (like flying enemies), so it would be wasteful to create the ground // controller. if (canTraverseGround) { groundController = new GroundController(this); } // TODO: Consider allowing actors to spawn directly on the ground (via a raycast). // This assumes that all actors spawn in the air (likely just above the ground). activeController = aerialController; facing = vec2.UnitX; }