Beispiel #1
0
        /// <summary>
        /// Updates the state of the ShardSession to represent that the given amount of game time has passed.
        /// </summary>
        /// <param name="diff">amount of game time passed since the last call to Update</param>
        public void Update(TimeSpan diff)
        {
            // just aliases for brevity
            World world = Server.World;

            Game.World.Shard shard = Server.Shard;

            // go through objects in map
            foreach (GameObject go in shard.GetObjects(Player.MapID))
            {
                if (Awareness.Contains(go))
                {
                    // update, remove, or do nothing
                    if (go.Position.Distance(Player.Position) < world.ViewDistance)
                    {
                        // update or do nothing
                        if (go.ChangeState != ObjectChangeState.None)
                        {
                            // update
                            UpdateAwareObject(go);
                        }
                    }
                    else
                    {
                        // remove
                        RemoveAwareObject(go);
                    }
                }
                else
                {
                    // add or do nothing
                    if (go.Position.Distance(Player.Position) < world.ViewDistance)
                    {
                        // add
                        AddAwareObject(go);
                    }
                }
            }

            // next, go through objects in awareness set, in case any don't have the correct map ID or no longer exist, and remove them
            ISet <GameObject> removalSet = new HashSet <GameObject>();

            foreach (GameObject go in Awareness)
            {
                if (go.MapID != Player.MapID)
                {
                    removalSet.Add(go);
                }
                else if (!Server.Shard.Exists(go))
                {
                    removalSet.Add(go);
                }
            }

            foreach (GameObject go in removalSet)
            {
                // remove
                RemoveAwareObject(go);
            }
        }
Beispiel #2
0
 public ShardServer(IWhisperComposerFactory <ShardRequest> composerFactory, IRandomSource randomSource, IWhisperDatasource wauth, IWhisperDatasource wshard, World world, Game.World.Shard shard, ShardConfig configuration) : base(composerFactory)
 {
     AppConfig    = configuration;
     SecureRandom = randomSource;
     AuthDB       = wauth;
     ShardDB      = wshard;
     World        = world;
     Shard        = shard;
 }