#include "StarGameTypes.hpp" namespace Star { float GlobalTimescale = 1.0f; float GlobalTimestep = 1.0f / 60.0f; float ServerGlobalTimestep = 1.0f / 60.0f; EnumMap const DirectionNames{ {Direction::Left, "left"}, {Direction::Right, "right"}, }; EnumMap const GenderNames{ {Gender::Male, "male"}, {Gender::Female, "female"}, }; EnumMap const FireModeNames{ {FireMode::None, "none"}, {FireMode::Primary, "primary"}, {FireMode::Alt, "alt"} }; EnumMap const ToolHandNames{ {ToolHand::Primary, "primary"}, {ToolHand::Alt, "alt"} }; EnumMap const TileLayerNames{ {TileLayer::Foreground, "foreground"}, {TileLayer::Background, "background"} }; EnumMap const MoveControlTypeNames{ {MoveControlType::Left, "left"}, {MoveControlType::Right, "right"}, {MoveControlType::Down, "down"}, {MoveControlType::Up, "up"}, {MoveControlType::Jump, "jump"} }; EnumMap const PortraitModeNames{ {PortraitMode::Head, "head"}, {PortraitMode::Bust, "bust"}, {PortraitMode::Full, "full"}, {PortraitMode::FullNeutral, "fullneutral"}, {PortraitMode::FullNude, "fullnude"}, {PortraitMode::FullNeutralNude, "fullneutralnude"} }; EnumMap const RarityNames{ {Rarity::Common, "common"}, {Rarity::Uncommon, "uncommon"}, {Rarity::Rare, "rare"}, {Rarity::Legendary, "legendary"}, {Rarity::Essential, "essential"} }; std::pair connectionEntitySpace(ConnectionId connectionId) { if (connectionId == ServerConnectionId) { return {MinServerEntityId, MaxServerEntityId}; } else if (connectionId >= MinClientConnectionId && connectionId <= MaxClientConnectionId) { EntityId beginIdSpace = (EntityId)connectionId * -65536; EntityId endIdSpace = beginIdSpace + 65535; return {beginIdSpace, endIdSpace}; } else { throw StarException::format("Invalid connection id in clientEntitySpace({})", connectionId); } } bool entityIdInSpace(EntityId entityId, ConnectionId connectionId) { auto pair = connectionEntitySpace(connectionId); return entityId >= pair.first && entityId <= pair.second; } ConnectionId connectionForEntity(EntityId entityId) { if (entityId > 0) return ServerConnectionId; else return (-entityId - 1) / 65536 + 1; } pair getAngleSide(float angle, bool ccRotation) { angle = constrainAngle(angle); Direction direction = Direction::Right; if (angle > Constants::pi / 2) { direction = Direction::Left; angle = Constants::pi - angle; } else if (angle < -Constants::pi / 2) { direction = Direction::Left; angle = -Constants::pi - angle; } if (direction == Direction::Left && ccRotation) angle *= -1; return make_pair(angle, direction); } }