Example #1
0
        internal Person(int id, double movementSpeed, BuildingBlock position)
        {
            if (id <= 0)
            { /* Negative or zero-valued id means this is a totally new person */
                int newID;
                do
                {
                    newID = _idCounter++;
                } while (IdsInUse.Contains(newID));
                ID = newID;
            }
            else
            {
                /* non-zeroed, positive value means this is an existing person */
                if (IdsInUse.Contains(id))
                {
                    throw new PersonException($"A user with ID {id} already exists!");
                }
                ID = id;
            }

            PersonInteractionStats = new DataSimulationStatistics();
            // 3 - 8 kmt
            MovementSpeed = movementSpeed < 3 ? 3 + Rand.NextDouble() * 5 : movementSpeed; // Less than 5 means that it was not created.
            MovementSpeed = 3 + Rand.NextDouble() * 5;
            MovementSpeedInMetersPerSecond = (MovementSpeed * 1000) / 60 / 60;
            Position = position;
            //If their position is int16.maxvalue, if the priority is not assigned == That there is no path,
            //They will not be touched in the simulation, but will be added to the counter in CP_SimulationStats
            if (position.Priority == Int16.MaxValue)
            {
                NoPathAvailable = true;
            }
            OriginalPosition = position;
        }
Example #2
0
File: Person.cs Project: pprintz/p2
        internal Person(int id, double movementSpeed, BuildingBlock position)
        {
            if (id <= 0)
            { /* Negative or zero-valued id means this is a totally new person */
                int newID;
                do
                {
                    newID = _idCounter++;
                } while (IdsInUse.Contains(newID));
                ID = newID;
            }
            else
            {
                /* non-zeroed, positive value means this is an existing person */
                if (IdsInUse.Contains(id))
                    throw new PersonException($"A user with ID {id} already exists!");
                ID = id;
            }

            PersonInteractionStats = new DataSimulationStatistics();
            // 3 - 8 kmt
            MovementSpeed = movementSpeed < 3 ? 3 + Rand.NextDouble() * 5 : movementSpeed; // Less than 5 means that it was not created.
            MovementSpeed = 3 + Rand.NextDouble() * 5;
            MovementSpeedInMetersPerSecond = (MovementSpeed * 1000) / 60 / 60;
            Position = position;
            //If their position is int16.maxvalue, if the priority is not assigned == That there is no path,
            //They will not be touched in the simulation, but will be added to the counter in CP_SimulationStats
            if (position.Priority == Int16.MaxValue)
            {
                NoPathAvailable = true;
            }
            OriginalPosition = position;
        }