Skip to content

Commit

Permalink
feat: add members for player events
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Jan 11, 2025
1 parent f0bfef3 commit 10251b7
Show file tree
Hide file tree
Showing 9 changed files with 286 additions and 82 deletions.
5 changes: 5 additions & 0 deletions include/endstone/actor/mob.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ namespace endstone {
*/
class Mob : public Actor {
public:
[[nodiscard]] Mob *asMob() const override
{
return const_cast<Mob *>(this);
}

/**
* @brief Checks to see if an actor is gliding, such as using an Elytra.
* @return True if this actor is gliding.
Expand Down
13 changes: 12 additions & 1 deletion include/endstone/command/command_sender.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace endstone {

class Actor;
class ConsoleCommandSender;
class Mob;
class Server;
class Player;

Expand Down Expand Up @@ -52,13 +53,23 @@ class CommandSender : public Permissible {
/**
* @brief Gets a CommandSender as Actor
*
* @return Player, nullptr if not an Actor
* @return Actor, nullptr if not an Actor
*/
[[nodiscard]] virtual Actor *asActor() const
{
return nullptr;
}

/**
* @brief Gets a CommandSender as Mob
*
* @return Mob, nullptr if not an Mob
*/
[[nodiscard]] virtual Mob *asMob() const
{
return nullptr;
}

/**
* @brief Gets a CommandSender as Player
*
Expand Down
4 changes: 4 additions & 0 deletions include/endstone/command/command_sender_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ class CommandSenderWrapper final : public CommandSender {
{
return sender_.asActor();
}
[[nodiscard]] Mob *asMob() const override
{
return sender_.asMob();
}
[[nodiscard]] Player *asPlayer() const override
{
return sender_.asPlayer();
Expand Down
34 changes: 34 additions & 0 deletions src/bedrock/entity/enums/client_input_lock_category.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) 2024, The Endstone Project. (https://endstone.dev) All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <cstdint>

enum class ClientInputLockCategory :std:: uint8_t {
Undefined = 0,
Camera = 1,
Movement = 2,
Emoting = 3,
LateralMovement = 4,
Sneak = 5,
Jump = 6,
Mount = 7,
Dismount = 8,
MoveForward = 9,
MoveBackward = 10,
MoveLeft = 11,
MoveRight = 12,
_Count = 13,
};
8 changes: 0 additions & 8 deletions src/bedrock/forward.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ class ILevelStorageManagerConnector;
class IMinecraftEventing;
class INpcDialogueData;
class IUnknownBlockTypeRegistry;
class InputMode;
class InternalComponentRegistry;
class InventoryTransaction;
class IPackLoadContext;
Expand All @@ -127,7 +126,6 @@ class MapDataManager;
class MapItemSavedData;
class MaterialTypeHelper;
class MobEffectInstance;
class MobSpawnerData;
class MolangVariableMap;
class NavigationComponent;
class NewInteractionModel;
Expand Down Expand Up @@ -241,14 +239,8 @@ namespace Core {
class FilePathManager;
class LevelStorageResult;
class StorageAreaState;
template <typename T>
class PathBuffer;
} // namespace Core

namespace Bedrock::PubSub {
class SubscriptionBase;
}

namespace Social {
class GamePublishSetting;
}
Expand Down
26 changes: 26 additions & 0 deletions src/bedrock/input/input_mode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2024, The Endstone Project. (https://endstone.dev) All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <cstdint>

enum class InputMode : unsigned int {
Undefined = 0,
Mouse = 1,
Touch = 2,
GamePad = 3,
MotionController = 4,
Count = 5,
};
28 changes: 28 additions & 0 deletions src/bedrock/input/scripting_input_button.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2024, The Endstone Project. (https://endstone.dev) All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <cstdint>

enum class ScriptingInputButton : unsigned int {
Jump = 0,
Sneak = 1,
};

enum class ScriptingInputButtonState : unsigned int {
Released = 0,
Pressed = 1,
};

Loading

0 comments on commit 10251b7

Please sign in to comment.