コード例 #1
0
        public override void Serialize(Archive archive)
        {
            archive.Serialize(ref _levelName);

            int numIds = (_travelActorNetIDs != null) ? _travelActorNetIDs.Values.Count : 0;

            archive.Serialize(ref numIds);

            if (archive.isLoading)
            {
                if (_travelActorNetIDs != null)
                {
                    _travelActorNetIDs.Clear();
                }
                else
                {
                    _travelActorNetIDs = new HashSetList <int>();
                }

                for (int i = 0; i < numIds; ++i)
                {
                    _travelActorNetIDs.Add(archive.ReadInt());
                }
            }
            else if (numIds > 0)
            {
                for (int i = 0; i < numIds; ++i)
                {
                    archive.Write(_travelActorNetIDs.Values[i]);
                }
            }
        }
コード例 #2
0
 protected override void BeginTravel(string travelLevel, HashSetList <int> travelActorNetIDs)
 {
     base.BeginTravel(travelLevel, travelActorNetIDs);
     _gameState = null;
     _ragdolls.Clear();
     _gibs.Clear();
 }
コード例 #3
0
    public SerializableObject AddReference(ISerializableObjectFieldSerializer serializer, int id, int fieldIndex)
    {
        var obj = _outerCollector.AddReference(this, id, _outerFieldIndex);

        if (obj != null)
        {
            return(obj);
        }

        if (!_simpleReferences)
        {
            if (_subFieldReferences == null)
            {
                _subFieldReferences = new Dictionary <int, Dictionary <int, HashSetList <int> > >();
            }
            Dictionary <int, HashSetList <int> > idToIndexSet;
            if (!_subFieldReferences.TryGetValue(_outerFieldIndex, out idToIndexSet))
            {
                idToIndexSet = new Dictionary <int, HashSetList <int> >();
                _subFieldReferences[_outerFieldIndex] = idToIndexSet;
            }
            HashSetList <int> fields;
            if (!idToIndexSet.TryGetValue(id, out fields))
            {
                fields           = new HashSetList <int>();
                idToIndexSet[id] = fields;
            }
            fields.Add(fieldIndex);
        }
        return(null);
    }
コード例 #4
0
        protected override void BeginTravel(string travelLevel, HashSetList <int> travelActorNetIDs)
        {
            base.BeginTravel(travelLevel, travelActorNetIDs);

            // tell clients to travel
            for (int i = 0; i < connectionList.Count; ++i)
            {
                var channel = connectionList[i];

                if (channel.owningPlayer != null)
                {
                    if ((travelActorNetIDs == null) || !travelActorNetIDs.Contains(channel.owningPlayer.netID))
                    {
                        channel.owningPlayer = null;
                    }
                }

                if (channel.didHandshake && !channel.pendingConnect && (channel.clientLevel == currentLevel))
                {
                    channel.connection.driverConnection.blocking = true;
                    channel.connection.SendReliable(NetMsgs.ClientTravel.New(travelLevel, travelActorNetIDs));
                    channel.clientLevel  = null;
                    channel.levelStarted = false;
                    channel.isTraveling  = true;
                }
            }
        }
コード例 #5
0
	public ActorReplicationChannel(NetConnection connection) {
		_connection = connection;
		pongTimeout = PONG_TIMEOUT;
		maxPongTimeout = PONG_TIMEOUT;

        if (connection.world is Server.ServerWorld) {
			garbage = new HashSetList<int>();
			isServer = true;
		}
	}
コード例 #6
0
	public void AddReference(int id, int fieldIndex) {
		if (objReferences == null) {
			objReferences = new DictionaryList<int, HashSetList<int>>();
		}
		HashSetList<int> subFields;
		if (!objReferences.TryGetValue(id, out subFields)) {
			subFields = new HashSetList<int>();
			objReferences[id] = subFields;
		}
		subFields.Add(fieldIndex);
	}
