Ejemplo n.º 1
0
        internal void SetSystem(FactionVM factionVM)
        {
            if (_sysState != null)
            {
                _sysState.StarSystem.ManagerSubpulses.SystemDateChangedEvent -= OnSystemDateChange;
                _sysState.StarSystem.GetSensorContacts(_faction.Guid).Changes.Unsubscribe(_sensorChanges);
            }
            if (_state.StarSystemStates.ContainsKey(factionVM.SystemMap.StarSystem.Guid))
            {
                _sysState = _state.StarSystemStates[factionVM.SystemMap.StarSystem.Guid];
            }
            else
            {
                _sysState = new SystemState(factionVM.SystemMap.StarSystem, factionVM.FactionEntity);
                _state.StarSystemStates[_sysState.StarSystem.Guid] = _sysState;
            }
            var starSys = _sysState.StarSystem;

            _faction = _state.Faction;
            starSys.ManagerSubpulses.SystemDateChangedEvent += OnSystemDateChange;
            _sensorMgr     = starSys.GetSensorContacts(_faction.Guid);
            _sensorChanges = _sensorMgr.Changes.Subscribe();



            _state.SetActiveSystem(starSys.Guid);


            foreach (var entityItem in _sysState.EntityStatesWithPosition.Values)
            {
                AddIconable(entityItem);
            }

            _state.LastClickedEntity = _sysState.EntityStatesWithPosition.Values.ElementAt(0);
        }
Ejemplo n.º 2
0
        internal void SetSystem(StarSystem starSys)
        {
            if (_sysState != null)
            {
                _sysState.StarSystem.GetSensorContacts(_faction.Guid).Changes.Unsubscribe(_sensorChanges);
            }
            if (_state.StarSystemStates.ContainsKey(starSys.Guid))
            {
                _sysState = _state.StarSystemStates[starSys.Guid];
            }
            else
            {
                _sysState = new SystemState(starSys, _state.Faction);
                _state.StarSystemStates[_sysState.StarSystem.Guid] = _sysState;
            }


            _faction = _state.Faction;

            _sensorMgr = starSys.GetSensorContacts(_faction.Guid);


            _sensorChanges = _sensorMgr.Changes.Subscribe();
            foreach (var entityItem in _sysState.EntityStatesWithPosition.Values)
            {
                AddIconable(entityItem);
            }

            //_uiState.LastClickedEntity = _sysState.EntityStates.Values.ElementAt(0);
        }
Ejemplo n.º 3
0
        public SystemState(StarSystem system, Entity faction)
        {
            StarSystem     = system;
            SystemContacts = system.GetSensorContacts(faction.Guid);
            _sensorChanges = SystemContacts.Changes.Subscribe();
            PulseMgr       = system.ManagerSubpulses;
            _faction       = faction;
            foreach (Entity entityItem in StarSystem.GetEntitiesByFaction(faction.Guid))
            {
                var entityState = new EntityState(entityItem);// { Name = "Unknown" };
                if (entityItem.HasDataBlob <NameDB>())
                {
                    entityState.Name = entityItem.GetDataBlob <NameDB>().GetName(faction);
                    EntityStatesWithNames.Add(entityItem.Guid, entityState);
                }
                if (entityItem.HasDataBlob <PositionDB>())
                {
                    EntityStatesWithPosition.Add(entityItem.Guid, entityState);
                }
                if (entityItem.HasDataBlob <ColonyInfoDB>())
                {
                    EntityStatesColonies.Add(entityItem.Guid, entityState);
                }
            }

            var listnerblobs = new List <int>();

            listnerblobs.Add(EntityManager.DataBlobTypes[typeof(PositionDB)]);
            AEntityChangeListner changeListner = new EntityChangeListner(StarSystem, faction, listnerblobs);//, listnerblobs);

            _changeListner = changeListner;

            foreach (SensorContact sensorContact in SystemContacts.GetAllContacts())
            {
                var entityState = new EntityState(sensorContact)
                {
                    Name = "Unknown"
                };
                EntityStatesWithNames.Add(sensorContact.ActualEntityGuid, entityState);
                EntityStatesWithPosition.Add(sensorContact.ActualEntityGuid, entityState);
            }
        }