예제 #1
0
        // ReSharper disable once UnusedParameter.Local
        public EntityManager(SerializationInfo info, StreamingContext context) : this((Game)context.Context)
        {
            var entities = (List <ProtoEntity>)info.GetValue("Entities", typeof(List <ProtoEntity>));

            ManagerSubpulses = (ManagerSubPulse)info.GetValue("ManagerSubpulses", typeof(ManagerSubPulse));
            ManagerSubpulses.PostLoadInit(context, this);
            foreach (ProtoEntity protoEntity in entities)
            {
                Entity entity;
                if (FindEntityByGuid(protoEntity.Guid, out entity))
                {
                    // Entity has already been deserialized as a reference. It currently exists on the global manager.
                    entity.Transfer(this);
                    foreach (BaseDataBlob dataBlob in protoEntity.DataBlobs.Where(dataBlob => dataBlob != null))
                    {
                        entity.SetDataBlob(dataBlob);
                    }
                }
                else
                {
                    // Entity has not been previously deserialized. TODO: check whether the faction guid will deserialise after this or if we need to read it and input it into the constructor here.
                    Entity.Create(this, Guid.Empty, protoEntity);
                }
            }
        }
예제 #2
0
        public void Initialise(GameVM gameVM, StarSystem starSys, Entity viewingFaction)
        {
            _viewingFaction = viewingFaction;

            var listnerblobs = new List <int>();

            listnerblobs.Add(EntityManager.DataBlobTypes[typeof(OwnedDB)]);
            listnerblobs.Add(EntityManager.DataBlobTypes[typeof(PositionDB)]);
            EntityChangeListner changeListner = new EntityChangeListner(starSys, viewingFaction, listnerblobs);

            _changeListner = changeListner;


            IconableEntitys.Clear();
            _iconableEntites.Clear();


            foreach (Entity entity in _changeListner.ListningToEntites)
            {
                AddIconableEntity(entity);
            }
            SystemSubpulse = starSys.ManagerSubpulses;
            //starSys.SystemManager.GetAllEntitiesWithDataBlob<NewtonBalisticDB>(gameVM.CurrentAuthToken);

            OnPropertyChanged(nameof(IconableEntitys));
        }
예제 #3
0
 internal CommandReferences(Guid faction, Guid entity, IOrderHandler handler, ManagerSubPulse subPulse)
 {
     FactionGuid = faction;
     EntityGuid  = entity;
     Handler     = handler;
     _subPulse   = subPulse;
 }
예제 #4
0
 internal EntityManager(Game game)
 {
     Game = game;
     for (int i = 0; i < InternalDataBlobTypes.Keys.Count; i++)
     {
         _dataBlobMap.Add(new List <BaseDataBlob>());
     }
     ManagerSubpulses = new ManagerSubPulse(this);
 }
예제 #5
0
 internal EntityManager(Game game, bool isGlobalManager = false)
 {
     Game        = game;
     ManagerGuid = Guid.NewGuid();
     game.GlobalManagerDictionary.Add(ManagerGuid, this);
     if (isGlobalManager)
     {
         _globalEntityDictionary   = new Dictionary <Guid, EntityManager>();
         _globalGuidDictionaryLock = new ReaderWriterLockSlim();
     }
     else
     {
         _globalEntityDictionary   = game.GlobalManager._globalEntityDictionary;
         _globalGuidDictionaryLock = game.GlobalManager._globalGuidDictionaryLock;
     }
     for (int i = 0; i < InternalDataBlobTypes.Keys.Count; i++)
     {
         _dataBlobMap.Add(new List <BaseDataBlob>());
     }
     ManagerSubpulses = new ManagerSubPulse(this, StaticRefLib.ProcessorManager);
 }
예제 #6
0
        // ReSharper disable once UnusedParameter.Local
        public EntityManager(SerializationInfo info, StreamingContext context) : this((Game)context.Context)
        {
            var entities = (List <ProtoEntity>)info.GetValue("Entities", typeof(List <ProtoEntity>));

            ManagerSubpulses = (ManagerSubPulse)info.GetValue("ManagerSubpulses", typeof(ManagerSubPulse));
            foreach (ProtoEntity protoEntity in entities)
            {
                Entity entity;
                if (FindEntityByGuid(protoEntity.Guid, out entity))
                {
                    // Entity has already been deserialized as a reference. It currently exists on the global manager.
                    entity.Transfer(this);
                    foreach (BaseDataBlob dataBlob in protoEntity.DataBlobs.Where(dataBlob => dataBlob != null))
                    {
                        entity.SetDataBlob(dataBlob);
                    }
                }
                else
                {
                    // Entity has not been previously deserialized.
                    Entity.Create(this, protoEntity);
                }
            }
        }
예제 #7
0
 public void SetUpdateListner(ManagerSubPulse subPulse)
 {
     subPulse.SystemDateChangedEvent += OnSubPulse_SystemDateChangedEvent;
 }