public void ProcessMovement(GameInputs.Movement movement) { if (movement == GameInputs.Movement.None) { return; } entityOpt.Update( world.ecsRegistry, entity => { Ecs.Systems.Movement.Process( movement, entity, world.ecsRegistry ); Ecs.Systems.CharacterOrientation.Process( movement, entity, world.ecsRegistry ); Ecs.Systems.CharacterAttack.Process( movement, entity, world.ecsRegistry ); } ); }
// Pre-condition: `movement != GameInputs.Movement.None` public static void Process( GameInputs.Movement movement, Entity entity, Registry registry ) { var character = registry .GetComponentUnsafe <Comps.Character>(entity); var orientation = registry .GetComponentUnsafe <Comps.Orientations.Cardinal>(entity); Physical.Orientation.Cardinal movementDirection = movement.ToCardinalDirection(); if (character.kind == Comps.Character.Kind.Aquamentus) { // Aquamentus can only face left and right switch (movementDirection) { case Physical.Orientation.Cardinal.Left: case Physical.Orientation.Cardinal.Right: orientation.data = movementDirection; break; } } else { orientation.data = movementDirection; } }
// Pre-condition: `movement != GameInputs.Movement.None` public static void Process( GameInputs.Movement movement, Entity entity, Registry registry ) { registry.AssignComponent( entity, new VelocityComp { data = movement.ToVector2() * 15 } ); }
// Pre-condition: `movement != GameInputs.Movement.None` public static void Process( GameInputs.Movement movement, Entity entity, Registry registry ) { // Stop attacking when moving var characterCompOpt = registry.GetComponent <Comps.Character>(entity); characterCompOpt.MatchSome(characterComp => { characterComp.attacking = false; }); }