public static bool IsCategory(Entity entity, int category) { EntityDefinitionComponent component = entity.GetComponent(EntityDefinitionComponent.ID) as EntityDefinitionComponent; if (component == null) { return(false); } return(component.IsCategory(category)); }
void GatherGeneral(ISpacePartition partition, Player player, Vector3FP position, Vector2FP facing, TargetGatheringParam param, List <Entity> targets) { if (partition == null) { return; } List <PositionComponent> list = null; int gathering_type = param.m_type; if (gathering_type == TargetGatheringType.ForwardRectangle) { list = partition.CollectEntity_ForwardRectangle(position, facing, param.m_param1, param.m_param2); } else if (gathering_type == TargetGatheringType.SurroundingRing) { list = partition.CollectEntity_SurroundingRing(position, param.m_param1, param.m_param2); } else if (gathering_type == TargetGatheringType.ForwardSector) { list = partition.CollectEntity_ForwardSector(position, facing, param.m_param1, param.m_param2); } else if (gathering_type == TargetGatheringType.All) { list = partition.CollectEntity_All(); } if (list == null) { return; } for (int i = 0; i < list.Count; ++i) { PositionComponent position_component = list[i]; Entity entity = position_component.GetOwnerEntity(); if (param.m_category != 0) { EntityDefinitionComponent definition_component = entity.GetComponent(EntityDefinitionComponent.ID) as EntityDefinitionComponent; if (definition_component == null) { continue; } if (!definition_component.IsCategory(param.m_category)) { continue; } } if (player != null && !FactionRelation.IsFactionSatisfied(player.GetFaction(entity.GetOwnerPlayerID()), param.m_faction)) { continue; } targets.Add(entity); } }