コード例 #7
0
        public void BeginTravel(string travelLevel, Type gameMode)
        {
            if ((gameMode == null) && (_gameMode != null))
            {
                gameMode = _gameMode.GetType();
            }

            if (_gameMode != null)
            {
                _gameMode.Dispose();
                _gameMode = null;
            }

            if ((gameMode == null) || !typeof(GameMode).IsAssignableFrom(gameMode) || gameMode.IsAbstract)
            {
                throw new System.Exception("Invalid game mode class!");
            }

            var constructor = gameMode.GetConstructor(new[] { typeof(ServerWorld) });

            if (constructor == null)
            {
                throw new System.Exception("Invalid game mode class!");
            }

            _gameMode = (GameMode)constructor.Invoke(new[] { this });
            _gameMode.PreTravel();

            HashSetList <int> travelActorNetIDs = new HashSetList <int>();

            _gameMode.GetTravelActorNetIds(travelActorNetIDs);

            base.BeginTravel(travelLevel, travelActorNetIDs);

            if (GameManager.instance.clientWorld != null)
            {
                GameManager.instance.clientWorld.InternalServer_BeginTravel(travelLevel, travelActorNetIDs);
            }

            _gameMode.BeginTravel();
        }
コード例 #8
0
    protected virtual void BeginTravel(string travelLevel, HashSetList <int> travelActorNetIDs)
    {
        _travelLevel       = travelLevel;
        _bIsLoading        = true;
        _travelActors      = new List <Actor>();
        _time              = 0f;
        _unscaledTime      = 0f;
        _deltaTime         = 0f;
        _unscaledDeltaTime = 0f;
        _nextNetID         = 0;
        _loadingQueue.Clear();
        _taskQueue.Clear();
        _sceneLoaded   = false;
        _didLevelStart = false;
        spawnTags      = null;

        for (int i = 0; i < _actors.Count;)
        {
            var actor = _actors[i];
            if ((travelActorNetIDs != null) && ActorWillTravel(actor, travelActorNetIDs))
            {
                actor.SetSpawnTagID(0);
                actor.BeginTravel();
                _travelActors.Add(actor);
                ++i;
            }
            else
            {
                DestroyActor(actor, true);
                _actors.RemoveAt(i);
            }
        }

        if (!_sharedWorldStreaming)
        {
            _worldStreaming.BeginTravel();
        }
    }
コード例 #9
0
 protected override void BeginTravel(string travelLevel, HashSetList <int> travelActorNetIDs)
 {
     _wasTraveling = true;
     base.BeginTravel(travelLevel, travelActorNetIDs);
 }
コード例 #10
0
 public void SerializesReadonlyICollection()
 {
     var start = new HashSetList();
     start.Names.Add("Duncan");
     start.Names.Add("Idaho");
     var bytes = BsonSerializer.Serialize(start);
     var end = BsonDeserializer.Deserialize<HashSetList>(bytes);
     Assert.Equal(2, end.Names.Count);
     Assert.Equal("Duncan", end.Names.ElementAt(0));
     Assert.Equal("Idaho", end.Names.ElementAt(1));
 }
コード例 #11
0
 internal void InternalServer_BeginTravel(string travelLevel, HashSetList <int> travelActorNetIDs)
 {
     isServerTraveling = true;
     BeginTravel(travelLevel, travelActorNetIDs);
 }
コード例 #12
0
 public virtual void GetTravelActorNetIds(HashSetList <int> travelActorNetIDs)
 {
 }
コード例 #13
0
 public static ClientTravel New(string levelName, HashSetList <int> travelActorNetIDs)
 {
     instance._levelName         = levelName;
     instance._travelActorNetIDs = travelActorNetIDs;
     return(instance);
 }
コード例 #14
0
 bool ActorWillTravel(Actor actor, HashSetList <int> travelActorNetIds)
 {
     return(!actor.pendingKill && (((actor.netID == 0) || !actor.replicates) && actor.nonReplicatedActorShouldTravel) || ((actor.netID != 0) && travelActorNetIds.Contains(actor.netID)));
 }