// 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); } } }
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)); }
internal CommandReferences(Guid faction, Guid entity, IOrderHandler handler, ManagerSubPulse subPulse) { FactionGuid = faction; EntityGuid = entity; Handler = handler; _subPulse = subPulse; }
internal EntityManager(Game game) { Game = game; for (int i = 0; i < InternalDataBlobTypes.Keys.Count; i++) { _dataBlobMap.Add(new List <BaseDataBlob>()); } ManagerSubpulses = new ManagerSubPulse(this); }
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); }
// 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); } } }
public void SetUpdateListner(ManagerSubPulse subPulse) { subPulse.SystemDateChangedEvent += OnSubPulse_SystemDateChangedEvent; }