Example #1
0
        public virtual void RemoveDataBlob <T>() where T : BaseDataBlob
        {
            int typeIndex = EntityManager.GetTypeIndex <T>();

            DataBlobs[typeIndex] = null;
            _protectedDataBlobMask_[typeIndex] = false;
        }
Example #2
0
 public bool HasDataBlob<T>() where T : BaseDataBlob
 {
     if (!IsValid)
     {
         throw new InvalidOperationException("Cannot query an invalid entity.");
     }
     int typeIndex = EntityManager.GetTypeIndex<T>();
     return DataBlobMask[typeIndex];
 }
Example #3
0
        private static bool IsOwnedEntityAuthorized(Player authorizedPlayer, Entity entity, ComparableBitArray entityMask)
        {
            if (entityMask[EntityManager.GetTypeIndex <OwnedDB>()])
            {
                var entityOwnedDB = entity.GetDataBlob <OwnedDB>();
                var factions      = new List <Entity>();

                if (entityMask[EntityManager.GetTypeIndex <SensorProfileDB>()])
                {
                    factions = FactionsWithAccess(authorizedPlayer, AccessRole.SensorVision);
                }

                /*
                 * if (entityMask[EntityManager.GetTypeIndex<ColonyInfoDB>()])
                 * {
                 *  // Check if entity is a SensorContact
                 *  if (entityOwnedDB.OwnedByFaction == entityOwnedDB.ObjectOwner)
                 *  {
                 *      // Entity is not a SensorContact
                 *      factions = FactionsWithAccess(authorizedPlayer, AccessRole.ColonyVision);
                 *  }
                 * }
                 * else if (entityMask[EntityManager.GetTypeIndex<ShipInfoDB>()])
                 * {
                 *  var entityShipInfoDB = entity.GetDataBlob<ShipInfoDB>();
                 *  if (entityOwnedDB.OwnedByFaction == entityOwnedDB.ObjectOwner)
                 *  {
                 *      if (entityShipInfoDB.IsClassDefinition())
                 *      {
                 *          factions = FactionsWithAccess(authorizedPlayer, AccessRole.Intelligence);
                 *      }
                 *      else
                 *      {
                 *          // Entity is an actual ship
                 *          factions = FactionsWithAccess(authorizedPlayer, AccessRole.UnitVision);
                 *      }
                 *  }
                 * }
                 * else if (entityMask[EntityManager.GetTypeIndex<FactionInfoDB>()])
                 * {
                 *  if (entityOwnedDB.OwnedByFaction == entityOwnedDB.ObjectOwner)
                 *  {
                 *      factions = FactionsWithAccess(authorizedPlayer, AccessRole.FullAccess);
                 *  }
                 * } */

                foreach (Entity faction in factions)
                {
                    if (faction == entityOwnedDB.OwnedByFaction)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Example #4
0
        private static bool IsSystemBodyAuthorized(Player authorizedPlayer, Entity entity, ComparableBitArray entityMask)
        {
            if (entityMask[EntityManager.GetTypeIndex <StarInfoDB>()] ||
                entityMask[EntityManager.GetTypeIndex <SystemBodyInfoDB>()] ||
                entityMask[EntityManager.GetTypeIndex <JPSurveyableDB>()] ||
                entityMask[EntityManager.GetTypeIndex <TransitableDB>()])
            {
                // Entity systemBody
                var entityPositionDB = entity.GetDataBlob <PositionDB>();

                List <Entity> factions = FactionsWithAccess(authorizedPlayer, AccessRole.SystemKnowledge);
                foreach (Entity faction in factions)
                {
                    var factionInfoDB = faction.GetDataBlob <FactionInfoDB>();
                    foreach (Guid knownSystem in factionInfoDB.KnownSystems)
                    {
                        if (knownSystem == entityPositionDB.SystemGuid)
                        {
                            if (!entityMask[EntityManager.GetTypeIndex <TransitableDB>()])
                            {
                                return(true);
                            }

                            if (factionInfoDB.KnownJumpPoints.ContainsKey(knownSystem))
                            {
                                List <Entity> knownJumpPoints = factionInfoDB.KnownJumpPoints[knownSystem];
                                foreach (Entity knownJumpPoint in knownJumpPoints)
                                {
                                    if (knownJumpPoint == entity)
                                    {
                                        return(true);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }
Example #5
0
 public virtual T GetDataBlob <T>() where T : BaseDataBlob
 {
     return((T)DataBlobs[EntityManager.GetTypeIndex <T>()]);
 }