public GamePhysics(ILogger logger, Scene scene, ITime engineTime, SnapshotTime gameTime, BSPModel worldModel, ICommandContext commandContext) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _scene = scene ?? throw new ArgumentNullException(nameof(scene)); _engineTime = engineTime ?? throw new ArgumentNullException(nameof(engineTime)); _gameTime = gameTime ?? throw new ArgumentNullException(nameof(gameTime)); _worldModel = worldModel ?? throw new ArgumentNullException(nameof(worldModel)); //TODO: need to reset this on map spawn for singleplayer //TODO: mark as server cvar _sv_clienttrace = commandContext.RegisterVariable( new VirtualVariableInfo <float>("sv_clienttrace", 1) .WithHelpInfo("Scale multiplier for trace lines ran against studio models")); InitBoxHull(); box_hull = new Hull[1] { new Hull(0, PhysicsConstants.MaxBoxSides, Vector3.Zero, Vector3.Zero, box_clipnodes, new Memory <Models.BSP.FileFormat.Plane>(box_planes)) }; CreateAreaNode(0, ref _worldModel.SubModel.Mins, ref _worldModel.SubModel.Maxs); }
public void FixSnapshotTimeUTC() { try { //2020:10:20-08:30:00 string[] splitTime = SnapshotTime.Split(':'); SnapshotTimeUTC = DateTime.ParseExact($"{splitTime[0]}/{splitTime[1]}/{splitTime[2]}:{splitTime[3]}:{splitTime[4]}", "yyyy/MM/dd-hh:mm:ss", CultureInfo.InvariantCulture); } catch (Exception) { } }
public GameMovement(ILogger logger, Scene scene, ITime engineTime, SnapshotTime gameTime, Random random, GamePhysics physics, ICommandContext commandContext) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _scene = scene ?? throw new ArgumentNullException(nameof(scene)); _engineTime = engineTime ?? throw new ArgumentNullException(nameof(engineTime)); _gameTime = gameTime ?? throw new ArgumentNullException(nameof(gameTime)); _random = random ?? throw new ArgumentNullException(nameof(random)); _physics = physics ?? throw new ArgumentNullException(nameof(physics)); //TODO: add a filter to enforce positive values only _sv_maxvelocity = commandContext.RegisterVariable( new VirtualVariableInfo <float>("sv_maxvelocity", 2000) .WithHelpInfo("The maximum velocity in any axis that an entity can have. Any velocity greater than this is clamped to this value") .ConfigureFilters(filters => filters.WithNumberSignFilter(true))); //TODO: mark as server cvar _sv_stepsize = commandContext.RegisterVariable( new VirtualVariableInfo <float>("sv_stepsize", 18) .WithHelpInfo("Defines the maximum height that characters can still step over (e.g. stairs)") .ConfigureFilters(filters => filters.WithNumberSignFilter(true))); //TODO: mark as server cvar _sv_bounce = commandContext.RegisterVariable( new VirtualVariableInfo <float>("sv_bounce") .WithHelpInfo("Multiplier for physics bounce effect when objects collide with other objects") .ConfigureFilters(filters => filters.WithNumberSignFilter(true))); //TODO: mark as server cvar _sv_gravity = commandContext.RegisterVariable( new VirtualVariableInfo <float>("sv_gravity", 800) .WithHelpInfo("The world's gravity amount, in units per second")); //TODO: mark as server cvar _sv_stopspeed = commandContext.RegisterVariable( new VirtualVariableInfo <float>("sv_stopspeed", 100) .WithHelpInfo("Minimum stopping speed when on the ground") .ConfigureFilters(filters => filters.WithNumberSignFilter(true))); //TODO: mark as server cvar _sv_friction = commandContext.RegisterVariable( new VirtualVariableInfo <float>("sv_friction", 4) .WithHelpInfo("World friction") .ConfigureFilters(filters => filters.WithNumberSignFilter(true))); }